google_recommender1/
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 Recommender 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_recommender1 as recommender1;
49/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationClaimedRequest;
50/// use recommender1::{Result, Error};
51/// # async fn dox() {
52/// use recommender1::{Recommender, 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 = Recommender::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 = GoogleCloudRecommenderV1MarkRecommendationClaimedRequest::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.billing_accounts().locations_recommenders_recommendations_mark_claimed(req, "name")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct Recommender<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for Recommender<C> {}
130
131impl<'a, C> Recommender<C> {
132    pub fn new<A: 'static + common::GetToken>(
133        client: common::Client<C>,
134        auth: A,
135    ) -> Recommender<C> {
136        Recommender {
137            client,
138            auth: Box::new(auth),
139            _user_agent: "google-api-rust-client/7.0.0".to_string(),
140            _base_url: "https://recommender.googleapis.com/".to_string(),
141            _root_url: "https://recommender.googleapis.com/".to_string(),
142        }
143    }
144
145    pub fn billing_accounts(&'a self) -> BillingAccountMethods<'a, C> {
146        BillingAccountMethods { hub: self }
147    }
148    pub fn folders(&'a self) -> FolderMethods<'a, C> {
149        FolderMethods { hub: self }
150    }
151    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
152        OrganizationMethods { hub: self }
153    }
154    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
155        ProjectMethods { hub: self }
156    }
157
158    /// Set the user-agent header field to use in all requests to the server.
159    /// It defaults to `google-api-rust-client/7.0.0`.
160    ///
161    /// Returns the previously set user-agent.
162    pub fn user_agent(&mut self, agent_name: String) -> String {
163        std::mem::replace(&mut self._user_agent, agent_name)
164    }
165
166    /// Set the base url to use in all requests to the server.
167    /// It defaults to `https://recommender.googleapis.com/`.
168    ///
169    /// Returns the previously set base url.
170    pub fn base_url(&mut self, new_base_url: String) -> String {
171        std::mem::replace(&mut self._base_url, new_base_url)
172    }
173
174    /// Set the root url to use in all requests to the server.
175    /// It defaults to `https://recommender.googleapis.com/`.
176    ///
177    /// Returns the previously set root url.
178    pub fn root_url(&mut self, new_root_url: String) -> String {
179        std::mem::replace(&mut self._root_url, new_root_url)
180    }
181}
182
183// ############
184// SCHEMAS ###
185// ##########
186/// Contains metadata about how much money a recommendation can save or incur.
187///
188/// This type is not used in any activity, and only used as *part* of another schema.
189///
190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
191#[serde_with::serde_as]
192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
193pub struct GoogleCloudRecommenderV1CostProjection {
194    /// An approximate projection on amount saved or amount incurred. Negative cost units indicate cost savings and positive cost units indicate increase. See google.type.Money documentation for positive/negative units. A user's permissions may affect whether the cost is computed using list prices or custom contract prices.
195    pub cost: Option<GoogleTypeMoney>,
196    /// The approximate cost savings in the billing account's local currency.
197    #[serde(rename = "costInLocalCurrency")]
198    pub cost_in_local_currency: Option<GoogleTypeMoney>,
199    /// Duration for which this cost applies.
200    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
201    pub duration: Option<chrono::Duration>,
202}
203
204impl common::Part for GoogleCloudRecommenderV1CostProjection {}
205
206/// Contains the impact a recommendation can have for a given category.
207///
208/// This type is not used in any activity, and only used as *part* of another schema.
209///
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct GoogleCloudRecommenderV1Impact {
214    /// Category that is being targeted.
215    pub category: Option<String>,
216    /// Use with CategoryType.COST
217    #[serde(rename = "costProjection")]
218    pub cost_projection: Option<GoogleCloudRecommenderV1CostProjection>,
219    /// If populated, the impact contains multiple components. In this case, the top-level impact contains aggregated values and each component contains per-service details.
220    #[serde(rename = "impactComponents")]
221    pub impact_components: Option<Vec<GoogleCloudRecommenderV1Impact>>,
222    /// Use with CategoryType.RELIABILITY
223    #[serde(rename = "reliabilityProjection")]
224    pub reliability_projection: Option<GoogleCloudRecommenderV1ReliabilityProjection>,
225    /// Use with CategoryType.SECURITY
226    #[serde(rename = "securityProjection")]
227    pub security_projection: Option<GoogleCloudRecommenderV1SecurityProjection>,
228    /// The service that this impact is associated with.
229    pub service: Option<String>,
230    /// Use with CategoryType.SUSTAINABILITY
231    #[serde(rename = "sustainabilityProjection")]
232    pub sustainability_projection: Option<GoogleCloudRecommenderV1SustainabilityProjection>,
233}
234
235impl common::Part for GoogleCloudRecommenderV1Impact {}
236
237/// An insight along with the information used to derive the insight. The insight may have associated recommendations as well.
238///
239/// # Activities
240///
241/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
242/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
243///
244/// * [locations insight types insights get billing accounts](BillingAccountLocationInsightTypeInsightGetCall) (response)
245/// * [locations insight types insights mark accepted billing accounts](BillingAccountLocationInsightTypeInsightMarkAcceptedCall) (response)
246/// * [locations insight types insights get folders](FolderLocationInsightTypeInsightGetCall) (response)
247/// * [locations insight types insights mark accepted folders](FolderLocationInsightTypeInsightMarkAcceptedCall) (response)
248/// * [locations insight types insights get organizations](OrganizationLocationInsightTypeInsightGetCall) (response)
249/// * [locations insight types insights mark accepted organizations](OrganizationLocationInsightTypeInsightMarkAcceptedCall) (response)
250/// * [locations insight types insights get projects](ProjectLocationInsightTypeInsightGetCall) (response)
251/// * [locations insight types insights mark accepted projects](ProjectLocationInsightTypeInsightMarkAcceptedCall) (response)
252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
253#[serde_with::serde_as]
254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
255pub struct GoogleCloudRecommenderV1Insight {
256    /// Recommendations derived from this insight.
257    #[serde(rename = "associatedRecommendations")]
258    pub associated_recommendations:
259        Option<Vec<GoogleCloudRecommenderV1InsightRecommendationReference>>,
260    /// Category being targeted by the insight.
261    pub category: Option<String>,
262    /// A struct of custom fields to explain the insight. Example: "grantedPermissionsCount": "1000"
263    pub content: Option<HashMap<String, serde_json::Value>>,
264    /// Free-form human readable summary in English. The maximum length is 500 characters.
265    pub description: Option<String>,
266    /// Fingerprint of the Insight. Provides optimistic locking when updating states.
267    pub etag: Option<String>,
268    /// Insight subtype. Insight content schema will be stable for a given subtype.
269    #[serde(rename = "insightSubtype")]
270    pub insight_subtype: Option<String>,
271    /// Timestamp of the latest data used to generate the insight.
272    #[serde(rename = "lastRefreshTime")]
273    pub last_refresh_time: Option<chrono::DateTime<chrono::offset::Utc>>,
274    /// Identifier. Name of the insight.
275    pub name: Option<String>,
276    /// Observation period that led to the insight. The source data used to generate the insight ends at last_refresh_time and begins at (last_refresh_time - observation_period).
277    #[serde(rename = "observationPeriod")]
278    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
279    pub observation_period: Option<chrono::Duration>,
280    /// Insight's severity.
281    pub severity: Option<String>,
282    /// Information state and metadata.
283    #[serde(rename = "stateInfo")]
284    pub state_info: Option<GoogleCloudRecommenderV1InsightStateInfo>,
285    /// Fully qualified resource names that this insight is targeting.
286    #[serde(rename = "targetResources")]
287    pub target_resources: Option<Vec<String>>,
288}
289
290impl common::ResponseResult for GoogleCloudRecommenderV1Insight {}
291
292/// Reference to an associated recommendation.
293///
294/// This type is not used in any activity, and only used as *part* of another schema.
295///
296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
297#[serde_with::serde_as]
298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
299pub struct GoogleCloudRecommenderV1InsightRecommendationReference {
300    /// Recommendation resource name, e.g. projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID]
301    pub recommendation: Option<String>,
302}
303
304impl common::Part for GoogleCloudRecommenderV1InsightRecommendationReference {}
305
306/// Information related to insight state.
307///
308/// This type is not used in any activity, and only used as *part* of another schema.
309///
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct GoogleCloudRecommenderV1InsightStateInfo {
314    /// Insight state.
315    pub state: Option<String>,
316    /// A map of metadata for the state, provided by user or automations systems.
317    #[serde(rename = "stateMetadata")]
318    pub state_metadata: Option<HashMap<String, String>>,
319}
320
321impl common::Part for GoogleCloudRecommenderV1InsightStateInfo {}
322
323/// Configuration for an InsightType.
324///
325/// # Activities
326///
327/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
328/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
329///
330/// * [locations insight types get config billing accounts](BillingAccountLocationInsightTypeGetConfigCall) (response)
331/// * [locations insight types update config billing accounts](BillingAccountLocationInsightTypeUpdateConfigCall) (request|response)
332/// * [locations insight types get config organizations](OrganizationLocationInsightTypeGetConfigCall) (response)
333/// * [locations insight types update config organizations](OrganizationLocationInsightTypeUpdateConfigCall) (request|response)
334/// * [locations insight types get config projects](ProjectLocationInsightTypeGetConfigCall) (response)
335/// * [locations insight types update config projects](ProjectLocationInsightTypeUpdateConfigCall) (request|response)
336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
337#[serde_with::serde_as]
338#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
339pub struct GoogleCloudRecommenderV1InsightTypeConfig {
340    /// Allows clients to store small amounts of arbitrary data. Annotations must follow the Kubernetes syntax. The total size of all keys and values combined is limited to 256k. Key can have 2 segments: prefix (optional) and name (required), separated by a slash (/). Prefix must be a DNS subdomain. Name must be 63 characters or less, begin and end with alphanumerics, with dashes (-), underscores (_), dots (.), and alphanumerics between.
341    pub annotations: Option<HashMap<String, String>>,
342    /// A user-settable field to provide a human-readable name to be used in user interfaces.
343    #[serde(rename = "displayName")]
344    pub display_name: Option<String>,
345    /// Fingerprint of the InsightTypeConfig. Provides optimistic locking when updating.
346    pub etag: Option<String>,
347    /// InsightTypeGenerationConfig which configures the generation of insights for this insight type.
348    #[serde(rename = "insightTypeGenerationConfig")]
349    pub insight_type_generation_config: Option<GoogleCloudRecommenderV1InsightTypeGenerationConfig>,
350    /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
351    pub name: Option<String>,
352    /// Output only. Immutable. The revision ID of the config. A new revision is committed whenever the config is changed in any way. The format is an 8-character hexadecimal string.
353    #[serde(rename = "revisionId")]
354    pub revision_id: Option<String>,
355    /// Last time when the config was updated.
356    #[serde(rename = "updateTime")]
357    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
358}
359
360impl common::RequestValue for GoogleCloudRecommenderV1InsightTypeConfig {}
361impl common::ResponseResult for GoogleCloudRecommenderV1InsightTypeConfig {}
362
363/// A configuration to customize the generation of insights. Eg, customizing the lookback period considered when generating a insight.
364///
365/// This type is not used in any activity, and only used as *part* of another schema.
366///
367#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
368#[serde_with::serde_as]
369#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
370pub struct GoogleCloudRecommenderV1InsightTypeGenerationConfig {
371    /// Parameters for this InsightTypeGenerationConfig. These configs can be used by or are applied to all subtypes.
372    pub params: Option<HashMap<String, serde_json::Value>>,
373}
374
375impl common::Part for GoogleCloudRecommenderV1InsightTypeGenerationConfig {}
376
377/// Response to the `ListInsights` method.
378///
379/// # Activities
380///
381/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
382/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
383///
384/// * [locations insight types insights list billing accounts](BillingAccountLocationInsightTypeInsightListCall) (response)
385/// * [locations insight types insights list folders](FolderLocationInsightTypeInsightListCall) (response)
386/// * [locations insight types insights list organizations](OrganizationLocationInsightTypeInsightListCall) (response)
387/// * [locations insight types insights list projects](ProjectLocationInsightTypeInsightListCall) (response)
388#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
389#[serde_with::serde_as]
390#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
391pub struct GoogleCloudRecommenderV1ListInsightsResponse {
392    /// The set of insights for the `parent` resource.
393    pub insights: Option<Vec<GoogleCloudRecommenderV1Insight>>,
394    /// A token that can be used to request the next page of results. This field is empty if there are no additional results.
395    #[serde(rename = "nextPageToken")]
396    pub next_page_token: Option<String>,
397}
398
399impl common::ResponseResult for GoogleCloudRecommenderV1ListInsightsResponse {}
400
401/// Response to the `ListRecommendations` method.
402///
403/// # Activities
404///
405/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
406/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
407///
408/// * [locations recommenders recommendations list billing accounts](BillingAccountLocationRecommenderRecommendationListCall) (response)
409/// * [locations recommenders recommendations list folders](FolderLocationRecommenderRecommendationListCall) (response)
410/// * [locations recommenders recommendations list organizations](OrganizationLocationRecommenderRecommendationListCall) (response)
411/// * [locations recommenders recommendations list projects](ProjectLocationRecommenderRecommendationListCall) (response)
412#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
413#[serde_with::serde_as]
414#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
415pub struct GoogleCloudRecommenderV1ListRecommendationsResponse {
416    /// A token that can be used to request the next page of results. This field is empty if there are no additional results.
417    #[serde(rename = "nextPageToken")]
418    pub next_page_token: Option<String>,
419    /// The set of recommendations for the `parent` resource.
420    pub recommendations: Option<Vec<GoogleCloudRecommenderV1Recommendation>>,
421}
422
423impl common::ResponseResult for GoogleCloudRecommenderV1ListRecommendationsResponse {}
424
425/// Request for the `MarkInsightAccepted` method.
426///
427/// # Activities
428///
429/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
430/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
431///
432/// * [locations insight types insights mark accepted billing accounts](BillingAccountLocationInsightTypeInsightMarkAcceptedCall) (request)
433/// * [locations insight types insights mark accepted folders](FolderLocationInsightTypeInsightMarkAcceptedCall) (request)
434/// * [locations insight types insights mark accepted organizations](OrganizationLocationInsightTypeInsightMarkAcceptedCall) (request)
435/// * [locations insight types insights mark accepted projects](ProjectLocationInsightTypeInsightMarkAcceptedCall) (request)
436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
437#[serde_with::serde_as]
438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
439pub struct GoogleCloudRecommenderV1MarkInsightAcceptedRequest {
440    /// Required. Fingerprint of the Insight. Provides optimistic locking.
441    pub etag: Option<String>,
442    /// Optional. State properties user wish to include with this state. Full replace of the current state_metadata.
443    #[serde(rename = "stateMetadata")]
444    pub state_metadata: Option<HashMap<String, String>>,
445}
446
447impl common::RequestValue for GoogleCloudRecommenderV1MarkInsightAcceptedRequest {}
448
449/// Request for the `MarkRecommendationClaimed` Method.
450///
451/// # Activities
452///
453/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
454/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
455///
456/// * [locations recommenders recommendations mark claimed billing accounts](BillingAccountLocationRecommenderRecommendationMarkClaimedCall) (request)
457/// * [locations recommenders recommendations mark claimed folders](FolderLocationRecommenderRecommendationMarkClaimedCall) (request)
458/// * [locations recommenders recommendations mark claimed organizations](OrganizationLocationRecommenderRecommendationMarkClaimedCall) (request)
459/// * [locations recommenders recommendations mark claimed projects](ProjectLocationRecommenderRecommendationMarkClaimedCall) (request)
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct GoogleCloudRecommenderV1MarkRecommendationClaimedRequest {
464    /// Required. Fingerprint of the Recommendation. Provides optimistic locking.
465    pub etag: Option<String>,
466    /// State properties to include with this state. Overwrites any existing `state_metadata`. Keys must match the regex `/^a-z0-9{0,62}$/`. Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
467    #[serde(rename = "stateMetadata")]
468    pub state_metadata: Option<HashMap<String, String>>,
469}
470
471impl common::RequestValue for GoogleCloudRecommenderV1MarkRecommendationClaimedRequest {}
472
473/// Request for the `MarkRecommendationDismissed` Method.
474///
475/// # Activities
476///
477/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
478/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
479///
480/// * [locations recommenders recommendations mark dismissed billing accounts](BillingAccountLocationRecommenderRecommendationMarkDismissedCall) (request)
481/// * [locations recommenders recommendations mark dismissed folders](FolderLocationRecommenderRecommendationMarkDismissedCall) (request)
482/// * [locations recommenders recommendations mark dismissed organizations](OrganizationLocationRecommenderRecommendationMarkDismissedCall) (request)
483/// * [locations recommenders recommendations mark dismissed projects](ProjectLocationRecommenderRecommendationMarkDismissedCall) (request)
484#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
485#[serde_with::serde_as]
486#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
487pub struct GoogleCloudRecommenderV1MarkRecommendationDismissedRequest {
488    /// Fingerprint of the Recommendation. Provides optimistic locking.
489    pub etag: Option<String>,
490}
491
492impl common::RequestValue for GoogleCloudRecommenderV1MarkRecommendationDismissedRequest {}
493
494/// Request for the `MarkRecommendationFailed` Method.
495///
496/// # Activities
497///
498/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
499/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
500///
501/// * [locations recommenders recommendations mark failed billing accounts](BillingAccountLocationRecommenderRecommendationMarkFailedCall) (request)
502/// * [locations recommenders recommendations mark failed folders](FolderLocationRecommenderRecommendationMarkFailedCall) (request)
503/// * [locations recommenders recommendations mark failed organizations](OrganizationLocationRecommenderRecommendationMarkFailedCall) (request)
504/// * [locations recommenders recommendations mark failed projects](ProjectLocationRecommenderRecommendationMarkFailedCall) (request)
505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
506#[serde_with::serde_as]
507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
508pub struct GoogleCloudRecommenderV1MarkRecommendationFailedRequest {
509    /// Required. Fingerprint of the Recommendation. Provides optimistic locking.
510    pub etag: Option<String>,
511    /// State properties to include with this state. Overwrites any existing `state_metadata`. Keys must match the regex `/^a-z0-9{0,62}$/`. Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
512    #[serde(rename = "stateMetadata")]
513    pub state_metadata: Option<HashMap<String, String>>,
514}
515
516impl common::RequestValue for GoogleCloudRecommenderV1MarkRecommendationFailedRequest {}
517
518/// Request for the `MarkRecommendationSucceeded` Method.
519///
520/// # Activities
521///
522/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
523/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
524///
525/// * [locations recommenders recommendations mark succeeded billing accounts](BillingAccountLocationRecommenderRecommendationMarkSucceededCall) (request)
526/// * [locations recommenders recommendations mark succeeded folders](FolderLocationRecommenderRecommendationMarkSucceededCall) (request)
527/// * [locations recommenders recommendations mark succeeded organizations](OrganizationLocationRecommenderRecommendationMarkSucceededCall) (request)
528/// * [locations recommenders recommendations mark succeeded projects](ProjectLocationRecommenderRecommendationMarkSucceededCall) (request)
529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
530#[serde_with::serde_as]
531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
532pub struct GoogleCloudRecommenderV1MarkRecommendationSucceededRequest {
533    /// Required. Fingerprint of the Recommendation. Provides optimistic locking.
534    pub etag: Option<String>,
535    /// State properties to include with this state. Overwrites any existing `state_metadata`. Keys must match the regex `/^a-z0-9{0,62}$/`. Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
536    #[serde(rename = "stateMetadata")]
537    pub state_metadata: Option<HashMap<String, String>>,
538}
539
540impl common::RequestValue for GoogleCloudRecommenderV1MarkRecommendationSucceededRequest {}
541
542/// Contains an operation for a resource loosely based on the JSON-PATCH format with support for: * Custom filters for describing partial array patch. * Extended path values for describing nested arrays. * Custom fields for describing the resource for which the operation is being described. * Allows extension to custom operations not natively supported by RFC6902. See https://tools.ietf.org/html/rfc6902 for details on the original RFC.
543///
544/// This type is not used in any activity, and only used as *part* of another schema.
545///
546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
547#[serde_with::serde_as]
548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
549pub struct GoogleCloudRecommenderV1Operation {
550    /// Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', 'copy', 'test' and custom operations. This field is case-insensitive and always populated.
551    pub action: Option<String>,
552    /// Path to the target field being operated on. If the operation is at the resource level, then path should be "/". This field is always populated.
553    pub path: Option<String>,
554    /// Set of filters to apply if `path` refers to array elements or nested array elements in order to narrow down to a single unique element that is being tested/modified. This is intended to be an exact match per filter. To perform advanced matching, use path_value_matchers. * Example: ``` { "/versions/*/name" : "it-123" "/versions/*/targetSize/percent": 20 } ``` * Example: ``` { "/bindings/*/role": "roles/owner" "/bindings/*/condition" : null } ``` * Example: ``` { "/bindings/*/role": "roles/owner" "/bindings/*/members/*" : ["x@example.com", "y@example.com"] } ``` When both path_filters and path_value_matchers are set, an implicit AND must be performed.
555    #[serde(rename = "pathFilters")]
556    pub path_filters: Option<HashMap<String, serde_json::Value>>,
557    /// Similar to path_filters, this contains set of filters to apply if `path` field refers to array elements. This is meant to support value matching beyond exact match. To perform exact match, use path_filters. When both path_filters and path_value_matchers are set, an implicit AND must be performed.
558    #[serde(rename = "pathValueMatchers")]
559    pub path_value_matchers: Option<HashMap<String, GoogleCloudRecommenderV1ValueMatcher>>,
560    /// Contains the fully qualified resource name. This field is always populated. ex: //cloudresourcemanager.googleapis.com/projects/foo.
561    pub resource: Option<String>,
562    /// Type of GCP resource being modified/tested. This field is always populated. Example: cloudresourcemanager.googleapis.com/Project, compute.googleapis.com/Instance
563    #[serde(rename = "resourceType")]
564    pub resource_type: Option<String>,
565    /// Can be set with action 'copy' or 'move' to indicate the source field within resource or source_resource, ignored if provided for other operation types.
566    #[serde(rename = "sourcePath")]
567    pub source_path: Option<String>,
568    /// Can be set with action 'copy' to copy resource configuration across different resources of the same type. Example: A resource clone can be done via action = 'copy', path = "/", from = "/", source_resource = and resource_name = . This field is empty for all other values of `action`.
569    #[serde(rename = "sourceResource")]
570    pub source_resource: Option<String>,
571    /// Value for the `path` field. Will be set for actions:'add'/'replace'. Maybe set for action: 'test'. Either this or `value_matcher` will be set for 'test' operation. An exact match must be performed.
572    pub value: Option<serde_json::Value>,
573    /// Can be set for action 'test' for advanced matching for the value of 'path' field. Either this or `value` will be set for 'test' operation.
574    #[serde(rename = "valueMatcher")]
575    pub value_matcher: Option<GoogleCloudRecommenderV1ValueMatcher>,
576}
577
578impl common::Part for GoogleCloudRecommenderV1Operation {}
579
580/// Group of operations that need to be performed atomically.
581///
582/// This type is not used in any activity, and only used as *part* of another schema.
583///
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct GoogleCloudRecommenderV1OperationGroup {
588    /// List of operations across one or more resources that belong to this group. Loosely based on RFC6902 and should be performed in the order they appear.
589    pub operations: Option<Vec<GoogleCloudRecommenderV1Operation>>,
590}
591
592impl common::Part for GoogleCloudRecommenderV1OperationGroup {}
593
594/// A recommendation along with a suggested action. E.g., a rightsizing recommendation for an underutilized VM, IAM role recommendations, etc
595///
596/// # Activities
597///
598/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
599/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
600///
601/// * [locations recommenders recommendations get billing accounts](BillingAccountLocationRecommenderRecommendationGetCall) (response)
602/// * [locations recommenders recommendations mark claimed billing accounts](BillingAccountLocationRecommenderRecommendationMarkClaimedCall) (response)
603/// * [locations recommenders recommendations mark dismissed billing accounts](BillingAccountLocationRecommenderRecommendationMarkDismissedCall) (response)
604/// * [locations recommenders recommendations mark failed billing accounts](BillingAccountLocationRecommenderRecommendationMarkFailedCall) (response)
605/// * [locations recommenders recommendations mark succeeded billing accounts](BillingAccountLocationRecommenderRecommendationMarkSucceededCall) (response)
606/// * [locations recommenders recommendations get folders](FolderLocationRecommenderRecommendationGetCall) (response)
607/// * [locations recommenders recommendations mark claimed folders](FolderLocationRecommenderRecommendationMarkClaimedCall) (response)
608/// * [locations recommenders recommendations mark dismissed folders](FolderLocationRecommenderRecommendationMarkDismissedCall) (response)
609/// * [locations recommenders recommendations mark failed folders](FolderLocationRecommenderRecommendationMarkFailedCall) (response)
610/// * [locations recommenders recommendations mark succeeded folders](FolderLocationRecommenderRecommendationMarkSucceededCall) (response)
611/// * [locations recommenders recommendations get organizations](OrganizationLocationRecommenderRecommendationGetCall) (response)
612/// * [locations recommenders recommendations mark claimed organizations](OrganizationLocationRecommenderRecommendationMarkClaimedCall) (response)
613/// * [locations recommenders recommendations mark dismissed organizations](OrganizationLocationRecommenderRecommendationMarkDismissedCall) (response)
614/// * [locations recommenders recommendations mark failed organizations](OrganizationLocationRecommenderRecommendationMarkFailedCall) (response)
615/// * [locations recommenders recommendations mark succeeded organizations](OrganizationLocationRecommenderRecommendationMarkSucceededCall) (response)
616/// * [locations recommenders recommendations get projects](ProjectLocationRecommenderRecommendationGetCall) (response)
617/// * [locations recommenders recommendations mark claimed projects](ProjectLocationRecommenderRecommendationMarkClaimedCall) (response)
618/// * [locations recommenders recommendations mark dismissed projects](ProjectLocationRecommenderRecommendationMarkDismissedCall) (response)
619/// * [locations recommenders recommendations mark failed projects](ProjectLocationRecommenderRecommendationMarkFailedCall) (response)
620/// * [locations recommenders recommendations mark succeeded projects](ProjectLocationRecommenderRecommendationMarkSucceededCall) (response)
621#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
622#[serde_with::serde_as]
623#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
624pub struct GoogleCloudRecommenderV1Recommendation {
625    /// Optional set of additional impact that this recommendation may have when trying to optimize for the primary category. These may be positive or negative.
626    #[serde(rename = "additionalImpact")]
627    pub additional_impact: Option<Vec<GoogleCloudRecommenderV1Impact>>,
628    /// Insights that led to this recommendation.
629    #[serde(rename = "associatedInsights")]
630    pub associated_insights: Option<Vec<GoogleCloudRecommenderV1RecommendationInsightReference>>,
631    /// Content of the recommendation describing recommended changes to resources.
632    pub content: Option<GoogleCloudRecommenderV1RecommendationContent>,
633    /// Free-form human readable summary in English. The maximum length is 500 characters.
634    pub description: Option<String>,
635    /// Fingerprint of the Recommendation. Provides optimistic locking when updating states.
636    pub etag: Option<String>,
637    /// Last time this recommendation was refreshed by the system that created it in the first place.
638    #[serde(rename = "lastRefreshTime")]
639    pub last_refresh_time: Option<chrono::DateTime<chrono::offset::Utc>>,
640    /// Identifier. Name of recommendation.
641    pub name: Option<String>,
642    /// The primary impact that this recommendation can have while trying to optimize for one category.
643    #[serde(rename = "primaryImpact")]
644    pub primary_impact: Option<GoogleCloudRecommenderV1Impact>,
645    /// Recommendation's priority.
646    pub priority: Option<String>,
647    /// Contains an identifier for a subtype of recommendations produced for the same recommender. Subtype is a function of content and impact, meaning a new subtype might be added when significant changes to `content` or `primary_impact.category` are introduced. See the Recommenders section to see a list of subtypes for a given Recommender. Examples: For recommender = "google.iam.policy.Recommender", recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE"
648    #[serde(rename = "recommenderSubtype")]
649    pub recommender_subtype: Option<String>,
650    /// Information for state. Contains state and metadata.
651    #[serde(rename = "stateInfo")]
652    pub state_info: Option<GoogleCloudRecommenderV1RecommendationStateInfo>,
653    /// Fully qualified resource names that this recommendation is targeting.
654    #[serde(rename = "targetResources")]
655    pub target_resources: Option<Vec<String>>,
656    /// Corresponds to a mutually exclusive group ID within a recommender. A non-empty ID indicates that the recommendation belongs to a mutually exclusive group. This means that only one recommendation within the group is suggested to be applied.
657    #[serde(rename = "xorGroupId")]
658    pub xor_group_id: Option<String>,
659}
660
661impl common::ResponseResult for GoogleCloudRecommenderV1Recommendation {}
662
663/// Contains what resources are changing and how they are changing.
664///
665/// This type is not used in any activity, and only used as *part* of another schema.
666///
667#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
668#[serde_with::serde_as]
669#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
670pub struct GoogleCloudRecommenderV1RecommendationContent {
671    /// Operations to one or more Google Cloud resources grouped in such a way that, all operations within one group are expected to be performed atomically and in an order.
672    #[serde(rename = "operationGroups")]
673    pub operation_groups: Option<Vec<GoogleCloudRecommenderV1OperationGroup>>,
674    /// Condensed overview information about the recommendation.
675    pub overview: Option<HashMap<String, serde_json::Value>>,
676}
677
678impl common::Part for GoogleCloudRecommenderV1RecommendationContent {}
679
680/// Reference to an associated insight.
681///
682/// This type is not used in any activity, and only used as *part* of another schema.
683///
684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
685#[serde_with::serde_as]
686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
687pub struct GoogleCloudRecommenderV1RecommendationInsightReference {
688    /// Insight resource name, e.g. projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID]
689    pub insight: Option<String>,
690}
691
692impl common::Part for GoogleCloudRecommenderV1RecommendationInsightReference {}
693
694/// Information for state. Contains state and metadata.
695///
696/// This type is not used in any activity, and only used as *part* of another schema.
697///
698#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
699#[serde_with::serde_as]
700#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
701pub struct GoogleCloudRecommenderV1RecommendationStateInfo {
702    /// The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED.
703    pub state: Option<String>,
704    /// A map of metadata for the state, provided by user or automations systems.
705    #[serde(rename = "stateMetadata")]
706    pub state_metadata: Option<HashMap<String, String>>,
707}
708
709impl common::Part for GoogleCloudRecommenderV1RecommendationStateInfo {}
710
711/// Configuration for a Recommender.
712///
713/// # Activities
714///
715/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
716/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
717///
718/// * [locations recommenders get config billing accounts](BillingAccountLocationRecommenderGetConfigCall) (response)
719/// * [locations recommenders update config billing accounts](BillingAccountLocationRecommenderUpdateConfigCall) (request|response)
720/// * [locations recommenders get config organizations](OrganizationLocationRecommenderGetConfigCall) (response)
721/// * [locations recommenders update config organizations](OrganizationLocationRecommenderUpdateConfigCall) (request|response)
722/// * [locations recommenders get config projects](ProjectLocationRecommenderGetConfigCall) (response)
723/// * [locations recommenders update config projects](ProjectLocationRecommenderUpdateConfigCall) (request|response)
724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
725#[serde_with::serde_as]
726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
727pub struct GoogleCloudRecommenderV1RecommenderConfig {
728    /// Allows clients to store small amounts of arbitrary data. Annotations must follow the Kubernetes syntax. The total size of all keys and values combined is limited to 256k. Key can have 2 segments: prefix (optional) and name (required), separated by a slash (/). Prefix must be a DNS subdomain. Name must be 63 characters or less, begin and end with alphanumerics, with dashes (-), underscores (_), dots (.), and alphanumerics between.
729    pub annotations: Option<HashMap<String, String>>,
730    /// A user-settable field to provide a human-readable name to be used in user interfaces.
731    #[serde(rename = "displayName")]
732    pub display_name: Option<String>,
733    /// Fingerprint of the RecommenderConfig. Provides optimistic locking when updating.
734    pub etag: Option<String>,
735    /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
736    pub name: Option<String>,
737    /// RecommenderGenerationConfig which configures the Generation of recommendations for this recommender.
738    #[serde(rename = "recommenderGenerationConfig")]
739    pub recommender_generation_config: Option<GoogleCloudRecommenderV1RecommenderGenerationConfig>,
740    /// Output only. Immutable. The revision ID of the config. A new revision is committed whenever the config is changed in any way. The format is an 8-character hexadecimal string.
741    #[serde(rename = "revisionId")]
742    pub revision_id: Option<String>,
743    /// Last time when the config was updated.
744    #[serde(rename = "updateTime")]
745    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
746}
747
748impl common::RequestValue for GoogleCloudRecommenderV1RecommenderConfig {}
749impl common::ResponseResult for GoogleCloudRecommenderV1RecommenderConfig {}
750
751/// A Configuration to customize the generation of recommendations. Eg, customizing the lookback period considered when generating a recommendation.
752///
753/// This type is not used in any activity, and only used as *part* of another schema.
754///
755#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
756#[serde_with::serde_as]
757#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
758pub struct GoogleCloudRecommenderV1RecommenderGenerationConfig {
759    /// Parameters for this RecommenderGenerationConfig. These configs can be used by or are applied to all subtypes.
760    pub params: Option<HashMap<String, serde_json::Value>>,
761}
762
763impl common::Part for GoogleCloudRecommenderV1RecommenderGenerationConfig {}
764
765/// Contains information on the impact of a reliability recommendation.
766///
767/// This type is not used in any activity, and only used as *part* of another schema.
768///
769#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
770#[serde_with::serde_as]
771#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
772pub struct GoogleCloudRecommenderV1ReliabilityProjection {
773    /// Per-recommender projection.
774    pub details: Option<HashMap<String, serde_json::Value>>,
775    /// Reliability risks mitigated by this recommendation.
776    pub risks: Option<Vec<String>>,
777}
778
779impl common::Part for GoogleCloudRecommenderV1ReliabilityProjection {}
780
781/// Contains various ways of describing the impact on Security.
782///
783/// This type is not used in any activity, and only used as *part* of another schema.
784///
785#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
786#[serde_with::serde_as]
787#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
788pub struct GoogleCloudRecommenderV1SecurityProjection {
789    /// Additional security impact details that is provided by the recommender.
790    pub details: Option<HashMap<String, serde_json::Value>>,
791}
792
793impl common::Part for GoogleCloudRecommenderV1SecurityProjection {}
794
795/// Contains metadata about how much sustainability a recommendation can save or incur.
796///
797/// This type is not used in any activity, and only used as *part* of another schema.
798///
799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
800#[serde_with::serde_as]
801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
802pub struct GoogleCloudRecommenderV1SustainabilityProjection {
803    /// Duration for which this sustainability applies.
804    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
805    pub duration: Option<chrono::Duration>,
806    /// Carbon Footprint generated in kg of CO2 equivalent. Chose kg_c_o2e so that the name renders correctly in camelCase (kgCO2e).
807    #[serde(rename = "kgCO2e")]
808    pub kg_co2e: Option<f64>,
809}
810
811impl common::Part for GoogleCloudRecommenderV1SustainabilityProjection {}
812
813/// Contains various matching options for values for a GCP resource field.
814///
815/// This type is not used in any activity, and only used as *part* of another schema.
816///
817#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
818#[serde_with::serde_as]
819#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
820pub struct GoogleCloudRecommenderV1ValueMatcher {
821    /// To be used for full regex matching. The regular expression is using the Google RE2 syntax (https://github.com/google/re2/wiki/Syntax), so to be used with RE2::FullMatch
822    #[serde(rename = "matchesPattern")]
823    pub matches_pattern: Option<String>,
824}
825
826impl common::Part for GoogleCloudRecommenderV1ValueMatcher {}
827
828/// Represents an amount of money with its currency type.
829///
830/// This type is not used in any activity, and only used as *part* of another schema.
831///
832#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
833#[serde_with::serde_as]
834#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
835pub struct GoogleTypeMoney {
836    /// The three-letter currency code defined in ISO 4217.
837    #[serde(rename = "currencyCode")]
838    pub currency_code: Option<String>,
839    /// Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If `units` is positive, `nanos` must be positive or zero. If `units` is zero, `nanos` can be positive, zero, or negative. If `units` is negative, `nanos` must be negative or zero. For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
840    pub nanos: Option<i32>,
841    /// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
842    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
843    pub units: Option<i64>,
844}
845
846impl common::Part for GoogleTypeMoney {}
847
848// ###################
849// MethodBuilders ###
850// #################
851
852/// A builder providing access to all methods supported on *billingAccount* resources.
853/// It is not used directly, but through the [`Recommender`] hub.
854///
855/// # Example
856///
857/// Instantiate a resource builder
858///
859/// ```test_harness,no_run
860/// extern crate hyper;
861/// extern crate hyper_rustls;
862/// extern crate google_recommender1 as recommender1;
863///
864/// # async fn dox() {
865/// use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
866///
867/// let secret: yup_oauth2::ApplicationSecret = Default::default();
868/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
869///     .with_native_roots()
870///     .unwrap()
871///     .https_only()
872///     .enable_http2()
873///     .build();
874///
875/// let executor = hyper_util::rt::TokioExecutor::new();
876/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
877///     secret,
878///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
879///     yup_oauth2::client::CustomHyperClientBuilder::from(
880///         hyper_util::client::legacy::Client::builder(executor).build(connector),
881///     ),
882/// ).build().await.unwrap();
883///
884/// let client = hyper_util::client::legacy::Client::builder(
885///     hyper_util::rt::TokioExecutor::new()
886/// )
887/// .build(
888///     hyper_rustls::HttpsConnectorBuilder::new()
889///         .with_native_roots()
890///         .unwrap()
891///         .https_or_http()
892///         .enable_http2()
893///         .build()
894/// );
895/// let mut hub = Recommender::new(client, auth);
896/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
897/// // like `locations_insight_types_get_config(...)`, `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_insight_types_update_config(...)`, `locations_recommenders_get_config(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)`, `locations_recommenders_recommendations_mark_succeeded(...)` and `locations_recommenders_update_config(...)`
898/// // to build up your call.
899/// let rb = hub.billing_accounts();
900/// # }
901/// ```
902pub struct BillingAccountMethods<'a, C>
903where
904    C: 'a,
905{
906    hub: &'a Recommender<C>,
907}
908
909impl<'a, C> common::MethodsBuilder for BillingAccountMethods<'a, C> {}
910
911impl<'a, C> BillingAccountMethods<'a, C> {
912    /// Create a builder to help you perform the following task:
913    ///
914    /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
915    ///
916    /// # Arguments
917    ///
918    /// * `name` - Required. Name of the insight.
919    pub fn locations_insight_types_insights_get(
920        &self,
921        name: &str,
922    ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
923        BillingAccountLocationInsightTypeInsightGetCall {
924            hub: self.hub,
925            _name: name.to_string(),
926            _delegate: Default::default(),
927            _additional_params: Default::default(),
928            _scopes: Default::default(),
929        }
930    }
931
932    /// Create a builder to help you perform the following task:
933    ///
934    /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
935    ///
936    /// # Arguments
937    ///
938    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
939    pub fn locations_insight_types_insights_list(
940        &self,
941        parent: &str,
942    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
943        BillingAccountLocationInsightTypeInsightListCall {
944            hub: self.hub,
945            _parent: parent.to_string(),
946            _page_token: Default::default(),
947            _page_size: Default::default(),
948            _filter: Default::default(),
949            _delegate: Default::default(),
950            _additional_params: Default::default(),
951            _scopes: Default::default(),
952        }
953    }
954
955    /// Create a builder to help you perform the following task:
956    ///
957    /// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
958    ///
959    /// # Arguments
960    ///
961    /// * `request` - No description provided.
962    /// * `name` - Required. Name of the insight.
963    pub fn locations_insight_types_insights_mark_accepted(
964        &self,
965        request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
966        name: &str,
967    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
968        BillingAccountLocationInsightTypeInsightMarkAcceptedCall {
969            hub: self.hub,
970            _request: request,
971            _name: name.to_string(),
972            _delegate: Default::default(),
973            _additional_params: Default::default(),
974            _scopes: Default::default(),
975        }
976    }
977
978    /// Create a builder to help you perform the following task:
979    ///
980    /// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
981    ///
982    /// # Arguments
983    ///
984    /// * `name` - Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
985    pub fn locations_insight_types_get_config(
986        &self,
987        name: &str,
988    ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
989        BillingAccountLocationInsightTypeGetConfigCall {
990            hub: self.hub,
991            _name: name.to_string(),
992            _delegate: Default::default(),
993            _additional_params: Default::default(),
994            _scopes: Default::default(),
995        }
996    }
997
998    /// Create a builder to help you perform the following task:
999    ///
1000    /// Updates an InsightTypeConfig change. This will create a new revision of the config.
1001    ///
1002    /// # Arguments
1003    ///
1004    /// * `request` - No description provided.
1005    /// * `name` - Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
1006    pub fn locations_insight_types_update_config(
1007        &self,
1008        request: GoogleCloudRecommenderV1InsightTypeConfig,
1009        name: &str,
1010    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
1011        BillingAccountLocationInsightTypeUpdateConfigCall {
1012            hub: self.hub,
1013            _request: request,
1014            _name: name.to_string(),
1015            _validate_only: Default::default(),
1016            _update_mask: Default::default(),
1017            _delegate: Default::default(),
1018            _additional_params: Default::default(),
1019            _scopes: Default::default(),
1020        }
1021    }
1022
1023    /// Create a builder to help you perform the following task:
1024    ///
1025    /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
1026    ///
1027    /// # Arguments
1028    ///
1029    /// * `name` - Required. Name of the recommendation.
1030    pub fn locations_recommenders_recommendations_get(
1031        &self,
1032        name: &str,
1033    ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
1034        BillingAccountLocationRecommenderRecommendationGetCall {
1035            hub: self.hub,
1036            _name: name.to_string(),
1037            _delegate: Default::default(),
1038            _additional_params: Default::default(),
1039            _scopes: Default::default(),
1040        }
1041    }
1042
1043    /// Create a builder to help you perform the following task:
1044    ///
1045    /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
1046    ///
1047    /// # Arguments
1048    ///
1049    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
1050    pub fn locations_recommenders_recommendations_list(
1051        &self,
1052        parent: &str,
1053    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
1054        BillingAccountLocationRecommenderRecommendationListCall {
1055            hub: self.hub,
1056            _parent: parent.to_string(),
1057            _page_token: Default::default(),
1058            _page_size: Default::default(),
1059            _filter: Default::default(),
1060            _delegate: Default::default(),
1061            _additional_params: Default::default(),
1062            _scopes: Default::default(),
1063        }
1064    }
1065
1066    /// Create a builder to help you perform the following task:
1067    ///
1068    /// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1069    ///
1070    /// # Arguments
1071    ///
1072    /// * `request` - No description provided.
1073    /// * `name` - Required. Name of the recommendation.
1074    pub fn locations_recommenders_recommendations_mark_claimed(
1075        &self,
1076        request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
1077        name: &str,
1078    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
1079        BillingAccountLocationRecommenderRecommendationMarkClaimedCall {
1080            hub: self.hub,
1081            _request: request,
1082            _name: name.to_string(),
1083            _delegate: Default::default(),
1084            _additional_params: Default::default(),
1085            _scopes: Default::default(),
1086        }
1087    }
1088
1089    /// Create a builder to help you perform the following task:
1090    ///
1091    /// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1092    ///
1093    /// # Arguments
1094    ///
1095    /// * `request` - No description provided.
1096    /// * `name` - Required. Name of the recommendation.
1097    pub fn locations_recommenders_recommendations_mark_dismissed(
1098        &self,
1099        request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
1100        name: &str,
1101    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
1102        BillingAccountLocationRecommenderRecommendationMarkDismissedCall {
1103            hub: self.hub,
1104            _request: request,
1105            _name: name.to_string(),
1106            _delegate: Default::default(),
1107            _additional_params: Default::default(),
1108            _scopes: Default::default(),
1109        }
1110    }
1111
1112    /// Create a builder to help you perform the following task:
1113    ///
1114    /// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
1115    ///
1116    /// # Arguments
1117    ///
1118    /// * `request` - No description provided.
1119    /// * `name` - Required. Name of the recommendation.
1120    pub fn locations_recommenders_recommendations_mark_failed(
1121        &self,
1122        request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
1123        name: &str,
1124    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
1125        BillingAccountLocationRecommenderRecommendationMarkFailedCall {
1126            hub: self.hub,
1127            _request: request,
1128            _name: name.to_string(),
1129            _delegate: Default::default(),
1130            _additional_params: Default::default(),
1131            _scopes: Default::default(),
1132        }
1133    }
1134
1135    /// Create a builder to help you perform the following task:
1136    ///
1137    /// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
1138    ///
1139    /// # Arguments
1140    ///
1141    /// * `request` - No description provided.
1142    /// * `name` - Required. Name of the recommendation.
1143    pub fn locations_recommenders_recommendations_mark_succeeded(
1144        &self,
1145        request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
1146        name: &str,
1147    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
1148        BillingAccountLocationRecommenderRecommendationMarkSucceededCall {
1149            hub: self.hub,
1150            _request: request,
1151            _name: name.to_string(),
1152            _delegate: Default::default(),
1153            _additional_params: Default::default(),
1154            _scopes: Default::default(),
1155        }
1156    }
1157
1158    /// Create a builder to help you perform the following task:
1159    ///
1160    /// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
1161    ///
1162    /// # Arguments
1163    ///
1164    /// * `name` - Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
1165    pub fn locations_recommenders_get_config(
1166        &self,
1167        name: &str,
1168    ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
1169        BillingAccountLocationRecommenderGetConfigCall {
1170            hub: self.hub,
1171            _name: name.to_string(),
1172            _delegate: Default::default(),
1173            _additional_params: Default::default(),
1174            _scopes: Default::default(),
1175        }
1176    }
1177
1178    /// Create a builder to help you perform the following task:
1179    ///
1180    /// Updates a Recommender Config. This will create a new revision of the config.
1181    ///
1182    /// # Arguments
1183    ///
1184    /// * `request` - No description provided.
1185    /// * `name` - Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
1186    pub fn locations_recommenders_update_config(
1187        &self,
1188        request: GoogleCloudRecommenderV1RecommenderConfig,
1189        name: &str,
1190    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
1191        BillingAccountLocationRecommenderUpdateConfigCall {
1192            hub: self.hub,
1193            _request: request,
1194            _name: name.to_string(),
1195            _validate_only: Default::default(),
1196            _update_mask: Default::default(),
1197            _delegate: Default::default(),
1198            _additional_params: Default::default(),
1199            _scopes: Default::default(),
1200        }
1201    }
1202}
1203
1204/// A builder providing access to all methods supported on *folder* resources.
1205/// It is not used directly, but through the [`Recommender`] hub.
1206///
1207/// # Example
1208///
1209/// Instantiate a resource builder
1210///
1211/// ```test_harness,no_run
1212/// extern crate hyper;
1213/// extern crate hyper_rustls;
1214/// extern crate google_recommender1 as recommender1;
1215///
1216/// # async fn dox() {
1217/// use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1218///
1219/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1220/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1221///     .with_native_roots()
1222///     .unwrap()
1223///     .https_only()
1224///     .enable_http2()
1225///     .build();
1226///
1227/// let executor = hyper_util::rt::TokioExecutor::new();
1228/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1229///     secret,
1230///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1231///     yup_oauth2::client::CustomHyperClientBuilder::from(
1232///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1233///     ),
1234/// ).build().await.unwrap();
1235///
1236/// let client = hyper_util::client::legacy::Client::builder(
1237///     hyper_util::rt::TokioExecutor::new()
1238/// )
1239/// .build(
1240///     hyper_rustls::HttpsConnectorBuilder::new()
1241///         .with_native_roots()
1242///         .unwrap()
1243///         .https_or_http()
1244///         .enable_http2()
1245///         .build()
1246/// );
1247/// let mut hub = Recommender::new(client, auth);
1248/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1249/// // like `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)` and `locations_recommenders_recommendations_mark_succeeded(...)`
1250/// // to build up your call.
1251/// let rb = hub.folders();
1252/// # }
1253/// ```
1254pub struct FolderMethods<'a, C>
1255where
1256    C: 'a,
1257{
1258    hub: &'a Recommender<C>,
1259}
1260
1261impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
1262
1263impl<'a, C> FolderMethods<'a, C> {
1264    /// Create a builder to help you perform the following task:
1265    ///
1266    /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
1267    ///
1268    /// # Arguments
1269    ///
1270    /// * `name` - Required. Name of the insight.
1271    pub fn locations_insight_types_insights_get(
1272        &self,
1273        name: &str,
1274    ) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
1275        FolderLocationInsightTypeInsightGetCall {
1276            hub: self.hub,
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    /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
1287    ///
1288    /// # Arguments
1289    ///
1290    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
1291    pub fn locations_insight_types_insights_list(
1292        &self,
1293        parent: &str,
1294    ) -> FolderLocationInsightTypeInsightListCall<'a, C> {
1295        FolderLocationInsightTypeInsightListCall {
1296            hub: self.hub,
1297            _parent: parent.to_string(),
1298            _page_token: Default::default(),
1299            _page_size: Default::default(),
1300            _filter: Default::default(),
1301            _delegate: Default::default(),
1302            _additional_params: Default::default(),
1303            _scopes: Default::default(),
1304        }
1305    }
1306
1307    /// Create a builder to help you perform the following task:
1308    ///
1309    /// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
1310    ///
1311    /// # Arguments
1312    ///
1313    /// * `request` - No description provided.
1314    /// * `name` - Required. Name of the insight.
1315    pub fn locations_insight_types_insights_mark_accepted(
1316        &self,
1317        request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
1318        name: &str,
1319    ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
1320        FolderLocationInsightTypeInsightMarkAcceptedCall {
1321            hub: self.hub,
1322            _request: request,
1323            _name: name.to_string(),
1324            _delegate: Default::default(),
1325            _additional_params: Default::default(),
1326            _scopes: Default::default(),
1327        }
1328    }
1329
1330    /// Create a builder to help you perform the following task:
1331    ///
1332    /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
1333    ///
1334    /// # Arguments
1335    ///
1336    /// * `name` - Required. Name of the recommendation.
1337    pub fn locations_recommenders_recommendations_get(
1338        &self,
1339        name: &str,
1340    ) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
1341        FolderLocationRecommenderRecommendationGetCall {
1342            hub: self.hub,
1343            _name: name.to_string(),
1344            _delegate: Default::default(),
1345            _additional_params: Default::default(),
1346            _scopes: Default::default(),
1347        }
1348    }
1349
1350    /// Create a builder to help you perform the following task:
1351    ///
1352    /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
1353    ///
1354    /// # Arguments
1355    ///
1356    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
1357    pub fn locations_recommenders_recommendations_list(
1358        &self,
1359        parent: &str,
1360    ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
1361        FolderLocationRecommenderRecommendationListCall {
1362            hub: self.hub,
1363            _parent: parent.to_string(),
1364            _page_token: Default::default(),
1365            _page_size: Default::default(),
1366            _filter: Default::default(),
1367            _delegate: Default::default(),
1368            _additional_params: Default::default(),
1369            _scopes: Default::default(),
1370        }
1371    }
1372
1373    /// Create a builder to help you perform the following task:
1374    ///
1375    /// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1376    ///
1377    /// # Arguments
1378    ///
1379    /// * `request` - No description provided.
1380    /// * `name` - Required. Name of the recommendation.
1381    pub fn locations_recommenders_recommendations_mark_claimed(
1382        &self,
1383        request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
1384        name: &str,
1385    ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
1386        FolderLocationRecommenderRecommendationMarkClaimedCall {
1387            hub: self.hub,
1388            _request: request,
1389            _name: name.to_string(),
1390            _delegate: Default::default(),
1391            _additional_params: Default::default(),
1392            _scopes: Default::default(),
1393        }
1394    }
1395
1396    /// Create a builder to help you perform the following task:
1397    ///
1398    /// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1399    ///
1400    /// # Arguments
1401    ///
1402    /// * `request` - No description provided.
1403    /// * `name` - Required. Name of the recommendation.
1404    pub fn locations_recommenders_recommendations_mark_dismissed(
1405        &self,
1406        request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
1407        name: &str,
1408    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
1409        FolderLocationRecommenderRecommendationMarkDismissedCall {
1410            hub: self.hub,
1411            _request: request,
1412            _name: name.to_string(),
1413            _delegate: Default::default(),
1414            _additional_params: Default::default(),
1415            _scopes: Default::default(),
1416        }
1417    }
1418
1419    /// Create a builder to help you perform the following task:
1420    ///
1421    /// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
1422    ///
1423    /// # Arguments
1424    ///
1425    /// * `request` - No description provided.
1426    /// * `name` - Required. Name of the recommendation.
1427    pub fn locations_recommenders_recommendations_mark_failed(
1428        &self,
1429        request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
1430        name: &str,
1431    ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
1432        FolderLocationRecommenderRecommendationMarkFailedCall {
1433            hub: self.hub,
1434            _request: request,
1435            _name: name.to_string(),
1436            _delegate: Default::default(),
1437            _additional_params: Default::default(),
1438            _scopes: Default::default(),
1439        }
1440    }
1441
1442    /// Create a builder to help you perform the following task:
1443    ///
1444    /// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
1445    ///
1446    /// # Arguments
1447    ///
1448    /// * `request` - No description provided.
1449    /// * `name` - Required. Name of the recommendation.
1450    pub fn locations_recommenders_recommendations_mark_succeeded(
1451        &self,
1452        request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
1453        name: &str,
1454    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
1455        FolderLocationRecommenderRecommendationMarkSucceededCall {
1456            hub: self.hub,
1457            _request: request,
1458            _name: name.to_string(),
1459            _delegate: Default::default(),
1460            _additional_params: Default::default(),
1461            _scopes: Default::default(),
1462        }
1463    }
1464}
1465
1466/// A builder providing access to all methods supported on *organization* resources.
1467/// It is not used directly, but through the [`Recommender`] hub.
1468///
1469/// # Example
1470///
1471/// Instantiate a resource builder
1472///
1473/// ```test_harness,no_run
1474/// extern crate hyper;
1475/// extern crate hyper_rustls;
1476/// extern crate google_recommender1 as recommender1;
1477///
1478/// # async fn dox() {
1479/// use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1480///
1481/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1482/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1483///     .with_native_roots()
1484///     .unwrap()
1485///     .https_only()
1486///     .enable_http2()
1487///     .build();
1488///
1489/// let executor = hyper_util::rt::TokioExecutor::new();
1490/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1491///     secret,
1492///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1493///     yup_oauth2::client::CustomHyperClientBuilder::from(
1494///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1495///     ),
1496/// ).build().await.unwrap();
1497///
1498/// let client = hyper_util::client::legacy::Client::builder(
1499///     hyper_util::rt::TokioExecutor::new()
1500/// )
1501/// .build(
1502///     hyper_rustls::HttpsConnectorBuilder::new()
1503///         .with_native_roots()
1504///         .unwrap()
1505///         .https_or_http()
1506///         .enable_http2()
1507///         .build()
1508/// );
1509/// let mut hub = Recommender::new(client, auth);
1510/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1511/// // like `locations_insight_types_get_config(...)`, `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_insight_types_update_config(...)`, `locations_recommenders_get_config(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)`, `locations_recommenders_recommendations_mark_succeeded(...)` and `locations_recommenders_update_config(...)`
1512/// // to build up your call.
1513/// let rb = hub.organizations();
1514/// # }
1515/// ```
1516pub struct OrganizationMethods<'a, C>
1517where
1518    C: 'a,
1519{
1520    hub: &'a Recommender<C>,
1521}
1522
1523impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
1524
1525impl<'a, C> OrganizationMethods<'a, C> {
1526    /// Create a builder to help you perform the following task:
1527    ///
1528    /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
1529    ///
1530    /// # Arguments
1531    ///
1532    /// * `name` - Required. Name of the insight.
1533    pub fn locations_insight_types_insights_get(
1534        &self,
1535        name: &str,
1536    ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
1537        OrganizationLocationInsightTypeInsightGetCall {
1538            hub: self.hub,
1539            _name: name.to_string(),
1540            _delegate: Default::default(),
1541            _additional_params: Default::default(),
1542            _scopes: Default::default(),
1543        }
1544    }
1545
1546    /// Create a builder to help you perform the following task:
1547    ///
1548    /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
1549    ///
1550    /// # Arguments
1551    ///
1552    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
1553    pub fn locations_insight_types_insights_list(
1554        &self,
1555        parent: &str,
1556    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
1557        OrganizationLocationInsightTypeInsightListCall {
1558            hub: self.hub,
1559            _parent: parent.to_string(),
1560            _page_token: Default::default(),
1561            _page_size: Default::default(),
1562            _filter: Default::default(),
1563            _delegate: Default::default(),
1564            _additional_params: Default::default(),
1565            _scopes: Default::default(),
1566        }
1567    }
1568
1569    /// Create a builder to help you perform the following task:
1570    ///
1571    /// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
1572    ///
1573    /// # Arguments
1574    ///
1575    /// * `request` - No description provided.
1576    /// * `name` - Required. Name of the insight.
1577    pub fn locations_insight_types_insights_mark_accepted(
1578        &self,
1579        request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
1580        name: &str,
1581    ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
1582        OrganizationLocationInsightTypeInsightMarkAcceptedCall {
1583            hub: self.hub,
1584            _request: request,
1585            _name: name.to_string(),
1586            _delegate: Default::default(),
1587            _additional_params: Default::default(),
1588            _scopes: Default::default(),
1589        }
1590    }
1591
1592    /// Create a builder to help you perform the following task:
1593    ///
1594    /// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
1595    ///
1596    /// # Arguments
1597    ///
1598    /// * `name` - Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
1599    pub fn locations_insight_types_get_config(
1600        &self,
1601        name: &str,
1602    ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
1603        OrganizationLocationInsightTypeGetConfigCall {
1604            hub: self.hub,
1605            _name: name.to_string(),
1606            _delegate: Default::default(),
1607            _additional_params: Default::default(),
1608            _scopes: Default::default(),
1609        }
1610    }
1611
1612    /// Create a builder to help you perform the following task:
1613    ///
1614    /// Updates an InsightTypeConfig change. This will create a new revision of the config.
1615    ///
1616    /// # Arguments
1617    ///
1618    /// * `request` - No description provided.
1619    /// * `name` - Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
1620    pub fn locations_insight_types_update_config(
1621        &self,
1622        request: GoogleCloudRecommenderV1InsightTypeConfig,
1623        name: &str,
1624    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
1625        OrganizationLocationInsightTypeUpdateConfigCall {
1626            hub: self.hub,
1627            _request: request,
1628            _name: name.to_string(),
1629            _validate_only: Default::default(),
1630            _update_mask: Default::default(),
1631            _delegate: Default::default(),
1632            _additional_params: Default::default(),
1633            _scopes: Default::default(),
1634        }
1635    }
1636
1637    /// Create a builder to help you perform the following task:
1638    ///
1639    /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
1640    ///
1641    /// # Arguments
1642    ///
1643    /// * `name` - Required. Name of the recommendation.
1644    pub fn locations_recommenders_recommendations_get(
1645        &self,
1646        name: &str,
1647    ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
1648        OrganizationLocationRecommenderRecommendationGetCall {
1649            hub: self.hub,
1650            _name: name.to_string(),
1651            _delegate: Default::default(),
1652            _additional_params: Default::default(),
1653            _scopes: Default::default(),
1654        }
1655    }
1656
1657    /// Create a builder to help you perform the following task:
1658    ///
1659    /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
1660    ///
1661    /// # Arguments
1662    ///
1663    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
1664    pub fn locations_recommenders_recommendations_list(
1665        &self,
1666        parent: &str,
1667    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
1668        OrganizationLocationRecommenderRecommendationListCall {
1669            hub: self.hub,
1670            _parent: parent.to_string(),
1671            _page_token: Default::default(),
1672            _page_size: Default::default(),
1673            _filter: Default::default(),
1674            _delegate: Default::default(),
1675            _additional_params: Default::default(),
1676            _scopes: Default::default(),
1677        }
1678    }
1679
1680    /// Create a builder to help you perform the following task:
1681    ///
1682    /// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1683    ///
1684    /// # Arguments
1685    ///
1686    /// * `request` - No description provided.
1687    /// * `name` - Required. Name of the recommendation.
1688    pub fn locations_recommenders_recommendations_mark_claimed(
1689        &self,
1690        request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
1691        name: &str,
1692    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
1693        OrganizationLocationRecommenderRecommendationMarkClaimedCall {
1694            hub: self.hub,
1695            _request: request,
1696            _name: name.to_string(),
1697            _delegate: Default::default(),
1698            _additional_params: Default::default(),
1699            _scopes: Default::default(),
1700        }
1701    }
1702
1703    /// Create a builder to help you perform the following task:
1704    ///
1705    /// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1706    ///
1707    /// # Arguments
1708    ///
1709    /// * `request` - No description provided.
1710    /// * `name` - Required. Name of the recommendation.
1711    pub fn locations_recommenders_recommendations_mark_dismissed(
1712        &self,
1713        request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
1714        name: &str,
1715    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
1716        OrganizationLocationRecommenderRecommendationMarkDismissedCall {
1717            hub: self.hub,
1718            _request: request,
1719            _name: name.to_string(),
1720            _delegate: Default::default(),
1721            _additional_params: Default::default(),
1722            _scopes: Default::default(),
1723        }
1724    }
1725
1726    /// Create a builder to help you perform the following task:
1727    ///
1728    /// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
1729    ///
1730    /// # Arguments
1731    ///
1732    /// * `request` - No description provided.
1733    /// * `name` - Required. Name of the recommendation.
1734    pub fn locations_recommenders_recommendations_mark_failed(
1735        &self,
1736        request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
1737        name: &str,
1738    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
1739        OrganizationLocationRecommenderRecommendationMarkFailedCall {
1740            hub: self.hub,
1741            _request: request,
1742            _name: name.to_string(),
1743            _delegate: Default::default(),
1744            _additional_params: Default::default(),
1745            _scopes: Default::default(),
1746        }
1747    }
1748
1749    /// Create a builder to help you perform the following task:
1750    ///
1751    /// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
1752    ///
1753    /// # Arguments
1754    ///
1755    /// * `request` - No description provided.
1756    /// * `name` - Required. Name of the recommendation.
1757    pub fn locations_recommenders_recommendations_mark_succeeded(
1758        &self,
1759        request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
1760        name: &str,
1761    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
1762        OrganizationLocationRecommenderRecommendationMarkSucceededCall {
1763            hub: self.hub,
1764            _request: request,
1765            _name: name.to_string(),
1766            _delegate: Default::default(),
1767            _additional_params: Default::default(),
1768            _scopes: Default::default(),
1769        }
1770    }
1771
1772    /// Create a builder to help you perform the following task:
1773    ///
1774    /// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
1775    ///
1776    /// # Arguments
1777    ///
1778    /// * `name` - Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
1779    pub fn locations_recommenders_get_config(
1780        &self,
1781        name: &str,
1782    ) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
1783        OrganizationLocationRecommenderGetConfigCall {
1784            hub: self.hub,
1785            _name: name.to_string(),
1786            _delegate: Default::default(),
1787            _additional_params: Default::default(),
1788            _scopes: Default::default(),
1789        }
1790    }
1791
1792    /// Create a builder to help you perform the following task:
1793    ///
1794    /// Updates a Recommender Config. This will create a new revision of the config.
1795    ///
1796    /// # Arguments
1797    ///
1798    /// * `request` - No description provided.
1799    /// * `name` - Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
1800    pub fn locations_recommenders_update_config(
1801        &self,
1802        request: GoogleCloudRecommenderV1RecommenderConfig,
1803        name: &str,
1804    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
1805        OrganizationLocationRecommenderUpdateConfigCall {
1806            hub: self.hub,
1807            _request: request,
1808            _name: name.to_string(),
1809            _validate_only: Default::default(),
1810            _update_mask: Default::default(),
1811            _delegate: Default::default(),
1812            _additional_params: Default::default(),
1813            _scopes: Default::default(),
1814        }
1815    }
1816}
1817
1818/// A builder providing access to all methods supported on *project* resources.
1819/// It is not used directly, but through the [`Recommender`] hub.
1820///
1821/// # Example
1822///
1823/// Instantiate a resource builder
1824///
1825/// ```test_harness,no_run
1826/// extern crate hyper;
1827/// extern crate hyper_rustls;
1828/// extern crate google_recommender1 as recommender1;
1829///
1830/// # async fn dox() {
1831/// use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1832///
1833/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1834/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1835///     .with_native_roots()
1836///     .unwrap()
1837///     .https_only()
1838///     .enable_http2()
1839///     .build();
1840///
1841/// let executor = hyper_util::rt::TokioExecutor::new();
1842/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1843///     secret,
1844///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1845///     yup_oauth2::client::CustomHyperClientBuilder::from(
1846///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1847///     ),
1848/// ).build().await.unwrap();
1849///
1850/// let client = hyper_util::client::legacy::Client::builder(
1851///     hyper_util::rt::TokioExecutor::new()
1852/// )
1853/// .build(
1854///     hyper_rustls::HttpsConnectorBuilder::new()
1855///         .with_native_roots()
1856///         .unwrap()
1857///         .https_or_http()
1858///         .enable_http2()
1859///         .build()
1860/// );
1861/// let mut hub = Recommender::new(client, auth);
1862/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1863/// // like `locations_insight_types_get_config(...)`, `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_insight_types_update_config(...)`, `locations_recommenders_get_config(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)`, `locations_recommenders_recommendations_mark_succeeded(...)` and `locations_recommenders_update_config(...)`
1864/// // to build up your call.
1865/// let rb = hub.projects();
1866/// # }
1867/// ```
1868pub struct ProjectMethods<'a, C>
1869where
1870    C: 'a,
1871{
1872    hub: &'a Recommender<C>,
1873}
1874
1875impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1876
1877impl<'a, C> ProjectMethods<'a, C> {
1878    /// Create a builder to help you perform the following task:
1879    ///
1880    /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
1881    ///
1882    /// # Arguments
1883    ///
1884    /// * `name` - Required. Name of the insight.
1885    pub fn locations_insight_types_insights_get(
1886        &self,
1887        name: &str,
1888    ) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
1889        ProjectLocationInsightTypeInsightGetCall {
1890            hub: self.hub,
1891            _name: name.to_string(),
1892            _delegate: Default::default(),
1893            _additional_params: Default::default(),
1894            _scopes: Default::default(),
1895        }
1896    }
1897
1898    /// Create a builder to help you perform the following task:
1899    ///
1900    /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
1901    ///
1902    /// # Arguments
1903    ///
1904    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
1905    pub fn locations_insight_types_insights_list(
1906        &self,
1907        parent: &str,
1908    ) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
1909        ProjectLocationInsightTypeInsightListCall {
1910            hub: self.hub,
1911            _parent: parent.to_string(),
1912            _page_token: Default::default(),
1913            _page_size: Default::default(),
1914            _filter: Default::default(),
1915            _delegate: Default::default(),
1916            _additional_params: Default::default(),
1917            _scopes: Default::default(),
1918        }
1919    }
1920
1921    /// Create a builder to help you perform the following task:
1922    ///
1923    /// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
1924    ///
1925    /// # Arguments
1926    ///
1927    /// * `request` - No description provided.
1928    /// * `name` - Required. Name of the insight.
1929    pub fn locations_insight_types_insights_mark_accepted(
1930        &self,
1931        request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
1932        name: &str,
1933    ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
1934        ProjectLocationInsightTypeInsightMarkAcceptedCall {
1935            hub: self.hub,
1936            _request: request,
1937            _name: name.to_string(),
1938            _delegate: Default::default(),
1939            _additional_params: Default::default(),
1940            _scopes: Default::default(),
1941        }
1942    }
1943
1944    /// Create a builder to help you perform the following task:
1945    ///
1946    /// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
1947    ///
1948    /// # Arguments
1949    ///
1950    /// * `name` - Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
1951    pub fn locations_insight_types_get_config(
1952        &self,
1953        name: &str,
1954    ) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
1955        ProjectLocationInsightTypeGetConfigCall {
1956            hub: self.hub,
1957            _name: name.to_string(),
1958            _delegate: Default::default(),
1959            _additional_params: Default::default(),
1960            _scopes: Default::default(),
1961        }
1962    }
1963
1964    /// Create a builder to help you perform the following task:
1965    ///
1966    /// Updates an InsightTypeConfig change. This will create a new revision of the config.
1967    ///
1968    /// # Arguments
1969    ///
1970    /// * `request` - No description provided.
1971    /// * `name` - Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
1972    pub fn locations_insight_types_update_config(
1973        &self,
1974        request: GoogleCloudRecommenderV1InsightTypeConfig,
1975        name: &str,
1976    ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
1977        ProjectLocationInsightTypeUpdateConfigCall {
1978            hub: self.hub,
1979            _request: request,
1980            _name: name.to_string(),
1981            _validate_only: Default::default(),
1982            _update_mask: Default::default(),
1983            _delegate: Default::default(),
1984            _additional_params: Default::default(),
1985            _scopes: Default::default(),
1986        }
1987    }
1988
1989    /// Create a builder to help you perform the following task:
1990    ///
1991    /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
1992    ///
1993    /// # Arguments
1994    ///
1995    /// * `name` - Required. Name of the recommendation.
1996    pub fn locations_recommenders_recommendations_get(
1997        &self,
1998        name: &str,
1999    ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
2000        ProjectLocationRecommenderRecommendationGetCall {
2001            hub: self.hub,
2002            _name: name.to_string(),
2003            _delegate: Default::default(),
2004            _additional_params: Default::default(),
2005            _scopes: Default::default(),
2006        }
2007    }
2008
2009    /// Create a builder to help you perform the following task:
2010    ///
2011    /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
2012    ///
2013    /// # Arguments
2014    ///
2015    /// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
2016    pub fn locations_recommenders_recommendations_list(
2017        &self,
2018        parent: &str,
2019    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
2020        ProjectLocationRecommenderRecommendationListCall {
2021            hub: self.hub,
2022            _parent: parent.to_string(),
2023            _page_token: Default::default(),
2024            _page_size: Default::default(),
2025            _filter: Default::default(),
2026            _delegate: Default::default(),
2027            _additional_params: Default::default(),
2028            _scopes: Default::default(),
2029        }
2030    }
2031
2032    /// Create a builder to help you perform the following task:
2033    ///
2034    /// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
2035    ///
2036    /// # Arguments
2037    ///
2038    /// * `request` - No description provided.
2039    /// * `name` - Required. Name of the recommendation.
2040    pub fn locations_recommenders_recommendations_mark_claimed(
2041        &self,
2042        request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
2043        name: &str,
2044    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
2045        ProjectLocationRecommenderRecommendationMarkClaimedCall {
2046            hub: self.hub,
2047            _request: request,
2048            _name: name.to_string(),
2049            _delegate: Default::default(),
2050            _additional_params: Default::default(),
2051            _scopes: Default::default(),
2052        }
2053    }
2054
2055    /// Create a builder to help you perform the following task:
2056    ///
2057    /// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
2058    ///
2059    /// # Arguments
2060    ///
2061    /// * `request` - No description provided.
2062    /// * `name` - Required. Name of the recommendation.
2063    pub fn locations_recommenders_recommendations_mark_dismissed(
2064        &self,
2065        request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
2066        name: &str,
2067    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
2068        ProjectLocationRecommenderRecommendationMarkDismissedCall {
2069            hub: self.hub,
2070            _request: request,
2071            _name: name.to_string(),
2072            _delegate: Default::default(),
2073            _additional_params: Default::default(),
2074            _scopes: Default::default(),
2075        }
2076    }
2077
2078    /// Create a builder to help you perform the following task:
2079    ///
2080    /// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
2081    ///
2082    /// # Arguments
2083    ///
2084    /// * `request` - No description provided.
2085    /// * `name` - Required. Name of the recommendation.
2086    pub fn locations_recommenders_recommendations_mark_failed(
2087        &self,
2088        request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
2089        name: &str,
2090    ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
2091        ProjectLocationRecommenderRecommendationMarkFailedCall {
2092            hub: self.hub,
2093            _request: request,
2094            _name: name.to_string(),
2095            _delegate: Default::default(),
2096            _additional_params: Default::default(),
2097            _scopes: Default::default(),
2098        }
2099    }
2100
2101    /// Create a builder to help you perform the following task:
2102    ///
2103    /// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
2104    ///
2105    /// # Arguments
2106    ///
2107    /// * `request` - No description provided.
2108    /// * `name` - Required. Name of the recommendation.
2109    pub fn locations_recommenders_recommendations_mark_succeeded(
2110        &self,
2111        request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
2112        name: &str,
2113    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
2114        ProjectLocationRecommenderRecommendationMarkSucceededCall {
2115            hub: self.hub,
2116            _request: request,
2117            _name: name.to_string(),
2118            _delegate: Default::default(),
2119            _additional_params: Default::default(),
2120            _scopes: Default::default(),
2121        }
2122    }
2123
2124    /// Create a builder to help you perform the following task:
2125    ///
2126    /// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
2127    ///
2128    /// # Arguments
2129    ///
2130    /// * `name` - Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
2131    pub fn locations_recommenders_get_config(
2132        &self,
2133        name: &str,
2134    ) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
2135        ProjectLocationRecommenderGetConfigCall {
2136            hub: self.hub,
2137            _name: name.to_string(),
2138            _delegate: Default::default(),
2139            _additional_params: Default::default(),
2140            _scopes: Default::default(),
2141        }
2142    }
2143
2144    /// Create a builder to help you perform the following task:
2145    ///
2146    /// Updates a Recommender Config. This will create a new revision of the config.
2147    ///
2148    /// # Arguments
2149    ///
2150    /// * `request` - No description provided.
2151    /// * `name` - Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
2152    pub fn locations_recommenders_update_config(
2153        &self,
2154        request: GoogleCloudRecommenderV1RecommenderConfig,
2155        name: &str,
2156    ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
2157        ProjectLocationRecommenderUpdateConfigCall {
2158            hub: self.hub,
2159            _request: request,
2160            _name: name.to_string(),
2161            _validate_only: Default::default(),
2162            _update_mask: Default::default(),
2163            _delegate: Default::default(),
2164            _additional_params: Default::default(),
2165            _scopes: Default::default(),
2166        }
2167    }
2168}
2169
2170// ###################
2171// CallBuilders   ###
2172// #################
2173
2174/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
2175///
2176/// A builder for the *locations.insightTypes.insights.get* method supported by a *billingAccount* resource.
2177/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2178///
2179/// # Example
2180///
2181/// Instantiate a resource method builder
2182///
2183/// ```test_harness,no_run
2184/// # extern crate hyper;
2185/// # extern crate hyper_rustls;
2186/// # extern crate google_recommender1 as recommender1;
2187/// # async fn dox() {
2188/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2189///
2190/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2191/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2192/// #     .with_native_roots()
2193/// #     .unwrap()
2194/// #     .https_only()
2195/// #     .enable_http2()
2196/// #     .build();
2197///
2198/// # let executor = hyper_util::rt::TokioExecutor::new();
2199/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2200/// #     secret,
2201/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2202/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2203/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2204/// #     ),
2205/// # ).build().await.unwrap();
2206///
2207/// # let client = hyper_util::client::legacy::Client::builder(
2208/// #     hyper_util::rt::TokioExecutor::new()
2209/// # )
2210/// # .build(
2211/// #     hyper_rustls::HttpsConnectorBuilder::new()
2212/// #         .with_native_roots()
2213/// #         .unwrap()
2214/// #         .https_or_http()
2215/// #         .enable_http2()
2216/// #         .build()
2217/// # );
2218/// # let mut hub = Recommender::new(client, auth);
2219/// // You can configure optional parameters by calling the respective setters at will, and
2220/// // execute the final call using `doit()`.
2221/// // Values shown here are possibly random and not representative !
2222/// let result = hub.billing_accounts().locations_insight_types_insights_get("name")
2223///              .doit().await;
2224/// # }
2225/// ```
2226pub struct BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2227where
2228    C: 'a,
2229{
2230    hub: &'a Recommender<C>,
2231    _name: String,
2232    _delegate: Option<&'a mut dyn common::Delegate>,
2233    _additional_params: HashMap<String, String>,
2234    _scopes: BTreeSet<String>,
2235}
2236
2237impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeInsightGetCall<'a, C> {}
2238
2239impl<'a, C> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2240where
2241    C: common::Connector,
2242{
2243    /// Perform the operation you have build so far.
2244    pub async fn doit(
2245        mut self,
2246    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
2247        use std::borrow::Cow;
2248        use std::io::{Read, Seek};
2249
2250        use common::{url::Params, ToParts};
2251        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2252
2253        let mut dd = common::DefaultDelegate;
2254        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2255        dlg.begin(common::MethodInfo {
2256            id: "recommender.billingAccounts.locations.insightTypes.insights.get",
2257            http_method: hyper::Method::GET,
2258        });
2259
2260        for &field in ["alt", "name"].iter() {
2261            if self._additional_params.contains_key(field) {
2262                dlg.finished(false);
2263                return Err(common::Error::FieldClash(field));
2264            }
2265        }
2266
2267        let mut params = Params::with_capacity(3 + self._additional_params.len());
2268        params.push("name", self._name);
2269
2270        params.extend(self._additional_params.iter());
2271
2272        params.push("alt", "json");
2273        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2274        if self._scopes.is_empty() {
2275            self._scopes
2276                .insert(Scope::CloudPlatform.as_ref().to_string());
2277        }
2278
2279        #[allow(clippy::single_element_loop)]
2280        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2281            url = params.uri_replacement(url, param_name, find_this, true);
2282        }
2283        {
2284            let to_remove = ["name"];
2285            params.remove_params(&to_remove);
2286        }
2287
2288        let url = params.parse_with_url(&url);
2289
2290        loop {
2291            let token = match self
2292                .hub
2293                .auth
2294                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2295                .await
2296            {
2297                Ok(token) => token,
2298                Err(e) => match dlg.token(e) {
2299                    Ok(token) => token,
2300                    Err(e) => {
2301                        dlg.finished(false);
2302                        return Err(common::Error::MissingToken(e));
2303                    }
2304                },
2305            };
2306            let mut req_result = {
2307                let client = &self.hub.client;
2308                dlg.pre_request();
2309                let mut req_builder = hyper::Request::builder()
2310                    .method(hyper::Method::GET)
2311                    .uri(url.as_str())
2312                    .header(USER_AGENT, self.hub._user_agent.clone());
2313
2314                if let Some(token) = token.as_ref() {
2315                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2316                }
2317
2318                let request = req_builder
2319                    .header(CONTENT_LENGTH, 0_u64)
2320                    .body(common::to_body::<String>(None));
2321
2322                client.request(request.unwrap()).await
2323            };
2324
2325            match req_result {
2326                Err(err) => {
2327                    if let common::Retry::After(d) = dlg.http_error(&err) {
2328                        sleep(d).await;
2329                        continue;
2330                    }
2331                    dlg.finished(false);
2332                    return Err(common::Error::HttpError(err));
2333                }
2334                Ok(res) => {
2335                    let (mut parts, body) = res.into_parts();
2336                    let mut body = common::Body::new(body);
2337                    if !parts.status.is_success() {
2338                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2339                        let error = serde_json::from_str(&common::to_string(&bytes));
2340                        let response = common::to_response(parts, bytes.into());
2341
2342                        if let common::Retry::After(d) =
2343                            dlg.http_failure(&response, error.as_ref().ok())
2344                        {
2345                            sleep(d).await;
2346                            continue;
2347                        }
2348
2349                        dlg.finished(false);
2350
2351                        return Err(match error {
2352                            Ok(value) => common::Error::BadRequest(value),
2353                            _ => common::Error::Failure(response),
2354                        });
2355                    }
2356                    let response = {
2357                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2358                        let encoded = common::to_string(&bytes);
2359                        match serde_json::from_str(&encoded) {
2360                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2361                            Err(error) => {
2362                                dlg.response_json_decode_error(&encoded, &error);
2363                                return Err(common::Error::JsonDecodeError(
2364                                    encoded.to_string(),
2365                                    error,
2366                                ));
2367                            }
2368                        }
2369                    };
2370
2371                    dlg.finished(true);
2372                    return Ok(response);
2373                }
2374            }
2375        }
2376    }
2377
2378    /// Required. Name of the insight.
2379    ///
2380    /// Sets the *name* path property to the given value.
2381    ///
2382    /// Even though the property as already been set when instantiating this call,
2383    /// we provide this method for API completeness.
2384    pub fn name(
2385        mut self,
2386        new_value: &str,
2387    ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
2388        self._name = new_value.to_string();
2389        self
2390    }
2391    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2392    /// while executing the actual API request.
2393    ///
2394    /// ````text
2395    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2396    /// ````
2397    ///
2398    /// Sets the *delegate* property to the given value.
2399    pub fn delegate(
2400        mut self,
2401        new_value: &'a mut dyn common::Delegate,
2402    ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
2403        self._delegate = Some(new_value);
2404        self
2405    }
2406
2407    /// Set any additional parameter of the query string used in the request.
2408    /// It should be used to set parameters which are not yet available through their own
2409    /// setters.
2410    ///
2411    /// Please note that this method must not be used to set any of the known parameters
2412    /// which have their own setter method. If done anyway, the request will fail.
2413    ///
2414    /// # Additional Parameters
2415    ///
2416    /// * *$.xgafv* (query-string) - V1 error format.
2417    /// * *access_token* (query-string) - OAuth access token.
2418    /// * *alt* (query-string) - Data format for response.
2419    /// * *callback* (query-string) - JSONP
2420    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2421    /// * *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.
2422    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2423    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2424    /// * *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.
2425    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2426    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2427    pub fn param<T>(
2428        mut self,
2429        name: T,
2430        value: T,
2431    ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2432    where
2433        T: AsRef<str>,
2434    {
2435        self._additional_params
2436            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2437        self
2438    }
2439
2440    /// Identifies the authorization scope for the method you are building.
2441    ///
2442    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2443    /// [`Scope::CloudPlatform`].
2444    ///
2445    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2446    /// tokens for more than one scope.
2447    ///
2448    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2449    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2450    /// sufficient, a read-write scope will do as well.
2451    pub fn add_scope<St>(
2452        mut self,
2453        scope: St,
2454    ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2455    where
2456        St: AsRef<str>,
2457    {
2458        self._scopes.insert(String::from(scope.as_ref()));
2459        self
2460    }
2461    /// Identifies the authorization scope(s) for the method you are building.
2462    ///
2463    /// See [`Self::add_scope()`] for details.
2464    pub fn add_scopes<I, St>(
2465        mut self,
2466        scopes: I,
2467    ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2468    where
2469        I: IntoIterator<Item = St>,
2470        St: AsRef<str>,
2471    {
2472        self._scopes
2473            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2474        self
2475    }
2476
2477    /// Removes all scopes, and no default scope will be used either.
2478    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2479    /// for details).
2480    pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
2481        self._scopes.clear();
2482        self
2483    }
2484}
2485
2486/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
2487///
2488/// A builder for the *locations.insightTypes.insights.list* method supported by a *billingAccount* resource.
2489/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2490///
2491/// # Example
2492///
2493/// Instantiate a resource method builder
2494///
2495/// ```test_harness,no_run
2496/// # extern crate hyper;
2497/// # extern crate hyper_rustls;
2498/// # extern crate google_recommender1 as recommender1;
2499/// # async fn dox() {
2500/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2501///
2502/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2503/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2504/// #     .with_native_roots()
2505/// #     .unwrap()
2506/// #     .https_only()
2507/// #     .enable_http2()
2508/// #     .build();
2509///
2510/// # let executor = hyper_util::rt::TokioExecutor::new();
2511/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2512/// #     secret,
2513/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2514/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2515/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2516/// #     ),
2517/// # ).build().await.unwrap();
2518///
2519/// # let client = hyper_util::client::legacy::Client::builder(
2520/// #     hyper_util::rt::TokioExecutor::new()
2521/// # )
2522/// # .build(
2523/// #     hyper_rustls::HttpsConnectorBuilder::new()
2524/// #         .with_native_roots()
2525/// #         .unwrap()
2526/// #         .https_or_http()
2527/// #         .enable_http2()
2528/// #         .build()
2529/// # );
2530/// # let mut hub = Recommender::new(client, auth);
2531/// // You can configure optional parameters by calling the respective setters at will, and
2532/// // execute the final call using `doit()`.
2533/// // Values shown here are possibly random and not representative !
2534/// let result = hub.billing_accounts().locations_insight_types_insights_list("parent")
2535///              .page_token("At")
2536///              .page_size(-8)
2537///              .filter("sed")
2538///              .doit().await;
2539/// # }
2540/// ```
2541pub struct BillingAccountLocationInsightTypeInsightListCall<'a, C>
2542where
2543    C: 'a,
2544{
2545    hub: &'a Recommender<C>,
2546    _parent: String,
2547    _page_token: Option<String>,
2548    _page_size: Option<i32>,
2549    _filter: Option<String>,
2550    _delegate: Option<&'a mut dyn common::Delegate>,
2551    _additional_params: HashMap<String, String>,
2552    _scopes: BTreeSet<String>,
2553}
2554
2555impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeInsightListCall<'a, C> {}
2556
2557impl<'a, C> BillingAccountLocationInsightTypeInsightListCall<'a, C>
2558where
2559    C: common::Connector,
2560{
2561    /// Perform the operation you have build so far.
2562    pub async fn doit(
2563        mut self,
2564    ) -> common::Result<(
2565        common::Response,
2566        GoogleCloudRecommenderV1ListInsightsResponse,
2567    )> {
2568        use std::borrow::Cow;
2569        use std::io::{Read, Seek};
2570
2571        use common::{url::Params, ToParts};
2572        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2573
2574        let mut dd = common::DefaultDelegate;
2575        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2576        dlg.begin(common::MethodInfo {
2577            id: "recommender.billingAccounts.locations.insightTypes.insights.list",
2578            http_method: hyper::Method::GET,
2579        });
2580
2581        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
2582            if self._additional_params.contains_key(field) {
2583                dlg.finished(false);
2584                return Err(common::Error::FieldClash(field));
2585            }
2586        }
2587
2588        let mut params = Params::with_capacity(6 + self._additional_params.len());
2589        params.push("parent", self._parent);
2590        if let Some(value) = self._page_token.as_ref() {
2591            params.push("pageToken", value);
2592        }
2593        if let Some(value) = self._page_size.as_ref() {
2594            params.push("pageSize", value.to_string());
2595        }
2596        if let Some(value) = self._filter.as_ref() {
2597            params.push("filter", value);
2598        }
2599
2600        params.extend(self._additional_params.iter());
2601
2602        params.push("alt", "json");
2603        let mut url = self.hub._base_url.clone() + "v1/{+parent}/insights";
2604        if self._scopes.is_empty() {
2605            self._scopes
2606                .insert(Scope::CloudPlatform.as_ref().to_string());
2607        }
2608
2609        #[allow(clippy::single_element_loop)]
2610        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2611            url = params.uri_replacement(url, param_name, find_this, true);
2612        }
2613        {
2614            let to_remove = ["parent"];
2615            params.remove_params(&to_remove);
2616        }
2617
2618        let url = params.parse_with_url(&url);
2619
2620        loop {
2621            let token = match self
2622                .hub
2623                .auth
2624                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2625                .await
2626            {
2627                Ok(token) => token,
2628                Err(e) => match dlg.token(e) {
2629                    Ok(token) => token,
2630                    Err(e) => {
2631                        dlg.finished(false);
2632                        return Err(common::Error::MissingToken(e));
2633                    }
2634                },
2635            };
2636            let mut req_result = {
2637                let client = &self.hub.client;
2638                dlg.pre_request();
2639                let mut req_builder = hyper::Request::builder()
2640                    .method(hyper::Method::GET)
2641                    .uri(url.as_str())
2642                    .header(USER_AGENT, self.hub._user_agent.clone());
2643
2644                if let Some(token) = token.as_ref() {
2645                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2646                }
2647
2648                let request = req_builder
2649                    .header(CONTENT_LENGTH, 0_u64)
2650                    .body(common::to_body::<String>(None));
2651
2652                client.request(request.unwrap()).await
2653            };
2654
2655            match req_result {
2656                Err(err) => {
2657                    if let common::Retry::After(d) = dlg.http_error(&err) {
2658                        sleep(d).await;
2659                        continue;
2660                    }
2661                    dlg.finished(false);
2662                    return Err(common::Error::HttpError(err));
2663                }
2664                Ok(res) => {
2665                    let (mut parts, body) = res.into_parts();
2666                    let mut body = common::Body::new(body);
2667                    if !parts.status.is_success() {
2668                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2669                        let error = serde_json::from_str(&common::to_string(&bytes));
2670                        let response = common::to_response(parts, bytes.into());
2671
2672                        if let common::Retry::After(d) =
2673                            dlg.http_failure(&response, error.as_ref().ok())
2674                        {
2675                            sleep(d).await;
2676                            continue;
2677                        }
2678
2679                        dlg.finished(false);
2680
2681                        return Err(match error {
2682                            Ok(value) => common::Error::BadRequest(value),
2683                            _ => common::Error::Failure(response),
2684                        });
2685                    }
2686                    let response = {
2687                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2688                        let encoded = common::to_string(&bytes);
2689                        match serde_json::from_str(&encoded) {
2690                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2691                            Err(error) => {
2692                                dlg.response_json_decode_error(&encoded, &error);
2693                                return Err(common::Error::JsonDecodeError(
2694                                    encoded.to_string(),
2695                                    error,
2696                                ));
2697                            }
2698                        }
2699                    };
2700
2701                    dlg.finished(true);
2702                    return Ok(response);
2703                }
2704            }
2705        }
2706    }
2707
2708    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
2709    ///
2710    /// Sets the *parent* path property to the given value.
2711    ///
2712    /// Even though the property as already been set when instantiating this call,
2713    /// we provide this method for API completeness.
2714    pub fn parent(
2715        mut self,
2716        new_value: &str,
2717    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
2718        self._parent = new_value.to_string();
2719        self
2720    }
2721    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
2722    ///
2723    /// Sets the *page token* query property to the given value.
2724    pub fn page_token(
2725        mut self,
2726        new_value: &str,
2727    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
2728        self._page_token = Some(new_value.to_string());
2729        self
2730    }
2731    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
2732    ///
2733    /// Sets the *page size* query property to the given value.
2734    pub fn page_size(
2735        mut self,
2736        new_value: i32,
2737    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
2738        self._page_size = Some(new_value);
2739        self
2740    }
2741    /// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
2742    ///
2743    /// Sets the *filter* query property to the given value.
2744    pub fn filter(
2745        mut self,
2746        new_value: &str,
2747    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
2748        self._filter = Some(new_value.to_string());
2749        self
2750    }
2751    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2752    /// while executing the actual API request.
2753    ///
2754    /// ````text
2755    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2756    /// ````
2757    ///
2758    /// Sets the *delegate* property to the given value.
2759    pub fn delegate(
2760        mut self,
2761        new_value: &'a mut dyn common::Delegate,
2762    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
2763        self._delegate = Some(new_value);
2764        self
2765    }
2766
2767    /// Set any additional parameter of the query string used in the request.
2768    /// It should be used to set parameters which are not yet available through their own
2769    /// setters.
2770    ///
2771    /// Please note that this method must not be used to set any of the known parameters
2772    /// which have their own setter method. If done anyway, the request will fail.
2773    ///
2774    /// # Additional Parameters
2775    ///
2776    /// * *$.xgafv* (query-string) - V1 error format.
2777    /// * *access_token* (query-string) - OAuth access token.
2778    /// * *alt* (query-string) - Data format for response.
2779    /// * *callback* (query-string) - JSONP
2780    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2781    /// * *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.
2782    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2783    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2784    /// * *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.
2785    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2786    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2787    pub fn param<T>(
2788        mut self,
2789        name: T,
2790        value: T,
2791    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C>
2792    where
2793        T: AsRef<str>,
2794    {
2795        self._additional_params
2796            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2797        self
2798    }
2799
2800    /// Identifies the authorization scope for the method you are building.
2801    ///
2802    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2803    /// [`Scope::CloudPlatform`].
2804    ///
2805    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2806    /// tokens for more than one scope.
2807    ///
2808    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2809    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2810    /// sufficient, a read-write scope will do as well.
2811    pub fn add_scope<St>(
2812        mut self,
2813        scope: St,
2814    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C>
2815    where
2816        St: AsRef<str>,
2817    {
2818        self._scopes.insert(String::from(scope.as_ref()));
2819        self
2820    }
2821    /// Identifies the authorization scope(s) for the method you are building.
2822    ///
2823    /// See [`Self::add_scope()`] for details.
2824    pub fn add_scopes<I, St>(
2825        mut self,
2826        scopes: I,
2827    ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C>
2828    where
2829        I: IntoIterator<Item = St>,
2830        St: AsRef<str>,
2831    {
2832        self._scopes
2833            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2834        self
2835    }
2836
2837    /// Removes all scopes, and no default scope will be used either.
2838    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2839    /// for details).
2840    pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
2841        self._scopes.clear();
2842        self
2843    }
2844}
2845
2846/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
2847///
2848/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *billingAccount* resource.
2849/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2850///
2851/// # Example
2852///
2853/// Instantiate a resource method builder
2854///
2855/// ```test_harness,no_run
2856/// # extern crate hyper;
2857/// # extern crate hyper_rustls;
2858/// # extern crate google_recommender1 as recommender1;
2859/// use recommender1::api::GoogleCloudRecommenderV1MarkInsightAcceptedRequest;
2860/// # async fn dox() {
2861/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2862///
2863/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2864/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2865/// #     .with_native_roots()
2866/// #     .unwrap()
2867/// #     .https_only()
2868/// #     .enable_http2()
2869/// #     .build();
2870///
2871/// # let executor = hyper_util::rt::TokioExecutor::new();
2872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2873/// #     secret,
2874/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2875/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2876/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2877/// #     ),
2878/// # ).build().await.unwrap();
2879///
2880/// # let client = hyper_util::client::legacy::Client::builder(
2881/// #     hyper_util::rt::TokioExecutor::new()
2882/// # )
2883/// # .build(
2884/// #     hyper_rustls::HttpsConnectorBuilder::new()
2885/// #         .with_native_roots()
2886/// #         .unwrap()
2887/// #         .https_or_http()
2888/// #         .enable_http2()
2889/// #         .build()
2890/// # );
2891/// # let mut hub = Recommender::new(client, auth);
2892/// // As the method needs a request, you would usually fill it with the desired information
2893/// // into the respective structure. Some of the parts shown here might not be applicable !
2894/// // Values shown here are possibly random and not representative !
2895/// let mut req = GoogleCloudRecommenderV1MarkInsightAcceptedRequest::default();
2896///
2897/// // You can configure optional parameters by calling the respective setters at will, and
2898/// // execute the final call using `doit()`.
2899/// // Values shown here are possibly random and not representative !
2900/// let result = hub.billing_accounts().locations_insight_types_insights_mark_accepted(req, "name")
2901///              .doit().await;
2902/// # }
2903/// ```
2904pub struct BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
2905where
2906    C: 'a,
2907{
2908    hub: &'a Recommender<C>,
2909    _request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
2910    _name: String,
2911    _delegate: Option<&'a mut dyn common::Delegate>,
2912    _additional_params: HashMap<String, String>,
2913    _scopes: BTreeSet<String>,
2914}
2915
2916impl<'a, C> common::CallBuilder
2917    for BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
2918{
2919}
2920
2921impl<'a, C> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
2922where
2923    C: common::Connector,
2924{
2925    /// Perform the operation you have build so far.
2926    pub async fn doit(
2927        mut self,
2928    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
2929        use std::borrow::Cow;
2930        use std::io::{Read, Seek};
2931
2932        use common::{url::Params, ToParts};
2933        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2934
2935        let mut dd = common::DefaultDelegate;
2936        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2937        dlg.begin(common::MethodInfo {
2938            id: "recommender.billingAccounts.locations.insightTypes.insights.markAccepted",
2939            http_method: hyper::Method::POST,
2940        });
2941
2942        for &field in ["alt", "name"].iter() {
2943            if self._additional_params.contains_key(field) {
2944                dlg.finished(false);
2945                return Err(common::Error::FieldClash(field));
2946            }
2947        }
2948
2949        let mut params = Params::with_capacity(4 + self._additional_params.len());
2950        params.push("name", self._name);
2951
2952        params.extend(self._additional_params.iter());
2953
2954        params.push("alt", "json");
2955        let mut url = self.hub._base_url.clone() + "v1/{+name}:markAccepted";
2956        if self._scopes.is_empty() {
2957            self._scopes
2958                .insert(Scope::CloudPlatform.as_ref().to_string());
2959        }
2960
2961        #[allow(clippy::single_element_loop)]
2962        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2963            url = params.uri_replacement(url, param_name, find_this, true);
2964        }
2965        {
2966            let to_remove = ["name"];
2967            params.remove_params(&to_remove);
2968        }
2969
2970        let url = params.parse_with_url(&url);
2971
2972        let mut json_mime_type = mime::APPLICATION_JSON;
2973        let mut request_value_reader = {
2974            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2975            common::remove_json_null_values(&mut value);
2976            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2977            serde_json::to_writer(&mut dst, &value).unwrap();
2978            dst
2979        };
2980        let request_size = request_value_reader
2981            .seek(std::io::SeekFrom::End(0))
2982            .unwrap();
2983        request_value_reader
2984            .seek(std::io::SeekFrom::Start(0))
2985            .unwrap();
2986
2987        loop {
2988            let token = match self
2989                .hub
2990                .auth
2991                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2992                .await
2993            {
2994                Ok(token) => token,
2995                Err(e) => match dlg.token(e) {
2996                    Ok(token) => token,
2997                    Err(e) => {
2998                        dlg.finished(false);
2999                        return Err(common::Error::MissingToken(e));
3000                    }
3001                },
3002            };
3003            request_value_reader
3004                .seek(std::io::SeekFrom::Start(0))
3005                .unwrap();
3006            let mut req_result = {
3007                let client = &self.hub.client;
3008                dlg.pre_request();
3009                let mut req_builder = hyper::Request::builder()
3010                    .method(hyper::Method::POST)
3011                    .uri(url.as_str())
3012                    .header(USER_AGENT, self.hub._user_agent.clone());
3013
3014                if let Some(token) = token.as_ref() {
3015                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3016                }
3017
3018                let request = req_builder
3019                    .header(CONTENT_TYPE, json_mime_type.to_string())
3020                    .header(CONTENT_LENGTH, request_size as u64)
3021                    .body(common::to_body(
3022                        request_value_reader.get_ref().clone().into(),
3023                    ));
3024
3025                client.request(request.unwrap()).await
3026            };
3027
3028            match req_result {
3029                Err(err) => {
3030                    if let common::Retry::After(d) = dlg.http_error(&err) {
3031                        sleep(d).await;
3032                        continue;
3033                    }
3034                    dlg.finished(false);
3035                    return Err(common::Error::HttpError(err));
3036                }
3037                Ok(res) => {
3038                    let (mut parts, body) = res.into_parts();
3039                    let mut body = common::Body::new(body);
3040                    if !parts.status.is_success() {
3041                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3042                        let error = serde_json::from_str(&common::to_string(&bytes));
3043                        let response = common::to_response(parts, bytes.into());
3044
3045                        if let common::Retry::After(d) =
3046                            dlg.http_failure(&response, error.as_ref().ok())
3047                        {
3048                            sleep(d).await;
3049                            continue;
3050                        }
3051
3052                        dlg.finished(false);
3053
3054                        return Err(match error {
3055                            Ok(value) => common::Error::BadRequest(value),
3056                            _ => common::Error::Failure(response),
3057                        });
3058                    }
3059                    let response = {
3060                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3061                        let encoded = common::to_string(&bytes);
3062                        match serde_json::from_str(&encoded) {
3063                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3064                            Err(error) => {
3065                                dlg.response_json_decode_error(&encoded, &error);
3066                                return Err(common::Error::JsonDecodeError(
3067                                    encoded.to_string(),
3068                                    error,
3069                                ));
3070                            }
3071                        }
3072                    };
3073
3074                    dlg.finished(true);
3075                    return Ok(response);
3076                }
3077            }
3078        }
3079    }
3080
3081    ///
3082    /// Sets the *request* property to the given value.
3083    ///
3084    /// Even though the property as already been set when instantiating this call,
3085    /// we provide this method for API completeness.
3086    pub fn request(
3087        mut self,
3088        new_value: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
3089    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3090        self._request = new_value;
3091        self
3092    }
3093    /// Required. Name of the insight.
3094    ///
3095    /// Sets the *name* path property to the given value.
3096    ///
3097    /// Even though the property as already been set when instantiating this call,
3098    /// we provide this method for API completeness.
3099    pub fn name(
3100        mut self,
3101        new_value: &str,
3102    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3103        self._name = new_value.to_string();
3104        self
3105    }
3106    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3107    /// while executing the actual API request.
3108    ///
3109    /// ````text
3110    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3111    /// ````
3112    ///
3113    /// Sets the *delegate* property to the given value.
3114    pub fn delegate(
3115        mut self,
3116        new_value: &'a mut dyn common::Delegate,
3117    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3118        self._delegate = Some(new_value);
3119        self
3120    }
3121
3122    /// Set any additional parameter of the query string used in the request.
3123    /// It should be used to set parameters which are not yet available through their own
3124    /// setters.
3125    ///
3126    /// Please note that this method must not be used to set any of the known parameters
3127    /// which have their own setter method. If done anyway, the request will fail.
3128    ///
3129    /// # Additional Parameters
3130    ///
3131    /// * *$.xgafv* (query-string) - V1 error format.
3132    /// * *access_token* (query-string) - OAuth access token.
3133    /// * *alt* (query-string) - Data format for response.
3134    /// * *callback* (query-string) - JSONP
3135    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3136    /// * *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.
3137    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3138    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3139    /// * *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.
3140    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3141    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3142    pub fn param<T>(
3143        mut self,
3144        name: T,
3145        value: T,
3146    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3147    where
3148        T: AsRef<str>,
3149    {
3150        self._additional_params
3151            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3152        self
3153    }
3154
3155    /// Identifies the authorization scope for the method you are building.
3156    ///
3157    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3158    /// [`Scope::CloudPlatform`].
3159    ///
3160    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3161    /// tokens for more than one scope.
3162    ///
3163    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3164    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3165    /// sufficient, a read-write scope will do as well.
3166    pub fn add_scope<St>(
3167        mut self,
3168        scope: St,
3169    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3170    where
3171        St: AsRef<str>,
3172    {
3173        self._scopes.insert(String::from(scope.as_ref()));
3174        self
3175    }
3176    /// Identifies the authorization scope(s) for the method you are building.
3177    ///
3178    /// See [`Self::add_scope()`] for details.
3179    pub fn add_scopes<I, St>(
3180        mut self,
3181        scopes: I,
3182    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3183    where
3184        I: IntoIterator<Item = St>,
3185        St: AsRef<str>,
3186    {
3187        self._scopes
3188            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3189        self
3190    }
3191
3192    /// Removes all scopes, and no default scope will be used either.
3193    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3194    /// for details).
3195    pub fn clear_scopes(
3196        mut self,
3197    ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3198        self._scopes.clear();
3199        self
3200    }
3201}
3202
3203/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
3204///
3205/// A builder for the *locations.insightTypes.getConfig* method supported by a *billingAccount* resource.
3206/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3207///
3208/// # Example
3209///
3210/// Instantiate a resource method builder
3211///
3212/// ```test_harness,no_run
3213/// # extern crate hyper;
3214/// # extern crate hyper_rustls;
3215/// # extern crate google_recommender1 as recommender1;
3216/// # async fn dox() {
3217/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3218///
3219/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3220/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3221/// #     .with_native_roots()
3222/// #     .unwrap()
3223/// #     .https_only()
3224/// #     .enable_http2()
3225/// #     .build();
3226///
3227/// # let executor = hyper_util::rt::TokioExecutor::new();
3228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3229/// #     secret,
3230/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3231/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3232/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3233/// #     ),
3234/// # ).build().await.unwrap();
3235///
3236/// # let client = hyper_util::client::legacy::Client::builder(
3237/// #     hyper_util::rt::TokioExecutor::new()
3238/// # )
3239/// # .build(
3240/// #     hyper_rustls::HttpsConnectorBuilder::new()
3241/// #         .with_native_roots()
3242/// #         .unwrap()
3243/// #         .https_or_http()
3244/// #         .enable_http2()
3245/// #         .build()
3246/// # );
3247/// # let mut hub = Recommender::new(client, auth);
3248/// // You can configure optional parameters by calling the respective setters at will, and
3249/// // execute the final call using `doit()`.
3250/// // Values shown here are possibly random and not representative !
3251/// let result = hub.billing_accounts().locations_insight_types_get_config("name")
3252///              .doit().await;
3253/// # }
3254/// ```
3255pub struct BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3256where
3257    C: 'a,
3258{
3259    hub: &'a Recommender<C>,
3260    _name: String,
3261    _delegate: Option<&'a mut dyn common::Delegate>,
3262    _additional_params: HashMap<String, String>,
3263    _scopes: BTreeSet<String>,
3264}
3265
3266impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeGetConfigCall<'a, C> {}
3267
3268impl<'a, C> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3269where
3270    C: common::Connector,
3271{
3272    /// Perform the operation you have build so far.
3273    pub async fn doit(
3274        mut self,
3275    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1InsightTypeConfig)> {
3276        use std::borrow::Cow;
3277        use std::io::{Read, Seek};
3278
3279        use common::{url::Params, ToParts};
3280        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3281
3282        let mut dd = common::DefaultDelegate;
3283        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3284        dlg.begin(common::MethodInfo {
3285            id: "recommender.billingAccounts.locations.insightTypes.getConfig",
3286            http_method: hyper::Method::GET,
3287        });
3288
3289        for &field in ["alt", "name"].iter() {
3290            if self._additional_params.contains_key(field) {
3291                dlg.finished(false);
3292                return Err(common::Error::FieldClash(field));
3293            }
3294        }
3295
3296        let mut params = Params::with_capacity(3 + self._additional_params.len());
3297        params.push("name", self._name);
3298
3299        params.extend(self._additional_params.iter());
3300
3301        params.push("alt", "json");
3302        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3303        if self._scopes.is_empty() {
3304            self._scopes
3305                .insert(Scope::CloudPlatform.as_ref().to_string());
3306        }
3307
3308        #[allow(clippy::single_element_loop)]
3309        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3310            url = params.uri_replacement(url, param_name, find_this, true);
3311        }
3312        {
3313            let to_remove = ["name"];
3314            params.remove_params(&to_remove);
3315        }
3316
3317        let url = params.parse_with_url(&url);
3318
3319        loop {
3320            let token = match self
3321                .hub
3322                .auth
3323                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3324                .await
3325            {
3326                Ok(token) => token,
3327                Err(e) => match dlg.token(e) {
3328                    Ok(token) => token,
3329                    Err(e) => {
3330                        dlg.finished(false);
3331                        return Err(common::Error::MissingToken(e));
3332                    }
3333                },
3334            };
3335            let mut req_result = {
3336                let client = &self.hub.client;
3337                dlg.pre_request();
3338                let mut req_builder = hyper::Request::builder()
3339                    .method(hyper::Method::GET)
3340                    .uri(url.as_str())
3341                    .header(USER_AGENT, self.hub._user_agent.clone());
3342
3343                if let Some(token) = token.as_ref() {
3344                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3345                }
3346
3347                let request = req_builder
3348                    .header(CONTENT_LENGTH, 0_u64)
3349                    .body(common::to_body::<String>(None));
3350
3351                client.request(request.unwrap()).await
3352            };
3353
3354            match req_result {
3355                Err(err) => {
3356                    if let common::Retry::After(d) = dlg.http_error(&err) {
3357                        sleep(d).await;
3358                        continue;
3359                    }
3360                    dlg.finished(false);
3361                    return Err(common::Error::HttpError(err));
3362                }
3363                Ok(res) => {
3364                    let (mut parts, body) = res.into_parts();
3365                    let mut body = common::Body::new(body);
3366                    if !parts.status.is_success() {
3367                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3368                        let error = serde_json::from_str(&common::to_string(&bytes));
3369                        let response = common::to_response(parts, bytes.into());
3370
3371                        if let common::Retry::After(d) =
3372                            dlg.http_failure(&response, error.as_ref().ok())
3373                        {
3374                            sleep(d).await;
3375                            continue;
3376                        }
3377
3378                        dlg.finished(false);
3379
3380                        return Err(match error {
3381                            Ok(value) => common::Error::BadRequest(value),
3382                            _ => common::Error::Failure(response),
3383                        });
3384                    }
3385                    let response = {
3386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3387                        let encoded = common::to_string(&bytes);
3388                        match serde_json::from_str(&encoded) {
3389                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3390                            Err(error) => {
3391                                dlg.response_json_decode_error(&encoded, &error);
3392                                return Err(common::Error::JsonDecodeError(
3393                                    encoded.to_string(),
3394                                    error,
3395                                ));
3396                            }
3397                        }
3398                    };
3399
3400                    dlg.finished(true);
3401                    return Ok(response);
3402                }
3403            }
3404        }
3405    }
3406
3407    /// Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
3408    ///
3409    /// Sets the *name* path property to the given value.
3410    ///
3411    /// Even though the property as already been set when instantiating this call,
3412    /// we provide this method for API completeness.
3413    pub fn name(
3414        mut self,
3415        new_value: &str,
3416    ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
3417        self._name = new_value.to_string();
3418        self
3419    }
3420    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3421    /// while executing the actual API request.
3422    ///
3423    /// ````text
3424    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3425    /// ````
3426    ///
3427    /// Sets the *delegate* property to the given value.
3428    pub fn delegate(
3429        mut self,
3430        new_value: &'a mut dyn common::Delegate,
3431    ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
3432        self._delegate = Some(new_value);
3433        self
3434    }
3435
3436    /// Set any additional parameter of the query string used in the request.
3437    /// It should be used to set parameters which are not yet available through their own
3438    /// setters.
3439    ///
3440    /// Please note that this method must not be used to set any of the known parameters
3441    /// which have their own setter method. If done anyway, the request will fail.
3442    ///
3443    /// # Additional Parameters
3444    ///
3445    /// * *$.xgafv* (query-string) - V1 error format.
3446    /// * *access_token* (query-string) - OAuth access token.
3447    /// * *alt* (query-string) - Data format for response.
3448    /// * *callback* (query-string) - JSONP
3449    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3450    /// * *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.
3451    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3452    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3453    /// * *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.
3454    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3455    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3456    pub fn param<T>(
3457        mut self,
3458        name: T,
3459        value: T,
3460    ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3461    where
3462        T: AsRef<str>,
3463    {
3464        self._additional_params
3465            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3466        self
3467    }
3468
3469    /// Identifies the authorization scope for the method you are building.
3470    ///
3471    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3472    /// [`Scope::CloudPlatform`].
3473    ///
3474    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3475    /// tokens for more than one scope.
3476    ///
3477    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3478    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3479    /// sufficient, a read-write scope will do as well.
3480    pub fn add_scope<St>(
3481        mut self,
3482        scope: St,
3483    ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3484    where
3485        St: AsRef<str>,
3486    {
3487        self._scopes.insert(String::from(scope.as_ref()));
3488        self
3489    }
3490    /// Identifies the authorization scope(s) for the method you are building.
3491    ///
3492    /// See [`Self::add_scope()`] for details.
3493    pub fn add_scopes<I, St>(
3494        mut self,
3495        scopes: I,
3496    ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3497    where
3498        I: IntoIterator<Item = St>,
3499        St: AsRef<str>,
3500    {
3501        self._scopes
3502            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3503        self
3504    }
3505
3506    /// Removes all scopes, and no default scope will be used either.
3507    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3508    /// for details).
3509    pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
3510        self._scopes.clear();
3511        self
3512    }
3513}
3514
3515/// Updates an InsightTypeConfig change. This will create a new revision of the config.
3516///
3517/// A builder for the *locations.insightTypes.updateConfig* method supported by a *billingAccount* resource.
3518/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3519///
3520/// # Example
3521///
3522/// Instantiate a resource method builder
3523///
3524/// ```test_harness,no_run
3525/// # extern crate hyper;
3526/// # extern crate hyper_rustls;
3527/// # extern crate google_recommender1 as recommender1;
3528/// use recommender1::api::GoogleCloudRecommenderV1InsightTypeConfig;
3529/// # async fn dox() {
3530/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3531///
3532/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3533/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3534/// #     .with_native_roots()
3535/// #     .unwrap()
3536/// #     .https_only()
3537/// #     .enable_http2()
3538/// #     .build();
3539///
3540/// # let executor = hyper_util::rt::TokioExecutor::new();
3541/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3542/// #     secret,
3543/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3544/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3545/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3546/// #     ),
3547/// # ).build().await.unwrap();
3548///
3549/// # let client = hyper_util::client::legacy::Client::builder(
3550/// #     hyper_util::rt::TokioExecutor::new()
3551/// # )
3552/// # .build(
3553/// #     hyper_rustls::HttpsConnectorBuilder::new()
3554/// #         .with_native_roots()
3555/// #         .unwrap()
3556/// #         .https_or_http()
3557/// #         .enable_http2()
3558/// #         .build()
3559/// # );
3560/// # let mut hub = Recommender::new(client, auth);
3561/// // As the method needs a request, you would usually fill it with the desired information
3562/// // into the respective structure. Some of the parts shown here might not be applicable !
3563/// // Values shown here are possibly random and not representative !
3564/// let mut req = GoogleCloudRecommenderV1InsightTypeConfig::default();
3565///
3566/// // You can configure optional parameters by calling the respective setters at will, and
3567/// // execute the final call using `doit()`.
3568/// // Values shown here are possibly random and not representative !
3569/// let result = hub.billing_accounts().locations_insight_types_update_config(req, "name")
3570///              .validate_only(true)
3571///              .update_mask(FieldMask::new::<&str>(&[]))
3572///              .doit().await;
3573/// # }
3574/// ```
3575pub struct BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
3576where
3577    C: 'a,
3578{
3579    hub: &'a Recommender<C>,
3580    _request: GoogleCloudRecommenderV1InsightTypeConfig,
3581    _name: String,
3582    _validate_only: Option<bool>,
3583    _update_mask: Option<common::FieldMask>,
3584    _delegate: Option<&'a mut dyn common::Delegate>,
3585    _additional_params: HashMap<String, String>,
3586    _scopes: BTreeSet<String>,
3587}
3588
3589impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {}
3590
3591impl<'a, C> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
3592where
3593    C: common::Connector,
3594{
3595    /// Perform the operation you have build so far.
3596    pub async fn doit(
3597        mut self,
3598    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1InsightTypeConfig)> {
3599        use std::borrow::Cow;
3600        use std::io::{Read, Seek};
3601
3602        use common::{url::Params, ToParts};
3603        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3604
3605        let mut dd = common::DefaultDelegate;
3606        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3607        dlg.begin(common::MethodInfo {
3608            id: "recommender.billingAccounts.locations.insightTypes.updateConfig",
3609            http_method: hyper::Method::PATCH,
3610        });
3611
3612        for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
3613            if self._additional_params.contains_key(field) {
3614                dlg.finished(false);
3615                return Err(common::Error::FieldClash(field));
3616            }
3617        }
3618
3619        let mut params = Params::with_capacity(6 + self._additional_params.len());
3620        params.push("name", self._name);
3621        if let Some(value) = self._validate_only.as_ref() {
3622            params.push("validateOnly", value.to_string());
3623        }
3624        if let Some(value) = self._update_mask.as_ref() {
3625            params.push("updateMask", value.to_string());
3626        }
3627
3628        params.extend(self._additional_params.iter());
3629
3630        params.push("alt", "json");
3631        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3632        if self._scopes.is_empty() {
3633            self._scopes
3634                .insert(Scope::CloudPlatform.as_ref().to_string());
3635        }
3636
3637        #[allow(clippy::single_element_loop)]
3638        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3639            url = params.uri_replacement(url, param_name, find_this, true);
3640        }
3641        {
3642            let to_remove = ["name"];
3643            params.remove_params(&to_remove);
3644        }
3645
3646        let url = params.parse_with_url(&url);
3647
3648        let mut json_mime_type = mime::APPLICATION_JSON;
3649        let mut request_value_reader = {
3650            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3651            common::remove_json_null_values(&mut value);
3652            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3653            serde_json::to_writer(&mut dst, &value).unwrap();
3654            dst
3655        };
3656        let request_size = request_value_reader
3657            .seek(std::io::SeekFrom::End(0))
3658            .unwrap();
3659        request_value_reader
3660            .seek(std::io::SeekFrom::Start(0))
3661            .unwrap();
3662
3663        loop {
3664            let token = match self
3665                .hub
3666                .auth
3667                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3668                .await
3669            {
3670                Ok(token) => token,
3671                Err(e) => match dlg.token(e) {
3672                    Ok(token) => token,
3673                    Err(e) => {
3674                        dlg.finished(false);
3675                        return Err(common::Error::MissingToken(e));
3676                    }
3677                },
3678            };
3679            request_value_reader
3680                .seek(std::io::SeekFrom::Start(0))
3681                .unwrap();
3682            let mut req_result = {
3683                let client = &self.hub.client;
3684                dlg.pre_request();
3685                let mut req_builder = hyper::Request::builder()
3686                    .method(hyper::Method::PATCH)
3687                    .uri(url.as_str())
3688                    .header(USER_AGENT, self.hub._user_agent.clone());
3689
3690                if let Some(token) = token.as_ref() {
3691                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3692                }
3693
3694                let request = req_builder
3695                    .header(CONTENT_TYPE, json_mime_type.to_string())
3696                    .header(CONTENT_LENGTH, request_size as u64)
3697                    .body(common::to_body(
3698                        request_value_reader.get_ref().clone().into(),
3699                    ));
3700
3701                client.request(request.unwrap()).await
3702            };
3703
3704            match req_result {
3705                Err(err) => {
3706                    if let common::Retry::After(d) = dlg.http_error(&err) {
3707                        sleep(d).await;
3708                        continue;
3709                    }
3710                    dlg.finished(false);
3711                    return Err(common::Error::HttpError(err));
3712                }
3713                Ok(res) => {
3714                    let (mut parts, body) = res.into_parts();
3715                    let mut body = common::Body::new(body);
3716                    if !parts.status.is_success() {
3717                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3718                        let error = serde_json::from_str(&common::to_string(&bytes));
3719                        let response = common::to_response(parts, bytes.into());
3720
3721                        if let common::Retry::After(d) =
3722                            dlg.http_failure(&response, error.as_ref().ok())
3723                        {
3724                            sleep(d).await;
3725                            continue;
3726                        }
3727
3728                        dlg.finished(false);
3729
3730                        return Err(match error {
3731                            Ok(value) => common::Error::BadRequest(value),
3732                            _ => common::Error::Failure(response),
3733                        });
3734                    }
3735                    let response = {
3736                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3737                        let encoded = common::to_string(&bytes);
3738                        match serde_json::from_str(&encoded) {
3739                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3740                            Err(error) => {
3741                                dlg.response_json_decode_error(&encoded, &error);
3742                                return Err(common::Error::JsonDecodeError(
3743                                    encoded.to_string(),
3744                                    error,
3745                                ));
3746                            }
3747                        }
3748                    };
3749
3750                    dlg.finished(true);
3751                    return Ok(response);
3752                }
3753            }
3754        }
3755    }
3756
3757    ///
3758    /// Sets the *request* property to the given value.
3759    ///
3760    /// Even though the property as already been set when instantiating this call,
3761    /// we provide this method for API completeness.
3762    pub fn request(
3763        mut self,
3764        new_value: GoogleCloudRecommenderV1InsightTypeConfig,
3765    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
3766        self._request = new_value;
3767        self
3768    }
3769    /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
3770    ///
3771    /// Sets the *name* path property to the given value.
3772    ///
3773    /// Even though the property as already been set when instantiating this call,
3774    /// we provide this method for API completeness.
3775    pub fn name(
3776        mut self,
3777        new_value: &str,
3778    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
3779        self._name = new_value.to_string();
3780        self
3781    }
3782    /// If true, validate the request and preview the change, but do not actually update it.
3783    ///
3784    /// Sets the *validate only* query property to the given value.
3785    pub fn validate_only(
3786        mut self,
3787        new_value: bool,
3788    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
3789        self._validate_only = Some(new_value);
3790        self
3791    }
3792    /// The list of fields to be updated.
3793    ///
3794    /// Sets the *update mask* query property to the given value.
3795    pub fn update_mask(
3796        mut self,
3797        new_value: common::FieldMask,
3798    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
3799        self._update_mask = Some(new_value);
3800        self
3801    }
3802    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3803    /// while executing the actual API request.
3804    ///
3805    /// ````text
3806    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3807    /// ````
3808    ///
3809    /// Sets the *delegate* property to the given value.
3810    pub fn delegate(
3811        mut self,
3812        new_value: &'a mut dyn common::Delegate,
3813    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
3814        self._delegate = Some(new_value);
3815        self
3816    }
3817
3818    /// Set any additional parameter of the query string used in the request.
3819    /// It should be used to set parameters which are not yet available through their own
3820    /// setters.
3821    ///
3822    /// Please note that this method must not be used to set any of the known parameters
3823    /// which have their own setter method. If done anyway, the request will fail.
3824    ///
3825    /// # Additional Parameters
3826    ///
3827    /// * *$.xgafv* (query-string) - V1 error format.
3828    /// * *access_token* (query-string) - OAuth access token.
3829    /// * *alt* (query-string) - Data format for response.
3830    /// * *callback* (query-string) - JSONP
3831    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3832    /// * *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.
3833    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3834    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3835    /// * *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.
3836    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3837    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3838    pub fn param<T>(
3839        mut self,
3840        name: T,
3841        value: T,
3842    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
3843    where
3844        T: AsRef<str>,
3845    {
3846        self._additional_params
3847            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3848        self
3849    }
3850
3851    /// Identifies the authorization scope for the method you are building.
3852    ///
3853    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3854    /// [`Scope::CloudPlatform`].
3855    ///
3856    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3857    /// tokens for more than one scope.
3858    ///
3859    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3860    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3861    /// sufficient, a read-write scope will do as well.
3862    pub fn add_scope<St>(
3863        mut self,
3864        scope: St,
3865    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
3866    where
3867        St: AsRef<str>,
3868    {
3869        self._scopes.insert(String::from(scope.as_ref()));
3870        self
3871    }
3872    /// Identifies the authorization scope(s) for the method you are building.
3873    ///
3874    /// See [`Self::add_scope()`] for details.
3875    pub fn add_scopes<I, St>(
3876        mut self,
3877        scopes: I,
3878    ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
3879    where
3880        I: IntoIterator<Item = St>,
3881        St: AsRef<str>,
3882    {
3883        self._scopes
3884            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3885        self
3886    }
3887
3888    /// Removes all scopes, and no default scope will be used either.
3889    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3890    /// for details).
3891    pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
3892        self._scopes.clear();
3893        self
3894    }
3895}
3896
3897/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
3898///
3899/// A builder for the *locations.recommenders.recommendations.get* method supported by a *billingAccount* resource.
3900/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3901///
3902/// # Example
3903///
3904/// Instantiate a resource method builder
3905///
3906/// ```test_harness,no_run
3907/// # extern crate hyper;
3908/// # extern crate hyper_rustls;
3909/// # extern crate google_recommender1 as recommender1;
3910/// # async fn dox() {
3911/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3912///
3913/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3914/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3915/// #     .with_native_roots()
3916/// #     .unwrap()
3917/// #     .https_only()
3918/// #     .enable_http2()
3919/// #     .build();
3920///
3921/// # let executor = hyper_util::rt::TokioExecutor::new();
3922/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3923/// #     secret,
3924/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3925/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3926/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3927/// #     ),
3928/// # ).build().await.unwrap();
3929///
3930/// # let client = hyper_util::client::legacy::Client::builder(
3931/// #     hyper_util::rt::TokioExecutor::new()
3932/// # )
3933/// # .build(
3934/// #     hyper_rustls::HttpsConnectorBuilder::new()
3935/// #         .with_native_roots()
3936/// #         .unwrap()
3937/// #         .https_or_http()
3938/// #         .enable_http2()
3939/// #         .build()
3940/// # );
3941/// # let mut hub = Recommender::new(client, auth);
3942/// // You can configure optional parameters by calling the respective setters at will, and
3943/// // execute the final call using `doit()`.
3944/// // Values shown here are possibly random and not representative !
3945/// let result = hub.billing_accounts().locations_recommenders_recommendations_get("name")
3946///              .doit().await;
3947/// # }
3948/// ```
3949pub struct BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
3950where
3951    C: 'a,
3952{
3953    hub: &'a Recommender<C>,
3954    _name: String,
3955    _delegate: Option<&'a mut dyn common::Delegate>,
3956    _additional_params: HashMap<String, String>,
3957    _scopes: BTreeSet<String>,
3958}
3959
3960impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {}
3961
3962impl<'a, C> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
3963where
3964    C: common::Connector,
3965{
3966    /// Perform the operation you have build so far.
3967    pub async fn doit(
3968        mut self,
3969    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
3970        use std::borrow::Cow;
3971        use std::io::{Read, Seek};
3972
3973        use common::{url::Params, ToParts};
3974        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3975
3976        let mut dd = common::DefaultDelegate;
3977        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3978        dlg.begin(common::MethodInfo {
3979            id: "recommender.billingAccounts.locations.recommenders.recommendations.get",
3980            http_method: hyper::Method::GET,
3981        });
3982
3983        for &field in ["alt", "name"].iter() {
3984            if self._additional_params.contains_key(field) {
3985                dlg.finished(false);
3986                return Err(common::Error::FieldClash(field));
3987            }
3988        }
3989
3990        let mut params = Params::with_capacity(3 + self._additional_params.len());
3991        params.push("name", self._name);
3992
3993        params.extend(self._additional_params.iter());
3994
3995        params.push("alt", "json");
3996        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3997        if self._scopes.is_empty() {
3998            self._scopes
3999                .insert(Scope::CloudPlatform.as_ref().to_string());
4000        }
4001
4002        #[allow(clippy::single_element_loop)]
4003        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4004            url = params.uri_replacement(url, param_name, find_this, true);
4005        }
4006        {
4007            let to_remove = ["name"];
4008            params.remove_params(&to_remove);
4009        }
4010
4011        let url = params.parse_with_url(&url);
4012
4013        loop {
4014            let token = match self
4015                .hub
4016                .auth
4017                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4018                .await
4019            {
4020                Ok(token) => token,
4021                Err(e) => match dlg.token(e) {
4022                    Ok(token) => token,
4023                    Err(e) => {
4024                        dlg.finished(false);
4025                        return Err(common::Error::MissingToken(e));
4026                    }
4027                },
4028            };
4029            let mut req_result = {
4030                let client = &self.hub.client;
4031                dlg.pre_request();
4032                let mut req_builder = hyper::Request::builder()
4033                    .method(hyper::Method::GET)
4034                    .uri(url.as_str())
4035                    .header(USER_AGENT, self.hub._user_agent.clone());
4036
4037                if let Some(token) = token.as_ref() {
4038                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4039                }
4040
4041                let request = req_builder
4042                    .header(CONTENT_LENGTH, 0_u64)
4043                    .body(common::to_body::<String>(None));
4044
4045                client.request(request.unwrap()).await
4046            };
4047
4048            match req_result {
4049                Err(err) => {
4050                    if let common::Retry::After(d) = dlg.http_error(&err) {
4051                        sleep(d).await;
4052                        continue;
4053                    }
4054                    dlg.finished(false);
4055                    return Err(common::Error::HttpError(err));
4056                }
4057                Ok(res) => {
4058                    let (mut parts, body) = res.into_parts();
4059                    let mut body = common::Body::new(body);
4060                    if !parts.status.is_success() {
4061                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4062                        let error = serde_json::from_str(&common::to_string(&bytes));
4063                        let response = common::to_response(parts, bytes.into());
4064
4065                        if let common::Retry::After(d) =
4066                            dlg.http_failure(&response, error.as_ref().ok())
4067                        {
4068                            sleep(d).await;
4069                            continue;
4070                        }
4071
4072                        dlg.finished(false);
4073
4074                        return Err(match error {
4075                            Ok(value) => common::Error::BadRequest(value),
4076                            _ => common::Error::Failure(response),
4077                        });
4078                    }
4079                    let response = {
4080                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4081                        let encoded = common::to_string(&bytes);
4082                        match serde_json::from_str(&encoded) {
4083                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4084                            Err(error) => {
4085                                dlg.response_json_decode_error(&encoded, &error);
4086                                return Err(common::Error::JsonDecodeError(
4087                                    encoded.to_string(),
4088                                    error,
4089                                ));
4090                            }
4091                        }
4092                    };
4093
4094                    dlg.finished(true);
4095                    return Ok(response);
4096                }
4097            }
4098        }
4099    }
4100
4101    /// Required. Name of the recommendation.
4102    ///
4103    /// Sets the *name* path property to the given value.
4104    ///
4105    /// Even though the property as already been set when instantiating this call,
4106    /// we provide this method for API completeness.
4107    pub fn name(
4108        mut self,
4109        new_value: &str,
4110    ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
4111        self._name = new_value.to_string();
4112        self
4113    }
4114    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4115    /// while executing the actual API request.
4116    ///
4117    /// ````text
4118    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4119    /// ````
4120    ///
4121    /// Sets the *delegate* property to the given value.
4122    pub fn delegate(
4123        mut self,
4124        new_value: &'a mut dyn common::Delegate,
4125    ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
4126        self._delegate = Some(new_value);
4127        self
4128    }
4129
4130    /// Set any additional parameter of the query string used in the request.
4131    /// It should be used to set parameters which are not yet available through their own
4132    /// setters.
4133    ///
4134    /// Please note that this method must not be used to set any of the known parameters
4135    /// which have their own setter method. If done anyway, the request will fail.
4136    ///
4137    /// # Additional Parameters
4138    ///
4139    /// * *$.xgafv* (query-string) - V1 error format.
4140    /// * *access_token* (query-string) - OAuth access token.
4141    /// * *alt* (query-string) - Data format for response.
4142    /// * *callback* (query-string) - JSONP
4143    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4144    /// * *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.
4145    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4146    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4147    /// * *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.
4148    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4149    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4150    pub fn param<T>(
4151        mut self,
4152        name: T,
4153        value: T,
4154    ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4155    where
4156        T: AsRef<str>,
4157    {
4158        self._additional_params
4159            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4160        self
4161    }
4162
4163    /// Identifies the authorization scope for the method you are building.
4164    ///
4165    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4166    /// [`Scope::CloudPlatform`].
4167    ///
4168    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4169    /// tokens for more than one scope.
4170    ///
4171    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4172    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4173    /// sufficient, a read-write scope will do as well.
4174    pub fn add_scope<St>(
4175        mut self,
4176        scope: St,
4177    ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4178    where
4179        St: AsRef<str>,
4180    {
4181        self._scopes.insert(String::from(scope.as_ref()));
4182        self
4183    }
4184    /// Identifies the authorization scope(s) for the method you are building.
4185    ///
4186    /// See [`Self::add_scope()`] for details.
4187    pub fn add_scopes<I, St>(
4188        mut self,
4189        scopes: I,
4190    ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4191    where
4192        I: IntoIterator<Item = St>,
4193        St: AsRef<str>,
4194    {
4195        self._scopes
4196            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4197        self
4198    }
4199
4200    /// Removes all scopes, and no default scope will be used either.
4201    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4202    /// for details).
4203    pub fn clear_scopes(mut self) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
4204        self._scopes.clear();
4205        self
4206    }
4207}
4208
4209/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
4210///
4211/// A builder for the *locations.recommenders.recommendations.list* method supported by a *billingAccount* resource.
4212/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4213///
4214/// # Example
4215///
4216/// Instantiate a resource method builder
4217///
4218/// ```test_harness,no_run
4219/// # extern crate hyper;
4220/// # extern crate hyper_rustls;
4221/// # extern crate google_recommender1 as recommender1;
4222/// # async fn dox() {
4223/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4224///
4225/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4226/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4227/// #     .with_native_roots()
4228/// #     .unwrap()
4229/// #     .https_only()
4230/// #     .enable_http2()
4231/// #     .build();
4232///
4233/// # let executor = hyper_util::rt::TokioExecutor::new();
4234/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4235/// #     secret,
4236/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4237/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4238/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4239/// #     ),
4240/// # ).build().await.unwrap();
4241///
4242/// # let client = hyper_util::client::legacy::Client::builder(
4243/// #     hyper_util::rt::TokioExecutor::new()
4244/// # )
4245/// # .build(
4246/// #     hyper_rustls::HttpsConnectorBuilder::new()
4247/// #         .with_native_roots()
4248/// #         .unwrap()
4249/// #         .https_or_http()
4250/// #         .enable_http2()
4251/// #         .build()
4252/// # );
4253/// # let mut hub = Recommender::new(client, auth);
4254/// // You can configure optional parameters by calling the respective setters at will, and
4255/// // execute the final call using `doit()`.
4256/// // Values shown here are possibly random and not representative !
4257/// let result = hub.billing_accounts().locations_recommenders_recommendations_list("parent")
4258///              .page_token("gubergren")
4259///              .page_size(-75)
4260///              .filter("dolor")
4261///              .doit().await;
4262/// # }
4263/// ```
4264pub struct BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4265where
4266    C: 'a,
4267{
4268    hub: &'a Recommender<C>,
4269    _parent: String,
4270    _page_token: Option<String>,
4271    _page_size: Option<i32>,
4272    _filter: Option<String>,
4273    _delegate: Option<&'a mut dyn common::Delegate>,
4274    _additional_params: HashMap<String, String>,
4275    _scopes: BTreeSet<String>,
4276}
4277
4278impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderRecommendationListCall<'a, C> {}
4279
4280impl<'a, C> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4281where
4282    C: common::Connector,
4283{
4284    /// Perform the operation you have build so far.
4285    pub async fn doit(
4286        mut self,
4287    ) -> common::Result<(
4288        common::Response,
4289        GoogleCloudRecommenderV1ListRecommendationsResponse,
4290    )> {
4291        use std::borrow::Cow;
4292        use std::io::{Read, Seek};
4293
4294        use common::{url::Params, ToParts};
4295        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4296
4297        let mut dd = common::DefaultDelegate;
4298        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4299        dlg.begin(common::MethodInfo {
4300            id: "recommender.billingAccounts.locations.recommenders.recommendations.list",
4301            http_method: hyper::Method::GET,
4302        });
4303
4304        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
4305            if self._additional_params.contains_key(field) {
4306                dlg.finished(false);
4307                return Err(common::Error::FieldClash(field));
4308            }
4309        }
4310
4311        let mut params = Params::with_capacity(6 + self._additional_params.len());
4312        params.push("parent", self._parent);
4313        if let Some(value) = self._page_token.as_ref() {
4314            params.push("pageToken", value);
4315        }
4316        if let Some(value) = self._page_size.as_ref() {
4317            params.push("pageSize", value.to_string());
4318        }
4319        if let Some(value) = self._filter.as_ref() {
4320            params.push("filter", value);
4321        }
4322
4323        params.extend(self._additional_params.iter());
4324
4325        params.push("alt", "json");
4326        let mut url = self.hub._base_url.clone() + "v1/{+parent}/recommendations";
4327        if self._scopes.is_empty() {
4328            self._scopes
4329                .insert(Scope::CloudPlatform.as_ref().to_string());
4330        }
4331
4332        #[allow(clippy::single_element_loop)]
4333        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4334            url = params.uri_replacement(url, param_name, find_this, true);
4335        }
4336        {
4337            let to_remove = ["parent"];
4338            params.remove_params(&to_remove);
4339        }
4340
4341        let url = params.parse_with_url(&url);
4342
4343        loop {
4344            let token = match self
4345                .hub
4346                .auth
4347                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4348                .await
4349            {
4350                Ok(token) => token,
4351                Err(e) => match dlg.token(e) {
4352                    Ok(token) => token,
4353                    Err(e) => {
4354                        dlg.finished(false);
4355                        return Err(common::Error::MissingToken(e));
4356                    }
4357                },
4358            };
4359            let mut req_result = {
4360                let client = &self.hub.client;
4361                dlg.pre_request();
4362                let mut req_builder = hyper::Request::builder()
4363                    .method(hyper::Method::GET)
4364                    .uri(url.as_str())
4365                    .header(USER_AGENT, self.hub._user_agent.clone());
4366
4367                if let Some(token) = token.as_ref() {
4368                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4369                }
4370
4371                let request = req_builder
4372                    .header(CONTENT_LENGTH, 0_u64)
4373                    .body(common::to_body::<String>(None));
4374
4375                client.request(request.unwrap()).await
4376            };
4377
4378            match req_result {
4379                Err(err) => {
4380                    if let common::Retry::After(d) = dlg.http_error(&err) {
4381                        sleep(d).await;
4382                        continue;
4383                    }
4384                    dlg.finished(false);
4385                    return Err(common::Error::HttpError(err));
4386                }
4387                Ok(res) => {
4388                    let (mut parts, body) = res.into_parts();
4389                    let mut body = common::Body::new(body);
4390                    if !parts.status.is_success() {
4391                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4392                        let error = serde_json::from_str(&common::to_string(&bytes));
4393                        let response = common::to_response(parts, bytes.into());
4394
4395                        if let common::Retry::After(d) =
4396                            dlg.http_failure(&response, error.as_ref().ok())
4397                        {
4398                            sleep(d).await;
4399                            continue;
4400                        }
4401
4402                        dlg.finished(false);
4403
4404                        return Err(match error {
4405                            Ok(value) => common::Error::BadRequest(value),
4406                            _ => common::Error::Failure(response),
4407                        });
4408                    }
4409                    let response = {
4410                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4411                        let encoded = common::to_string(&bytes);
4412                        match serde_json::from_str(&encoded) {
4413                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4414                            Err(error) => {
4415                                dlg.response_json_decode_error(&encoded, &error);
4416                                return Err(common::Error::JsonDecodeError(
4417                                    encoded.to_string(),
4418                                    error,
4419                                ));
4420                            }
4421                        }
4422                    };
4423
4424                    dlg.finished(true);
4425                    return Ok(response);
4426                }
4427            }
4428        }
4429    }
4430
4431    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
4432    ///
4433    /// Sets the *parent* path property to the given value.
4434    ///
4435    /// Even though the property as already been set when instantiating this call,
4436    /// we provide this method for API completeness.
4437    pub fn parent(
4438        mut self,
4439        new_value: &str,
4440    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4441        self._parent = new_value.to_string();
4442        self
4443    }
4444    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
4445    ///
4446    /// Sets the *page token* query property to the given value.
4447    pub fn page_token(
4448        mut self,
4449        new_value: &str,
4450    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4451        self._page_token = Some(new_value.to_string());
4452        self
4453    }
4454    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
4455    ///
4456    /// Sets the *page size* query property to the given value.
4457    pub fn page_size(
4458        mut self,
4459        new_value: i32,
4460    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4461        self._page_size = Some(new_value);
4462        self
4463    }
4464    /// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
4465    ///
4466    /// Sets the *filter* query property to the given value.
4467    pub fn filter(
4468        mut self,
4469        new_value: &str,
4470    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4471        self._filter = Some(new_value.to_string());
4472        self
4473    }
4474    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4475    /// while executing the actual API request.
4476    ///
4477    /// ````text
4478    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4479    /// ````
4480    ///
4481    /// Sets the *delegate* property to the given value.
4482    pub fn delegate(
4483        mut self,
4484        new_value: &'a mut dyn common::Delegate,
4485    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4486        self._delegate = Some(new_value);
4487        self
4488    }
4489
4490    /// Set any additional parameter of the query string used in the request.
4491    /// It should be used to set parameters which are not yet available through their own
4492    /// setters.
4493    ///
4494    /// Please note that this method must not be used to set any of the known parameters
4495    /// which have their own setter method. If done anyway, the request will fail.
4496    ///
4497    /// # Additional Parameters
4498    ///
4499    /// * *$.xgafv* (query-string) - V1 error format.
4500    /// * *access_token* (query-string) - OAuth access token.
4501    /// * *alt* (query-string) - Data format for response.
4502    /// * *callback* (query-string) - JSONP
4503    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4504    /// * *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.
4505    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4506    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4507    /// * *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.
4508    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4509    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4510    pub fn param<T>(
4511        mut self,
4512        name: T,
4513        value: T,
4514    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4515    where
4516        T: AsRef<str>,
4517    {
4518        self._additional_params
4519            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4520        self
4521    }
4522
4523    /// Identifies the authorization scope for the method you are building.
4524    ///
4525    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4526    /// [`Scope::CloudPlatform`].
4527    ///
4528    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4529    /// tokens for more than one scope.
4530    ///
4531    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4532    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4533    /// sufficient, a read-write scope will do as well.
4534    pub fn add_scope<St>(
4535        mut self,
4536        scope: St,
4537    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4538    where
4539        St: AsRef<str>,
4540    {
4541        self._scopes.insert(String::from(scope.as_ref()));
4542        self
4543    }
4544    /// Identifies the authorization scope(s) for the method you are building.
4545    ///
4546    /// See [`Self::add_scope()`] for details.
4547    pub fn add_scopes<I, St>(
4548        mut self,
4549        scopes: I,
4550    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4551    where
4552        I: IntoIterator<Item = St>,
4553        St: AsRef<str>,
4554    {
4555        self._scopes
4556            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4557        self
4558    }
4559
4560    /// Removes all scopes, and no default scope will be used either.
4561    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4562    /// for details).
4563    pub fn clear_scopes(
4564        mut self,
4565    ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4566        self._scopes.clear();
4567        self
4568    }
4569}
4570
4571/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
4572///
4573/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *billingAccount* resource.
4574/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4575///
4576/// # Example
4577///
4578/// Instantiate a resource method builder
4579///
4580/// ```test_harness,no_run
4581/// # extern crate hyper;
4582/// # extern crate hyper_rustls;
4583/// # extern crate google_recommender1 as recommender1;
4584/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationClaimedRequest;
4585/// # async fn dox() {
4586/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4587///
4588/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4589/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4590/// #     .with_native_roots()
4591/// #     .unwrap()
4592/// #     .https_only()
4593/// #     .enable_http2()
4594/// #     .build();
4595///
4596/// # let executor = hyper_util::rt::TokioExecutor::new();
4597/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4598/// #     secret,
4599/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4600/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4601/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4602/// #     ),
4603/// # ).build().await.unwrap();
4604///
4605/// # let client = hyper_util::client::legacy::Client::builder(
4606/// #     hyper_util::rt::TokioExecutor::new()
4607/// # )
4608/// # .build(
4609/// #     hyper_rustls::HttpsConnectorBuilder::new()
4610/// #         .with_native_roots()
4611/// #         .unwrap()
4612/// #         .https_or_http()
4613/// #         .enable_http2()
4614/// #         .build()
4615/// # );
4616/// # let mut hub = Recommender::new(client, auth);
4617/// // As the method needs a request, you would usually fill it with the desired information
4618/// // into the respective structure. Some of the parts shown here might not be applicable !
4619/// // Values shown here are possibly random and not representative !
4620/// let mut req = GoogleCloudRecommenderV1MarkRecommendationClaimedRequest::default();
4621///
4622/// // You can configure optional parameters by calling the respective setters at will, and
4623/// // execute the final call using `doit()`.
4624/// // Values shown here are possibly random and not representative !
4625/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_claimed(req, "name")
4626///              .doit().await;
4627/// # }
4628/// ```
4629pub struct BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
4630where
4631    C: 'a,
4632{
4633    hub: &'a Recommender<C>,
4634    _request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
4635    _name: String,
4636    _delegate: Option<&'a mut dyn common::Delegate>,
4637    _additional_params: HashMap<String, String>,
4638    _scopes: BTreeSet<String>,
4639}
4640
4641impl<'a, C> common::CallBuilder
4642    for BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
4643{
4644}
4645
4646impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
4647where
4648    C: common::Connector,
4649{
4650    /// Perform the operation you have build so far.
4651    pub async fn doit(
4652        mut self,
4653    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
4654        use std::borrow::Cow;
4655        use std::io::{Read, Seek};
4656
4657        use common::{url::Params, ToParts};
4658        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4659
4660        let mut dd = common::DefaultDelegate;
4661        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4662        dlg.begin(common::MethodInfo {
4663            id: "recommender.billingAccounts.locations.recommenders.recommendations.markClaimed",
4664            http_method: hyper::Method::POST,
4665        });
4666
4667        for &field in ["alt", "name"].iter() {
4668            if self._additional_params.contains_key(field) {
4669                dlg.finished(false);
4670                return Err(common::Error::FieldClash(field));
4671            }
4672        }
4673
4674        let mut params = Params::with_capacity(4 + self._additional_params.len());
4675        params.push("name", self._name);
4676
4677        params.extend(self._additional_params.iter());
4678
4679        params.push("alt", "json");
4680        let mut url = self.hub._base_url.clone() + "v1/{+name}:markClaimed";
4681        if self._scopes.is_empty() {
4682            self._scopes
4683                .insert(Scope::CloudPlatform.as_ref().to_string());
4684        }
4685
4686        #[allow(clippy::single_element_loop)]
4687        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4688            url = params.uri_replacement(url, param_name, find_this, true);
4689        }
4690        {
4691            let to_remove = ["name"];
4692            params.remove_params(&to_remove);
4693        }
4694
4695        let url = params.parse_with_url(&url);
4696
4697        let mut json_mime_type = mime::APPLICATION_JSON;
4698        let mut request_value_reader = {
4699            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4700            common::remove_json_null_values(&mut value);
4701            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4702            serde_json::to_writer(&mut dst, &value).unwrap();
4703            dst
4704        };
4705        let request_size = request_value_reader
4706            .seek(std::io::SeekFrom::End(0))
4707            .unwrap();
4708        request_value_reader
4709            .seek(std::io::SeekFrom::Start(0))
4710            .unwrap();
4711
4712        loop {
4713            let token = match self
4714                .hub
4715                .auth
4716                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4717                .await
4718            {
4719                Ok(token) => token,
4720                Err(e) => match dlg.token(e) {
4721                    Ok(token) => token,
4722                    Err(e) => {
4723                        dlg.finished(false);
4724                        return Err(common::Error::MissingToken(e));
4725                    }
4726                },
4727            };
4728            request_value_reader
4729                .seek(std::io::SeekFrom::Start(0))
4730                .unwrap();
4731            let mut req_result = {
4732                let client = &self.hub.client;
4733                dlg.pre_request();
4734                let mut req_builder = hyper::Request::builder()
4735                    .method(hyper::Method::POST)
4736                    .uri(url.as_str())
4737                    .header(USER_AGENT, self.hub._user_agent.clone());
4738
4739                if let Some(token) = token.as_ref() {
4740                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4741                }
4742
4743                let request = req_builder
4744                    .header(CONTENT_TYPE, json_mime_type.to_string())
4745                    .header(CONTENT_LENGTH, request_size as u64)
4746                    .body(common::to_body(
4747                        request_value_reader.get_ref().clone().into(),
4748                    ));
4749
4750                client.request(request.unwrap()).await
4751            };
4752
4753            match req_result {
4754                Err(err) => {
4755                    if let common::Retry::After(d) = dlg.http_error(&err) {
4756                        sleep(d).await;
4757                        continue;
4758                    }
4759                    dlg.finished(false);
4760                    return Err(common::Error::HttpError(err));
4761                }
4762                Ok(res) => {
4763                    let (mut parts, body) = res.into_parts();
4764                    let mut body = common::Body::new(body);
4765                    if !parts.status.is_success() {
4766                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4767                        let error = serde_json::from_str(&common::to_string(&bytes));
4768                        let response = common::to_response(parts, bytes.into());
4769
4770                        if let common::Retry::After(d) =
4771                            dlg.http_failure(&response, error.as_ref().ok())
4772                        {
4773                            sleep(d).await;
4774                            continue;
4775                        }
4776
4777                        dlg.finished(false);
4778
4779                        return Err(match error {
4780                            Ok(value) => common::Error::BadRequest(value),
4781                            _ => common::Error::Failure(response),
4782                        });
4783                    }
4784                    let response = {
4785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4786                        let encoded = common::to_string(&bytes);
4787                        match serde_json::from_str(&encoded) {
4788                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4789                            Err(error) => {
4790                                dlg.response_json_decode_error(&encoded, &error);
4791                                return Err(common::Error::JsonDecodeError(
4792                                    encoded.to_string(),
4793                                    error,
4794                                ));
4795                            }
4796                        }
4797                    };
4798
4799                    dlg.finished(true);
4800                    return Ok(response);
4801                }
4802            }
4803        }
4804    }
4805
4806    ///
4807    /// Sets the *request* property to the given value.
4808    ///
4809    /// Even though the property as already been set when instantiating this call,
4810    /// we provide this method for API completeness.
4811    pub fn request(
4812        mut self,
4813        new_value: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
4814    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
4815        self._request = new_value;
4816        self
4817    }
4818    /// Required. Name of the recommendation.
4819    ///
4820    /// Sets the *name* path property to the given value.
4821    ///
4822    /// Even though the property as already been set when instantiating this call,
4823    /// we provide this method for API completeness.
4824    pub fn name(
4825        mut self,
4826        new_value: &str,
4827    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
4828        self._name = new_value.to_string();
4829        self
4830    }
4831    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4832    /// while executing the actual API request.
4833    ///
4834    /// ````text
4835    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4836    /// ````
4837    ///
4838    /// Sets the *delegate* property to the given value.
4839    pub fn delegate(
4840        mut self,
4841        new_value: &'a mut dyn common::Delegate,
4842    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
4843        self._delegate = Some(new_value);
4844        self
4845    }
4846
4847    /// Set any additional parameter of the query string used in the request.
4848    /// It should be used to set parameters which are not yet available through their own
4849    /// setters.
4850    ///
4851    /// Please note that this method must not be used to set any of the known parameters
4852    /// which have their own setter method. If done anyway, the request will fail.
4853    ///
4854    /// # Additional Parameters
4855    ///
4856    /// * *$.xgafv* (query-string) - V1 error format.
4857    /// * *access_token* (query-string) - OAuth access token.
4858    /// * *alt* (query-string) - Data format for response.
4859    /// * *callback* (query-string) - JSONP
4860    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4861    /// * *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.
4862    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4863    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4864    /// * *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.
4865    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4866    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4867    pub fn param<T>(
4868        mut self,
4869        name: T,
4870        value: T,
4871    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
4872    where
4873        T: AsRef<str>,
4874    {
4875        self._additional_params
4876            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4877        self
4878    }
4879
4880    /// Identifies the authorization scope for the method you are building.
4881    ///
4882    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4883    /// [`Scope::CloudPlatform`].
4884    ///
4885    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4886    /// tokens for more than one scope.
4887    ///
4888    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4889    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4890    /// sufficient, a read-write scope will do as well.
4891    pub fn add_scope<St>(
4892        mut self,
4893        scope: St,
4894    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
4895    where
4896        St: AsRef<str>,
4897    {
4898        self._scopes.insert(String::from(scope.as_ref()));
4899        self
4900    }
4901    /// Identifies the authorization scope(s) for the method you are building.
4902    ///
4903    /// See [`Self::add_scope()`] for details.
4904    pub fn add_scopes<I, St>(
4905        mut self,
4906        scopes: I,
4907    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
4908    where
4909        I: IntoIterator<Item = St>,
4910        St: AsRef<str>,
4911    {
4912        self._scopes
4913            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4914        self
4915    }
4916
4917    /// Removes all scopes, and no default scope will be used either.
4918    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4919    /// for details).
4920    pub fn clear_scopes(
4921        mut self,
4922    ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
4923        self._scopes.clear();
4924        self
4925    }
4926}
4927
4928/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
4929///
4930/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *billingAccount* resource.
4931/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4932///
4933/// # Example
4934///
4935/// Instantiate a resource method builder
4936///
4937/// ```test_harness,no_run
4938/// # extern crate hyper;
4939/// # extern crate hyper_rustls;
4940/// # extern crate google_recommender1 as recommender1;
4941/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationDismissedRequest;
4942/// # async fn dox() {
4943/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4944///
4945/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4946/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4947/// #     .with_native_roots()
4948/// #     .unwrap()
4949/// #     .https_only()
4950/// #     .enable_http2()
4951/// #     .build();
4952///
4953/// # let executor = hyper_util::rt::TokioExecutor::new();
4954/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4955/// #     secret,
4956/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4957/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4958/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4959/// #     ),
4960/// # ).build().await.unwrap();
4961///
4962/// # let client = hyper_util::client::legacy::Client::builder(
4963/// #     hyper_util::rt::TokioExecutor::new()
4964/// # )
4965/// # .build(
4966/// #     hyper_rustls::HttpsConnectorBuilder::new()
4967/// #         .with_native_roots()
4968/// #         .unwrap()
4969/// #         .https_or_http()
4970/// #         .enable_http2()
4971/// #         .build()
4972/// # );
4973/// # let mut hub = Recommender::new(client, auth);
4974/// // As the method needs a request, you would usually fill it with the desired information
4975/// // into the respective structure. Some of the parts shown here might not be applicable !
4976/// // Values shown here are possibly random and not representative !
4977/// let mut req = GoogleCloudRecommenderV1MarkRecommendationDismissedRequest::default();
4978///
4979/// // You can configure optional parameters by calling the respective setters at will, and
4980/// // execute the final call using `doit()`.
4981/// // Values shown here are possibly random and not representative !
4982/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_dismissed(req, "name")
4983///              .doit().await;
4984/// # }
4985/// ```
4986pub struct BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
4987where
4988    C: 'a,
4989{
4990    hub: &'a Recommender<C>,
4991    _request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
4992    _name: String,
4993    _delegate: Option<&'a mut dyn common::Delegate>,
4994    _additional_params: HashMap<String, String>,
4995    _scopes: BTreeSet<String>,
4996}
4997
4998impl<'a, C> common::CallBuilder
4999    for BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5000{
5001}
5002
5003impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5004where
5005    C: common::Connector,
5006{
5007    /// Perform the operation you have build so far.
5008    pub async fn doit(
5009        mut self,
5010    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
5011        use std::borrow::Cow;
5012        use std::io::{Read, Seek};
5013
5014        use common::{url::Params, ToParts};
5015        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5016
5017        let mut dd = common::DefaultDelegate;
5018        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5019        dlg.begin(common::MethodInfo {
5020            id: "recommender.billingAccounts.locations.recommenders.recommendations.markDismissed",
5021            http_method: hyper::Method::POST,
5022        });
5023
5024        for &field in ["alt", "name"].iter() {
5025            if self._additional_params.contains_key(field) {
5026                dlg.finished(false);
5027                return Err(common::Error::FieldClash(field));
5028            }
5029        }
5030
5031        let mut params = Params::with_capacity(4 + self._additional_params.len());
5032        params.push("name", self._name);
5033
5034        params.extend(self._additional_params.iter());
5035
5036        params.push("alt", "json");
5037        let mut url = self.hub._base_url.clone() + "v1/{+name}:markDismissed";
5038        if self._scopes.is_empty() {
5039            self._scopes
5040                .insert(Scope::CloudPlatform.as_ref().to_string());
5041        }
5042
5043        #[allow(clippy::single_element_loop)]
5044        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5045            url = params.uri_replacement(url, param_name, find_this, true);
5046        }
5047        {
5048            let to_remove = ["name"];
5049            params.remove_params(&to_remove);
5050        }
5051
5052        let url = params.parse_with_url(&url);
5053
5054        let mut json_mime_type = mime::APPLICATION_JSON;
5055        let mut request_value_reader = {
5056            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5057            common::remove_json_null_values(&mut value);
5058            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5059            serde_json::to_writer(&mut dst, &value).unwrap();
5060            dst
5061        };
5062        let request_size = request_value_reader
5063            .seek(std::io::SeekFrom::End(0))
5064            .unwrap();
5065        request_value_reader
5066            .seek(std::io::SeekFrom::Start(0))
5067            .unwrap();
5068
5069        loop {
5070            let token = match self
5071                .hub
5072                .auth
5073                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5074                .await
5075            {
5076                Ok(token) => token,
5077                Err(e) => match dlg.token(e) {
5078                    Ok(token) => token,
5079                    Err(e) => {
5080                        dlg.finished(false);
5081                        return Err(common::Error::MissingToken(e));
5082                    }
5083                },
5084            };
5085            request_value_reader
5086                .seek(std::io::SeekFrom::Start(0))
5087                .unwrap();
5088            let mut req_result = {
5089                let client = &self.hub.client;
5090                dlg.pre_request();
5091                let mut req_builder = hyper::Request::builder()
5092                    .method(hyper::Method::POST)
5093                    .uri(url.as_str())
5094                    .header(USER_AGENT, self.hub._user_agent.clone());
5095
5096                if let Some(token) = token.as_ref() {
5097                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5098                }
5099
5100                let request = req_builder
5101                    .header(CONTENT_TYPE, json_mime_type.to_string())
5102                    .header(CONTENT_LENGTH, request_size as u64)
5103                    .body(common::to_body(
5104                        request_value_reader.get_ref().clone().into(),
5105                    ));
5106
5107                client.request(request.unwrap()).await
5108            };
5109
5110            match req_result {
5111                Err(err) => {
5112                    if let common::Retry::After(d) = dlg.http_error(&err) {
5113                        sleep(d).await;
5114                        continue;
5115                    }
5116                    dlg.finished(false);
5117                    return Err(common::Error::HttpError(err));
5118                }
5119                Ok(res) => {
5120                    let (mut parts, body) = res.into_parts();
5121                    let mut body = common::Body::new(body);
5122                    if !parts.status.is_success() {
5123                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5124                        let error = serde_json::from_str(&common::to_string(&bytes));
5125                        let response = common::to_response(parts, bytes.into());
5126
5127                        if let common::Retry::After(d) =
5128                            dlg.http_failure(&response, error.as_ref().ok())
5129                        {
5130                            sleep(d).await;
5131                            continue;
5132                        }
5133
5134                        dlg.finished(false);
5135
5136                        return Err(match error {
5137                            Ok(value) => common::Error::BadRequest(value),
5138                            _ => common::Error::Failure(response),
5139                        });
5140                    }
5141                    let response = {
5142                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5143                        let encoded = common::to_string(&bytes);
5144                        match serde_json::from_str(&encoded) {
5145                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5146                            Err(error) => {
5147                                dlg.response_json_decode_error(&encoded, &error);
5148                                return Err(common::Error::JsonDecodeError(
5149                                    encoded.to_string(),
5150                                    error,
5151                                ));
5152                            }
5153                        }
5154                    };
5155
5156                    dlg.finished(true);
5157                    return Ok(response);
5158                }
5159            }
5160        }
5161    }
5162
5163    ///
5164    /// Sets the *request* property to the given value.
5165    ///
5166    /// Even though the property as already been set when instantiating this call,
5167    /// we provide this method for API completeness.
5168    pub fn request(
5169        mut self,
5170        new_value: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
5171    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5172        self._request = new_value;
5173        self
5174    }
5175    /// Required. Name of the recommendation.
5176    ///
5177    /// Sets the *name* path property to the given value.
5178    ///
5179    /// Even though the property as already been set when instantiating this call,
5180    /// we provide this method for API completeness.
5181    pub fn name(
5182        mut self,
5183        new_value: &str,
5184    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5185        self._name = new_value.to_string();
5186        self
5187    }
5188    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5189    /// while executing the actual API request.
5190    ///
5191    /// ````text
5192    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5193    /// ````
5194    ///
5195    /// Sets the *delegate* property to the given value.
5196    pub fn delegate(
5197        mut self,
5198        new_value: &'a mut dyn common::Delegate,
5199    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5200        self._delegate = Some(new_value);
5201        self
5202    }
5203
5204    /// Set any additional parameter of the query string used in the request.
5205    /// It should be used to set parameters which are not yet available through their own
5206    /// setters.
5207    ///
5208    /// Please note that this method must not be used to set any of the known parameters
5209    /// which have their own setter method. If done anyway, the request will fail.
5210    ///
5211    /// # Additional Parameters
5212    ///
5213    /// * *$.xgafv* (query-string) - V1 error format.
5214    /// * *access_token* (query-string) - OAuth access token.
5215    /// * *alt* (query-string) - Data format for response.
5216    /// * *callback* (query-string) - JSONP
5217    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5218    /// * *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.
5219    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5220    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5221    /// * *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.
5222    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5223    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5224    pub fn param<T>(
5225        mut self,
5226        name: T,
5227        value: T,
5228    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5229    where
5230        T: AsRef<str>,
5231    {
5232        self._additional_params
5233            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5234        self
5235    }
5236
5237    /// Identifies the authorization scope for the method you are building.
5238    ///
5239    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5240    /// [`Scope::CloudPlatform`].
5241    ///
5242    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5243    /// tokens for more than one scope.
5244    ///
5245    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5246    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5247    /// sufficient, a read-write scope will do as well.
5248    pub fn add_scope<St>(
5249        mut self,
5250        scope: St,
5251    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5252    where
5253        St: AsRef<str>,
5254    {
5255        self._scopes.insert(String::from(scope.as_ref()));
5256        self
5257    }
5258    /// Identifies the authorization scope(s) for the method you are building.
5259    ///
5260    /// See [`Self::add_scope()`] for details.
5261    pub fn add_scopes<I, St>(
5262        mut self,
5263        scopes: I,
5264    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5265    where
5266        I: IntoIterator<Item = St>,
5267        St: AsRef<str>,
5268    {
5269        self._scopes
5270            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5271        self
5272    }
5273
5274    /// Removes all scopes, and no default scope will be used either.
5275    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5276    /// for details).
5277    pub fn clear_scopes(
5278        mut self,
5279    ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5280        self._scopes.clear();
5281        self
5282    }
5283}
5284
5285/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
5286///
5287/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *billingAccount* resource.
5288/// It is not used directly, but through a [`BillingAccountMethods`] instance.
5289///
5290/// # Example
5291///
5292/// Instantiate a resource method builder
5293///
5294/// ```test_harness,no_run
5295/// # extern crate hyper;
5296/// # extern crate hyper_rustls;
5297/// # extern crate google_recommender1 as recommender1;
5298/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationFailedRequest;
5299/// # async fn dox() {
5300/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5301///
5302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5303/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5304/// #     .with_native_roots()
5305/// #     .unwrap()
5306/// #     .https_only()
5307/// #     .enable_http2()
5308/// #     .build();
5309///
5310/// # let executor = hyper_util::rt::TokioExecutor::new();
5311/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5312/// #     secret,
5313/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5314/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5315/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5316/// #     ),
5317/// # ).build().await.unwrap();
5318///
5319/// # let client = hyper_util::client::legacy::Client::builder(
5320/// #     hyper_util::rt::TokioExecutor::new()
5321/// # )
5322/// # .build(
5323/// #     hyper_rustls::HttpsConnectorBuilder::new()
5324/// #         .with_native_roots()
5325/// #         .unwrap()
5326/// #         .https_or_http()
5327/// #         .enable_http2()
5328/// #         .build()
5329/// # );
5330/// # let mut hub = Recommender::new(client, auth);
5331/// // As the method needs a request, you would usually fill it with the desired information
5332/// // into the respective structure. Some of the parts shown here might not be applicable !
5333/// // Values shown here are possibly random and not representative !
5334/// let mut req = GoogleCloudRecommenderV1MarkRecommendationFailedRequest::default();
5335///
5336/// // You can configure optional parameters by calling the respective setters at will, and
5337/// // execute the final call using `doit()`.
5338/// // Values shown here are possibly random and not representative !
5339/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_failed(req, "name")
5340///              .doit().await;
5341/// # }
5342/// ```
5343pub struct BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5344where
5345    C: 'a,
5346{
5347    hub: &'a Recommender<C>,
5348    _request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
5349    _name: String,
5350    _delegate: Option<&'a mut dyn common::Delegate>,
5351    _additional_params: HashMap<String, String>,
5352    _scopes: BTreeSet<String>,
5353}
5354
5355impl<'a, C> common::CallBuilder
5356    for BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5357{
5358}
5359
5360impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5361where
5362    C: common::Connector,
5363{
5364    /// Perform the operation you have build so far.
5365    pub async fn doit(
5366        mut self,
5367    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
5368        use std::borrow::Cow;
5369        use std::io::{Read, Seek};
5370
5371        use common::{url::Params, ToParts};
5372        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5373
5374        let mut dd = common::DefaultDelegate;
5375        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5376        dlg.begin(common::MethodInfo {
5377            id: "recommender.billingAccounts.locations.recommenders.recommendations.markFailed",
5378            http_method: hyper::Method::POST,
5379        });
5380
5381        for &field in ["alt", "name"].iter() {
5382            if self._additional_params.contains_key(field) {
5383                dlg.finished(false);
5384                return Err(common::Error::FieldClash(field));
5385            }
5386        }
5387
5388        let mut params = Params::with_capacity(4 + self._additional_params.len());
5389        params.push("name", self._name);
5390
5391        params.extend(self._additional_params.iter());
5392
5393        params.push("alt", "json");
5394        let mut url = self.hub._base_url.clone() + "v1/{+name}:markFailed";
5395        if self._scopes.is_empty() {
5396            self._scopes
5397                .insert(Scope::CloudPlatform.as_ref().to_string());
5398        }
5399
5400        #[allow(clippy::single_element_loop)]
5401        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5402            url = params.uri_replacement(url, param_name, find_this, true);
5403        }
5404        {
5405            let to_remove = ["name"];
5406            params.remove_params(&to_remove);
5407        }
5408
5409        let url = params.parse_with_url(&url);
5410
5411        let mut json_mime_type = mime::APPLICATION_JSON;
5412        let mut request_value_reader = {
5413            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5414            common::remove_json_null_values(&mut value);
5415            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5416            serde_json::to_writer(&mut dst, &value).unwrap();
5417            dst
5418        };
5419        let request_size = request_value_reader
5420            .seek(std::io::SeekFrom::End(0))
5421            .unwrap();
5422        request_value_reader
5423            .seek(std::io::SeekFrom::Start(0))
5424            .unwrap();
5425
5426        loop {
5427            let token = match self
5428                .hub
5429                .auth
5430                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5431                .await
5432            {
5433                Ok(token) => token,
5434                Err(e) => match dlg.token(e) {
5435                    Ok(token) => token,
5436                    Err(e) => {
5437                        dlg.finished(false);
5438                        return Err(common::Error::MissingToken(e));
5439                    }
5440                },
5441            };
5442            request_value_reader
5443                .seek(std::io::SeekFrom::Start(0))
5444                .unwrap();
5445            let mut req_result = {
5446                let client = &self.hub.client;
5447                dlg.pre_request();
5448                let mut req_builder = hyper::Request::builder()
5449                    .method(hyper::Method::POST)
5450                    .uri(url.as_str())
5451                    .header(USER_AGENT, self.hub._user_agent.clone());
5452
5453                if let Some(token) = token.as_ref() {
5454                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5455                }
5456
5457                let request = req_builder
5458                    .header(CONTENT_TYPE, json_mime_type.to_string())
5459                    .header(CONTENT_LENGTH, request_size as u64)
5460                    .body(common::to_body(
5461                        request_value_reader.get_ref().clone().into(),
5462                    ));
5463
5464                client.request(request.unwrap()).await
5465            };
5466
5467            match req_result {
5468                Err(err) => {
5469                    if let common::Retry::After(d) = dlg.http_error(&err) {
5470                        sleep(d).await;
5471                        continue;
5472                    }
5473                    dlg.finished(false);
5474                    return Err(common::Error::HttpError(err));
5475                }
5476                Ok(res) => {
5477                    let (mut parts, body) = res.into_parts();
5478                    let mut body = common::Body::new(body);
5479                    if !parts.status.is_success() {
5480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5481                        let error = serde_json::from_str(&common::to_string(&bytes));
5482                        let response = common::to_response(parts, bytes.into());
5483
5484                        if let common::Retry::After(d) =
5485                            dlg.http_failure(&response, error.as_ref().ok())
5486                        {
5487                            sleep(d).await;
5488                            continue;
5489                        }
5490
5491                        dlg.finished(false);
5492
5493                        return Err(match error {
5494                            Ok(value) => common::Error::BadRequest(value),
5495                            _ => common::Error::Failure(response),
5496                        });
5497                    }
5498                    let response = {
5499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5500                        let encoded = common::to_string(&bytes);
5501                        match serde_json::from_str(&encoded) {
5502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5503                            Err(error) => {
5504                                dlg.response_json_decode_error(&encoded, &error);
5505                                return Err(common::Error::JsonDecodeError(
5506                                    encoded.to_string(),
5507                                    error,
5508                                ));
5509                            }
5510                        }
5511                    };
5512
5513                    dlg.finished(true);
5514                    return Ok(response);
5515                }
5516            }
5517        }
5518    }
5519
5520    ///
5521    /// Sets the *request* property to the given value.
5522    ///
5523    /// Even though the property as already been set when instantiating this call,
5524    /// we provide this method for API completeness.
5525    pub fn request(
5526        mut self,
5527        new_value: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
5528    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
5529        self._request = new_value;
5530        self
5531    }
5532    /// Required. Name of the recommendation.
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    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'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    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'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    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'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    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'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    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'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    ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
5637        self._scopes.clear();
5638        self
5639    }
5640}
5641
5642/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
5643///
5644/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *billingAccount* resource.
5645/// It is not used directly, but through a [`BillingAccountMethods`] 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_recommender1 as recommender1;
5655/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationSucceededRequest;
5656/// # async fn dox() {
5657/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5658///
5659/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5660/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5661/// #     .with_native_roots()
5662/// #     .unwrap()
5663/// #     .https_only()
5664/// #     .enable_http2()
5665/// #     .build();
5666///
5667/// # let executor = hyper_util::rt::TokioExecutor::new();
5668/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5669/// #     secret,
5670/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5671/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5672/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5673/// #     ),
5674/// # ).build().await.unwrap();
5675///
5676/// # let client = hyper_util::client::legacy::Client::builder(
5677/// #     hyper_util::rt::TokioExecutor::new()
5678/// # )
5679/// # .build(
5680/// #     hyper_rustls::HttpsConnectorBuilder::new()
5681/// #         .with_native_roots()
5682/// #         .unwrap()
5683/// #         .https_or_http()
5684/// #         .enable_http2()
5685/// #         .build()
5686/// # );
5687/// # let mut hub = Recommender::new(client, auth);
5688/// // As the method needs a request, you would usually fill it with the desired information
5689/// // into the respective structure. Some of the parts shown here might not be applicable !
5690/// // Values shown here are possibly random and not representative !
5691/// let mut req = GoogleCloudRecommenderV1MarkRecommendationSucceededRequest::default();
5692///
5693/// // You can configure optional parameters by calling the respective setters at will, and
5694/// // execute the final call using `doit()`.
5695/// // Values shown here are possibly random and not representative !
5696/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_succeeded(req, "name")
5697///              .doit().await;
5698/// # }
5699/// ```
5700pub struct BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
5701where
5702    C: 'a,
5703{
5704    hub: &'a Recommender<C>,
5705    _request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
5706    _name: String,
5707    _delegate: Option<&'a mut dyn common::Delegate>,
5708    _additional_params: HashMap<String, String>,
5709    _scopes: BTreeSet<String>,
5710}
5711
5712impl<'a, C> common::CallBuilder
5713    for BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
5714{
5715}
5716
5717impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
5718where
5719    C: common::Connector,
5720{
5721    /// Perform the operation you have build so far.
5722    pub async fn doit(
5723        mut self,
5724    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
5725        use std::borrow::Cow;
5726        use std::io::{Read, Seek};
5727
5728        use common::{url::Params, ToParts};
5729        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5730
5731        let mut dd = common::DefaultDelegate;
5732        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5733        dlg.begin(common::MethodInfo {
5734            id: "recommender.billingAccounts.locations.recommenders.recommendations.markSucceeded",
5735            http_method: hyper::Method::POST,
5736        });
5737
5738        for &field in ["alt", "name"].iter() {
5739            if self._additional_params.contains_key(field) {
5740                dlg.finished(false);
5741                return Err(common::Error::FieldClash(field));
5742            }
5743        }
5744
5745        let mut params = Params::with_capacity(4 + self._additional_params.len());
5746        params.push("name", self._name);
5747
5748        params.extend(self._additional_params.iter());
5749
5750        params.push("alt", "json");
5751        let mut url = self.hub._base_url.clone() + "v1/{+name}:markSucceeded";
5752        if self._scopes.is_empty() {
5753            self._scopes
5754                .insert(Scope::CloudPlatform.as_ref().to_string());
5755        }
5756
5757        #[allow(clippy::single_element_loop)]
5758        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5759            url = params.uri_replacement(url, param_name, find_this, true);
5760        }
5761        {
5762            let to_remove = ["name"];
5763            params.remove_params(&to_remove);
5764        }
5765
5766        let url = params.parse_with_url(&url);
5767
5768        let mut json_mime_type = mime::APPLICATION_JSON;
5769        let mut request_value_reader = {
5770            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5771            common::remove_json_null_values(&mut value);
5772            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5773            serde_json::to_writer(&mut dst, &value).unwrap();
5774            dst
5775        };
5776        let request_size = request_value_reader
5777            .seek(std::io::SeekFrom::End(0))
5778            .unwrap();
5779        request_value_reader
5780            .seek(std::io::SeekFrom::Start(0))
5781            .unwrap();
5782
5783        loop {
5784            let token = match self
5785                .hub
5786                .auth
5787                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5788                .await
5789            {
5790                Ok(token) => token,
5791                Err(e) => match dlg.token(e) {
5792                    Ok(token) => token,
5793                    Err(e) => {
5794                        dlg.finished(false);
5795                        return Err(common::Error::MissingToken(e));
5796                    }
5797                },
5798            };
5799            request_value_reader
5800                .seek(std::io::SeekFrom::Start(0))
5801                .unwrap();
5802            let mut req_result = {
5803                let client = &self.hub.client;
5804                dlg.pre_request();
5805                let mut req_builder = hyper::Request::builder()
5806                    .method(hyper::Method::POST)
5807                    .uri(url.as_str())
5808                    .header(USER_AGENT, self.hub._user_agent.clone());
5809
5810                if let Some(token) = token.as_ref() {
5811                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5812                }
5813
5814                let request = req_builder
5815                    .header(CONTENT_TYPE, json_mime_type.to_string())
5816                    .header(CONTENT_LENGTH, request_size as u64)
5817                    .body(common::to_body(
5818                        request_value_reader.get_ref().clone().into(),
5819                    ));
5820
5821                client.request(request.unwrap()).await
5822            };
5823
5824            match req_result {
5825                Err(err) => {
5826                    if let common::Retry::After(d) = dlg.http_error(&err) {
5827                        sleep(d).await;
5828                        continue;
5829                    }
5830                    dlg.finished(false);
5831                    return Err(common::Error::HttpError(err));
5832                }
5833                Ok(res) => {
5834                    let (mut parts, body) = res.into_parts();
5835                    let mut body = common::Body::new(body);
5836                    if !parts.status.is_success() {
5837                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5838                        let error = serde_json::from_str(&common::to_string(&bytes));
5839                        let response = common::to_response(parts, bytes.into());
5840
5841                        if let common::Retry::After(d) =
5842                            dlg.http_failure(&response, error.as_ref().ok())
5843                        {
5844                            sleep(d).await;
5845                            continue;
5846                        }
5847
5848                        dlg.finished(false);
5849
5850                        return Err(match error {
5851                            Ok(value) => common::Error::BadRequest(value),
5852                            _ => common::Error::Failure(response),
5853                        });
5854                    }
5855                    let response = {
5856                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5857                        let encoded = common::to_string(&bytes);
5858                        match serde_json::from_str(&encoded) {
5859                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5860                            Err(error) => {
5861                                dlg.response_json_decode_error(&encoded, &error);
5862                                return Err(common::Error::JsonDecodeError(
5863                                    encoded.to_string(),
5864                                    error,
5865                                ));
5866                            }
5867                        }
5868                    };
5869
5870                    dlg.finished(true);
5871                    return Ok(response);
5872                }
5873            }
5874        }
5875    }
5876
5877    ///
5878    /// Sets the *request* property to the given value.
5879    ///
5880    /// Even though the property as already been set when instantiating this call,
5881    /// we provide this method for API completeness.
5882    pub fn request(
5883        mut self,
5884        new_value: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
5885    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
5886        self._request = new_value;
5887        self
5888    }
5889    /// Required. Name of the recommendation.
5890    ///
5891    /// Sets the *name* path property to the given value.
5892    ///
5893    /// Even though the property as already been set when instantiating this call,
5894    /// we provide this method for API completeness.
5895    pub fn name(
5896        mut self,
5897        new_value: &str,
5898    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
5899        self._name = new_value.to_string();
5900        self
5901    }
5902    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5903    /// while executing the actual API request.
5904    ///
5905    /// ````text
5906    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5907    /// ````
5908    ///
5909    /// Sets the *delegate* property to the given value.
5910    pub fn delegate(
5911        mut self,
5912        new_value: &'a mut dyn common::Delegate,
5913    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
5914        self._delegate = Some(new_value);
5915        self
5916    }
5917
5918    /// Set any additional parameter of the query string used in the request.
5919    /// It should be used to set parameters which are not yet available through their own
5920    /// setters.
5921    ///
5922    /// Please note that this method must not be used to set any of the known parameters
5923    /// which have their own setter method. If done anyway, the request will fail.
5924    ///
5925    /// # Additional Parameters
5926    ///
5927    /// * *$.xgafv* (query-string) - V1 error format.
5928    /// * *access_token* (query-string) - OAuth access token.
5929    /// * *alt* (query-string) - Data format for response.
5930    /// * *callback* (query-string) - JSONP
5931    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5932    /// * *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.
5933    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5934    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5935    /// * *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.
5936    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5937    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5938    pub fn param<T>(
5939        mut self,
5940        name: T,
5941        value: T,
5942    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
5943    where
5944        T: AsRef<str>,
5945    {
5946        self._additional_params
5947            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5948        self
5949    }
5950
5951    /// Identifies the authorization scope for the method you are building.
5952    ///
5953    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5954    /// [`Scope::CloudPlatform`].
5955    ///
5956    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5957    /// tokens for more than one scope.
5958    ///
5959    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5960    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5961    /// sufficient, a read-write scope will do as well.
5962    pub fn add_scope<St>(
5963        mut self,
5964        scope: St,
5965    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
5966    where
5967        St: AsRef<str>,
5968    {
5969        self._scopes.insert(String::from(scope.as_ref()));
5970        self
5971    }
5972    /// Identifies the authorization scope(s) for the method you are building.
5973    ///
5974    /// See [`Self::add_scope()`] for details.
5975    pub fn add_scopes<I, St>(
5976        mut self,
5977        scopes: I,
5978    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
5979    where
5980        I: IntoIterator<Item = St>,
5981        St: AsRef<str>,
5982    {
5983        self._scopes
5984            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5985        self
5986    }
5987
5988    /// Removes all scopes, and no default scope will be used either.
5989    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5990    /// for details).
5991    pub fn clear_scopes(
5992        mut self,
5993    ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
5994        self._scopes.clear();
5995        self
5996    }
5997}
5998
5999/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
6000///
6001/// A builder for the *locations.recommenders.getConfig* method supported by a *billingAccount* resource.
6002/// It is not used directly, but through a [`BillingAccountMethods`] instance.
6003///
6004/// # Example
6005///
6006/// Instantiate a resource method builder
6007///
6008/// ```test_harness,no_run
6009/// # extern crate hyper;
6010/// # extern crate hyper_rustls;
6011/// # extern crate google_recommender1 as recommender1;
6012/// # async fn dox() {
6013/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6014///
6015/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6016/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6017/// #     .with_native_roots()
6018/// #     .unwrap()
6019/// #     .https_only()
6020/// #     .enable_http2()
6021/// #     .build();
6022///
6023/// # let executor = hyper_util::rt::TokioExecutor::new();
6024/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6025/// #     secret,
6026/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6027/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6028/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6029/// #     ),
6030/// # ).build().await.unwrap();
6031///
6032/// # let client = hyper_util::client::legacy::Client::builder(
6033/// #     hyper_util::rt::TokioExecutor::new()
6034/// # )
6035/// # .build(
6036/// #     hyper_rustls::HttpsConnectorBuilder::new()
6037/// #         .with_native_roots()
6038/// #         .unwrap()
6039/// #         .https_or_http()
6040/// #         .enable_http2()
6041/// #         .build()
6042/// # );
6043/// # let mut hub = Recommender::new(client, auth);
6044/// // You can configure optional parameters by calling the respective setters at will, and
6045/// // execute the final call using `doit()`.
6046/// // Values shown here are possibly random and not representative !
6047/// let result = hub.billing_accounts().locations_recommenders_get_config("name")
6048///              .doit().await;
6049/// # }
6050/// ```
6051pub struct BillingAccountLocationRecommenderGetConfigCall<'a, C>
6052where
6053    C: 'a,
6054{
6055    hub: &'a Recommender<C>,
6056    _name: String,
6057    _delegate: Option<&'a mut dyn common::Delegate>,
6058    _additional_params: HashMap<String, String>,
6059    _scopes: BTreeSet<String>,
6060}
6061
6062impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderGetConfigCall<'a, C> {}
6063
6064impl<'a, C> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6065where
6066    C: common::Connector,
6067{
6068    /// Perform the operation you have build so far.
6069    pub async fn doit(
6070        mut self,
6071    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1RecommenderConfig)> {
6072        use std::borrow::Cow;
6073        use std::io::{Read, Seek};
6074
6075        use common::{url::Params, ToParts};
6076        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6077
6078        let mut dd = common::DefaultDelegate;
6079        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6080        dlg.begin(common::MethodInfo {
6081            id: "recommender.billingAccounts.locations.recommenders.getConfig",
6082            http_method: hyper::Method::GET,
6083        });
6084
6085        for &field in ["alt", "name"].iter() {
6086            if self._additional_params.contains_key(field) {
6087                dlg.finished(false);
6088                return Err(common::Error::FieldClash(field));
6089            }
6090        }
6091
6092        let mut params = Params::with_capacity(3 + self._additional_params.len());
6093        params.push("name", self._name);
6094
6095        params.extend(self._additional_params.iter());
6096
6097        params.push("alt", "json");
6098        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6099        if self._scopes.is_empty() {
6100            self._scopes
6101                .insert(Scope::CloudPlatform.as_ref().to_string());
6102        }
6103
6104        #[allow(clippy::single_element_loop)]
6105        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6106            url = params.uri_replacement(url, param_name, find_this, true);
6107        }
6108        {
6109            let to_remove = ["name"];
6110            params.remove_params(&to_remove);
6111        }
6112
6113        let url = params.parse_with_url(&url);
6114
6115        loop {
6116            let token = match self
6117                .hub
6118                .auth
6119                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6120                .await
6121            {
6122                Ok(token) => token,
6123                Err(e) => match dlg.token(e) {
6124                    Ok(token) => token,
6125                    Err(e) => {
6126                        dlg.finished(false);
6127                        return Err(common::Error::MissingToken(e));
6128                    }
6129                },
6130            };
6131            let mut req_result = {
6132                let client = &self.hub.client;
6133                dlg.pre_request();
6134                let mut req_builder = hyper::Request::builder()
6135                    .method(hyper::Method::GET)
6136                    .uri(url.as_str())
6137                    .header(USER_AGENT, self.hub._user_agent.clone());
6138
6139                if let Some(token) = token.as_ref() {
6140                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6141                }
6142
6143                let request = req_builder
6144                    .header(CONTENT_LENGTH, 0_u64)
6145                    .body(common::to_body::<String>(None));
6146
6147                client.request(request.unwrap()).await
6148            };
6149
6150            match req_result {
6151                Err(err) => {
6152                    if let common::Retry::After(d) = dlg.http_error(&err) {
6153                        sleep(d).await;
6154                        continue;
6155                    }
6156                    dlg.finished(false);
6157                    return Err(common::Error::HttpError(err));
6158                }
6159                Ok(res) => {
6160                    let (mut parts, body) = res.into_parts();
6161                    let mut body = common::Body::new(body);
6162                    if !parts.status.is_success() {
6163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6164                        let error = serde_json::from_str(&common::to_string(&bytes));
6165                        let response = common::to_response(parts, bytes.into());
6166
6167                        if let common::Retry::After(d) =
6168                            dlg.http_failure(&response, error.as_ref().ok())
6169                        {
6170                            sleep(d).await;
6171                            continue;
6172                        }
6173
6174                        dlg.finished(false);
6175
6176                        return Err(match error {
6177                            Ok(value) => common::Error::BadRequest(value),
6178                            _ => common::Error::Failure(response),
6179                        });
6180                    }
6181                    let response = {
6182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6183                        let encoded = common::to_string(&bytes);
6184                        match serde_json::from_str(&encoded) {
6185                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6186                            Err(error) => {
6187                                dlg.response_json_decode_error(&encoded, &error);
6188                                return Err(common::Error::JsonDecodeError(
6189                                    encoded.to_string(),
6190                                    error,
6191                                ));
6192                            }
6193                        }
6194                    };
6195
6196                    dlg.finished(true);
6197                    return Ok(response);
6198                }
6199            }
6200        }
6201    }
6202
6203    /// Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
6204    ///
6205    /// Sets the *name* path property to the given value.
6206    ///
6207    /// Even though the property as already been set when instantiating this call,
6208    /// we provide this method for API completeness.
6209    pub fn name(
6210        mut self,
6211        new_value: &str,
6212    ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
6213        self._name = new_value.to_string();
6214        self
6215    }
6216    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6217    /// while executing the actual API request.
6218    ///
6219    /// ````text
6220    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6221    /// ````
6222    ///
6223    /// Sets the *delegate* property to the given value.
6224    pub fn delegate(
6225        mut self,
6226        new_value: &'a mut dyn common::Delegate,
6227    ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
6228        self._delegate = Some(new_value);
6229        self
6230    }
6231
6232    /// Set any additional parameter of the query string used in the request.
6233    /// It should be used to set parameters which are not yet available through their own
6234    /// setters.
6235    ///
6236    /// Please note that this method must not be used to set any of the known parameters
6237    /// which have their own setter method. If done anyway, the request will fail.
6238    ///
6239    /// # Additional Parameters
6240    ///
6241    /// * *$.xgafv* (query-string) - V1 error format.
6242    /// * *access_token* (query-string) - OAuth access token.
6243    /// * *alt* (query-string) - Data format for response.
6244    /// * *callback* (query-string) - JSONP
6245    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6246    /// * *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.
6247    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6248    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6249    /// * *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.
6250    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6251    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6252    pub fn param<T>(
6253        mut self,
6254        name: T,
6255        value: T,
6256    ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6257    where
6258        T: AsRef<str>,
6259    {
6260        self._additional_params
6261            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6262        self
6263    }
6264
6265    /// Identifies the authorization scope for the method you are building.
6266    ///
6267    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6268    /// [`Scope::CloudPlatform`].
6269    ///
6270    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6271    /// tokens for more than one scope.
6272    ///
6273    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6274    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6275    /// sufficient, a read-write scope will do as well.
6276    pub fn add_scope<St>(
6277        mut self,
6278        scope: St,
6279    ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6280    where
6281        St: AsRef<str>,
6282    {
6283        self._scopes.insert(String::from(scope.as_ref()));
6284        self
6285    }
6286    /// Identifies the authorization scope(s) for the method you are building.
6287    ///
6288    /// See [`Self::add_scope()`] for details.
6289    pub fn add_scopes<I, St>(
6290        mut self,
6291        scopes: I,
6292    ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6293    where
6294        I: IntoIterator<Item = St>,
6295        St: AsRef<str>,
6296    {
6297        self._scopes
6298            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6299        self
6300    }
6301
6302    /// Removes all scopes, and no default scope will be used either.
6303    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6304    /// for details).
6305    pub fn clear_scopes(mut self) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
6306        self._scopes.clear();
6307        self
6308    }
6309}
6310
6311/// Updates a Recommender Config. This will create a new revision of the config.
6312///
6313/// A builder for the *locations.recommenders.updateConfig* method supported by a *billingAccount* resource.
6314/// It is not used directly, but through a [`BillingAccountMethods`] instance.
6315///
6316/// # Example
6317///
6318/// Instantiate a resource method builder
6319///
6320/// ```test_harness,no_run
6321/// # extern crate hyper;
6322/// # extern crate hyper_rustls;
6323/// # extern crate google_recommender1 as recommender1;
6324/// use recommender1::api::GoogleCloudRecommenderV1RecommenderConfig;
6325/// # async fn dox() {
6326/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6327///
6328/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6329/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6330/// #     .with_native_roots()
6331/// #     .unwrap()
6332/// #     .https_only()
6333/// #     .enable_http2()
6334/// #     .build();
6335///
6336/// # let executor = hyper_util::rt::TokioExecutor::new();
6337/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6338/// #     secret,
6339/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6340/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6341/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6342/// #     ),
6343/// # ).build().await.unwrap();
6344///
6345/// # let client = hyper_util::client::legacy::Client::builder(
6346/// #     hyper_util::rt::TokioExecutor::new()
6347/// # )
6348/// # .build(
6349/// #     hyper_rustls::HttpsConnectorBuilder::new()
6350/// #         .with_native_roots()
6351/// #         .unwrap()
6352/// #         .https_or_http()
6353/// #         .enable_http2()
6354/// #         .build()
6355/// # );
6356/// # let mut hub = Recommender::new(client, auth);
6357/// // As the method needs a request, you would usually fill it with the desired information
6358/// // into the respective structure. Some of the parts shown here might not be applicable !
6359/// // Values shown here are possibly random and not representative !
6360/// let mut req = GoogleCloudRecommenderV1RecommenderConfig::default();
6361///
6362/// // You can configure optional parameters by calling the respective setters at will, and
6363/// // execute the final call using `doit()`.
6364/// // Values shown here are possibly random and not representative !
6365/// let result = hub.billing_accounts().locations_recommenders_update_config(req, "name")
6366///              .validate_only(false)
6367///              .update_mask(FieldMask::new::<&str>(&[]))
6368///              .doit().await;
6369/// # }
6370/// ```
6371pub struct BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
6372where
6373    C: 'a,
6374{
6375    hub: &'a Recommender<C>,
6376    _request: GoogleCloudRecommenderV1RecommenderConfig,
6377    _name: String,
6378    _validate_only: Option<bool>,
6379    _update_mask: Option<common::FieldMask>,
6380    _delegate: Option<&'a mut dyn common::Delegate>,
6381    _additional_params: HashMap<String, String>,
6382    _scopes: BTreeSet<String>,
6383}
6384
6385impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {}
6386
6387impl<'a, C> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
6388where
6389    C: common::Connector,
6390{
6391    /// Perform the operation you have build so far.
6392    pub async fn doit(
6393        mut self,
6394    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1RecommenderConfig)> {
6395        use std::borrow::Cow;
6396        use std::io::{Read, Seek};
6397
6398        use common::{url::Params, ToParts};
6399        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6400
6401        let mut dd = common::DefaultDelegate;
6402        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6403        dlg.begin(common::MethodInfo {
6404            id: "recommender.billingAccounts.locations.recommenders.updateConfig",
6405            http_method: hyper::Method::PATCH,
6406        });
6407
6408        for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
6409            if self._additional_params.contains_key(field) {
6410                dlg.finished(false);
6411                return Err(common::Error::FieldClash(field));
6412            }
6413        }
6414
6415        let mut params = Params::with_capacity(6 + self._additional_params.len());
6416        params.push("name", self._name);
6417        if let Some(value) = self._validate_only.as_ref() {
6418            params.push("validateOnly", value.to_string());
6419        }
6420        if let Some(value) = self._update_mask.as_ref() {
6421            params.push("updateMask", value.to_string());
6422        }
6423
6424        params.extend(self._additional_params.iter());
6425
6426        params.push("alt", "json");
6427        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6428        if self._scopes.is_empty() {
6429            self._scopes
6430                .insert(Scope::CloudPlatform.as_ref().to_string());
6431        }
6432
6433        #[allow(clippy::single_element_loop)]
6434        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6435            url = params.uri_replacement(url, param_name, find_this, true);
6436        }
6437        {
6438            let to_remove = ["name"];
6439            params.remove_params(&to_remove);
6440        }
6441
6442        let url = params.parse_with_url(&url);
6443
6444        let mut json_mime_type = mime::APPLICATION_JSON;
6445        let mut request_value_reader = {
6446            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6447            common::remove_json_null_values(&mut value);
6448            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6449            serde_json::to_writer(&mut dst, &value).unwrap();
6450            dst
6451        };
6452        let request_size = request_value_reader
6453            .seek(std::io::SeekFrom::End(0))
6454            .unwrap();
6455        request_value_reader
6456            .seek(std::io::SeekFrom::Start(0))
6457            .unwrap();
6458
6459        loop {
6460            let token = match self
6461                .hub
6462                .auth
6463                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6464                .await
6465            {
6466                Ok(token) => token,
6467                Err(e) => match dlg.token(e) {
6468                    Ok(token) => token,
6469                    Err(e) => {
6470                        dlg.finished(false);
6471                        return Err(common::Error::MissingToken(e));
6472                    }
6473                },
6474            };
6475            request_value_reader
6476                .seek(std::io::SeekFrom::Start(0))
6477                .unwrap();
6478            let mut req_result = {
6479                let client = &self.hub.client;
6480                dlg.pre_request();
6481                let mut req_builder = hyper::Request::builder()
6482                    .method(hyper::Method::PATCH)
6483                    .uri(url.as_str())
6484                    .header(USER_AGENT, self.hub._user_agent.clone());
6485
6486                if let Some(token) = token.as_ref() {
6487                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6488                }
6489
6490                let request = req_builder
6491                    .header(CONTENT_TYPE, json_mime_type.to_string())
6492                    .header(CONTENT_LENGTH, request_size as u64)
6493                    .body(common::to_body(
6494                        request_value_reader.get_ref().clone().into(),
6495                    ));
6496
6497                client.request(request.unwrap()).await
6498            };
6499
6500            match req_result {
6501                Err(err) => {
6502                    if let common::Retry::After(d) = dlg.http_error(&err) {
6503                        sleep(d).await;
6504                        continue;
6505                    }
6506                    dlg.finished(false);
6507                    return Err(common::Error::HttpError(err));
6508                }
6509                Ok(res) => {
6510                    let (mut parts, body) = res.into_parts();
6511                    let mut body = common::Body::new(body);
6512                    if !parts.status.is_success() {
6513                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6514                        let error = serde_json::from_str(&common::to_string(&bytes));
6515                        let response = common::to_response(parts, bytes.into());
6516
6517                        if let common::Retry::After(d) =
6518                            dlg.http_failure(&response, error.as_ref().ok())
6519                        {
6520                            sleep(d).await;
6521                            continue;
6522                        }
6523
6524                        dlg.finished(false);
6525
6526                        return Err(match error {
6527                            Ok(value) => common::Error::BadRequest(value),
6528                            _ => common::Error::Failure(response),
6529                        });
6530                    }
6531                    let response = {
6532                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6533                        let encoded = common::to_string(&bytes);
6534                        match serde_json::from_str(&encoded) {
6535                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6536                            Err(error) => {
6537                                dlg.response_json_decode_error(&encoded, &error);
6538                                return Err(common::Error::JsonDecodeError(
6539                                    encoded.to_string(),
6540                                    error,
6541                                ));
6542                            }
6543                        }
6544                    };
6545
6546                    dlg.finished(true);
6547                    return Ok(response);
6548                }
6549            }
6550        }
6551    }
6552
6553    ///
6554    /// Sets the *request* property to the given value.
6555    ///
6556    /// Even though the property as already been set when instantiating this call,
6557    /// we provide this method for API completeness.
6558    pub fn request(
6559        mut self,
6560        new_value: GoogleCloudRecommenderV1RecommenderConfig,
6561    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6562        self._request = new_value;
6563        self
6564    }
6565    /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
6566    ///
6567    /// Sets the *name* path property to the given value.
6568    ///
6569    /// Even though the property as already been set when instantiating this call,
6570    /// we provide this method for API completeness.
6571    pub fn name(
6572        mut self,
6573        new_value: &str,
6574    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6575        self._name = new_value.to_string();
6576        self
6577    }
6578    /// If true, validate the request and preview the change, but do not actually update it.
6579    ///
6580    /// Sets the *validate only* query property to the given value.
6581    pub fn validate_only(
6582        mut self,
6583        new_value: bool,
6584    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6585        self._validate_only = Some(new_value);
6586        self
6587    }
6588    /// The list of fields to be updated.
6589    ///
6590    /// Sets the *update mask* query property to the given value.
6591    pub fn update_mask(
6592        mut self,
6593        new_value: common::FieldMask,
6594    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6595        self._update_mask = Some(new_value);
6596        self
6597    }
6598    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6599    /// while executing the actual API request.
6600    ///
6601    /// ````text
6602    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6603    /// ````
6604    ///
6605    /// Sets the *delegate* property to the given value.
6606    pub fn delegate(
6607        mut self,
6608        new_value: &'a mut dyn common::Delegate,
6609    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6610        self._delegate = Some(new_value);
6611        self
6612    }
6613
6614    /// Set any additional parameter of the query string used in the request.
6615    /// It should be used to set parameters which are not yet available through their own
6616    /// setters.
6617    ///
6618    /// Please note that this method must not be used to set any of the known parameters
6619    /// which have their own setter method. If done anyway, the request will fail.
6620    ///
6621    /// # Additional Parameters
6622    ///
6623    /// * *$.xgafv* (query-string) - V1 error format.
6624    /// * *access_token* (query-string) - OAuth access token.
6625    /// * *alt* (query-string) - Data format for response.
6626    /// * *callback* (query-string) - JSONP
6627    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6628    /// * *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.
6629    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6630    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6631    /// * *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.
6632    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6633    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6634    pub fn param<T>(
6635        mut self,
6636        name: T,
6637        value: T,
6638    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
6639    where
6640        T: AsRef<str>,
6641    {
6642        self._additional_params
6643            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6644        self
6645    }
6646
6647    /// Identifies the authorization scope for the method you are building.
6648    ///
6649    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6650    /// [`Scope::CloudPlatform`].
6651    ///
6652    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6653    /// tokens for more than one scope.
6654    ///
6655    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6656    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6657    /// sufficient, a read-write scope will do as well.
6658    pub fn add_scope<St>(
6659        mut self,
6660        scope: St,
6661    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
6662    where
6663        St: AsRef<str>,
6664    {
6665        self._scopes.insert(String::from(scope.as_ref()));
6666        self
6667    }
6668    /// Identifies the authorization scope(s) for the method you are building.
6669    ///
6670    /// See [`Self::add_scope()`] for details.
6671    pub fn add_scopes<I, St>(
6672        mut self,
6673        scopes: I,
6674    ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
6675    where
6676        I: IntoIterator<Item = St>,
6677        St: AsRef<str>,
6678    {
6679        self._scopes
6680            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6681        self
6682    }
6683
6684    /// Removes all scopes, and no default scope will be used either.
6685    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6686    /// for details).
6687    pub fn clear_scopes(mut self) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6688        self._scopes.clear();
6689        self
6690    }
6691}
6692
6693/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
6694///
6695/// A builder for the *locations.insightTypes.insights.get* method supported by a *folder* resource.
6696/// It is not used directly, but through a [`FolderMethods`] instance.
6697///
6698/// # Example
6699///
6700/// Instantiate a resource method builder
6701///
6702/// ```test_harness,no_run
6703/// # extern crate hyper;
6704/// # extern crate hyper_rustls;
6705/// # extern crate google_recommender1 as recommender1;
6706/// # async fn dox() {
6707/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6708///
6709/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6710/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6711/// #     .with_native_roots()
6712/// #     .unwrap()
6713/// #     .https_only()
6714/// #     .enable_http2()
6715/// #     .build();
6716///
6717/// # let executor = hyper_util::rt::TokioExecutor::new();
6718/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6719/// #     secret,
6720/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6721/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6722/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6723/// #     ),
6724/// # ).build().await.unwrap();
6725///
6726/// # let client = hyper_util::client::legacy::Client::builder(
6727/// #     hyper_util::rt::TokioExecutor::new()
6728/// # )
6729/// # .build(
6730/// #     hyper_rustls::HttpsConnectorBuilder::new()
6731/// #         .with_native_roots()
6732/// #         .unwrap()
6733/// #         .https_or_http()
6734/// #         .enable_http2()
6735/// #         .build()
6736/// # );
6737/// # let mut hub = Recommender::new(client, auth);
6738/// // You can configure optional parameters by calling the respective setters at will, and
6739/// // execute the final call using `doit()`.
6740/// // Values shown here are possibly random and not representative !
6741/// let result = hub.folders().locations_insight_types_insights_get("name")
6742///              .doit().await;
6743/// # }
6744/// ```
6745pub struct FolderLocationInsightTypeInsightGetCall<'a, C>
6746where
6747    C: 'a,
6748{
6749    hub: &'a Recommender<C>,
6750    _name: String,
6751    _delegate: Option<&'a mut dyn common::Delegate>,
6752    _additional_params: HashMap<String, String>,
6753    _scopes: BTreeSet<String>,
6754}
6755
6756impl<'a, C> common::CallBuilder for FolderLocationInsightTypeInsightGetCall<'a, C> {}
6757
6758impl<'a, C> FolderLocationInsightTypeInsightGetCall<'a, C>
6759where
6760    C: common::Connector,
6761{
6762    /// Perform the operation you have build so far.
6763    pub async fn doit(
6764        mut self,
6765    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
6766        use std::borrow::Cow;
6767        use std::io::{Read, Seek};
6768
6769        use common::{url::Params, ToParts};
6770        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6771
6772        let mut dd = common::DefaultDelegate;
6773        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6774        dlg.begin(common::MethodInfo {
6775            id: "recommender.folders.locations.insightTypes.insights.get",
6776            http_method: hyper::Method::GET,
6777        });
6778
6779        for &field in ["alt", "name"].iter() {
6780            if self._additional_params.contains_key(field) {
6781                dlg.finished(false);
6782                return Err(common::Error::FieldClash(field));
6783            }
6784        }
6785
6786        let mut params = Params::with_capacity(3 + self._additional_params.len());
6787        params.push("name", self._name);
6788
6789        params.extend(self._additional_params.iter());
6790
6791        params.push("alt", "json");
6792        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6793        if self._scopes.is_empty() {
6794            self._scopes
6795                .insert(Scope::CloudPlatform.as_ref().to_string());
6796        }
6797
6798        #[allow(clippy::single_element_loop)]
6799        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6800            url = params.uri_replacement(url, param_name, find_this, true);
6801        }
6802        {
6803            let to_remove = ["name"];
6804            params.remove_params(&to_remove);
6805        }
6806
6807        let url = params.parse_with_url(&url);
6808
6809        loop {
6810            let token = match self
6811                .hub
6812                .auth
6813                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6814                .await
6815            {
6816                Ok(token) => token,
6817                Err(e) => match dlg.token(e) {
6818                    Ok(token) => token,
6819                    Err(e) => {
6820                        dlg.finished(false);
6821                        return Err(common::Error::MissingToken(e));
6822                    }
6823                },
6824            };
6825            let mut req_result = {
6826                let client = &self.hub.client;
6827                dlg.pre_request();
6828                let mut req_builder = hyper::Request::builder()
6829                    .method(hyper::Method::GET)
6830                    .uri(url.as_str())
6831                    .header(USER_AGENT, self.hub._user_agent.clone());
6832
6833                if let Some(token) = token.as_ref() {
6834                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6835                }
6836
6837                let request = req_builder
6838                    .header(CONTENT_LENGTH, 0_u64)
6839                    .body(common::to_body::<String>(None));
6840
6841                client.request(request.unwrap()).await
6842            };
6843
6844            match req_result {
6845                Err(err) => {
6846                    if let common::Retry::After(d) = dlg.http_error(&err) {
6847                        sleep(d).await;
6848                        continue;
6849                    }
6850                    dlg.finished(false);
6851                    return Err(common::Error::HttpError(err));
6852                }
6853                Ok(res) => {
6854                    let (mut parts, body) = res.into_parts();
6855                    let mut body = common::Body::new(body);
6856                    if !parts.status.is_success() {
6857                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6858                        let error = serde_json::from_str(&common::to_string(&bytes));
6859                        let response = common::to_response(parts, bytes.into());
6860
6861                        if let common::Retry::After(d) =
6862                            dlg.http_failure(&response, error.as_ref().ok())
6863                        {
6864                            sleep(d).await;
6865                            continue;
6866                        }
6867
6868                        dlg.finished(false);
6869
6870                        return Err(match error {
6871                            Ok(value) => common::Error::BadRequest(value),
6872                            _ => common::Error::Failure(response),
6873                        });
6874                    }
6875                    let response = {
6876                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6877                        let encoded = common::to_string(&bytes);
6878                        match serde_json::from_str(&encoded) {
6879                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6880                            Err(error) => {
6881                                dlg.response_json_decode_error(&encoded, &error);
6882                                return Err(common::Error::JsonDecodeError(
6883                                    encoded.to_string(),
6884                                    error,
6885                                ));
6886                            }
6887                        }
6888                    };
6889
6890                    dlg.finished(true);
6891                    return Ok(response);
6892                }
6893            }
6894        }
6895    }
6896
6897    /// Required. Name of the insight.
6898    ///
6899    /// Sets the *name* path property to the given value.
6900    ///
6901    /// Even though the property as already been set when instantiating this call,
6902    /// we provide this method for API completeness.
6903    pub fn name(mut self, new_value: &str) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
6904        self._name = new_value.to_string();
6905        self
6906    }
6907    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6908    /// while executing the actual API request.
6909    ///
6910    /// ````text
6911    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6912    /// ````
6913    ///
6914    /// Sets the *delegate* property to the given value.
6915    pub fn delegate(
6916        mut self,
6917        new_value: &'a mut dyn common::Delegate,
6918    ) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
6919        self._delegate = Some(new_value);
6920        self
6921    }
6922
6923    /// Set any additional parameter of the query string used in the request.
6924    /// It should be used to set parameters which are not yet available through their own
6925    /// setters.
6926    ///
6927    /// Please note that this method must not be used to set any of the known parameters
6928    /// which have their own setter method. If done anyway, the request will fail.
6929    ///
6930    /// # Additional Parameters
6931    ///
6932    /// * *$.xgafv* (query-string) - V1 error format.
6933    /// * *access_token* (query-string) - OAuth access token.
6934    /// * *alt* (query-string) - Data format for response.
6935    /// * *callback* (query-string) - JSONP
6936    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6937    /// * *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.
6938    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6939    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6940    /// * *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.
6941    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6942    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6943    pub fn param<T>(mut self, name: T, value: T) -> FolderLocationInsightTypeInsightGetCall<'a, C>
6944    where
6945        T: AsRef<str>,
6946    {
6947        self._additional_params
6948            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6949        self
6950    }
6951
6952    /// Identifies the authorization scope for the method you are building.
6953    ///
6954    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6955    /// [`Scope::CloudPlatform`].
6956    ///
6957    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6958    /// tokens for more than one scope.
6959    ///
6960    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6961    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6962    /// sufficient, a read-write scope will do as well.
6963    pub fn add_scope<St>(mut self, scope: St) -> FolderLocationInsightTypeInsightGetCall<'a, C>
6964    where
6965        St: AsRef<str>,
6966    {
6967        self._scopes.insert(String::from(scope.as_ref()));
6968        self
6969    }
6970    /// Identifies the authorization scope(s) for the method you are building.
6971    ///
6972    /// See [`Self::add_scope()`] for details.
6973    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderLocationInsightTypeInsightGetCall<'a, C>
6974    where
6975        I: IntoIterator<Item = St>,
6976        St: AsRef<str>,
6977    {
6978        self._scopes
6979            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6980        self
6981    }
6982
6983    /// Removes all scopes, and no default scope will be used either.
6984    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6985    /// for details).
6986    pub fn clear_scopes(mut self) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
6987        self._scopes.clear();
6988        self
6989    }
6990}
6991
6992/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
6993///
6994/// A builder for the *locations.insightTypes.insights.list* method supported by a *folder* resource.
6995/// It is not used directly, but through a [`FolderMethods`] instance.
6996///
6997/// # Example
6998///
6999/// Instantiate a resource method builder
7000///
7001/// ```test_harness,no_run
7002/// # extern crate hyper;
7003/// # extern crate hyper_rustls;
7004/// # extern crate google_recommender1 as recommender1;
7005/// # async fn dox() {
7006/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7007///
7008/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7009/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7010/// #     .with_native_roots()
7011/// #     .unwrap()
7012/// #     .https_only()
7013/// #     .enable_http2()
7014/// #     .build();
7015///
7016/// # let executor = hyper_util::rt::TokioExecutor::new();
7017/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7018/// #     secret,
7019/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7020/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7021/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7022/// #     ),
7023/// # ).build().await.unwrap();
7024///
7025/// # let client = hyper_util::client::legacy::Client::builder(
7026/// #     hyper_util::rt::TokioExecutor::new()
7027/// # )
7028/// # .build(
7029/// #     hyper_rustls::HttpsConnectorBuilder::new()
7030/// #         .with_native_roots()
7031/// #         .unwrap()
7032/// #         .https_or_http()
7033/// #         .enable_http2()
7034/// #         .build()
7035/// # );
7036/// # let mut hub = Recommender::new(client, auth);
7037/// // You can configure optional parameters by calling the respective setters at will, and
7038/// // execute the final call using `doit()`.
7039/// // Values shown here are possibly random and not representative !
7040/// let result = hub.folders().locations_insight_types_insights_list("parent")
7041///              .page_token("rebum.")
7042///              .page_size(-57)
7043///              .filter("ipsum")
7044///              .doit().await;
7045/// # }
7046/// ```
7047pub struct FolderLocationInsightTypeInsightListCall<'a, C>
7048where
7049    C: 'a,
7050{
7051    hub: &'a Recommender<C>,
7052    _parent: String,
7053    _page_token: Option<String>,
7054    _page_size: Option<i32>,
7055    _filter: Option<String>,
7056    _delegate: Option<&'a mut dyn common::Delegate>,
7057    _additional_params: HashMap<String, String>,
7058    _scopes: BTreeSet<String>,
7059}
7060
7061impl<'a, C> common::CallBuilder for FolderLocationInsightTypeInsightListCall<'a, C> {}
7062
7063impl<'a, C> FolderLocationInsightTypeInsightListCall<'a, C>
7064where
7065    C: common::Connector,
7066{
7067    /// Perform the operation you have build so far.
7068    pub async fn doit(
7069        mut self,
7070    ) -> common::Result<(
7071        common::Response,
7072        GoogleCloudRecommenderV1ListInsightsResponse,
7073    )> {
7074        use std::borrow::Cow;
7075        use std::io::{Read, Seek};
7076
7077        use common::{url::Params, ToParts};
7078        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7079
7080        let mut dd = common::DefaultDelegate;
7081        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7082        dlg.begin(common::MethodInfo {
7083            id: "recommender.folders.locations.insightTypes.insights.list",
7084            http_method: hyper::Method::GET,
7085        });
7086
7087        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
7088            if self._additional_params.contains_key(field) {
7089                dlg.finished(false);
7090                return Err(common::Error::FieldClash(field));
7091            }
7092        }
7093
7094        let mut params = Params::with_capacity(6 + self._additional_params.len());
7095        params.push("parent", self._parent);
7096        if let Some(value) = self._page_token.as_ref() {
7097            params.push("pageToken", value);
7098        }
7099        if let Some(value) = self._page_size.as_ref() {
7100            params.push("pageSize", value.to_string());
7101        }
7102        if let Some(value) = self._filter.as_ref() {
7103            params.push("filter", value);
7104        }
7105
7106        params.extend(self._additional_params.iter());
7107
7108        params.push("alt", "json");
7109        let mut url = self.hub._base_url.clone() + "v1/{+parent}/insights";
7110        if self._scopes.is_empty() {
7111            self._scopes
7112                .insert(Scope::CloudPlatform.as_ref().to_string());
7113        }
7114
7115        #[allow(clippy::single_element_loop)]
7116        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7117            url = params.uri_replacement(url, param_name, find_this, true);
7118        }
7119        {
7120            let to_remove = ["parent"];
7121            params.remove_params(&to_remove);
7122        }
7123
7124        let url = params.parse_with_url(&url);
7125
7126        loop {
7127            let token = match self
7128                .hub
7129                .auth
7130                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7131                .await
7132            {
7133                Ok(token) => token,
7134                Err(e) => match dlg.token(e) {
7135                    Ok(token) => token,
7136                    Err(e) => {
7137                        dlg.finished(false);
7138                        return Err(common::Error::MissingToken(e));
7139                    }
7140                },
7141            };
7142            let mut req_result = {
7143                let client = &self.hub.client;
7144                dlg.pre_request();
7145                let mut req_builder = hyper::Request::builder()
7146                    .method(hyper::Method::GET)
7147                    .uri(url.as_str())
7148                    .header(USER_AGENT, self.hub._user_agent.clone());
7149
7150                if let Some(token) = token.as_ref() {
7151                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7152                }
7153
7154                let request = req_builder
7155                    .header(CONTENT_LENGTH, 0_u64)
7156                    .body(common::to_body::<String>(None));
7157
7158                client.request(request.unwrap()).await
7159            };
7160
7161            match req_result {
7162                Err(err) => {
7163                    if let common::Retry::After(d) = dlg.http_error(&err) {
7164                        sleep(d).await;
7165                        continue;
7166                    }
7167                    dlg.finished(false);
7168                    return Err(common::Error::HttpError(err));
7169                }
7170                Ok(res) => {
7171                    let (mut parts, body) = res.into_parts();
7172                    let mut body = common::Body::new(body);
7173                    if !parts.status.is_success() {
7174                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7175                        let error = serde_json::from_str(&common::to_string(&bytes));
7176                        let response = common::to_response(parts, bytes.into());
7177
7178                        if let common::Retry::After(d) =
7179                            dlg.http_failure(&response, error.as_ref().ok())
7180                        {
7181                            sleep(d).await;
7182                            continue;
7183                        }
7184
7185                        dlg.finished(false);
7186
7187                        return Err(match error {
7188                            Ok(value) => common::Error::BadRequest(value),
7189                            _ => common::Error::Failure(response),
7190                        });
7191                    }
7192                    let response = {
7193                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7194                        let encoded = common::to_string(&bytes);
7195                        match serde_json::from_str(&encoded) {
7196                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7197                            Err(error) => {
7198                                dlg.response_json_decode_error(&encoded, &error);
7199                                return Err(common::Error::JsonDecodeError(
7200                                    encoded.to_string(),
7201                                    error,
7202                                ));
7203                            }
7204                        }
7205                    };
7206
7207                    dlg.finished(true);
7208                    return Ok(response);
7209                }
7210            }
7211        }
7212    }
7213
7214    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
7215    ///
7216    /// Sets the *parent* path property to the given value.
7217    ///
7218    /// Even though the property as already been set when instantiating this call,
7219    /// we provide this method for API completeness.
7220    pub fn parent(mut self, new_value: &str) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7221        self._parent = new_value.to_string();
7222        self
7223    }
7224    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
7225    ///
7226    /// Sets the *page token* query property to the given value.
7227    pub fn page_token(
7228        mut self,
7229        new_value: &str,
7230    ) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7231        self._page_token = Some(new_value.to_string());
7232        self
7233    }
7234    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
7235    ///
7236    /// Sets the *page size* query property to the given value.
7237    pub fn page_size(mut self, new_value: i32) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7238        self._page_size = Some(new_value);
7239        self
7240    }
7241    /// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
7242    ///
7243    /// Sets the *filter* query property to the given value.
7244    pub fn filter(mut self, new_value: &str) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7245        self._filter = Some(new_value.to_string());
7246        self
7247    }
7248    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7249    /// while executing the actual API request.
7250    ///
7251    /// ````text
7252    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7253    /// ````
7254    ///
7255    /// Sets the *delegate* property to the given value.
7256    pub fn delegate(
7257        mut self,
7258        new_value: &'a mut dyn common::Delegate,
7259    ) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7260        self._delegate = Some(new_value);
7261        self
7262    }
7263
7264    /// Set any additional parameter of the query string used in the request.
7265    /// It should be used to set parameters which are not yet available through their own
7266    /// setters.
7267    ///
7268    /// Please note that this method must not be used to set any of the known parameters
7269    /// which have their own setter method. If done anyway, the request will fail.
7270    ///
7271    /// # Additional Parameters
7272    ///
7273    /// * *$.xgafv* (query-string) - V1 error format.
7274    /// * *access_token* (query-string) - OAuth access token.
7275    /// * *alt* (query-string) - Data format for response.
7276    /// * *callback* (query-string) - JSONP
7277    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7278    /// * *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.
7279    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7280    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7281    /// * *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.
7282    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7283    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7284    pub fn param<T>(mut self, name: T, value: T) -> FolderLocationInsightTypeInsightListCall<'a, C>
7285    where
7286        T: AsRef<str>,
7287    {
7288        self._additional_params
7289            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7290        self
7291    }
7292
7293    /// Identifies the authorization scope for the method you are building.
7294    ///
7295    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7296    /// [`Scope::CloudPlatform`].
7297    ///
7298    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7299    /// tokens for more than one scope.
7300    ///
7301    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7302    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7303    /// sufficient, a read-write scope will do as well.
7304    pub fn add_scope<St>(mut self, scope: St) -> FolderLocationInsightTypeInsightListCall<'a, C>
7305    where
7306        St: AsRef<str>,
7307    {
7308        self._scopes.insert(String::from(scope.as_ref()));
7309        self
7310    }
7311    /// Identifies the authorization scope(s) for the method you are building.
7312    ///
7313    /// See [`Self::add_scope()`] for details.
7314    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderLocationInsightTypeInsightListCall<'a, C>
7315    where
7316        I: IntoIterator<Item = St>,
7317        St: AsRef<str>,
7318    {
7319        self._scopes
7320            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7321        self
7322    }
7323
7324    /// Removes all scopes, and no default scope will be used either.
7325    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7326    /// for details).
7327    pub fn clear_scopes(mut self) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7328        self._scopes.clear();
7329        self
7330    }
7331}
7332
7333/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
7334///
7335/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *folder* resource.
7336/// It is not used directly, but through a [`FolderMethods`] instance.
7337///
7338/// # Example
7339///
7340/// Instantiate a resource method builder
7341///
7342/// ```test_harness,no_run
7343/// # extern crate hyper;
7344/// # extern crate hyper_rustls;
7345/// # extern crate google_recommender1 as recommender1;
7346/// use recommender1::api::GoogleCloudRecommenderV1MarkInsightAcceptedRequest;
7347/// # async fn dox() {
7348/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7349///
7350/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7351/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7352/// #     .with_native_roots()
7353/// #     .unwrap()
7354/// #     .https_only()
7355/// #     .enable_http2()
7356/// #     .build();
7357///
7358/// # let executor = hyper_util::rt::TokioExecutor::new();
7359/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7360/// #     secret,
7361/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7362/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7363/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7364/// #     ),
7365/// # ).build().await.unwrap();
7366///
7367/// # let client = hyper_util::client::legacy::Client::builder(
7368/// #     hyper_util::rt::TokioExecutor::new()
7369/// # )
7370/// # .build(
7371/// #     hyper_rustls::HttpsConnectorBuilder::new()
7372/// #         .with_native_roots()
7373/// #         .unwrap()
7374/// #         .https_or_http()
7375/// #         .enable_http2()
7376/// #         .build()
7377/// # );
7378/// # let mut hub = Recommender::new(client, auth);
7379/// // As the method needs a request, you would usually fill it with the desired information
7380/// // into the respective structure. Some of the parts shown here might not be applicable !
7381/// // Values shown here are possibly random and not representative !
7382/// let mut req = GoogleCloudRecommenderV1MarkInsightAcceptedRequest::default();
7383///
7384/// // You can configure optional parameters by calling the respective setters at will, and
7385/// // execute the final call using `doit()`.
7386/// // Values shown here are possibly random and not representative !
7387/// let result = hub.folders().locations_insight_types_insights_mark_accepted(req, "name")
7388///              .doit().await;
7389/// # }
7390/// ```
7391pub struct FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
7392where
7393    C: 'a,
7394{
7395    hub: &'a Recommender<C>,
7396    _request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
7397    _name: String,
7398    _delegate: Option<&'a mut dyn common::Delegate>,
7399    _additional_params: HashMap<String, String>,
7400    _scopes: BTreeSet<String>,
7401}
7402
7403impl<'a, C> common::CallBuilder for FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {}
7404
7405impl<'a, C> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
7406where
7407    C: common::Connector,
7408{
7409    /// Perform the operation you have build so far.
7410    pub async fn doit(
7411        mut self,
7412    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
7413        use std::borrow::Cow;
7414        use std::io::{Read, Seek};
7415
7416        use common::{url::Params, ToParts};
7417        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7418
7419        let mut dd = common::DefaultDelegate;
7420        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7421        dlg.begin(common::MethodInfo {
7422            id: "recommender.folders.locations.insightTypes.insights.markAccepted",
7423            http_method: hyper::Method::POST,
7424        });
7425
7426        for &field in ["alt", "name"].iter() {
7427            if self._additional_params.contains_key(field) {
7428                dlg.finished(false);
7429                return Err(common::Error::FieldClash(field));
7430            }
7431        }
7432
7433        let mut params = Params::with_capacity(4 + self._additional_params.len());
7434        params.push("name", self._name);
7435
7436        params.extend(self._additional_params.iter());
7437
7438        params.push("alt", "json");
7439        let mut url = self.hub._base_url.clone() + "v1/{+name}:markAccepted";
7440        if self._scopes.is_empty() {
7441            self._scopes
7442                .insert(Scope::CloudPlatform.as_ref().to_string());
7443        }
7444
7445        #[allow(clippy::single_element_loop)]
7446        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7447            url = params.uri_replacement(url, param_name, find_this, true);
7448        }
7449        {
7450            let to_remove = ["name"];
7451            params.remove_params(&to_remove);
7452        }
7453
7454        let url = params.parse_with_url(&url);
7455
7456        let mut json_mime_type = mime::APPLICATION_JSON;
7457        let mut request_value_reader = {
7458            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7459            common::remove_json_null_values(&mut value);
7460            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7461            serde_json::to_writer(&mut dst, &value).unwrap();
7462            dst
7463        };
7464        let request_size = request_value_reader
7465            .seek(std::io::SeekFrom::End(0))
7466            .unwrap();
7467        request_value_reader
7468            .seek(std::io::SeekFrom::Start(0))
7469            .unwrap();
7470
7471        loop {
7472            let token = match self
7473                .hub
7474                .auth
7475                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7476                .await
7477            {
7478                Ok(token) => token,
7479                Err(e) => match dlg.token(e) {
7480                    Ok(token) => token,
7481                    Err(e) => {
7482                        dlg.finished(false);
7483                        return Err(common::Error::MissingToken(e));
7484                    }
7485                },
7486            };
7487            request_value_reader
7488                .seek(std::io::SeekFrom::Start(0))
7489                .unwrap();
7490            let mut req_result = {
7491                let client = &self.hub.client;
7492                dlg.pre_request();
7493                let mut req_builder = hyper::Request::builder()
7494                    .method(hyper::Method::POST)
7495                    .uri(url.as_str())
7496                    .header(USER_AGENT, self.hub._user_agent.clone());
7497
7498                if let Some(token) = token.as_ref() {
7499                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7500                }
7501
7502                let request = req_builder
7503                    .header(CONTENT_TYPE, json_mime_type.to_string())
7504                    .header(CONTENT_LENGTH, request_size as u64)
7505                    .body(common::to_body(
7506                        request_value_reader.get_ref().clone().into(),
7507                    ));
7508
7509                client.request(request.unwrap()).await
7510            };
7511
7512            match req_result {
7513                Err(err) => {
7514                    if let common::Retry::After(d) = dlg.http_error(&err) {
7515                        sleep(d).await;
7516                        continue;
7517                    }
7518                    dlg.finished(false);
7519                    return Err(common::Error::HttpError(err));
7520                }
7521                Ok(res) => {
7522                    let (mut parts, body) = res.into_parts();
7523                    let mut body = common::Body::new(body);
7524                    if !parts.status.is_success() {
7525                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7526                        let error = serde_json::from_str(&common::to_string(&bytes));
7527                        let response = common::to_response(parts, bytes.into());
7528
7529                        if let common::Retry::After(d) =
7530                            dlg.http_failure(&response, error.as_ref().ok())
7531                        {
7532                            sleep(d).await;
7533                            continue;
7534                        }
7535
7536                        dlg.finished(false);
7537
7538                        return Err(match error {
7539                            Ok(value) => common::Error::BadRequest(value),
7540                            _ => common::Error::Failure(response),
7541                        });
7542                    }
7543                    let response = {
7544                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7545                        let encoded = common::to_string(&bytes);
7546                        match serde_json::from_str(&encoded) {
7547                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7548                            Err(error) => {
7549                                dlg.response_json_decode_error(&encoded, &error);
7550                                return Err(common::Error::JsonDecodeError(
7551                                    encoded.to_string(),
7552                                    error,
7553                                ));
7554                            }
7555                        }
7556                    };
7557
7558                    dlg.finished(true);
7559                    return Ok(response);
7560                }
7561            }
7562        }
7563    }
7564
7565    ///
7566    /// Sets the *request* property to the given value.
7567    ///
7568    /// Even though the property as already been set when instantiating this call,
7569    /// we provide this method for API completeness.
7570    pub fn request(
7571        mut self,
7572        new_value: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
7573    ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
7574        self._request = new_value;
7575        self
7576    }
7577    /// Required. Name of the insight.
7578    ///
7579    /// Sets the *name* path property to the given value.
7580    ///
7581    /// Even though the property as already been set when instantiating this call,
7582    /// we provide this method for API completeness.
7583    pub fn name(
7584        mut self,
7585        new_value: &str,
7586    ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
7587        self._name = new_value.to_string();
7588        self
7589    }
7590    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7591    /// while executing the actual API request.
7592    ///
7593    /// ````text
7594    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7595    /// ````
7596    ///
7597    /// Sets the *delegate* property to the given value.
7598    pub fn delegate(
7599        mut self,
7600        new_value: &'a mut dyn common::Delegate,
7601    ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
7602        self._delegate = Some(new_value);
7603        self
7604    }
7605
7606    /// Set any additional parameter of the query string used in the request.
7607    /// It should be used to set parameters which are not yet available through their own
7608    /// setters.
7609    ///
7610    /// Please note that this method must not be used to set any of the known parameters
7611    /// which have their own setter method. If done anyway, the request will fail.
7612    ///
7613    /// # Additional Parameters
7614    ///
7615    /// * *$.xgafv* (query-string) - V1 error format.
7616    /// * *access_token* (query-string) - OAuth access token.
7617    /// * *alt* (query-string) - Data format for response.
7618    /// * *callback* (query-string) - JSONP
7619    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7620    /// * *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.
7621    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7622    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7623    /// * *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.
7624    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7625    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7626    pub fn param<T>(
7627        mut self,
7628        name: T,
7629        value: T,
7630    ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
7631    where
7632        T: AsRef<str>,
7633    {
7634        self._additional_params
7635            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7636        self
7637    }
7638
7639    /// Identifies the authorization scope for the method you are building.
7640    ///
7641    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7642    /// [`Scope::CloudPlatform`].
7643    ///
7644    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7645    /// tokens for more than one scope.
7646    ///
7647    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7648    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7649    /// sufficient, a read-write scope will do as well.
7650    pub fn add_scope<St>(
7651        mut self,
7652        scope: St,
7653    ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
7654    where
7655        St: AsRef<str>,
7656    {
7657        self._scopes.insert(String::from(scope.as_ref()));
7658        self
7659    }
7660    /// Identifies the authorization scope(s) for the method you are building.
7661    ///
7662    /// See [`Self::add_scope()`] for details.
7663    pub fn add_scopes<I, St>(
7664        mut self,
7665        scopes: I,
7666    ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
7667    where
7668        I: IntoIterator<Item = St>,
7669        St: AsRef<str>,
7670    {
7671        self._scopes
7672            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7673        self
7674    }
7675
7676    /// Removes all scopes, and no default scope will be used either.
7677    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7678    /// for details).
7679    pub fn clear_scopes(mut self) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
7680        self._scopes.clear();
7681        self
7682    }
7683}
7684
7685/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
7686///
7687/// A builder for the *locations.recommenders.recommendations.get* method supported by a *folder* resource.
7688/// It is not used directly, but through a [`FolderMethods`] instance.
7689///
7690/// # Example
7691///
7692/// Instantiate a resource method builder
7693///
7694/// ```test_harness,no_run
7695/// # extern crate hyper;
7696/// # extern crate hyper_rustls;
7697/// # extern crate google_recommender1 as recommender1;
7698/// # async fn dox() {
7699/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7700///
7701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7702/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7703/// #     .with_native_roots()
7704/// #     .unwrap()
7705/// #     .https_only()
7706/// #     .enable_http2()
7707/// #     .build();
7708///
7709/// # let executor = hyper_util::rt::TokioExecutor::new();
7710/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7711/// #     secret,
7712/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7713/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7714/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7715/// #     ),
7716/// # ).build().await.unwrap();
7717///
7718/// # let client = hyper_util::client::legacy::Client::builder(
7719/// #     hyper_util::rt::TokioExecutor::new()
7720/// # )
7721/// # .build(
7722/// #     hyper_rustls::HttpsConnectorBuilder::new()
7723/// #         .with_native_roots()
7724/// #         .unwrap()
7725/// #         .https_or_http()
7726/// #         .enable_http2()
7727/// #         .build()
7728/// # );
7729/// # let mut hub = Recommender::new(client, auth);
7730/// // You can configure optional parameters by calling the respective setters at will, and
7731/// // execute the final call using `doit()`.
7732/// // Values shown here are possibly random and not representative !
7733/// let result = hub.folders().locations_recommenders_recommendations_get("name")
7734///              .doit().await;
7735/// # }
7736/// ```
7737pub struct FolderLocationRecommenderRecommendationGetCall<'a, C>
7738where
7739    C: 'a,
7740{
7741    hub: &'a Recommender<C>,
7742    _name: String,
7743    _delegate: Option<&'a mut dyn common::Delegate>,
7744    _additional_params: HashMap<String, String>,
7745    _scopes: BTreeSet<String>,
7746}
7747
7748impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationGetCall<'a, C> {}
7749
7750impl<'a, C> FolderLocationRecommenderRecommendationGetCall<'a, C>
7751where
7752    C: common::Connector,
7753{
7754    /// Perform the operation you have build so far.
7755    pub async fn doit(
7756        mut self,
7757    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
7758        use std::borrow::Cow;
7759        use std::io::{Read, Seek};
7760
7761        use common::{url::Params, ToParts};
7762        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7763
7764        let mut dd = common::DefaultDelegate;
7765        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7766        dlg.begin(common::MethodInfo {
7767            id: "recommender.folders.locations.recommenders.recommendations.get",
7768            http_method: hyper::Method::GET,
7769        });
7770
7771        for &field in ["alt", "name"].iter() {
7772            if self._additional_params.contains_key(field) {
7773                dlg.finished(false);
7774                return Err(common::Error::FieldClash(field));
7775            }
7776        }
7777
7778        let mut params = Params::with_capacity(3 + self._additional_params.len());
7779        params.push("name", self._name);
7780
7781        params.extend(self._additional_params.iter());
7782
7783        params.push("alt", "json");
7784        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7785        if self._scopes.is_empty() {
7786            self._scopes
7787                .insert(Scope::CloudPlatform.as_ref().to_string());
7788        }
7789
7790        #[allow(clippy::single_element_loop)]
7791        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7792            url = params.uri_replacement(url, param_name, find_this, true);
7793        }
7794        {
7795            let to_remove = ["name"];
7796            params.remove_params(&to_remove);
7797        }
7798
7799        let url = params.parse_with_url(&url);
7800
7801        loop {
7802            let token = match self
7803                .hub
7804                .auth
7805                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7806                .await
7807            {
7808                Ok(token) => token,
7809                Err(e) => match dlg.token(e) {
7810                    Ok(token) => token,
7811                    Err(e) => {
7812                        dlg.finished(false);
7813                        return Err(common::Error::MissingToken(e));
7814                    }
7815                },
7816            };
7817            let mut req_result = {
7818                let client = &self.hub.client;
7819                dlg.pre_request();
7820                let mut req_builder = hyper::Request::builder()
7821                    .method(hyper::Method::GET)
7822                    .uri(url.as_str())
7823                    .header(USER_AGENT, self.hub._user_agent.clone());
7824
7825                if let Some(token) = token.as_ref() {
7826                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7827                }
7828
7829                let request = req_builder
7830                    .header(CONTENT_LENGTH, 0_u64)
7831                    .body(common::to_body::<String>(None));
7832
7833                client.request(request.unwrap()).await
7834            };
7835
7836            match req_result {
7837                Err(err) => {
7838                    if let common::Retry::After(d) = dlg.http_error(&err) {
7839                        sleep(d).await;
7840                        continue;
7841                    }
7842                    dlg.finished(false);
7843                    return Err(common::Error::HttpError(err));
7844                }
7845                Ok(res) => {
7846                    let (mut parts, body) = res.into_parts();
7847                    let mut body = common::Body::new(body);
7848                    if !parts.status.is_success() {
7849                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7850                        let error = serde_json::from_str(&common::to_string(&bytes));
7851                        let response = common::to_response(parts, bytes.into());
7852
7853                        if let common::Retry::After(d) =
7854                            dlg.http_failure(&response, error.as_ref().ok())
7855                        {
7856                            sleep(d).await;
7857                            continue;
7858                        }
7859
7860                        dlg.finished(false);
7861
7862                        return Err(match error {
7863                            Ok(value) => common::Error::BadRequest(value),
7864                            _ => common::Error::Failure(response),
7865                        });
7866                    }
7867                    let response = {
7868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7869                        let encoded = common::to_string(&bytes);
7870                        match serde_json::from_str(&encoded) {
7871                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7872                            Err(error) => {
7873                                dlg.response_json_decode_error(&encoded, &error);
7874                                return Err(common::Error::JsonDecodeError(
7875                                    encoded.to_string(),
7876                                    error,
7877                                ));
7878                            }
7879                        }
7880                    };
7881
7882                    dlg.finished(true);
7883                    return Ok(response);
7884                }
7885            }
7886        }
7887    }
7888
7889    /// Required. Name of the recommendation.
7890    ///
7891    /// Sets the *name* path property to the given value.
7892    ///
7893    /// Even though the property as already been set when instantiating this call,
7894    /// we provide this method for API completeness.
7895    pub fn name(
7896        mut self,
7897        new_value: &str,
7898    ) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
7899        self._name = new_value.to_string();
7900        self
7901    }
7902    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7903    /// while executing the actual API request.
7904    ///
7905    /// ````text
7906    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7907    /// ````
7908    ///
7909    /// Sets the *delegate* property to the given value.
7910    pub fn delegate(
7911        mut self,
7912        new_value: &'a mut dyn common::Delegate,
7913    ) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
7914        self._delegate = Some(new_value);
7915        self
7916    }
7917
7918    /// Set any additional parameter of the query string used in the request.
7919    /// It should be used to set parameters which are not yet available through their own
7920    /// setters.
7921    ///
7922    /// Please note that this method must not be used to set any of the known parameters
7923    /// which have their own setter method. If done anyway, the request will fail.
7924    ///
7925    /// # Additional Parameters
7926    ///
7927    /// * *$.xgafv* (query-string) - V1 error format.
7928    /// * *access_token* (query-string) - OAuth access token.
7929    /// * *alt* (query-string) - Data format for response.
7930    /// * *callback* (query-string) - JSONP
7931    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7932    /// * *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.
7933    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7934    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7935    /// * *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.
7936    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7937    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7938    pub fn param<T>(
7939        mut self,
7940        name: T,
7941        value: T,
7942    ) -> FolderLocationRecommenderRecommendationGetCall<'a, C>
7943    where
7944        T: AsRef<str>,
7945    {
7946        self._additional_params
7947            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7948        self
7949    }
7950
7951    /// Identifies the authorization scope for the method you are building.
7952    ///
7953    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7954    /// [`Scope::CloudPlatform`].
7955    ///
7956    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7957    /// tokens for more than one scope.
7958    ///
7959    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7960    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7961    /// sufficient, a read-write scope will do as well.
7962    pub fn add_scope<St>(
7963        mut self,
7964        scope: St,
7965    ) -> FolderLocationRecommenderRecommendationGetCall<'a, C>
7966    where
7967        St: AsRef<str>,
7968    {
7969        self._scopes.insert(String::from(scope.as_ref()));
7970        self
7971    }
7972    /// Identifies the authorization scope(s) for the method you are building.
7973    ///
7974    /// See [`Self::add_scope()`] for details.
7975    pub fn add_scopes<I, St>(
7976        mut self,
7977        scopes: I,
7978    ) -> FolderLocationRecommenderRecommendationGetCall<'a, C>
7979    where
7980        I: IntoIterator<Item = St>,
7981        St: AsRef<str>,
7982    {
7983        self._scopes
7984            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7985        self
7986    }
7987
7988    /// Removes all scopes, and no default scope will be used either.
7989    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7990    /// for details).
7991    pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
7992        self._scopes.clear();
7993        self
7994    }
7995}
7996
7997/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
7998///
7999/// A builder for the *locations.recommenders.recommendations.list* method supported by a *folder* resource.
8000/// It is not used directly, but through a [`FolderMethods`] instance.
8001///
8002/// # Example
8003///
8004/// Instantiate a resource method builder
8005///
8006/// ```test_harness,no_run
8007/// # extern crate hyper;
8008/// # extern crate hyper_rustls;
8009/// # extern crate google_recommender1 as recommender1;
8010/// # async fn dox() {
8011/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8012///
8013/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8014/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8015/// #     .with_native_roots()
8016/// #     .unwrap()
8017/// #     .https_only()
8018/// #     .enable_http2()
8019/// #     .build();
8020///
8021/// # let executor = hyper_util::rt::TokioExecutor::new();
8022/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8023/// #     secret,
8024/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8025/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8026/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8027/// #     ),
8028/// # ).build().await.unwrap();
8029///
8030/// # let client = hyper_util::client::legacy::Client::builder(
8031/// #     hyper_util::rt::TokioExecutor::new()
8032/// # )
8033/// # .build(
8034/// #     hyper_rustls::HttpsConnectorBuilder::new()
8035/// #         .with_native_roots()
8036/// #         .unwrap()
8037/// #         .https_or_http()
8038/// #         .enable_http2()
8039/// #         .build()
8040/// # );
8041/// # let mut hub = Recommender::new(client, auth);
8042/// // You can configure optional parameters by calling the respective setters at will, and
8043/// // execute the final call using `doit()`.
8044/// // Values shown here are possibly random and not representative !
8045/// let result = hub.folders().locations_recommenders_recommendations_list("parent")
8046///              .page_token("ea")
8047///              .page_size(-99)
8048///              .filter("Lorem")
8049///              .doit().await;
8050/// # }
8051/// ```
8052pub struct FolderLocationRecommenderRecommendationListCall<'a, C>
8053where
8054    C: 'a,
8055{
8056    hub: &'a Recommender<C>,
8057    _parent: String,
8058    _page_token: Option<String>,
8059    _page_size: Option<i32>,
8060    _filter: Option<String>,
8061    _delegate: Option<&'a mut dyn common::Delegate>,
8062    _additional_params: HashMap<String, String>,
8063    _scopes: BTreeSet<String>,
8064}
8065
8066impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationListCall<'a, C> {}
8067
8068impl<'a, C> FolderLocationRecommenderRecommendationListCall<'a, C>
8069where
8070    C: common::Connector,
8071{
8072    /// Perform the operation you have build so far.
8073    pub async fn doit(
8074        mut self,
8075    ) -> common::Result<(
8076        common::Response,
8077        GoogleCloudRecommenderV1ListRecommendationsResponse,
8078    )> {
8079        use std::borrow::Cow;
8080        use std::io::{Read, Seek};
8081
8082        use common::{url::Params, ToParts};
8083        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8084
8085        let mut dd = common::DefaultDelegate;
8086        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8087        dlg.begin(common::MethodInfo {
8088            id: "recommender.folders.locations.recommenders.recommendations.list",
8089            http_method: hyper::Method::GET,
8090        });
8091
8092        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
8093            if self._additional_params.contains_key(field) {
8094                dlg.finished(false);
8095                return Err(common::Error::FieldClash(field));
8096            }
8097        }
8098
8099        let mut params = Params::with_capacity(6 + self._additional_params.len());
8100        params.push("parent", self._parent);
8101        if let Some(value) = self._page_token.as_ref() {
8102            params.push("pageToken", value);
8103        }
8104        if let Some(value) = self._page_size.as_ref() {
8105            params.push("pageSize", value.to_string());
8106        }
8107        if let Some(value) = self._filter.as_ref() {
8108            params.push("filter", value);
8109        }
8110
8111        params.extend(self._additional_params.iter());
8112
8113        params.push("alt", "json");
8114        let mut url = self.hub._base_url.clone() + "v1/{+parent}/recommendations";
8115        if self._scopes.is_empty() {
8116            self._scopes
8117                .insert(Scope::CloudPlatform.as_ref().to_string());
8118        }
8119
8120        #[allow(clippy::single_element_loop)]
8121        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8122            url = params.uri_replacement(url, param_name, find_this, true);
8123        }
8124        {
8125            let to_remove = ["parent"];
8126            params.remove_params(&to_remove);
8127        }
8128
8129        let url = params.parse_with_url(&url);
8130
8131        loop {
8132            let token = match self
8133                .hub
8134                .auth
8135                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8136                .await
8137            {
8138                Ok(token) => token,
8139                Err(e) => match dlg.token(e) {
8140                    Ok(token) => token,
8141                    Err(e) => {
8142                        dlg.finished(false);
8143                        return Err(common::Error::MissingToken(e));
8144                    }
8145                },
8146            };
8147            let mut req_result = {
8148                let client = &self.hub.client;
8149                dlg.pre_request();
8150                let mut req_builder = hyper::Request::builder()
8151                    .method(hyper::Method::GET)
8152                    .uri(url.as_str())
8153                    .header(USER_AGENT, self.hub._user_agent.clone());
8154
8155                if let Some(token) = token.as_ref() {
8156                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8157                }
8158
8159                let request = req_builder
8160                    .header(CONTENT_LENGTH, 0_u64)
8161                    .body(common::to_body::<String>(None));
8162
8163                client.request(request.unwrap()).await
8164            };
8165
8166            match req_result {
8167                Err(err) => {
8168                    if let common::Retry::After(d) = dlg.http_error(&err) {
8169                        sleep(d).await;
8170                        continue;
8171                    }
8172                    dlg.finished(false);
8173                    return Err(common::Error::HttpError(err));
8174                }
8175                Ok(res) => {
8176                    let (mut parts, body) = res.into_parts();
8177                    let mut body = common::Body::new(body);
8178                    if !parts.status.is_success() {
8179                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8180                        let error = serde_json::from_str(&common::to_string(&bytes));
8181                        let response = common::to_response(parts, bytes.into());
8182
8183                        if let common::Retry::After(d) =
8184                            dlg.http_failure(&response, error.as_ref().ok())
8185                        {
8186                            sleep(d).await;
8187                            continue;
8188                        }
8189
8190                        dlg.finished(false);
8191
8192                        return Err(match error {
8193                            Ok(value) => common::Error::BadRequest(value),
8194                            _ => common::Error::Failure(response),
8195                        });
8196                    }
8197                    let response = {
8198                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8199                        let encoded = common::to_string(&bytes);
8200                        match serde_json::from_str(&encoded) {
8201                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8202                            Err(error) => {
8203                                dlg.response_json_decode_error(&encoded, &error);
8204                                return Err(common::Error::JsonDecodeError(
8205                                    encoded.to_string(),
8206                                    error,
8207                                ));
8208                            }
8209                        }
8210                    };
8211
8212                    dlg.finished(true);
8213                    return Ok(response);
8214                }
8215            }
8216        }
8217    }
8218
8219    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
8220    ///
8221    /// Sets the *parent* path property to the given value.
8222    ///
8223    /// Even though the property as already been set when instantiating this call,
8224    /// we provide this method for API completeness.
8225    pub fn parent(
8226        mut self,
8227        new_value: &str,
8228    ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8229        self._parent = new_value.to_string();
8230        self
8231    }
8232    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
8233    ///
8234    /// Sets the *page token* query property to the given value.
8235    pub fn page_token(
8236        mut self,
8237        new_value: &str,
8238    ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8239        self._page_token = Some(new_value.to_string());
8240        self
8241    }
8242    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
8243    ///
8244    /// Sets the *page size* query property to the given value.
8245    pub fn page_size(
8246        mut self,
8247        new_value: i32,
8248    ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8249        self._page_size = Some(new_value);
8250        self
8251    }
8252    /// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
8253    ///
8254    /// Sets the *filter* query property to the given value.
8255    pub fn filter(
8256        mut self,
8257        new_value: &str,
8258    ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8259        self._filter = Some(new_value.to_string());
8260        self
8261    }
8262    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8263    /// while executing the actual API request.
8264    ///
8265    /// ````text
8266    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8267    /// ````
8268    ///
8269    /// Sets the *delegate* property to the given value.
8270    pub fn delegate(
8271        mut self,
8272        new_value: &'a mut dyn common::Delegate,
8273    ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8274        self._delegate = Some(new_value);
8275        self
8276    }
8277
8278    /// Set any additional parameter of the query string used in the request.
8279    /// It should be used to set parameters which are not yet available through their own
8280    /// setters.
8281    ///
8282    /// Please note that this method must not be used to set any of the known parameters
8283    /// which have their own setter method. If done anyway, the request will fail.
8284    ///
8285    /// # Additional Parameters
8286    ///
8287    /// * *$.xgafv* (query-string) - V1 error format.
8288    /// * *access_token* (query-string) - OAuth access token.
8289    /// * *alt* (query-string) - Data format for response.
8290    /// * *callback* (query-string) - JSONP
8291    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8292    /// * *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.
8293    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8294    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8295    /// * *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.
8296    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8297    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8298    pub fn param<T>(
8299        mut self,
8300        name: T,
8301        value: T,
8302    ) -> FolderLocationRecommenderRecommendationListCall<'a, C>
8303    where
8304        T: AsRef<str>,
8305    {
8306        self._additional_params
8307            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8308        self
8309    }
8310
8311    /// Identifies the authorization scope for the method you are building.
8312    ///
8313    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8314    /// [`Scope::CloudPlatform`].
8315    ///
8316    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8317    /// tokens for more than one scope.
8318    ///
8319    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8320    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8321    /// sufficient, a read-write scope will do as well.
8322    pub fn add_scope<St>(
8323        mut self,
8324        scope: St,
8325    ) -> FolderLocationRecommenderRecommendationListCall<'a, C>
8326    where
8327        St: AsRef<str>,
8328    {
8329        self._scopes.insert(String::from(scope.as_ref()));
8330        self
8331    }
8332    /// Identifies the authorization scope(s) for the method you are building.
8333    ///
8334    /// See [`Self::add_scope()`] for details.
8335    pub fn add_scopes<I, St>(
8336        mut self,
8337        scopes: I,
8338    ) -> FolderLocationRecommenderRecommendationListCall<'a, C>
8339    where
8340        I: IntoIterator<Item = St>,
8341        St: AsRef<str>,
8342    {
8343        self._scopes
8344            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8345        self
8346    }
8347
8348    /// Removes all scopes, and no default scope will be used either.
8349    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8350    /// for details).
8351    pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8352        self._scopes.clear();
8353        self
8354    }
8355}
8356
8357/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
8358///
8359/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *folder* resource.
8360/// It is not used directly, but through a [`FolderMethods`] instance.
8361///
8362/// # Example
8363///
8364/// Instantiate a resource method builder
8365///
8366/// ```test_harness,no_run
8367/// # extern crate hyper;
8368/// # extern crate hyper_rustls;
8369/// # extern crate google_recommender1 as recommender1;
8370/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationClaimedRequest;
8371/// # async fn dox() {
8372/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8373///
8374/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8375/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8376/// #     .with_native_roots()
8377/// #     .unwrap()
8378/// #     .https_only()
8379/// #     .enable_http2()
8380/// #     .build();
8381///
8382/// # let executor = hyper_util::rt::TokioExecutor::new();
8383/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8384/// #     secret,
8385/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8386/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8387/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8388/// #     ),
8389/// # ).build().await.unwrap();
8390///
8391/// # let client = hyper_util::client::legacy::Client::builder(
8392/// #     hyper_util::rt::TokioExecutor::new()
8393/// # )
8394/// # .build(
8395/// #     hyper_rustls::HttpsConnectorBuilder::new()
8396/// #         .with_native_roots()
8397/// #         .unwrap()
8398/// #         .https_or_http()
8399/// #         .enable_http2()
8400/// #         .build()
8401/// # );
8402/// # let mut hub = Recommender::new(client, auth);
8403/// // As the method needs a request, you would usually fill it with the desired information
8404/// // into the respective structure. Some of the parts shown here might not be applicable !
8405/// // Values shown here are possibly random and not representative !
8406/// let mut req = GoogleCloudRecommenderV1MarkRecommendationClaimedRequest::default();
8407///
8408/// // You can configure optional parameters by calling the respective setters at will, and
8409/// // execute the final call using `doit()`.
8410/// // Values shown here are possibly random and not representative !
8411/// let result = hub.folders().locations_recommenders_recommendations_mark_claimed(req, "name")
8412///              .doit().await;
8413/// # }
8414/// ```
8415pub struct FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
8416where
8417    C: 'a,
8418{
8419    hub: &'a Recommender<C>,
8420    _request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
8421    _name: String,
8422    _delegate: Option<&'a mut dyn common::Delegate>,
8423    _additional_params: HashMap<String, String>,
8424    _scopes: BTreeSet<String>,
8425}
8426
8427impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {}
8428
8429impl<'a, C> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
8430where
8431    C: common::Connector,
8432{
8433    /// Perform the operation you have build so far.
8434    pub async fn doit(
8435        mut self,
8436    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
8437        use std::borrow::Cow;
8438        use std::io::{Read, Seek};
8439
8440        use common::{url::Params, ToParts};
8441        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8442
8443        let mut dd = common::DefaultDelegate;
8444        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8445        dlg.begin(common::MethodInfo {
8446            id: "recommender.folders.locations.recommenders.recommendations.markClaimed",
8447            http_method: hyper::Method::POST,
8448        });
8449
8450        for &field in ["alt", "name"].iter() {
8451            if self._additional_params.contains_key(field) {
8452                dlg.finished(false);
8453                return Err(common::Error::FieldClash(field));
8454            }
8455        }
8456
8457        let mut params = Params::with_capacity(4 + self._additional_params.len());
8458        params.push("name", self._name);
8459
8460        params.extend(self._additional_params.iter());
8461
8462        params.push("alt", "json");
8463        let mut url = self.hub._base_url.clone() + "v1/{+name}:markClaimed";
8464        if self._scopes.is_empty() {
8465            self._scopes
8466                .insert(Scope::CloudPlatform.as_ref().to_string());
8467        }
8468
8469        #[allow(clippy::single_element_loop)]
8470        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8471            url = params.uri_replacement(url, param_name, find_this, true);
8472        }
8473        {
8474            let to_remove = ["name"];
8475            params.remove_params(&to_remove);
8476        }
8477
8478        let url = params.parse_with_url(&url);
8479
8480        let mut json_mime_type = mime::APPLICATION_JSON;
8481        let mut request_value_reader = {
8482            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8483            common::remove_json_null_values(&mut value);
8484            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8485            serde_json::to_writer(&mut dst, &value).unwrap();
8486            dst
8487        };
8488        let request_size = request_value_reader
8489            .seek(std::io::SeekFrom::End(0))
8490            .unwrap();
8491        request_value_reader
8492            .seek(std::io::SeekFrom::Start(0))
8493            .unwrap();
8494
8495        loop {
8496            let token = match self
8497                .hub
8498                .auth
8499                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8500                .await
8501            {
8502                Ok(token) => token,
8503                Err(e) => match dlg.token(e) {
8504                    Ok(token) => token,
8505                    Err(e) => {
8506                        dlg.finished(false);
8507                        return Err(common::Error::MissingToken(e));
8508                    }
8509                },
8510            };
8511            request_value_reader
8512                .seek(std::io::SeekFrom::Start(0))
8513                .unwrap();
8514            let mut req_result = {
8515                let client = &self.hub.client;
8516                dlg.pre_request();
8517                let mut req_builder = hyper::Request::builder()
8518                    .method(hyper::Method::POST)
8519                    .uri(url.as_str())
8520                    .header(USER_AGENT, self.hub._user_agent.clone());
8521
8522                if let Some(token) = token.as_ref() {
8523                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8524                }
8525
8526                let request = req_builder
8527                    .header(CONTENT_TYPE, json_mime_type.to_string())
8528                    .header(CONTENT_LENGTH, request_size as u64)
8529                    .body(common::to_body(
8530                        request_value_reader.get_ref().clone().into(),
8531                    ));
8532
8533                client.request(request.unwrap()).await
8534            };
8535
8536            match req_result {
8537                Err(err) => {
8538                    if let common::Retry::After(d) = dlg.http_error(&err) {
8539                        sleep(d).await;
8540                        continue;
8541                    }
8542                    dlg.finished(false);
8543                    return Err(common::Error::HttpError(err));
8544                }
8545                Ok(res) => {
8546                    let (mut parts, body) = res.into_parts();
8547                    let mut body = common::Body::new(body);
8548                    if !parts.status.is_success() {
8549                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8550                        let error = serde_json::from_str(&common::to_string(&bytes));
8551                        let response = common::to_response(parts, bytes.into());
8552
8553                        if let common::Retry::After(d) =
8554                            dlg.http_failure(&response, error.as_ref().ok())
8555                        {
8556                            sleep(d).await;
8557                            continue;
8558                        }
8559
8560                        dlg.finished(false);
8561
8562                        return Err(match error {
8563                            Ok(value) => common::Error::BadRequest(value),
8564                            _ => common::Error::Failure(response),
8565                        });
8566                    }
8567                    let response = {
8568                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8569                        let encoded = common::to_string(&bytes);
8570                        match serde_json::from_str(&encoded) {
8571                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8572                            Err(error) => {
8573                                dlg.response_json_decode_error(&encoded, &error);
8574                                return Err(common::Error::JsonDecodeError(
8575                                    encoded.to_string(),
8576                                    error,
8577                                ));
8578                            }
8579                        }
8580                    };
8581
8582                    dlg.finished(true);
8583                    return Ok(response);
8584                }
8585            }
8586        }
8587    }
8588
8589    ///
8590    /// Sets the *request* property to the given value.
8591    ///
8592    /// Even though the property as already been set when instantiating this call,
8593    /// we provide this method for API completeness.
8594    pub fn request(
8595        mut self,
8596        new_value: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
8597    ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
8598        self._request = new_value;
8599        self
8600    }
8601    /// Required. Name of the recommendation.
8602    ///
8603    /// Sets the *name* path property to the given value.
8604    ///
8605    /// Even though the property as already been set when instantiating this call,
8606    /// we provide this method for API completeness.
8607    pub fn name(
8608        mut self,
8609        new_value: &str,
8610    ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
8611        self._name = new_value.to_string();
8612        self
8613    }
8614    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8615    /// while executing the actual API request.
8616    ///
8617    /// ````text
8618    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8619    /// ````
8620    ///
8621    /// Sets the *delegate* property to the given value.
8622    pub fn delegate(
8623        mut self,
8624        new_value: &'a mut dyn common::Delegate,
8625    ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
8626        self._delegate = Some(new_value);
8627        self
8628    }
8629
8630    /// Set any additional parameter of the query string used in the request.
8631    /// It should be used to set parameters which are not yet available through their own
8632    /// setters.
8633    ///
8634    /// Please note that this method must not be used to set any of the known parameters
8635    /// which have their own setter method. If done anyway, the request will fail.
8636    ///
8637    /// # Additional Parameters
8638    ///
8639    /// * *$.xgafv* (query-string) - V1 error format.
8640    /// * *access_token* (query-string) - OAuth access token.
8641    /// * *alt* (query-string) - Data format for response.
8642    /// * *callback* (query-string) - JSONP
8643    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8644    /// * *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.
8645    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8646    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8647    /// * *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.
8648    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8649    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8650    pub fn param<T>(
8651        mut self,
8652        name: T,
8653        value: T,
8654    ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
8655    where
8656        T: AsRef<str>,
8657    {
8658        self._additional_params
8659            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8660        self
8661    }
8662
8663    /// Identifies the authorization scope for the method you are building.
8664    ///
8665    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8666    /// [`Scope::CloudPlatform`].
8667    ///
8668    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8669    /// tokens for more than one scope.
8670    ///
8671    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8672    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8673    /// sufficient, a read-write scope will do as well.
8674    pub fn add_scope<St>(
8675        mut self,
8676        scope: St,
8677    ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
8678    where
8679        St: AsRef<str>,
8680    {
8681        self._scopes.insert(String::from(scope.as_ref()));
8682        self
8683    }
8684    /// Identifies the authorization scope(s) for the method you are building.
8685    ///
8686    /// See [`Self::add_scope()`] for details.
8687    pub fn add_scopes<I, St>(
8688        mut self,
8689        scopes: I,
8690    ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
8691    where
8692        I: IntoIterator<Item = St>,
8693        St: AsRef<str>,
8694    {
8695        self._scopes
8696            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8697        self
8698    }
8699
8700    /// Removes all scopes, and no default scope will be used either.
8701    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8702    /// for details).
8703    pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
8704        self._scopes.clear();
8705        self
8706    }
8707}
8708
8709/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
8710///
8711/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *folder* resource.
8712/// It is not used directly, but through a [`FolderMethods`] instance.
8713///
8714/// # Example
8715///
8716/// Instantiate a resource method builder
8717///
8718/// ```test_harness,no_run
8719/// # extern crate hyper;
8720/// # extern crate hyper_rustls;
8721/// # extern crate google_recommender1 as recommender1;
8722/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationDismissedRequest;
8723/// # async fn dox() {
8724/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8725///
8726/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8727/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8728/// #     .with_native_roots()
8729/// #     .unwrap()
8730/// #     .https_only()
8731/// #     .enable_http2()
8732/// #     .build();
8733///
8734/// # let executor = hyper_util::rt::TokioExecutor::new();
8735/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8736/// #     secret,
8737/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8738/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8739/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8740/// #     ),
8741/// # ).build().await.unwrap();
8742///
8743/// # let client = hyper_util::client::legacy::Client::builder(
8744/// #     hyper_util::rt::TokioExecutor::new()
8745/// # )
8746/// # .build(
8747/// #     hyper_rustls::HttpsConnectorBuilder::new()
8748/// #         .with_native_roots()
8749/// #         .unwrap()
8750/// #         .https_or_http()
8751/// #         .enable_http2()
8752/// #         .build()
8753/// # );
8754/// # let mut hub = Recommender::new(client, auth);
8755/// // As the method needs a request, you would usually fill it with the desired information
8756/// // into the respective structure. Some of the parts shown here might not be applicable !
8757/// // Values shown here are possibly random and not representative !
8758/// let mut req = GoogleCloudRecommenderV1MarkRecommendationDismissedRequest::default();
8759///
8760/// // You can configure optional parameters by calling the respective setters at will, and
8761/// // execute the final call using `doit()`.
8762/// // Values shown here are possibly random and not representative !
8763/// let result = hub.folders().locations_recommenders_recommendations_mark_dismissed(req, "name")
8764///              .doit().await;
8765/// # }
8766/// ```
8767pub struct FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
8768where
8769    C: 'a,
8770{
8771    hub: &'a Recommender<C>,
8772    _request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
8773    _name: String,
8774    _delegate: Option<&'a mut dyn common::Delegate>,
8775    _additional_params: HashMap<String, String>,
8776    _scopes: BTreeSet<String>,
8777}
8778
8779impl<'a, C> common::CallBuilder
8780    for FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
8781{
8782}
8783
8784impl<'a, C> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
8785where
8786    C: common::Connector,
8787{
8788    /// Perform the operation you have build so far.
8789    pub async fn doit(
8790        mut self,
8791    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
8792        use std::borrow::Cow;
8793        use std::io::{Read, Seek};
8794
8795        use common::{url::Params, ToParts};
8796        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8797
8798        let mut dd = common::DefaultDelegate;
8799        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8800        dlg.begin(common::MethodInfo {
8801            id: "recommender.folders.locations.recommenders.recommendations.markDismissed",
8802            http_method: hyper::Method::POST,
8803        });
8804
8805        for &field in ["alt", "name"].iter() {
8806            if self._additional_params.contains_key(field) {
8807                dlg.finished(false);
8808                return Err(common::Error::FieldClash(field));
8809            }
8810        }
8811
8812        let mut params = Params::with_capacity(4 + self._additional_params.len());
8813        params.push("name", self._name);
8814
8815        params.extend(self._additional_params.iter());
8816
8817        params.push("alt", "json");
8818        let mut url = self.hub._base_url.clone() + "v1/{+name}:markDismissed";
8819        if self._scopes.is_empty() {
8820            self._scopes
8821                .insert(Scope::CloudPlatform.as_ref().to_string());
8822        }
8823
8824        #[allow(clippy::single_element_loop)]
8825        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8826            url = params.uri_replacement(url, param_name, find_this, true);
8827        }
8828        {
8829            let to_remove = ["name"];
8830            params.remove_params(&to_remove);
8831        }
8832
8833        let url = params.parse_with_url(&url);
8834
8835        let mut json_mime_type = mime::APPLICATION_JSON;
8836        let mut request_value_reader = {
8837            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8838            common::remove_json_null_values(&mut value);
8839            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8840            serde_json::to_writer(&mut dst, &value).unwrap();
8841            dst
8842        };
8843        let request_size = request_value_reader
8844            .seek(std::io::SeekFrom::End(0))
8845            .unwrap();
8846        request_value_reader
8847            .seek(std::io::SeekFrom::Start(0))
8848            .unwrap();
8849
8850        loop {
8851            let token = match self
8852                .hub
8853                .auth
8854                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8855                .await
8856            {
8857                Ok(token) => token,
8858                Err(e) => match dlg.token(e) {
8859                    Ok(token) => token,
8860                    Err(e) => {
8861                        dlg.finished(false);
8862                        return Err(common::Error::MissingToken(e));
8863                    }
8864                },
8865            };
8866            request_value_reader
8867                .seek(std::io::SeekFrom::Start(0))
8868                .unwrap();
8869            let mut req_result = {
8870                let client = &self.hub.client;
8871                dlg.pre_request();
8872                let mut req_builder = hyper::Request::builder()
8873                    .method(hyper::Method::POST)
8874                    .uri(url.as_str())
8875                    .header(USER_AGENT, self.hub._user_agent.clone());
8876
8877                if let Some(token) = token.as_ref() {
8878                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8879                }
8880
8881                let request = req_builder
8882                    .header(CONTENT_TYPE, json_mime_type.to_string())
8883                    .header(CONTENT_LENGTH, request_size as u64)
8884                    .body(common::to_body(
8885                        request_value_reader.get_ref().clone().into(),
8886                    ));
8887
8888                client.request(request.unwrap()).await
8889            };
8890
8891            match req_result {
8892                Err(err) => {
8893                    if let common::Retry::After(d) = dlg.http_error(&err) {
8894                        sleep(d).await;
8895                        continue;
8896                    }
8897                    dlg.finished(false);
8898                    return Err(common::Error::HttpError(err));
8899                }
8900                Ok(res) => {
8901                    let (mut parts, body) = res.into_parts();
8902                    let mut body = common::Body::new(body);
8903                    if !parts.status.is_success() {
8904                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8905                        let error = serde_json::from_str(&common::to_string(&bytes));
8906                        let response = common::to_response(parts, bytes.into());
8907
8908                        if let common::Retry::After(d) =
8909                            dlg.http_failure(&response, error.as_ref().ok())
8910                        {
8911                            sleep(d).await;
8912                            continue;
8913                        }
8914
8915                        dlg.finished(false);
8916
8917                        return Err(match error {
8918                            Ok(value) => common::Error::BadRequest(value),
8919                            _ => common::Error::Failure(response),
8920                        });
8921                    }
8922                    let response = {
8923                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8924                        let encoded = common::to_string(&bytes);
8925                        match serde_json::from_str(&encoded) {
8926                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8927                            Err(error) => {
8928                                dlg.response_json_decode_error(&encoded, &error);
8929                                return Err(common::Error::JsonDecodeError(
8930                                    encoded.to_string(),
8931                                    error,
8932                                ));
8933                            }
8934                        }
8935                    };
8936
8937                    dlg.finished(true);
8938                    return Ok(response);
8939                }
8940            }
8941        }
8942    }
8943
8944    ///
8945    /// Sets the *request* property to the given value.
8946    ///
8947    /// Even though the property as already been set when instantiating this call,
8948    /// we provide this method for API completeness.
8949    pub fn request(
8950        mut self,
8951        new_value: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
8952    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
8953        self._request = new_value;
8954        self
8955    }
8956    /// Required. Name of the recommendation.
8957    ///
8958    /// Sets the *name* path property to the given value.
8959    ///
8960    /// Even though the property as already been set when instantiating this call,
8961    /// we provide this method for API completeness.
8962    pub fn name(
8963        mut self,
8964        new_value: &str,
8965    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
8966        self._name = new_value.to_string();
8967        self
8968    }
8969    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8970    /// while executing the actual API request.
8971    ///
8972    /// ````text
8973    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8974    /// ````
8975    ///
8976    /// Sets the *delegate* property to the given value.
8977    pub fn delegate(
8978        mut self,
8979        new_value: &'a mut dyn common::Delegate,
8980    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
8981        self._delegate = Some(new_value);
8982        self
8983    }
8984
8985    /// Set any additional parameter of the query string used in the request.
8986    /// It should be used to set parameters which are not yet available through their own
8987    /// setters.
8988    ///
8989    /// Please note that this method must not be used to set any of the known parameters
8990    /// which have their own setter method. If done anyway, the request will fail.
8991    ///
8992    /// # Additional Parameters
8993    ///
8994    /// * *$.xgafv* (query-string) - V1 error format.
8995    /// * *access_token* (query-string) - OAuth access token.
8996    /// * *alt* (query-string) - Data format for response.
8997    /// * *callback* (query-string) - JSONP
8998    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8999    /// * *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.
9000    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9001    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9002    /// * *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.
9003    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9004    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9005    pub fn param<T>(
9006        mut self,
9007        name: T,
9008        value: T,
9009    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9010    where
9011        T: AsRef<str>,
9012    {
9013        self._additional_params
9014            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9015        self
9016    }
9017
9018    /// Identifies the authorization scope for the method you are building.
9019    ///
9020    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9021    /// [`Scope::CloudPlatform`].
9022    ///
9023    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9024    /// tokens for more than one scope.
9025    ///
9026    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9027    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9028    /// sufficient, a read-write scope will do as well.
9029    pub fn add_scope<St>(
9030        mut self,
9031        scope: St,
9032    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9033    where
9034        St: AsRef<str>,
9035    {
9036        self._scopes.insert(String::from(scope.as_ref()));
9037        self
9038    }
9039    /// Identifies the authorization scope(s) for the method you are building.
9040    ///
9041    /// See [`Self::add_scope()`] for details.
9042    pub fn add_scopes<I, St>(
9043        mut self,
9044        scopes: I,
9045    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9046    where
9047        I: IntoIterator<Item = St>,
9048        St: AsRef<str>,
9049    {
9050        self._scopes
9051            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9052        self
9053    }
9054
9055    /// Removes all scopes, and no default scope will be used either.
9056    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9057    /// for details).
9058    pub fn clear_scopes(
9059        mut self,
9060    ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
9061        self._scopes.clear();
9062        self
9063    }
9064}
9065
9066/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
9067///
9068/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *folder* resource.
9069/// It is not used directly, but through a [`FolderMethods`] instance.
9070///
9071/// # Example
9072///
9073/// Instantiate a resource method builder
9074///
9075/// ```test_harness,no_run
9076/// # extern crate hyper;
9077/// # extern crate hyper_rustls;
9078/// # extern crate google_recommender1 as recommender1;
9079/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationFailedRequest;
9080/// # async fn dox() {
9081/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9082///
9083/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9084/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9085/// #     .with_native_roots()
9086/// #     .unwrap()
9087/// #     .https_only()
9088/// #     .enable_http2()
9089/// #     .build();
9090///
9091/// # let executor = hyper_util::rt::TokioExecutor::new();
9092/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9093/// #     secret,
9094/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9095/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9096/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9097/// #     ),
9098/// # ).build().await.unwrap();
9099///
9100/// # let client = hyper_util::client::legacy::Client::builder(
9101/// #     hyper_util::rt::TokioExecutor::new()
9102/// # )
9103/// # .build(
9104/// #     hyper_rustls::HttpsConnectorBuilder::new()
9105/// #         .with_native_roots()
9106/// #         .unwrap()
9107/// #         .https_or_http()
9108/// #         .enable_http2()
9109/// #         .build()
9110/// # );
9111/// # let mut hub = Recommender::new(client, auth);
9112/// // As the method needs a request, you would usually fill it with the desired information
9113/// // into the respective structure. Some of the parts shown here might not be applicable !
9114/// // Values shown here are possibly random and not representative !
9115/// let mut req = GoogleCloudRecommenderV1MarkRecommendationFailedRequest::default();
9116///
9117/// // You can configure optional parameters by calling the respective setters at will, and
9118/// // execute the final call using `doit()`.
9119/// // Values shown here are possibly random and not representative !
9120/// let result = hub.folders().locations_recommenders_recommendations_mark_failed(req, "name")
9121///              .doit().await;
9122/// # }
9123/// ```
9124pub struct FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
9125where
9126    C: 'a,
9127{
9128    hub: &'a Recommender<C>,
9129    _request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
9130    _name: String,
9131    _delegate: Option<&'a mut dyn common::Delegate>,
9132    _additional_params: HashMap<String, String>,
9133    _scopes: BTreeSet<String>,
9134}
9135
9136impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {}
9137
9138impl<'a, C> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
9139where
9140    C: common::Connector,
9141{
9142    /// Perform the operation you have build so far.
9143    pub async fn doit(
9144        mut self,
9145    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
9146        use std::borrow::Cow;
9147        use std::io::{Read, Seek};
9148
9149        use common::{url::Params, ToParts};
9150        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9151
9152        let mut dd = common::DefaultDelegate;
9153        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9154        dlg.begin(common::MethodInfo {
9155            id: "recommender.folders.locations.recommenders.recommendations.markFailed",
9156            http_method: hyper::Method::POST,
9157        });
9158
9159        for &field in ["alt", "name"].iter() {
9160            if self._additional_params.contains_key(field) {
9161                dlg.finished(false);
9162                return Err(common::Error::FieldClash(field));
9163            }
9164        }
9165
9166        let mut params = Params::with_capacity(4 + self._additional_params.len());
9167        params.push("name", self._name);
9168
9169        params.extend(self._additional_params.iter());
9170
9171        params.push("alt", "json");
9172        let mut url = self.hub._base_url.clone() + "v1/{+name}:markFailed";
9173        if self._scopes.is_empty() {
9174            self._scopes
9175                .insert(Scope::CloudPlatform.as_ref().to_string());
9176        }
9177
9178        #[allow(clippy::single_element_loop)]
9179        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9180            url = params.uri_replacement(url, param_name, find_this, true);
9181        }
9182        {
9183            let to_remove = ["name"];
9184            params.remove_params(&to_remove);
9185        }
9186
9187        let url = params.parse_with_url(&url);
9188
9189        let mut json_mime_type = mime::APPLICATION_JSON;
9190        let mut request_value_reader = {
9191            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9192            common::remove_json_null_values(&mut value);
9193            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9194            serde_json::to_writer(&mut dst, &value).unwrap();
9195            dst
9196        };
9197        let request_size = request_value_reader
9198            .seek(std::io::SeekFrom::End(0))
9199            .unwrap();
9200        request_value_reader
9201            .seek(std::io::SeekFrom::Start(0))
9202            .unwrap();
9203
9204        loop {
9205            let token = match self
9206                .hub
9207                .auth
9208                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9209                .await
9210            {
9211                Ok(token) => token,
9212                Err(e) => match dlg.token(e) {
9213                    Ok(token) => token,
9214                    Err(e) => {
9215                        dlg.finished(false);
9216                        return Err(common::Error::MissingToken(e));
9217                    }
9218                },
9219            };
9220            request_value_reader
9221                .seek(std::io::SeekFrom::Start(0))
9222                .unwrap();
9223            let mut req_result = {
9224                let client = &self.hub.client;
9225                dlg.pre_request();
9226                let mut req_builder = hyper::Request::builder()
9227                    .method(hyper::Method::POST)
9228                    .uri(url.as_str())
9229                    .header(USER_AGENT, self.hub._user_agent.clone());
9230
9231                if let Some(token) = token.as_ref() {
9232                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9233                }
9234
9235                let request = req_builder
9236                    .header(CONTENT_TYPE, json_mime_type.to_string())
9237                    .header(CONTENT_LENGTH, request_size as u64)
9238                    .body(common::to_body(
9239                        request_value_reader.get_ref().clone().into(),
9240                    ));
9241
9242                client.request(request.unwrap()).await
9243            };
9244
9245            match req_result {
9246                Err(err) => {
9247                    if let common::Retry::After(d) = dlg.http_error(&err) {
9248                        sleep(d).await;
9249                        continue;
9250                    }
9251                    dlg.finished(false);
9252                    return Err(common::Error::HttpError(err));
9253                }
9254                Ok(res) => {
9255                    let (mut parts, body) = res.into_parts();
9256                    let mut body = common::Body::new(body);
9257                    if !parts.status.is_success() {
9258                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9259                        let error = serde_json::from_str(&common::to_string(&bytes));
9260                        let response = common::to_response(parts, bytes.into());
9261
9262                        if let common::Retry::After(d) =
9263                            dlg.http_failure(&response, error.as_ref().ok())
9264                        {
9265                            sleep(d).await;
9266                            continue;
9267                        }
9268
9269                        dlg.finished(false);
9270
9271                        return Err(match error {
9272                            Ok(value) => common::Error::BadRequest(value),
9273                            _ => common::Error::Failure(response),
9274                        });
9275                    }
9276                    let response = {
9277                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9278                        let encoded = common::to_string(&bytes);
9279                        match serde_json::from_str(&encoded) {
9280                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9281                            Err(error) => {
9282                                dlg.response_json_decode_error(&encoded, &error);
9283                                return Err(common::Error::JsonDecodeError(
9284                                    encoded.to_string(),
9285                                    error,
9286                                ));
9287                            }
9288                        }
9289                    };
9290
9291                    dlg.finished(true);
9292                    return Ok(response);
9293                }
9294            }
9295        }
9296    }
9297
9298    ///
9299    /// Sets the *request* property to the given value.
9300    ///
9301    /// Even though the property as already been set when instantiating this call,
9302    /// we provide this method for API completeness.
9303    pub fn request(
9304        mut self,
9305        new_value: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
9306    ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
9307        self._request = new_value;
9308        self
9309    }
9310    /// Required. Name of the recommendation.
9311    ///
9312    /// Sets the *name* path property to the given value.
9313    ///
9314    /// Even though the property as already been set when instantiating this call,
9315    /// we provide this method for API completeness.
9316    pub fn name(
9317        mut self,
9318        new_value: &str,
9319    ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
9320        self._name = new_value.to_string();
9321        self
9322    }
9323    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9324    /// while executing the actual API request.
9325    ///
9326    /// ````text
9327    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9328    /// ````
9329    ///
9330    /// Sets the *delegate* property to the given value.
9331    pub fn delegate(
9332        mut self,
9333        new_value: &'a mut dyn common::Delegate,
9334    ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
9335        self._delegate = Some(new_value);
9336        self
9337    }
9338
9339    /// Set any additional parameter of the query string used in the request.
9340    /// It should be used to set parameters which are not yet available through their own
9341    /// setters.
9342    ///
9343    /// Please note that this method must not be used to set any of the known parameters
9344    /// which have their own setter method. If done anyway, the request will fail.
9345    ///
9346    /// # Additional Parameters
9347    ///
9348    /// * *$.xgafv* (query-string) - V1 error format.
9349    /// * *access_token* (query-string) - OAuth access token.
9350    /// * *alt* (query-string) - Data format for response.
9351    /// * *callback* (query-string) - JSONP
9352    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9353    /// * *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.
9354    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9355    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9356    /// * *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.
9357    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9358    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9359    pub fn param<T>(
9360        mut self,
9361        name: T,
9362        value: T,
9363    ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
9364    where
9365        T: AsRef<str>,
9366    {
9367        self._additional_params
9368            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9369        self
9370    }
9371
9372    /// Identifies the authorization scope for the method you are building.
9373    ///
9374    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9375    /// [`Scope::CloudPlatform`].
9376    ///
9377    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9378    /// tokens for more than one scope.
9379    ///
9380    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9381    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9382    /// sufficient, a read-write scope will do as well.
9383    pub fn add_scope<St>(
9384        mut self,
9385        scope: St,
9386    ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
9387    where
9388        St: AsRef<str>,
9389    {
9390        self._scopes.insert(String::from(scope.as_ref()));
9391        self
9392    }
9393    /// Identifies the authorization scope(s) for the method you are building.
9394    ///
9395    /// See [`Self::add_scope()`] for details.
9396    pub fn add_scopes<I, St>(
9397        mut self,
9398        scopes: I,
9399    ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
9400    where
9401        I: IntoIterator<Item = St>,
9402        St: AsRef<str>,
9403    {
9404        self._scopes
9405            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9406        self
9407    }
9408
9409    /// Removes all scopes, and no default scope will be used either.
9410    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9411    /// for details).
9412    pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
9413        self._scopes.clear();
9414        self
9415    }
9416}
9417
9418/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
9419///
9420/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *folder* resource.
9421/// It is not used directly, but through a [`FolderMethods`] instance.
9422///
9423/// # Example
9424///
9425/// Instantiate a resource method builder
9426///
9427/// ```test_harness,no_run
9428/// # extern crate hyper;
9429/// # extern crate hyper_rustls;
9430/// # extern crate google_recommender1 as recommender1;
9431/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationSucceededRequest;
9432/// # async fn dox() {
9433/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9434///
9435/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9436/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9437/// #     .with_native_roots()
9438/// #     .unwrap()
9439/// #     .https_only()
9440/// #     .enable_http2()
9441/// #     .build();
9442///
9443/// # let executor = hyper_util::rt::TokioExecutor::new();
9444/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9445/// #     secret,
9446/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9447/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9448/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9449/// #     ),
9450/// # ).build().await.unwrap();
9451///
9452/// # let client = hyper_util::client::legacy::Client::builder(
9453/// #     hyper_util::rt::TokioExecutor::new()
9454/// # )
9455/// # .build(
9456/// #     hyper_rustls::HttpsConnectorBuilder::new()
9457/// #         .with_native_roots()
9458/// #         .unwrap()
9459/// #         .https_or_http()
9460/// #         .enable_http2()
9461/// #         .build()
9462/// # );
9463/// # let mut hub = Recommender::new(client, auth);
9464/// // As the method needs a request, you would usually fill it with the desired information
9465/// // into the respective structure. Some of the parts shown here might not be applicable !
9466/// // Values shown here are possibly random and not representative !
9467/// let mut req = GoogleCloudRecommenderV1MarkRecommendationSucceededRequest::default();
9468///
9469/// // You can configure optional parameters by calling the respective setters at will, and
9470/// // execute the final call using `doit()`.
9471/// // Values shown here are possibly random and not representative !
9472/// let result = hub.folders().locations_recommenders_recommendations_mark_succeeded(req, "name")
9473///              .doit().await;
9474/// # }
9475/// ```
9476pub struct FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
9477where
9478    C: 'a,
9479{
9480    hub: &'a Recommender<C>,
9481    _request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
9482    _name: String,
9483    _delegate: Option<&'a mut dyn common::Delegate>,
9484    _additional_params: HashMap<String, String>,
9485    _scopes: BTreeSet<String>,
9486}
9487
9488impl<'a, C> common::CallBuilder
9489    for FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
9490{
9491}
9492
9493impl<'a, C> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
9494where
9495    C: common::Connector,
9496{
9497    /// Perform the operation you have build so far.
9498    pub async fn doit(
9499        mut self,
9500    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
9501        use std::borrow::Cow;
9502        use std::io::{Read, Seek};
9503
9504        use common::{url::Params, ToParts};
9505        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9506
9507        let mut dd = common::DefaultDelegate;
9508        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9509        dlg.begin(common::MethodInfo {
9510            id: "recommender.folders.locations.recommenders.recommendations.markSucceeded",
9511            http_method: hyper::Method::POST,
9512        });
9513
9514        for &field in ["alt", "name"].iter() {
9515            if self._additional_params.contains_key(field) {
9516                dlg.finished(false);
9517                return Err(common::Error::FieldClash(field));
9518            }
9519        }
9520
9521        let mut params = Params::with_capacity(4 + self._additional_params.len());
9522        params.push("name", self._name);
9523
9524        params.extend(self._additional_params.iter());
9525
9526        params.push("alt", "json");
9527        let mut url = self.hub._base_url.clone() + "v1/{+name}:markSucceeded";
9528        if self._scopes.is_empty() {
9529            self._scopes
9530                .insert(Scope::CloudPlatform.as_ref().to_string());
9531        }
9532
9533        #[allow(clippy::single_element_loop)]
9534        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9535            url = params.uri_replacement(url, param_name, find_this, true);
9536        }
9537        {
9538            let to_remove = ["name"];
9539            params.remove_params(&to_remove);
9540        }
9541
9542        let url = params.parse_with_url(&url);
9543
9544        let mut json_mime_type = mime::APPLICATION_JSON;
9545        let mut request_value_reader = {
9546            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9547            common::remove_json_null_values(&mut value);
9548            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9549            serde_json::to_writer(&mut dst, &value).unwrap();
9550            dst
9551        };
9552        let request_size = request_value_reader
9553            .seek(std::io::SeekFrom::End(0))
9554            .unwrap();
9555        request_value_reader
9556            .seek(std::io::SeekFrom::Start(0))
9557            .unwrap();
9558
9559        loop {
9560            let token = match self
9561                .hub
9562                .auth
9563                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9564                .await
9565            {
9566                Ok(token) => token,
9567                Err(e) => match dlg.token(e) {
9568                    Ok(token) => token,
9569                    Err(e) => {
9570                        dlg.finished(false);
9571                        return Err(common::Error::MissingToken(e));
9572                    }
9573                },
9574            };
9575            request_value_reader
9576                .seek(std::io::SeekFrom::Start(0))
9577                .unwrap();
9578            let mut req_result = {
9579                let client = &self.hub.client;
9580                dlg.pre_request();
9581                let mut req_builder = hyper::Request::builder()
9582                    .method(hyper::Method::POST)
9583                    .uri(url.as_str())
9584                    .header(USER_AGENT, self.hub._user_agent.clone());
9585
9586                if let Some(token) = token.as_ref() {
9587                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9588                }
9589
9590                let request = req_builder
9591                    .header(CONTENT_TYPE, json_mime_type.to_string())
9592                    .header(CONTENT_LENGTH, request_size as u64)
9593                    .body(common::to_body(
9594                        request_value_reader.get_ref().clone().into(),
9595                    ));
9596
9597                client.request(request.unwrap()).await
9598            };
9599
9600            match req_result {
9601                Err(err) => {
9602                    if let common::Retry::After(d) = dlg.http_error(&err) {
9603                        sleep(d).await;
9604                        continue;
9605                    }
9606                    dlg.finished(false);
9607                    return Err(common::Error::HttpError(err));
9608                }
9609                Ok(res) => {
9610                    let (mut parts, body) = res.into_parts();
9611                    let mut body = common::Body::new(body);
9612                    if !parts.status.is_success() {
9613                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9614                        let error = serde_json::from_str(&common::to_string(&bytes));
9615                        let response = common::to_response(parts, bytes.into());
9616
9617                        if let common::Retry::After(d) =
9618                            dlg.http_failure(&response, error.as_ref().ok())
9619                        {
9620                            sleep(d).await;
9621                            continue;
9622                        }
9623
9624                        dlg.finished(false);
9625
9626                        return Err(match error {
9627                            Ok(value) => common::Error::BadRequest(value),
9628                            _ => common::Error::Failure(response),
9629                        });
9630                    }
9631                    let response = {
9632                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9633                        let encoded = common::to_string(&bytes);
9634                        match serde_json::from_str(&encoded) {
9635                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9636                            Err(error) => {
9637                                dlg.response_json_decode_error(&encoded, &error);
9638                                return Err(common::Error::JsonDecodeError(
9639                                    encoded.to_string(),
9640                                    error,
9641                                ));
9642                            }
9643                        }
9644                    };
9645
9646                    dlg.finished(true);
9647                    return Ok(response);
9648                }
9649            }
9650        }
9651    }
9652
9653    ///
9654    /// Sets the *request* property to the given value.
9655    ///
9656    /// Even though the property as already been set when instantiating this call,
9657    /// we provide this method for API completeness.
9658    pub fn request(
9659        mut self,
9660        new_value: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
9661    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
9662        self._request = new_value;
9663        self
9664    }
9665    /// Required. Name of the recommendation.
9666    ///
9667    /// Sets the *name* path property to the given value.
9668    ///
9669    /// Even though the property as already been set when instantiating this call,
9670    /// we provide this method for API completeness.
9671    pub fn name(
9672        mut self,
9673        new_value: &str,
9674    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
9675        self._name = new_value.to_string();
9676        self
9677    }
9678    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9679    /// while executing the actual API request.
9680    ///
9681    /// ````text
9682    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9683    /// ````
9684    ///
9685    /// Sets the *delegate* property to the given value.
9686    pub fn delegate(
9687        mut self,
9688        new_value: &'a mut dyn common::Delegate,
9689    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
9690        self._delegate = Some(new_value);
9691        self
9692    }
9693
9694    /// Set any additional parameter of the query string used in the request.
9695    /// It should be used to set parameters which are not yet available through their own
9696    /// setters.
9697    ///
9698    /// Please note that this method must not be used to set any of the known parameters
9699    /// which have their own setter method. If done anyway, the request will fail.
9700    ///
9701    /// # Additional Parameters
9702    ///
9703    /// * *$.xgafv* (query-string) - V1 error format.
9704    /// * *access_token* (query-string) - OAuth access token.
9705    /// * *alt* (query-string) - Data format for response.
9706    /// * *callback* (query-string) - JSONP
9707    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9708    /// * *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.
9709    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9710    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9711    /// * *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.
9712    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9713    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9714    pub fn param<T>(
9715        mut self,
9716        name: T,
9717        value: T,
9718    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
9719    where
9720        T: AsRef<str>,
9721    {
9722        self._additional_params
9723            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9724        self
9725    }
9726
9727    /// Identifies the authorization scope for the method you are building.
9728    ///
9729    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9730    /// [`Scope::CloudPlatform`].
9731    ///
9732    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9733    /// tokens for more than one scope.
9734    ///
9735    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9736    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9737    /// sufficient, a read-write scope will do as well.
9738    pub fn add_scope<St>(
9739        mut self,
9740        scope: St,
9741    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
9742    where
9743        St: AsRef<str>,
9744    {
9745        self._scopes.insert(String::from(scope.as_ref()));
9746        self
9747    }
9748    /// Identifies the authorization scope(s) for the method you are building.
9749    ///
9750    /// See [`Self::add_scope()`] for details.
9751    pub fn add_scopes<I, St>(
9752        mut self,
9753        scopes: I,
9754    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
9755    where
9756        I: IntoIterator<Item = St>,
9757        St: AsRef<str>,
9758    {
9759        self._scopes
9760            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9761        self
9762    }
9763
9764    /// Removes all scopes, and no default scope will be used either.
9765    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9766    /// for details).
9767    pub fn clear_scopes(
9768        mut self,
9769    ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
9770        self._scopes.clear();
9771        self
9772    }
9773}
9774
9775/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
9776///
9777/// A builder for the *locations.insightTypes.insights.get* method supported by a *organization* resource.
9778/// It is not used directly, but through a [`OrganizationMethods`] instance.
9779///
9780/// # Example
9781///
9782/// Instantiate a resource method builder
9783///
9784/// ```test_harness,no_run
9785/// # extern crate hyper;
9786/// # extern crate hyper_rustls;
9787/// # extern crate google_recommender1 as recommender1;
9788/// # async fn dox() {
9789/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9790///
9791/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9792/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9793/// #     .with_native_roots()
9794/// #     .unwrap()
9795/// #     .https_only()
9796/// #     .enable_http2()
9797/// #     .build();
9798///
9799/// # let executor = hyper_util::rt::TokioExecutor::new();
9800/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9801/// #     secret,
9802/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9803/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9804/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9805/// #     ),
9806/// # ).build().await.unwrap();
9807///
9808/// # let client = hyper_util::client::legacy::Client::builder(
9809/// #     hyper_util::rt::TokioExecutor::new()
9810/// # )
9811/// # .build(
9812/// #     hyper_rustls::HttpsConnectorBuilder::new()
9813/// #         .with_native_roots()
9814/// #         .unwrap()
9815/// #         .https_or_http()
9816/// #         .enable_http2()
9817/// #         .build()
9818/// # );
9819/// # let mut hub = Recommender::new(client, auth);
9820/// // You can configure optional parameters by calling the respective setters at will, and
9821/// // execute the final call using `doit()`.
9822/// // Values shown here are possibly random and not representative !
9823/// let result = hub.organizations().locations_insight_types_insights_get("name")
9824///              .doit().await;
9825/// # }
9826/// ```
9827pub struct OrganizationLocationInsightTypeInsightGetCall<'a, C>
9828where
9829    C: 'a,
9830{
9831    hub: &'a Recommender<C>,
9832    _name: String,
9833    _delegate: Option<&'a mut dyn common::Delegate>,
9834    _additional_params: HashMap<String, String>,
9835    _scopes: BTreeSet<String>,
9836}
9837
9838impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeInsightGetCall<'a, C> {}
9839
9840impl<'a, C> OrganizationLocationInsightTypeInsightGetCall<'a, C>
9841where
9842    C: common::Connector,
9843{
9844    /// Perform the operation you have build so far.
9845    pub async fn doit(
9846        mut self,
9847    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
9848        use std::borrow::Cow;
9849        use std::io::{Read, Seek};
9850
9851        use common::{url::Params, ToParts};
9852        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9853
9854        let mut dd = common::DefaultDelegate;
9855        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9856        dlg.begin(common::MethodInfo {
9857            id: "recommender.organizations.locations.insightTypes.insights.get",
9858            http_method: hyper::Method::GET,
9859        });
9860
9861        for &field in ["alt", "name"].iter() {
9862            if self._additional_params.contains_key(field) {
9863                dlg.finished(false);
9864                return Err(common::Error::FieldClash(field));
9865            }
9866        }
9867
9868        let mut params = Params::with_capacity(3 + self._additional_params.len());
9869        params.push("name", self._name);
9870
9871        params.extend(self._additional_params.iter());
9872
9873        params.push("alt", "json");
9874        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9875        if self._scopes.is_empty() {
9876            self._scopes
9877                .insert(Scope::CloudPlatform.as_ref().to_string());
9878        }
9879
9880        #[allow(clippy::single_element_loop)]
9881        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9882            url = params.uri_replacement(url, param_name, find_this, true);
9883        }
9884        {
9885            let to_remove = ["name"];
9886            params.remove_params(&to_remove);
9887        }
9888
9889        let url = params.parse_with_url(&url);
9890
9891        loop {
9892            let token = match self
9893                .hub
9894                .auth
9895                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9896                .await
9897            {
9898                Ok(token) => token,
9899                Err(e) => match dlg.token(e) {
9900                    Ok(token) => token,
9901                    Err(e) => {
9902                        dlg.finished(false);
9903                        return Err(common::Error::MissingToken(e));
9904                    }
9905                },
9906            };
9907            let mut req_result = {
9908                let client = &self.hub.client;
9909                dlg.pre_request();
9910                let mut req_builder = hyper::Request::builder()
9911                    .method(hyper::Method::GET)
9912                    .uri(url.as_str())
9913                    .header(USER_AGENT, self.hub._user_agent.clone());
9914
9915                if let Some(token) = token.as_ref() {
9916                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9917                }
9918
9919                let request = req_builder
9920                    .header(CONTENT_LENGTH, 0_u64)
9921                    .body(common::to_body::<String>(None));
9922
9923                client.request(request.unwrap()).await
9924            };
9925
9926            match req_result {
9927                Err(err) => {
9928                    if let common::Retry::After(d) = dlg.http_error(&err) {
9929                        sleep(d).await;
9930                        continue;
9931                    }
9932                    dlg.finished(false);
9933                    return Err(common::Error::HttpError(err));
9934                }
9935                Ok(res) => {
9936                    let (mut parts, body) = res.into_parts();
9937                    let mut body = common::Body::new(body);
9938                    if !parts.status.is_success() {
9939                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9940                        let error = serde_json::from_str(&common::to_string(&bytes));
9941                        let response = common::to_response(parts, bytes.into());
9942
9943                        if let common::Retry::After(d) =
9944                            dlg.http_failure(&response, error.as_ref().ok())
9945                        {
9946                            sleep(d).await;
9947                            continue;
9948                        }
9949
9950                        dlg.finished(false);
9951
9952                        return Err(match error {
9953                            Ok(value) => common::Error::BadRequest(value),
9954                            _ => common::Error::Failure(response),
9955                        });
9956                    }
9957                    let response = {
9958                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9959                        let encoded = common::to_string(&bytes);
9960                        match serde_json::from_str(&encoded) {
9961                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9962                            Err(error) => {
9963                                dlg.response_json_decode_error(&encoded, &error);
9964                                return Err(common::Error::JsonDecodeError(
9965                                    encoded.to_string(),
9966                                    error,
9967                                ));
9968                            }
9969                        }
9970                    };
9971
9972                    dlg.finished(true);
9973                    return Ok(response);
9974                }
9975            }
9976        }
9977    }
9978
9979    /// Required. Name of the insight.
9980    ///
9981    /// Sets the *name* path property to the given value.
9982    ///
9983    /// Even though the property as already been set when instantiating this call,
9984    /// we provide this method for API completeness.
9985    pub fn name(mut self, new_value: &str) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
9986        self._name = new_value.to_string();
9987        self
9988    }
9989    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9990    /// while executing the actual API request.
9991    ///
9992    /// ````text
9993    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9994    /// ````
9995    ///
9996    /// Sets the *delegate* property to the given value.
9997    pub fn delegate(
9998        mut self,
9999        new_value: &'a mut dyn common::Delegate,
10000    ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
10001        self._delegate = Some(new_value);
10002        self
10003    }
10004
10005    /// Set any additional parameter of the query string used in the request.
10006    /// It should be used to set parameters which are not yet available through their own
10007    /// setters.
10008    ///
10009    /// Please note that this method must not be used to set any of the known parameters
10010    /// which have their own setter method. If done anyway, the request will fail.
10011    ///
10012    /// # Additional Parameters
10013    ///
10014    /// * *$.xgafv* (query-string) - V1 error format.
10015    /// * *access_token* (query-string) - OAuth access token.
10016    /// * *alt* (query-string) - Data format for response.
10017    /// * *callback* (query-string) - JSONP
10018    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10019    /// * *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.
10020    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10021    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10022    /// * *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.
10023    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10024    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10025    pub fn param<T>(
10026        mut self,
10027        name: T,
10028        value: T,
10029    ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C>
10030    where
10031        T: AsRef<str>,
10032    {
10033        self._additional_params
10034            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10035        self
10036    }
10037
10038    /// Identifies the authorization scope for the method you are building.
10039    ///
10040    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10041    /// [`Scope::CloudPlatform`].
10042    ///
10043    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10044    /// tokens for more than one scope.
10045    ///
10046    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10047    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10048    /// sufficient, a read-write scope will do as well.
10049    pub fn add_scope<St>(
10050        mut self,
10051        scope: St,
10052    ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C>
10053    where
10054        St: AsRef<str>,
10055    {
10056        self._scopes.insert(String::from(scope.as_ref()));
10057        self
10058    }
10059    /// Identifies the authorization scope(s) for the method you are building.
10060    ///
10061    /// See [`Self::add_scope()`] for details.
10062    pub fn add_scopes<I, St>(
10063        mut self,
10064        scopes: I,
10065    ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C>
10066    where
10067        I: IntoIterator<Item = St>,
10068        St: AsRef<str>,
10069    {
10070        self._scopes
10071            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10072        self
10073    }
10074
10075    /// Removes all scopes, and no default scope will be used either.
10076    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10077    /// for details).
10078    pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
10079        self._scopes.clear();
10080        self
10081    }
10082}
10083
10084/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
10085///
10086/// A builder for the *locations.insightTypes.insights.list* method supported by a *organization* resource.
10087/// It is not used directly, but through a [`OrganizationMethods`] instance.
10088///
10089/// # Example
10090///
10091/// Instantiate a resource method builder
10092///
10093/// ```test_harness,no_run
10094/// # extern crate hyper;
10095/// # extern crate hyper_rustls;
10096/// # extern crate google_recommender1 as recommender1;
10097/// # async fn dox() {
10098/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10099///
10100/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10101/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10102/// #     .with_native_roots()
10103/// #     .unwrap()
10104/// #     .https_only()
10105/// #     .enable_http2()
10106/// #     .build();
10107///
10108/// # let executor = hyper_util::rt::TokioExecutor::new();
10109/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10110/// #     secret,
10111/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10112/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10113/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10114/// #     ),
10115/// # ).build().await.unwrap();
10116///
10117/// # let client = hyper_util::client::legacy::Client::builder(
10118/// #     hyper_util::rt::TokioExecutor::new()
10119/// # )
10120/// # .build(
10121/// #     hyper_rustls::HttpsConnectorBuilder::new()
10122/// #         .with_native_roots()
10123/// #         .unwrap()
10124/// #         .https_or_http()
10125/// #         .enable_http2()
10126/// #         .build()
10127/// # );
10128/// # let mut hub = Recommender::new(client, auth);
10129/// // You can configure optional parameters by calling the respective setters at will, and
10130/// // execute the final call using `doit()`.
10131/// // Values shown here are possibly random and not representative !
10132/// let result = hub.organizations().locations_insight_types_insights_list("parent")
10133///              .page_token("Stet")
10134///              .page_size(-13)
10135///              .filter("et")
10136///              .doit().await;
10137/// # }
10138/// ```
10139pub struct OrganizationLocationInsightTypeInsightListCall<'a, C>
10140where
10141    C: 'a,
10142{
10143    hub: &'a Recommender<C>,
10144    _parent: String,
10145    _page_token: Option<String>,
10146    _page_size: Option<i32>,
10147    _filter: Option<String>,
10148    _delegate: Option<&'a mut dyn common::Delegate>,
10149    _additional_params: HashMap<String, String>,
10150    _scopes: BTreeSet<String>,
10151}
10152
10153impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeInsightListCall<'a, C> {}
10154
10155impl<'a, C> OrganizationLocationInsightTypeInsightListCall<'a, C>
10156where
10157    C: common::Connector,
10158{
10159    /// Perform the operation you have build so far.
10160    pub async fn doit(
10161        mut self,
10162    ) -> common::Result<(
10163        common::Response,
10164        GoogleCloudRecommenderV1ListInsightsResponse,
10165    )> {
10166        use std::borrow::Cow;
10167        use std::io::{Read, Seek};
10168
10169        use common::{url::Params, ToParts};
10170        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10171
10172        let mut dd = common::DefaultDelegate;
10173        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10174        dlg.begin(common::MethodInfo {
10175            id: "recommender.organizations.locations.insightTypes.insights.list",
10176            http_method: hyper::Method::GET,
10177        });
10178
10179        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
10180            if self._additional_params.contains_key(field) {
10181                dlg.finished(false);
10182                return Err(common::Error::FieldClash(field));
10183            }
10184        }
10185
10186        let mut params = Params::with_capacity(6 + self._additional_params.len());
10187        params.push("parent", self._parent);
10188        if let Some(value) = self._page_token.as_ref() {
10189            params.push("pageToken", value);
10190        }
10191        if let Some(value) = self._page_size.as_ref() {
10192            params.push("pageSize", value.to_string());
10193        }
10194        if let Some(value) = self._filter.as_ref() {
10195            params.push("filter", value);
10196        }
10197
10198        params.extend(self._additional_params.iter());
10199
10200        params.push("alt", "json");
10201        let mut url = self.hub._base_url.clone() + "v1/{+parent}/insights";
10202        if self._scopes.is_empty() {
10203            self._scopes
10204                .insert(Scope::CloudPlatform.as_ref().to_string());
10205        }
10206
10207        #[allow(clippy::single_element_loop)]
10208        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10209            url = params.uri_replacement(url, param_name, find_this, true);
10210        }
10211        {
10212            let to_remove = ["parent"];
10213            params.remove_params(&to_remove);
10214        }
10215
10216        let url = params.parse_with_url(&url);
10217
10218        loop {
10219            let token = match self
10220                .hub
10221                .auth
10222                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10223                .await
10224            {
10225                Ok(token) => token,
10226                Err(e) => match dlg.token(e) {
10227                    Ok(token) => token,
10228                    Err(e) => {
10229                        dlg.finished(false);
10230                        return Err(common::Error::MissingToken(e));
10231                    }
10232                },
10233            };
10234            let mut req_result = {
10235                let client = &self.hub.client;
10236                dlg.pre_request();
10237                let mut req_builder = hyper::Request::builder()
10238                    .method(hyper::Method::GET)
10239                    .uri(url.as_str())
10240                    .header(USER_AGENT, self.hub._user_agent.clone());
10241
10242                if let Some(token) = token.as_ref() {
10243                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10244                }
10245
10246                let request = req_builder
10247                    .header(CONTENT_LENGTH, 0_u64)
10248                    .body(common::to_body::<String>(None));
10249
10250                client.request(request.unwrap()).await
10251            };
10252
10253            match req_result {
10254                Err(err) => {
10255                    if let common::Retry::After(d) = dlg.http_error(&err) {
10256                        sleep(d).await;
10257                        continue;
10258                    }
10259                    dlg.finished(false);
10260                    return Err(common::Error::HttpError(err));
10261                }
10262                Ok(res) => {
10263                    let (mut parts, body) = res.into_parts();
10264                    let mut body = common::Body::new(body);
10265                    if !parts.status.is_success() {
10266                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10267                        let error = serde_json::from_str(&common::to_string(&bytes));
10268                        let response = common::to_response(parts, bytes.into());
10269
10270                        if let common::Retry::After(d) =
10271                            dlg.http_failure(&response, error.as_ref().ok())
10272                        {
10273                            sleep(d).await;
10274                            continue;
10275                        }
10276
10277                        dlg.finished(false);
10278
10279                        return Err(match error {
10280                            Ok(value) => common::Error::BadRequest(value),
10281                            _ => common::Error::Failure(response),
10282                        });
10283                    }
10284                    let response = {
10285                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10286                        let encoded = common::to_string(&bytes);
10287                        match serde_json::from_str(&encoded) {
10288                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10289                            Err(error) => {
10290                                dlg.response_json_decode_error(&encoded, &error);
10291                                return Err(common::Error::JsonDecodeError(
10292                                    encoded.to_string(),
10293                                    error,
10294                                ));
10295                            }
10296                        }
10297                    };
10298
10299                    dlg.finished(true);
10300                    return Ok(response);
10301                }
10302            }
10303        }
10304    }
10305
10306    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
10307    ///
10308    /// Sets the *parent* path property to the given value.
10309    ///
10310    /// Even though the property as already been set when instantiating this call,
10311    /// we provide this method for API completeness.
10312    pub fn parent(
10313        mut self,
10314        new_value: &str,
10315    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
10316        self._parent = new_value.to_string();
10317        self
10318    }
10319    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
10320    ///
10321    /// Sets the *page token* query property to the given value.
10322    pub fn page_token(
10323        mut self,
10324        new_value: &str,
10325    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
10326        self._page_token = Some(new_value.to_string());
10327        self
10328    }
10329    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
10330    ///
10331    /// Sets the *page size* query property to the given value.
10332    pub fn page_size(
10333        mut self,
10334        new_value: i32,
10335    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
10336        self._page_size = Some(new_value);
10337        self
10338    }
10339    /// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
10340    ///
10341    /// Sets the *filter* query property to the given value.
10342    pub fn filter(
10343        mut self,
10344        new_value: &str,
10345    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
10346        self._filter = Some(new_value.to_string());
10347        self
10348    }
10349    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10350    /// while executing the actual API request.
10351    ///
10352    /// ````text
10353    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10354    /// ````
10355    ///
10356    /// Sets the *delegate* property to the given value.
10357    pub fn delegate(
10358        mut self,
10359        new_value: &'a mut dyn common::Delegate,
10360    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
10361        self._delegate = Some(new_value);
10362        self
10363    }
10364
10365    /// Set any additional parameter of the query string used in the request.
10366    /// It should be used to set parameters which are not yet available through their own
10367    /// setters.
10368    ///
10369    /// Please note that this method must not be used to set any of the known parameters
10370    /// which have their own setter method. If done anyway, the request will fail.
10371    ///
10372    /// # Additional Parameters
10373    ///
10374    /// * *$.xgafv* (query-string) - V1 error format.
10375    /// * *access_token* (query-string) - OAuth access token.
10376    /// * *alt* (query-string) - Data format for response.
10377    /// * *callback* (query-string) - JSONP
10378    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10379    /// * *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.
10380    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10381    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10382    /// * *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.
10383    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10384    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10385    pub fn param<T>(
10386        mut self,
10387        name: T,
10388        value: T,
10389    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C>
10390    where
10391        T: AsRef<str>,
10392    {
10393        self._additional_params
10394            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10395        self
10396    }
10397
10398    /// Identifies the authorization scope for the method you are building.
10399    ///
10400    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10401    /// [`Scope::CloudPlatform`].
10402    ///
10403    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10404    /// tokens for more than one scope.
10405    ///
10406    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10407    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10408    /// sufficient, a read-write scope will do as well.
10409    pub fn add_scope<St>(
10410        mut self,
10411        scope: St,
10412    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C>
10413    where
10414        St: AsRef<str>,
10415    {
10416        self._scopes.insert(String::from(scope.as_ref()));
10417        self
10418    }
10419    /// Identifies the authorization scope(s) for the method you are building.
10420    ///
10421    /// See [`Self::add_scope()`] for details.
10422    pub fn add_scopes<I, St>(
10423        mut self,
10424        scopes: I,
10425    ) -> OrganizationLocationInsightTypeInsightListCall<'a, C>
10426    where
10427        I: IntoIterator<Item = St>,
10428        St: AsRef<str>,
10429    {
10430        self._scopes
10431            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10432        self
10433    }
10434
10435    /// Removes all scopes, and no default scope will be used either.
10436    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10437    /// for details).
10438    pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
10439        self._scopes.clear();
10440        self
10441    }
10442}
10443
10444/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
10445///
10446/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *organization* resource.
10447/// It is not used directly, but through a [`OrganizationMethods`] instance.
10448///
10449/// # Example
10450///
10451/// Instantiate a resource method builder
10452///
10453/// ```test_harness,no_run
10454/// # extern crate hyper;
10455/// # extern crate hyper_rustls;
10456/// # extern crate google_recommender1 as recommender1;
10457/// use recommender1::api::GoogleCloudRecommenderV1MarkInsightAcceptedRequest;
10458/// # async fn dox() {
10459/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10460///
10461/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10462/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10463/// #     .with_native_roots()
10464/// #     .unwrap()
10465/// #     .https_only()
10466/// #     .enable_http2()
10467/// #     .build();
10468///
10469/// # let executor = hyper_util::rt::TokioExecutor::new();
10470/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10471/// #     secret,
10472/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10473/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10474/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10475/// #     ),
10476/// # ).build().await.unwrap();
10477///
10478/// # let client = hyper_util::client::legacy::Client::builder(
10479/// #     hyper_util::rt::TokioExecutor::new()
10480/// # )
10481/// # .build(
10482/// #     hyper_rustls::HttpsConnectorBuilder::new()
10483/// #         .with_native_roots()
10484/// #         .unwrap()
10485/// #         .https_or_http()
10486/// #         .enable_http2()
10487/// #         .build()
10488/// # );
10489/// # let mut hub = Recommender::new(client, auth);
10490/// // As the method needs a request, you would usually fill it with the desired information
10491/// // into the respective structure. Some of the parts shown here might not be applicable !
10492/// // Values shown here are possibly random and not representative !
10493/// let mut req = GoogleCloudRecommenderV1MarkInsightAcceptedRequest::default();
10494///
10495/// // You can configure optional parameters by calling the respective setters at will, and
10496/// // execute the final call using `doit()`.
10497/// // Values shown here are possibly random and not representative !
10498/// let result = hub.organizations().locations_insight_types_insights_mark_accepted(req, "name")
10499///              .doit().await;
10500/// # }
10501/// ```
10502pub struct OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
10503where
10504    C: 'a,
10505{
10506    hub: &'a Recommender<C>,
10507    _request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
10508    _name: String,
10509    _delegate: Option<&'a mut dyn common::Delegate>,
10510    _additional_params: HashMap<String, String>,
10511    _scopes: BTreeSet<String>,
10512}
10513
10514impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {}
10515
10516impl<'a, C> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
10517where
10518    C: common::Connector,
10519{
10520    /// Perform the operation you have build so far.
10521    pub async fn doit(
10522        mut self,
10523    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
10524        use std::borrow::Cow;
10525        use std::io::{Read, Seek};
10526
10527        use common::{url::Params, ToParts};
10528        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10529
10530        let mut dd = common::DefaultDelegate;
10531        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10532        dlg.begin(common::MethodInfo {
10533            id: "recommender.organizations.locations.insightTypes.insights.markAccepted",
10534            http_method: hyper::Method::POST,
10535        });
10536
10537        for &field in ["alt", "name"].iter() {
10538            if self._additional_params.contains_key(field) {
10539                dlg.finished(false);
10540                return Err(common::Error::FieldClash(field));
10541            }
10542        }
10543
10544        let mut params = Params::with_capacity(4 + self._additional_params.len());
10545        params.push("name", self._name);
10546
10547        params.extend(self._additional_params.iter());
10548
10549        params.push("alt", "json");
10550        let mut url = self.hub._base_url.clone() + "v1/{+name}:markAccepted";
10551        if self._scopes.is_empty() {
10552            self._scopes
10553                .insert(Scope::CloudPlatform.as_ref().to_string());
10554        }
10555
10556        #[allow(clippy::single_element_loop)]
10557        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10558            url = params.uri_replacement(url, param_name, find_this, true);
10559        }
10560        {
10561            let to_remove = ["name"];
10562            params.remove_params(&to_remove);
10563        }
10564
10565        let url = params.parse_with_url(&url);
10566
10567        let mut json_mime_type = mime::APPLICATION_JSON;
10568        let mut request_value_reader = {
10569            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10570            common::remove_json_null_values(&mut value);
10571            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10572            serde_json::to_writer(&mut dst, &value).unwrap();
10573            dst
10574        };
10575        let request_size = request_value_reader
10576            .seek(std::io::SeekFrom::End(0))
10577            .unwrap();
10578        request_value_reader
10579            .seek(std::io::SeekFrom::Start(0))
10580            .unwrap();
10581
10582        loop {
10583            let token = match self
10584                .hub
10585                .auth
10586                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10587                .await
10588            {
10589                Ok(token) => token,
10590                Err(e) => match dlg.token(e) {
10591                    Ok(token) => token,
10592                    Err(e) => {
10593                        dlg.finished(false);
10594                        return Err(common::Error::MissingToken(e));
10595                    }
10596                },
10597            };
10598            request_value_reader
10599                .seek(std::io::SeekFrom::Start(0))
10600                .unwrap();
10601            let mut req_result = {
10602                let client = &self.hub.client;
10603                dlg.pre_request();
10604                let mut req_builder = hyper::Request::builder()
10605                    .method(hyper::Method::POST)
10606                    .uri(url.as_str())
10607                    .header(USER_AGENT, self.hub._user_agent.clone());
10608
10609                if let Some(token) = token.as_ref() {
10610                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10611                }
10612
10613                let request = req_builder
10614                    .header(CONTENT_TYPE, json_mime_type.to_string())
10615                    .header(CONTENT_LENGTH, request_size as u64)
10616                    .body(common::to_body(
10617                        request_value_reader.get_ref().clone().into(),
10618                    ));
10619
10620                client.request(request.unwrap()).await
10621            };
10622
10623            match req_result {
10624                Err(err) => {
10625                    if let common::Retry::After(d) = dlg.http_error(&err) {
10626                        sleep(d).await;
10627                        continue;
10628                    }
10629                    dlg.finished(false);
10630                    return Err(common::Error::HttpError(err));
10631                }
10632                Ok(res) => {
10633                    let (mut parts, body) = res.into_parts();
10634                    let mut body = common::Body::new(body);
10635                    if !parts.status.is_success() {
10636                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10637                        let error = serde_json::from_str(&common::to_string(&bytes));
10638                        let response = common::to_response(parts, bytes.into());
10639
10640                        if let common::Retry::After(d) =
10641                            dlg.http_failure(&response, error.as_ref().ok())
10642                        {
10643                            sleep(d).await;
10644                            continue;
10645                        }
10646
10647                        dlg.finished(false);
10648
10649                        return Err(match error {
10650                            Ok(value) => common::Error::BadRequest(value),
10651                            _ => common::Error::Failure(response),
10652                        });
10653                    }
10654                    let response = {
10655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10656                        let encoded = common::to_string(&bytes);
10657                        match serde_json::from_str(&encoded) {
10658                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10659                            Err(error) => {
10660                                dlg.response_json_decode_error(&encoded, &error);
10661                                return Err(common::Error::JsonDecodeError(
10662                                    encoded.to_string(),
10663                                    error,
10664                                ));
10665                            }
10666                        }
10667                    };
10668
10669                    dlg.finished(true);
10670                    return Ok(response);
10671                }
10672            }
10673        }
10674    }
10675
10676    ///
10677    /// Sets the *request* property to the given value.
10678    ///
10679    /// Even though the property as already been set when instantiating this call,
10680    /// we provide this method for API completeness.
10681    pub fn request(
10682        mut self,
10683        new_value: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
10684    ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
10685        self._request = new_value;
10686        self
10687    }
10688    /// Required. Name of the insight.
10689    ///
10690    /// Sets the *name* path property to the given value.
10691    ///
10692    /// Even though the property as already been set when instantiating this call,
10693    /// we provide this method for API completeness.
10694    pub fn name(
10695        mut self,
10696        new_value: &str,
10697    ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
10698        self._name = new_value.to_string();
10699        self
10700    }
10701    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10702    /// while executing the actual API request.
10703    ///
10704    /// ````text
10705    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10706    /// ````
10707    ///
10708    /// Sets the *delegate* property to the given value.
10709    pub fn delegate(
10710        mut self,
10711        new_value: &'a mut dyn common::Delegate,
10712    ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
10713        self._delegate = Some(new_value);
10714        self
10715    }
10716
10717    /// Set any additional parameter of the query string used in the request.
10718    /// It should be used to set parameters which are not yet available through their own
10719    /// setters.
10720    ///
10721    /// Please note that this method must not be used to set any of the known parameters
10722    /// which have their own setter method. If done anyway, the request will fail.
10723    ///
10724    /// # Additional Parameters
10725    ///
10726    /// * *$.xgafv* (query-string) - V1 error format.
10727    /// * *access_token* (query-string) - OAuth access token.
10728    /// * *alt* (query-string) - Data format for response.
10729    /// * *callback* (query-string) - JSONP
10730    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10731    /// * *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.
10732    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10733    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10734    /// * *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.
10735    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10736    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10737    pub fn param<T>(
10738        mut self,
10739        name: T,
10740        value: T,
10741    ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
10742    where
10743        T: AsRef<str>,
10744    {
10745        self._additional_params
10746            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10747        self
10748    }
10749
10750    /// Identifies the authorization scope for the method you are building.
10751    ///
10752    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10753    /// [`Scope::CloudPlatform`].
10754    ///
10755    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10756    /// tokens for more than one scope.
10757    ///
10758    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10759    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10760    /// sufficient, a read-write scope will do as well.
10761    pub fn add_scope<St>(
10762        mut self,
10763        scope: St,
10764    ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
10765    where
10766        St: AsRef<str>,
10767    {
10768        self._scopes.insert(String::from(scope.as_ref()));
10769        self
10770    }
10771    /// Identifies the authorization scope(s) for the method you are building.
10772    ///
10773    /// See [`Self::add_scope()`] for details.
10774    pub fn add_scopes<I, St>(
10775        mut self,
10776        scopes: I,
10777    ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
10778    where
10779        I: IntoIterator<Item = St>,
10780        St: AsRef<str>,
10781    {
10782        self._scopes
10783            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10784        self
10785    }
10786
10787    /// Removes all scopes, and no default scope will be used either.
10788    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10789    /// for details).
10790    pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
10791        self._scopes.clear();
10792        self
10793    }
10794}
10795
10796/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
10797///
10798/// A builder for the *locations.insightTypes.getConfig* method supported by a *organization* resource.
10799/// It is not used directly, but through a [`OrganizationMethods`] instance.
10800///
10801/// # Example
10802///
10803/// Instantiate a resource method builder
10804///
10805/// ```test_harness,no_run
10806/// # extern crate hyper;
10807/// # extern crate hyper_rustls;
10808/// # extern crate google_recommender1 as recommender1;
10809/// # async fn dox() {
10810/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10811///
10812/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10813/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10814/// #     .with_native_roots()
10815/// #     .unwrap()
10816/// #     .https_only()
10817/// #     .enable_http2()
10818/// #     .build();
10819///
10820/// # let executor = hyper_util::rt::TokioExecutor::new();
10821/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10822/// #     secret,
10823/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10824/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10825/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10826/// #     ),
10827/// # ).build().await.unwrap();
10828///
10829/// # let client = hyper_util::client::legacy::Client::builder(
10830/// #     hyper_util::rt::TokioExecutor::new()
10831/// # )
10832/// # .build(
10833/// #     hyper_rustls::HttpsConnectorBuilder::new()
10834/// #         .with_native_roots()
10835/// #         .unwrap()
10836/// #         .https_or_http()
10837/// #         .enable_http2()
10838/// #         .build()
10839/// # );
10840/// # let mut hub = Recommender::new(client, auth);
10841/// // You can configure optional parameters by calling the respective setters at will, and
10842/// // execute the final call using `doit()`.
10843/// // Values shown here are possibly random and not representative !
10844/// let result = hub.organizations().locations_insight_types_get_config("name")
10845///              .doit().await;
10846/// # }
10847/// ```
10848pub struct OrganizationLocationInsightTypeGetConfigCall<'a, C>
10849where
10850    C: 'a,
10851{
10852    hub: &'a Recommender<C>,
10853    _name: String,
10854    _delegate: Option<&'a mut dyn common::Delegate>,
10855    _additional_params: HashMap<String, String>,
10856    _scopes: BTreeSet<String>,
10857}
10858
10859impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeGetConfigCall<'a, C> {}
10860
10861impl<'a, C> OrganizationLocationInsightTypeGetConfigCall<'a, C>
10862where
10863    C: common::Connector,
10864{
10865    /// Perform the operation you have build so far.
10866    pub async fn doit(
10867        mut self,
10868    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1InsightTypeConfig)> {
10869        use std::borrow::Cow;
10870        use std::io::{Read, Seek};
10871
10872        use common::{url::Params, ToParts};
10873        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10874
10875        let mut dd = common::DefaultDelegate;
10876        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10877        dlg.begin(common::MethodInfo {
10878            id: "recommender.organizations.locations.insightTypes.getConfig",
10879            http_method: hyper::Method::GET,
10880        });
10881
10882        for &field in ["alt", "name"].iter() {
10883            if self._additional_params.contains_key(field) {
10884                dlg.finished(false);
10885                return Err(common::Error::FieldClash(field));
10886            }
10887        }
10888
10889        let mut params = Params::with_capacity(3 + self._additional_params.len());
10890        params.push("name", self._name);
10891
10892        params.extend(self._additional_params.iter());
10893
10894        params.push("alt", "json");
10895        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10896        if self._scopes.is_empty() {
10897            self._scopes
10898                .insert(Scope::CloudPlatform.as_ref().to_string());
10899        }
10900
10901        #[allow(clippy::single_element_loop)]
10902        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10903            url = params.uri_replacement(url, param_name, find_this, true);
10904        }
10905        {
10906            let to_remove = ["name"];
10907            params.remove_params(&to_remove);
10908        }
10909
10910        let url = params.parse_with_url(&url);
10911
10912        loop {
10913            let token = match self
10914                .hub
10915                .auth
10916                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10917                .await
10918            {
10919                Ok(token) => token,
10920                Err(e) => match dlg.token(e) {
10921                    Ok(token) => token,
10922                    Err(e) => {
10923                        dlg.finished(false);
10924                        return Err(common::Error::MissingToken(e));
10925                    }
10926                },
10927            };
10928            let mut req_result = {
10929                let client = &self.hub.client;
10930                dlg.pre_request();
10931                let mut req_builder = hyper::Request::builder()
10932                    .method(hyper::Method::GET)
10933                    .uri(url.as_str())
10934                    .header(USER_AGENT, self.hub._user_agent.clone());
10935
10936                if let Some(token) = token.as_ref() {
10937                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10938                }
10939
10940                let request = req_builder
10941                    .header(CONTENT_LENGTH, 0_u64)
10942                    .body(common::to_body::<String>(None));
10943
10944                client.request(request.unwrap()).await
10945            };
10946
10947            match req_result {
10948                Err(err) => {
10949                    if let common::Retry::After(d) = dlg.http_error(&err) {
10950                        sleep(d).await;
10951                        continue;
10952                    }
10953                    dlg.finished(false);
10954                    return Err(common::Error::HttpError(err));
10955                }
10956                Ok(res) => {
10957                    let (mut parts, body) = res.into_parts();
10958                    let mut body = common::Body::new(body);
10959                    if !parts.status.is_success() {
10960                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10961                        let error = serde_json::from_str(&common::to_string(&bytes));
10962                        let response = common::to_response(parts, bytes.into());
10963
10964                        if let common::Retry::After(d) =
10965                            dlg.http_failure(&response, error.as_ref().ok())
10966                        {
10967                            sleep(d).await;
10968                            continue;
10969                        }
10970
10971                        dlg.finished(false);
10972
10973                        return Err(match error {
10974                            Ok(value) => common::Error::BadRequest(value),
10975                            _ => common::Error::Failure(response),
10976                        });
10977                    }
10978                    let response = {
10979                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10980                        let encoded = common::to_string(&bytes);
10981                        match serde_json::from_str(&encoded) {
10982                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10983                            Err(error) => {
10984                                dlg.response_json_decode_error(&encoded, &error);
10985                                return Err(common::Error::JsonDecodeError(
10986                                    encoded.to_string(),
10987                                    error,
10988                                ));
10989                            }
10990                        }
10991                    };
10992
10993                    dlg.finished(true);
10994                    return Ok(response);
10995                }
10996            }
10997        }
10998    }
10999
11000    /// Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
11001    ///
11002    /// Sets the *name* path property to the given value.
11003    ///
11004    /// Even though the property as already been set when instantiating this call,
11005    /// we provide this method for API completeness.
11006    pub fn name(mut self, new_value: &str) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
11007        self._name = new_value.to_string();
11008        self
11009    }
11010    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11011    /// while executing the actual API request.
11012    ///
11013    /// ````text
11014    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11015    /// ````
11016    ///
11017    /// Sets the *delegate* property to the given value.
11018    pub fn delegate(
11019        mut self,
11020        new_value: &'a mut dyn common::Delegate,
11021    ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
11022        self._delegate = Some(new_value);
11023        self
11024    }
11025
11026    /// Set any additional parameter of the query string used in the request.
11027    /// It should be used to set parameters which are not yet available through their own
11028    /// setters.
11029    ///
11030    /// Please note that this method must not be used to set any of the known parameters
11031    /// which have their own setter method. If done anyway, the request will fail.
11032    ///
11033    /// # Additional Parameters
11034    ///
11035    /// * *$.xgafv* (query-string) - V1 error format.
11036    /// * *access_token* (query-string) - OAuth access token.
11037    /// * *alt* (query-string) - Data format for response.
11038    /// * *callback* (query-string) - JSONP
11039    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11040    /// * *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.
11041    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11042    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11043    /// * *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.
11044    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11045    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11046    pub fn param<T>(
11047        mut self,
11048        name: T,
11049        value: T,
11050    ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C>
11051    where
11052        T: AsRef<str>,
11053    {
11054        self._additional_params
11055            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11056        self
11057    }
11058
11059    /// Identifies the authorization scope for the method you are building.
11060    ///
11061    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11062    /// [`Scope::CloudPlatform`].
11063    ///
11064    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11065    /// tokens for more than one scope.
11066    ///
11067    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11068    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11069    /// sufficient, a read-write scope will do as well.
11070    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationInsightTypeGetConfigCall<'a, C>
11071    where
11072        St: AsRef<str>,
11073    {
11074        self._scopes.insert(String::from(scope.as_ref()));
11075        self
11076    }
11077    /// Identifies the authorization scope(s) for the method you are building.
11078    ///
11079    /// See [`Self::add_scope()`] for details.
11080    pub fn add_scopes<I, St>(
11081        mut self,
11082        scopes: I,
11083    ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C>
11084    where
11085        I: IntoIterator<Item = St>,
11086        St: AsRef<str>,
11087    {
11088        self._scopes
11089            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11090        self
11091    }
11092
11093    /// Removes all scopes, and no default scope will be used either.
11094    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11095    /// for details).
11096    pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
11097        self._scopes.clear();
11098        self
11099    }
11100}
11101
11102/// Updates an InsightTypeConfig change. This will create a new revision of the config.
11103///
11104/// A builder for the *locations.insightTypes.updateConfig* method supported by a *organization* resource.
11105/// It is not used directly, but through a [`OrganizationMethods`] instance.
11106///
11107/// # Example
11108///
11109/// Instantiate a resource method builder
11110///
11111/// ```test_harness,no_run
11112/// # extern crate hyper;
11113/// # extern crate hyper_rustls;
11114/// # extern crate google_recommender1 as recommender1;
11115/// use recommender1::api::GoogleCloudRecommenderV1InsightTypeConfig;
11116/// # async fn dox() {
11117/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11118///
11119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11120/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11121/// #     .with_native_roots()
11122/// #     .unwrap()
11123/// #     .https_only()
11124/// #     .enable_http2()
11125/// #     .build();
11126///
11127/// # let executor = hyper_util::rt::TokioExecutor::new();
11128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11129/// #     secret,
11130/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11131/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11132/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11133/// #     ),
11134/// # ).build().await.unwrap();
11135///
11136/// # let client = hyper_util::client::legacy::Client::builder(
11137/// #     hyper_util::rt::TokioExecutor::new()
11138/// # )
11139/// # .build(
11140/// #     hyper_rustls::HttpsConnectorBuilder::new()
11141/// #         .with_native_roots()
11142/// #         .unwrap()
11143/// #         .https_or_http()
11144/// #         .enable_http2()
11145/// #         .build()
11146/// # );
11147/// # let mut hub = Recommender::new(client, auth);
11148/// // As the method needs a request, you would usually fill it with the desired information
11149/// // into the respective structure. Some of the parts shown here might not be applicable !
11150/// // Values shown here are possibly random and not representative !
11151/// let mut req = GoogleCloudRecommenderV1InsightTypeConfig::default();
11152///
11153/// // You can configure optional parameters by calling the respective setters at will, and
11154/// // execute the final call using `doit()`.
11155/// // Values shown here are possibly random and not representative !
11156/// let result = hub.organizations().locations_insight_types_update_config(req, "name")
11157///              .validate_only(false)
11158///              .update_mask(FieldMask::new::<&str>(&[]))
11159///              .doit().await;
11160/// # }
11161/// ```
11162pub struct OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
11163where
11164    C: 'a,
11165{
11166    hub: &'a Recommender<C>,
11167    _request: GoogleCloudRecommenderV1InsightTypeConfig,
11168    _name: String,
11169    _validate_only: Option<bool>,
11170    _update_mask: Option<common::FieldMask>,
11171    _delegate: Option<&'a mut dyn common::Delegate>,
11172    _additional_params: HashMap<String, String>,
11173    _scopes: BTreeSet<String>,
11174}
11175
11176impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {}
11177
11178impl<'a, C> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
11179where
11180    C: common::Connector,
11181{
11182    /// Perform the operation you have build so far.
11183    pub async fn doit(
11184        mut self,
11185    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1InsightTypeConfig)> {
11186        use std::borrow::Cow;
11187        use std::io::{Read, Seek};
11188
11189        use common::{url::Params, ToParts};
11190        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11191
11192        let mut dd = common::DefaultDelegate;
11193        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11194        dlg.begin(common::MethodInfo {
11195            id: "recommender.organizations.locations.insightTypes.updateConfig",
11196            http_method: hyper::Method::PATCH,
11197        });
11198
11199        for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
11200            if self._additional_params.contains_key(field) {
11201                dlg.finished(false);
11202                return Err(common::Error::FieldClash(field));
11203            }
11204        }
11205
11206        let mut params = Params::with_capacity(6 + self._additional_params.len());
11207        params.push("name", self._name);
11208        if let Some(value) = self._validate_only.as_ref() {
11209            params.push("validateOnly", value.to_string());
11210        }
11211        if let Some(value) = self._update_mask.as_ref() {
11212            params.push("updateMask", value.to_string());
11213        }
11214
11215        params.extend(self._additional_params.iter());
11216
11217        params.push("alt", "json");
11218        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11219        if self._scopes.is_empty() {
11220            self._scopes
11221                .insert(Scope::CloudPlatform.as_ref().to_string());
11222        }
11223
11224        #[allow(clippy::single_element_loop)]
11225        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11226            url = params.uri_replacement(url, param_name, find_this, true);
11227        }
11228        {
11229            let to_remove = ["name"];
11230            params.remove_params(&to_remove);
11231        }
11232
11233        let url = params.parse_with_url(&url);
11234
11235        let mut json_mime_type = mime::APPLICATION_JSON;
11236        let mut request_value_reader = {
11237            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11238            common::remove_json_null_values(&mut value);
11239            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11240            serde_json::to_writer(&mut dst, &value).unwrap();
11241            dst
11242        };
11243        let request_size = request_value_reader
11244            .seek(std::io::SeekFrom::End(0))
11245            .unwrap();
11246        request_value_reader
11247            .seek(std::io::SeekFrom::Start(0))
11248            .unwrap();
11249
11250        loop {
11251            let token = match self
11252                .hub
11253                .auth
11254                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11255                .await
11256            {
11257                Ok(token) => token,
11258                Err(e) => match dlg.token(e) {
11259                    Ok(token) => token,
11260                    Err(e) => {
11261                        dlg.finished(false);
11262                        return Err(common::Error::MissingToken(e));
11263                    }
11264                },
11265            };
11266            request_value_reader
11267                .seek(std::io::SeekFrom::Start(0))
11268                .unwrap();
11269            let mut req_result = {
11270                let client = &self.hub.client;
11271                dlg.pre_request();
11272                let mut req_builder = hyper::Request::builder()
11273                    .method(hyper::Method::PATCH)
11274                    .uri(url.as_str())
11275                    .header(USER_AGENT, self.hub._user_agent.clone());
11276
11277                if let Some(token) = token.as_ref() {
11278                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11279                }
11280
11281                let request = req_builder
11282                    .header(CONTENT_TYPE, json_mime_type.to_string())
11283                    .header(CONTENT_LENGTH, request_size as u64)
11284                    .body(common::to_body(
11285                        request_value_reader.get_ref().clone().into(),
11286                    ));
11287
11288                client.request(request.unwrap()).await
11289            };
11290
11291            match req_result {
11292                Err(err) => {
11293                    if let common::Retry::After(d) = dlg.http_error(&err) {
11294                        sleep(d).await;
11295                        continue;
11296                    }
11297                    dlg.finished(false);
11298                    return Err(common::Error::HttpError(err));
11299                }
11300                Ok(res) => {
11301                    let (mut parts, body) = res.into_parts();
11302                    let mut body = common::Body::new(body);
11303                    if !parts.status.is_success() {
11304                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11305                        let error = serde_json::from_str(&common::to_string(&bytes));
11306                        let response = common::to_response(parts, bytes.into());
11307
11308                        if let common::Retry::After(d) =
11309                            dlg.http_failure(&response, error.as_ref().ok())
11310                        {
11311                            sleep(d).await;
11312                            continue;
11313                        }
11314
11315                        dlg.finished(false);
11316
11317                        return Err(match error {
11318                            Ok(value) => common::Error::BadRequest(value),
11319                            _ => common::Error::Failure(response),
11320                        });
11321                    }
11322                    let response = {
11323                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11324                        let encoded = common::to_string(&bytes);
11325                        match serde_json::from_str(&encoded) {
11326                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11327                            Err(error) => {
11328                                dlg.response_json_decode_error(&encoded, &error);
11329                                return Err(common::Error::JsonDecodeError(
11330                                    encoded.to_string(),
11331                                    error,
11332                                ));
11333                            }
11334                        }
11335                    };
11336
11337                    dlg.finished(true);
11338                    return Ok(response);
11339                }
11340            }
11341        }
11342    }
11343
11344    ///
11345    /// Sets the *request* property to the given value.
11346    ///
11347    /// Even though the property as already been set when instantiating this call,
11348    /// we provide this method for API completeness.
11349    pub fn request(
11350        mut self,
11351        new_value: GoogleCloudRecommenderV1InsightTypeConfig,
11352    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
11353        self._request = new_value;
11354        self
11355    }
11356    /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
11357    ///
11358    /// Sets the *name* path property to the given value.
11359    ///
11360    /// Even though the property as already been set when instantiating this call,
11361    /// we provide this method for API completeness.
11362    pub fn name(
11363        mut self,
11364        new_value: &str,
11365    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
11366        self._name = new_value.to_string();
11367        self
11368    }
11369    /// If true, validate the request and preview the change, but do not actually update it.
11370    ///
11371    /// Sets the *validate only* query property to the given value.
11372    pub fn validate_only(
11373        mut self,
11374        new_value: bool,
11375    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
11376        self._validate_only = Some(new_value);
11377        self
11378    }
11379    /// The list of fields to be updated.
11380    ///
11381    /// Sets the *update mask* query property to the given value.
11382    pub fn update_mask(
11383        mut self,
11384        new_value: common::FieldMask,
11385    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
11386        self._update_mask = Some(new_value);
11387        self
11388    }
11389    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11390    /// while executing the actual API request.
11391    ///
11392    /// ````text
11393    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11394    /// ````
11395    ///
11396    /// Sets the *delegate* property to the given value.
11397    pub fn delegate(
11398        mut self,
11399        new_value: &'a mut dyn common::Delegate,
11400    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
11401        self._delegate = Some(new_value);
11402        self
11403    }
11404
11405    /// Set any additional parameter of the query string used in the request.
11406    /// It should be used to set parameters which are not yet available through their own
11407    /// setters.
11408    ///
11409    /// Please note that this method must not be used to set any of the known parameters
11410    /// which have their own setter method. If done anyway, the request will fail.
11411    ///
11412    /// # Additional Parameters
11413    ///
11414    /// * *$.xgafv* (query-string) - V1 error format.
11415    /// * *access_token* (query-string) - OAuth access token.
11416    /// * *alt* (query-string) - Data format for response.
11417    /// * *callback* (query-string) - JSONP
11418    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11419    /// * *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.
11420    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11421    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11422    /// * *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.
11423    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11424    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11425    pub fn param<T>(
11426        mut self,
11427        name: T,
11428        value: T,
11429    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
11430    where
11431        T: AsRef<str>,
11432    {
11433        self._additional_params
11434            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11435        self
11436    }
11437
11438    /// Identifies the authorization scope for the method you are building.
11439    ///
11440    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11441    /// [`Scope::CloudPlatform`].
11442    ///
11443    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11444    /// tokens for more than one scope.
11445    ///
11446    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11447    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11448    /// sufficient, a read-write scope will do as well.
11449    pub fn add_scope<St>(
11450        mut self,
11451        scope: St,
11452    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
11453    where
11454        St: AsRef<str>,
11455    {
11456        self._scopes.insert(String::from(scope.as_ref()));
11457        self
11458    }
11459    /// Identifies the authorization scope(s) for the method you are building.
11460    ///
11461    /// See [`Self::add_scope()`] for details.
11462    pub fn add_scopes<I, St>(
11463        mut self,
11464        scopes: I,
11465    ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
11466    where
11467        I: IntoIterator<Item = St>,
11468        St: AsRef<str>,
11469    {
11470        self._scopes
11471            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11472        self
11473    }
11474
11475    /// Removes all scopes, and no default scope will be used either.
11476    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11477    /// for details).
11478    pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
11479        self._scopes.clear();
11480        self
11481    }
11482}
11483
11484/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
11485///
11486/// A builder for the *locations.recommenders.recommendations.get* method supported by a *organization* resource.
11487/// It is not used directly, but through a [`OrganizationMethods`] instance.
11488///
11489/// # Example
11490///
11491/// Instantiate a resource method builder
11492///
11493/// ```test_harness,no_run
11494/// # extern crate hyper;
11495/// # extern crate hyper_rustls;
11496/// # extern crate google_recommender1 as recommender1;
11497/// # async fn dox() {
11498/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11499///
11500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11501/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11502/// #     .with_native_roots()
11503/// #     .unwrap()
11504/// #     .https_only()
11505/// #     .enable_http2()
11506/// #     .build();
11507///
11508/// # let executor = hyper_util::rt::TokioExecutor::new();
11509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11510/// #     secret,
11511/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11512/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11513/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11514/// #     ),
11515/// # ).build().await.unwrap();
11516///
11517/// # let client = hyper_util::client::legacy::Client::builder(
11518/// #     hyper_util::rt::TokioExecutor::new()
11519/// # )
11520/// # .build(
11521/// #     hyper_rustls::HttpsConnectorBuilder::new()
11522/// #         .with_native_roots()
11523/// #         .unwrap()
11524/// #         .https_or_http()
11525/// #         .enable_http2()
11526/// #         .build()
11527/// # );
11528/// # let mut hub = Recommender::new(client, auth);
11529/// // You can configure optional parameters by calling the respective setters at will, and
11530/// // execute the final call using `doit()`.
11531/// // Values shown here are possibly random and not representative !
11532/// let result = hub.organizations().locations_recommenders_recommendations_get("name")
11533///              .doit().await;
11534/// # }
11535/// ```
11536pub struct OrganizationLocationRecommenderRecommendationGetCall<'a, C>
11537where
11538    C: 'a,
11539{
11540    hub: &'a Recommender<C>,
11541    _name: String,
11542    _delegate: Option<&'a mut dyn common::Delegate>,
11543    _additional_params: HashMap<String, String>,
11544    _scopes: BTreeSet<String>,
11545}
11546
11547impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderRecommendationGetCall<'a, C> {}
11548
11549impl<'a, C> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
11550where
11551    C: common::Connector,
11552{
11553    /// Perform the operation you have build so far.
11554    pub async fn doit(
11555        mut self,
11556    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
11557        use std::borrow::Cow;
11558        use std::io::{Read, Seek};
11559
11560        use common::{url::Params, ToParts};
11561        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11562
11563        let mut dd = common::DefaultDelegate;
11564        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11565        dlg.begin(common::MethodInfo {
11566            id: "recommender.organizations.locations.recommenders.recommendations.get",
11567            http_method: hyper::Method::GET,
11568        });
11569
11570        for &field in ["alt", "name"].iter() {
11571            if self._additional_params.contains_key(field) {
11572                dlg.finished(false);
11573                return Err(common::Error::FieldClash(field));
11574            }
11575        }
11576
11577        let mut params = Params::with_capacity(3 + self._additional_params.len());
11578        params.push("name", self._name);
11579
11580        params.extend(self._additional_params.iter());
11581
11582        params.push("alt", "json");
11583        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11584        if self._scopes.is_empty() {
11585            self._scopes
11586                .insert(Scope::CloudPlatform.as_ref().to_string());
11587        }
11588
11589        #[allow(clippy::single_element_loop)]
11590        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11591            url = params.uri_replacement(url, param_name, find_this, true);
11592        }
11593        {
11594            let to_remove = ["name"];
11595            params.remove_params(&to_remove);
11596        }
11597
11598        let url = params.parse_with_url(&url);
11599
11600        loop {
11601            let token = match self
11602                .hub
11603                .auth
11604                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11605                .await
11606            {
11607                Ok(token) => token,
11608                Err(e) => match dlg.token(e) {
11609                    Ok(token) => token,
11610                    Err(e) => {
11611                        dlg.finished(false);
11612                        return Err(common::Error::MissingToken(e));
11613                    }
11614                },
11615            };
11616            let mut req_result = {
11617                let client = &self.hub.client;
11618                dlg.pre_request();
11619                let mut req_builder = hyper::Request::builder()
11620                    .method(hyper::Method::GET)
11621                    .uri(url.as_str())
11622                    .header(USER_AGENT, self.hub._user_agent.clone());
11623
11624                if let Some(token) = token.as_ref() {
11625                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11626                }
11627
11628                let request = req_builder
11629                    .header(CONTENT_LENGTH, 0_u64)
11630                    .body(common::to_body::<String>(None));
11631
11632                client.request(request.unwrap()).await
11633            };
11634
11635            match req_result {
11636                Err(err) => {
11637                    if let common::Retry::After(d) = dlg.http_error(&err) {
11638                        sleep(d).await;
11639                        continue;
11640                    }
11641                    dlg.finished(false);
11642                    return Err(common::Error::HttpError(err));
11643                }
11644                Ok(res) => {
11645                    let (mut parts, body) = res.into_parts();
11646                    let mut body = common::Body::new(body);
11647                    if !parts.status.is_success() {
11648                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11649                        let error = serde_json::from_str(&common::to_string(&bytes));
11650                        let response = common::to_response(parts, bytes.into());
11651
11652                        if let common::Retry::After(d) =
11653                            dlg.http_failure(&response, error.as_ref().ok())
11654                        {
11655                            sleep(d).await;
11656                            continue;
11657                        }
11658
11659                        dlg.finished(false);
11660
11661                        return Err(match error {
11662                            Ok(value) => common::Error::BadRequest(value),
11663                            _ => common::Error::Failure(response),
11664                        });
11665                    }
11666                    let response = {
11667                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11668                        let encoded = common::to_string(&bytes);
11669                        match serde_json::from_str(&encoded) {
11670                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11671                            Err(error) => {
11672                                dlg.response_json_decode_error(&encoded, &error);
11673                                return Err(common::Error::JsonDecodeError(
11674                                    encoded.to_string(),
11675                                    error,
11676                                ));
11677                            }
11678                        }
11679                    };
11680
11681                    dlg.finished(true);
11682                    return Ok(response);
11683                }
11684            }
11685        }
11686    }
11687
11688    /// Required. Name of the recommendation.
11689    ///
11690    /// Sets the *name* path property to the given value.
11691    ///
11692    /// Even though the property as already been set when instantiating this call,
11693    /// we provide this method for API completeness.
11694    pub fn name(
11695        mut self,
11696        new_value: &str,
11697    ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
11698        self._name = new_value.to_string();
11699        self
11700    }
11701    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11702    /// while executing the actual API request.
11703    ///
11704    /// ````text
11705    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11706    /// ````
11707    ///
11708    /// Sets the *delegate* property to the given value.
11709    pub fn delegate(
11710        mut self,
11711        new_value: &'a mut dyn common::Delegate,
11712    ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
11713        self._delegate = Some(new_value);
11714        self
11715    }
11716
11717    /// Set any additional parameter of the query string used in the request.
11718    /// It should be used to set parameters which are not yet available through their own
11719    /// setters.
11720    ///
11721    /// Please note that this method must not be used to set any of the known parameters
11722    /// which have their own setter method. If done anyway, the request will fail.
11723    ///
11724    /// # Additional Parameters
11725    ///
11726    /// * *$.xgafv* (query-string) - V1 error format.
11727    /// * *access_token* (query-string) - OAuth access token.
11728    /// * *alt* (query-string) - Data format for response.
11729    /// * *callback* (query-string) - JSONP
11730    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11731    /// * *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.
11732    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11733    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11734    /// * *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.
11735    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11736    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11737    pub fn param<T>(
11738        mut self,
11739        name: T,
11740        value: T,
11741    ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
11742    where
11743        T: AsRef<str>,
11744    {
11745        self._additional_params
11746            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11747        self
11748    }
11749
11750    /// Identifies the authorization scope for the method you are building.
11751    ///
11752    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11753    /// [`Scope::CloudPlatform`].
11754    ///
11755    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11756    /// tokens for more than one scope.
11757    ///
11758    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11759    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11760    /// sufficient, a read-write scope will do as well.
11761    pub fn add_scope<St>(
11762        mut self,
11763        scope: St,
11764    ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
11765    where
11766        St: AsRef<str>,
11767    {
11768        self._scopes.insert(String::from(scope.as_ref()));
11769        self
11770    }
11771    /// Identifies the authorization scope(s) for the method you are building.
11772    ///
11773    /// See [`Self::add_scope()`] for details.
11774    pub fn add_scopes<I, St>(
11775        mut self,
11776        scopes: I,
11777    ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
11778    where
11779        I: IntoIterator<Item = St>,
11780        St: AsRef<str>,
11781    {
11782        self._scopes
11783            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11784        self
11785    }
11786
11787    /// Removes all scopes, and no default scope will be used either.
11788    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11789    /// for details).
11790    pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
11791        self._scopes.clear();
11792        self
11793    }
11794}
11795
11796/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
11797///
11798/// A builder for the *locations.recommenders.recommendations.list* method supported by a *organization* resource.
11799/// It is not used directly, but through a [`OrganizationMethods`] instance.
11800///
11801/// # Example
11802///
11803/// Instantiate a resource method builder
11804///
11805/// ```test_harness,no_run
11806/// # extern crate hyper;
11807/// # extern crate hyper_rustls;
11808/// # extern crate google_recommender1 as recommender1;
11809/// # async fn dox() {
11810/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11811///
11812/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11813/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11814/// #     .with_native_roots()
11815/// #     .unwrap()
11816/// #     .https_only()
11817/// #     .enable_http2()
11818/// #     .build();
11819///
11820/// # let executor = hyper_util::rt::TokioExecutor::new();
11821/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11822/// #     secret,
11823/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11824/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11825/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11826/// #     ),
11827/// # ).build().await.unwrap();
11828///
11829/// # let client = hyper_util::client::legacy::Client::builder(
11830/// #     hyper_util::rt::TokioExecutor::new()
11831/// # )
11832/// # .build(
11833/// #     hyper_rustls::HttpsConnectorBuilder::new()
11834/// #         .with_native_roots()
11835/// #         .unwrap()
11836/// #         .https_or_http()
11837/// #         .enable_http2()
11838/// #         .build()
11839/// # );
11840/// # let mut hub = Recommender::new(client, auth);
11841/// // You can configure optional parameters by calling the respective setters at will, and
11842/// // execute the final call using `doit()`.
11843/// // Values shown here are possibly random and not representative !
11844/// let result = hub.organizations().locations_recommenders_recommendations_list("parent")
11845///              .page_token("duo")
11846///              .page_size(-34)
11847///              .filter("et")
11848///              .doit().await;
11849/// # }
11850/// ```
11851pub struct OrganizationLocationRecommenderRecommendationListCall<'a, C>
11852where
11853    C: 'a,
11854{
11855    hub: &'a Recommender<C>,
11856    _parent: String,
11857    _page_token: Option<String>,
11858    _page_size: Option<i32>,
11859    _filter: Option<String>,
11860    _delegate: Option<&'a mut dyn common::Delegate>,
11861    _additional_params: HashMap<String, String>,
11862    _scopes: BTreeSet<String>,
11863}
11864
11865impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderRecommendationListCall<'a, C> {}
11866
11867impl<'a, C> OrganizationLocationRecommenderRecommendationListCall<'a, C>
11868where
11869    C: common::Connector,
11870{
11871    /// Perform the operation you have build so far.
11872    pub async fn doit(
11873        mut self,
11874    ) -> common::Result<(
11875        common::Response,
11876        GoogleCloudRecommenderV1ListRecommendationsResponse,
11877    )> {
11878        use std::borrow::Cow;
11879        use std::io::{Read, Seek};
11880
11881        use common::{url::Params, ToParts};
11882        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11883
11884        let mut dd = common::DefaultDelegate;
11885        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11886        dlg.begin(common::MethodInfo {
11887            id: "recommender.organizations.locations.recommenders.recommendations.list",
11888            http_method: hyper::Method::GET,
11889        });
11890
11891        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
11892            if self._additional_params.contains_key(field) {
11893                dlg.finished(false);
11894                return Err(common::Error::FieldClash(field));
11895            }
11896        }
11897
11898        let mut params = Params::with_capacity(6 + self._additional_params.len());
11899        params.push("parent", self._parent);
11900        if let Some(value) = self._page_token.as_ref() {
11901            params.push("pageToken", value);
11902        }
11903        if let Some(value) = self._page_size.as_ref() {
11904            params.push("pageSize", value.to_string());
11905        }
11906        if let Some(value) = self._filter.as_ref() {
11907            params.push("filter", value);
11908        }
11909
11910        params.extend(self._additional_params.iter());
11911
11912        params.push("alt", "json");
11913        let mut url = self.hub._base_url.clone() + "v1/{+parent}/recommendations";
11914        if self._scopes.is_empty() {
11915            self._scopes
11916                .insert(Scope::CloudPlatform.as_ref().to_string());
11917        }
11918
11919        #[allow(clippy::single_element_loop)]
11920        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11921            url = params.uri_replacement(url, param_name, find_this, true);
11922        }
11923        {
11924            let to_remove = ["parent"];
11925            params.remove_params(&to_remove);
11926        }
11927
11928        let url = params.parse_with_url(&url);
11929
11930        loop {
11931            let token = match self
11932                .hub
11933                .auth
11934                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11935                .await
11936            {
11937                Ok(token) => token,
11938                Err(e) => match dlg.token(e) {
11939                    Ok(token) => token,
11940                    Err(e) => {
11941                        dlg.finished(false);
11942                        return Err(common::Error::MissingToken(e));
11943                    }
11944                },
11945            };
11946            let mut req_result = {
11947                let client = &self.hub.client;
11948                dlg.pre_request();
11949                let mut req_builder = hyper::Request::builder()
11950                    .method(hyper::Method::GET)
11951                    .uri(url.as_str())
11952                    .header(USER_AGENT, self.hub._user_agent.clone());
11953
11954                if let Some(token) = token.as_ref() {
11955                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11956                }
11957
11958                let request = req_builder
11959                    .header(CONTENT_LENGTH, 0_u64)
11960                    .body(common::to_body::<String>(None));
11961
11962                client.request(request.unwrap()).await
11963            };
11964
11965            match req_result {
11966                Err(err) => {
11967                    if let common::Retry::After(d) = dlg.http_error(&err) {
11968                        sleep(d).await;
11969                        continue;
11970                    }
11971                    dlg.finished(false);
11972                    return Err(common::Error::HttpError(err));
11973                }
11974                Ok(res) => {
11975                    let (mut parts, body) = res.into_parts();
11976                    let mut body = common::Body::new(body);
11977                    if !parts.status.is_success() {
11978                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11979                        let error = serde_json::from_str(&common::to_string(&bytes));
11980                        let response = common::to_response(parts, bytes.into());
11981
11982                        if let common::Retry::After(d) =
11983                            dlg.http_failure(&response, error.as_ref().ok())
11984                        {
11985                            sleep(d).await;
11986                            continue;
11987                        }
11988
11989                        dlg.finished(false);
11990
11991                        return Err(match error {
11992                            Ok(value) => common::Error::BadRequest(value),
11993                            _ => common::Error::Failure(response),
11994                        });
11995                    }
11996                    let response = {
11997                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11998                        let encoded = common::to_string(&bytes);
11999                        match serde_json::from_str(&encoded) {
12000                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12001                            Err(error) => {
12002                                dlg.response_json_decode_error(&encoded, &error);
12003                                return Err(common::Error::JsonDecodeError(
12004                                    encoded.to_string(),
12005                                    error,
12006                                ));
12007                            }
12008                        }
12009                    };
12010
12011                    dlg.finished(true);
12012                    return Ok(response);
12013                }
12014            }
12015        }
12016    }
12017
12018    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
12019    ///
12020    /// Sets the *parent* path property to the given value.
12021    ///
12022    /// Even though the property as already been set when instantiating this call,
12023    /// we provide this method for API completeness.
12024    pub fn parent(
12025        mut self,
12026        new_value: &str,
12027    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
12028        self._parent = new_value.to_string();
12029        self
12030    }
12031    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
12032    ///
12033    /// Sets the *page token* query property to the given value.
12034    pub fn page_token(
12035        mut self,
12036        new_value: &str,
12037    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
12038        self._page_token = Some(new_value.to_string());
12039        self
12040    }
12041    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
12042    ///
12043    /// Sets the *page size* query property to the given value.
12044    pub fn page_size(
12045        mut self,
12046        new_value: i32,
12047    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
12048        self._page_size = Some(new_value);
12049        self
12050    }
12051    /// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
12052    ///
12053    /// Sets the *filter* query property to the given value.
12054    pub fn filter(
12055        mut self,
12056        new_value: &str,
12057    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
12058        self._filter = Some(new_value.to_string());
12059        self
12060    }
12061    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12062    /// while executing the actual API request.
12063    ///
12064    /// ````text
12065    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12066    /// ````
12067    ///
12068    /// Sets the *delegate* property to the given value.
12069    pub fn delegate(
12070        mut self,
12071        new_value: &'a mut dyn common::Delegate,
12072    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
12073        self._delegate = Some(new_value);
12074        self
12075    }
12076
12077    /// Set any additional parameter of the query string used in the request.
12078    /// It should be used to set parameters which are not yet available through their own
12079    /// setters.
12080    ///
12081    /// Please note that this method must not be used to set any of the known parameters
12082    /// which have their own setter method. If done anyway, the request will fail.
12083    ///
12084    /// # Additional Parameters
12085    ///
12086    /// * *$.xgafv* (query-string) - V1 error format.
12087    /// * *access_token* (query-string) - OAuth access token.
12088    /// * *alt* (query-string) - Data format for response.
12089    /// * *callback* (query-string) - JSONP
12090    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12091    /// * *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.
12092    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12093    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12094    /// * *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.
12095    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12096    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12097    pub fn param<T>(
12098        mut self,
12099        name: T,
12100        value: T,
12101    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C>
12102    where
12103        T: AsRef<str>,
12104    {
12105        self._additional_params
12106            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12107        self
12108    }
12109
12110    /// Identifies the authorization scope for the method you are building.
12111    ///
12112    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12113    /// [`Scope::CloudPlatform`].
12114    ///
12115    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12116    /// tokens for more than one scope.
12117    ///
12118    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12119    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12120    /// sufficient, a read-write scope will do as well.
12121    pub fn add_scope<St>(
12122        mut self,
12123        scope: St,
12124    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C>
12125    where
12126        St: AsRef<str>,
12127    {
12128        self._scopes.insert(String::from(scope.as_ref()));
12129        self
12130    }
12131    /// Identifies the authorization scope(s) for the method you are building.
12132    ///
12133    /// See [`Self::add_scope()`] for details.
12134    pub fn add_scopes<I, St>(
12135        mut self,
12136        scopes: I,
12137    ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C>
12138    where
12139        I: IntoIterator<Item = St>,
12140        St: AsRef<str>,
12141    {
12142        self._scopes
12143            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12144        self
12145    }
12146
12147    /// Removes all scopes, and no default scope will be used either.
12148    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12149    /// for details).
12150    pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
12151        self._scopes.clear();
12152        self
12153    }
12154}
12155
12156/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
12157///
12158/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *organization* resource.
12159/// It is not used directly, but through a [`OrganizationMethods`] instance.
12160///
12161/// # Example
12162///
12163/// Instantiate a resource method builder
12164///
12165/// ```test_harness,no_run
12166/// # extern crate hyper;
12167/// # extern crate hyper_rustls;
12168/// # extern crate google_recommender1 as recommender1;
12169/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationClaimedRequest;
12170/// # async fn dox() {
12171/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12172///
12173/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12174/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12175/// #     .with_native_roots()
12176/// #     .unwrap()
12177/// #     .https_only()
12178/// #     .enable_http2()
12179/// #     .build();
12180///
12181/// # let executor = hyper_util::rt::TokioExecutor::new();
12182/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12183/// #     secret,
12184/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12185/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12186/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12187/// #     ),
12188/// # ).build().await.unwrap();
12189///
12190/// # let client = hyper_util::client::legacy::Client::builder(
12191/// #     hyper_util::rt::TokioExecutor::new()
12192/// # )
12193/// # .build(
12194/// #     hyper_rustls::HttpsConnectorBuilder::new()
12195/// #         .with_native_roots()
12196/// #         .unwrap()
12197/// #         .https_or_http()
12198/// #         .enable_http2()
12199/// #         .build()
12200/// # );
12201/// # let mut hub = Recommender::new(client, auth);
12202/// // As the method needs a request, you would usually fill it with the desired information
12203/// // into the respective structure. Some of the parts shown here might not be applicable !
12204/// // Values shown here are possibly random and not representative !
12205/// let mut req = GoogleCloudRecommenderV1MarkRecommendationClaimedRequest::default();
12206///
12207/// // You can configure optional parameters by calling the respective setters at will, and
12208/// // execute the final call using `doit()`.
12209/// // Values shown here are possibly random and not representative !
12210/// let result = hub.organizations().locations_recommenders_recommendations_mark_claimed(req, "name")
12211///              .doit().await;
12212/// # }
12213/// ```
12214pub struct OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
12215where
12216    C: 'a,
12217{
12218    hub: &'a Recommender<C>,
12219    _request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
12220    _name: String,
12221    _delegate: Option<&'a mut dyn common::Delegate>,
12222    _additional_params: HashMap<String, String>,
12223    _scopes: BTreeSet<String>,
12224}
12225
12226impl<'a, C> common::CallBuilder
12227    for OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
12228{
12229}
12230
12231impl<'a, C> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
12232where
12233    C: common::Connector,
12234{
12235    /// Perform the operation you have build so far.
12236    pub async fn doit(
12237        mut self,
12238    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
12239        use std::borrow::Cow;
12240        use std::io::{Read, Seek};
12241
12242        use common::{url::Params, ToParts};
12243        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12244
12245        let mut dd = common::DefaultDelegate;
12246        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12247        dlg.begin(common::MethodInfo {
12248            id: "recommender.organizations.locations.recommenders.recommendations.markClaimed",
12249            http_method: hyper::Method::POST,
12250        });
12251
12252        for &field in ["alt", "name"].iter() {
12253            if self._additional_params.contains_key(field) {
12254                dlg.finished(false);
12255                return Err(common::Error::FieldClash(field));
12256            }
12257        }
12258
12259        let mut params = Params::with_capacity(4 + self._additional_params.len());
12260        params.push("name", self._name);
12261
12262        params.extend(self._additional_params.iter());
12263
12264        params.push("alt", "json");
12265        let mut url = self.hub._base_url.clone() + "v1/{+name}:markClaimed";
12266        if self._scopes.is_empty() {
12267            self._scopes
12268                .insert(Scope::CloudPlatform.as_ref().to_string());
12269        }
12270
12271        #[allow(clippy::single_element_loop)]
12272        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12273            url = params.uri_replacement(url, param_name, find_this, true);
12274        }
12275        {
12276            let to_remove = ["name"];
12277            params.remove_params(&to_remove);
12278        }
12279
12280        let url = params.parse_with_url(&url);
12281
12282        let mut json_mime_type = mime::APPLICATION_JSON;
12283        let mut request_value_reader = {
12284            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12285            common::remove_json_null_values(&mut value);
12286            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12287            serde_json::to_writer(&mut dst, &value).unwrap();
12288            dst
12289        };
12290        let request_size = request_value_reader
12291            .seek(std::io::SeekFrom::End(0))
12292            .unwrap();
12293        request_value_reader
12294            .seek(std::io::SeekFrom::Start(0))
12295            .unwrap();
12296
12297        loop {
12298            let token = match self
12299                .hub
12300                .auth
12301                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12302                .await
12303            {
12304                Ok(token) => token,
12305                Err(e) => match dlg.token(e) {
12306                    Ok(token) => token,
12307                    Err(e) => {
12308                        dlg.finished(false);
12309                        return Err(common::Error::MissingToken(e));
12310                    }
12311                },
12312            };
12313            request_value_reader
12314                .seek(std::io::SeekFrom::Start(0))
12315                .unwrap();
12316            let mut req_result = {
12317                let client = &self.hub.client;
12318                dlg.pre_request();
12319                let mut req_builder = hyper::Request::builder()
12320                    .method(hyper::Method::POST)
12321                    .uri(url.as_str())
12322                    .header(USER_AGENT, self.hub._user_agent.clone());
12323
12324                if let Some(token) = token.as_ref() {
12325                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12326                }
12327
12328                let request = req_builder
12329                    .header(CONTENT_TYPE, json_mime_type.to_string())
12330                    .header(CONTENT_LENGTH, request_size as u64)
12331                    .body(common::to_body(
12332                        request_value_reader.get_ref().clone().into(),
12333                    ));
12334
12335                client.request(request.unwrap()).await
12336            };
12337
12338            match req_result {
12339                Err(err) => {
12340                    if let common::Retry::After(d) = dlg.http_error(&err) {
12341                        sleep(d).await;
12342                        continue;
12343                    }
12344                    dlg.finished(false);
12345                    return Err(common::Error::HttpError(err));
12346                }
12347                Ok(res) => {
12348                    let (mut parts, body) = res.into_parts();
12349                    let mut body = common::Body::new(body);
12350                    if !parts.status.is_success() {
12351                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12352                        let error = serde_json::from_str(&common::to_string(&bytes));
12353                        let response = common::to_response(parts, bytes.into());
12354
12355                        if let common::Retry::After(d) =
12356                            dlg.http_failure(&response, error.as_ref().ok())
12357                        {
12358                            sleep(d).await;
12359                            continue;
12360                        }
12361
12362                        dlg.finished(false);
12363
12364                        return Err(match error {
12365                            Ok(value) => common::Error::BadRequest(value),
12366                            _ => common::Error::Failure(response),
12367                        });
12368                    }
12369                    let response = {
12370                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12371                        let encoded = common::to_string(&bytes);
12372                        match serde_json::from_str(&encoded) {
12373                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12374                            Err(error) => {
12375                                dlg.response_json_decode_error(&encoded, &error);
12376                                return Err(common::Error::JsonDecodeError(
12377                                    encoded.to_string(),
12378                                    error,
12379                                ));
12380                            }
12381                        }
12382                    };
12383
12384                    dlg.finished(true);
12385                    return Ok(response);
12386                }
12387            }
12388        }
12389    }
12390
12391    ///
12392    /// Sets the *request* property to the given value.
12393    ///
12394    /// Even though the property as already been set when instantiating this call,
12395    /// we provide this method for API completeness.
12396    pub fn request(
12397        mut self,
12398        new_value: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
12399    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
12400        self._request = new_value;
12401        self
12402    }
12403    /// Required. Name of the recommendation.
12404    ///
12405    /// Sets the *name* path property to the given value.
12406    ///
12407    /// Even though the property as already been set when instantiating this call,
12408    /// we provide this method for API completeness.
12409    pub fn name(
12410        mut self,
12411        new_value: &str,
12412    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
12413        self._name = new_value.to_string();
12414        self
12415    }
12416    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12417    /// while executing the actual API request.
12418    ///
12419    /// ````text
12420    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12421    /// ````
12422    ///
12423    /// Sets the *delegate* property to the given value.
12424    pub fn delegate(
12425        mut self,
12426        new_value: &'a mut dyn common::Delegate,
12427    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
12428        self._delegate = Some(new_value);
12429        self
12430    }
12431
12432    /// Set any additional parameter of the query string used in the request.
12433    /// It should be used to set parameters which are not yet available through their own
12434    /// setters.
12435    ///
12436    /// Please note that this method must not be used to set any of the known parameters
12437    /// which have their own setter method. If done anyway, the request will fail.
12438    ///
12439    /// # Additional Parameters
12440    ///
12441    /// * *$.xgafv* (query-string) - V1 error format.
12442    /// * *access_token* (query-string) - OAuth access token.
12443    /// * *alt* (query-string) - Data format for response.
12444    /// * *callback* (query-string) - JSONP
12445    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12446    /// * *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.
12447    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12448    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12449    /// * *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.
12450    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12451    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12452    pub fn param<T>(
12453        mut self,
12454        name: T,
12455        value: T,
12456    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
12457    where
12458        T: AsRef<str>,
12459    {
12460        self._additional_params
12461            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12462        self
12463    }
12464
12465    /// Identifies the authorization scope for the method you are building.
12466    ///
12467    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12468    /// [`Scope::CloudPlatform`].
12469    ///
12470    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12471    /// tokens for more than one scope.
12472    ///
12473    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12474    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12475    /// sufficient, a read-write scope will do as well.
12476    pub fn add_scope<St>(
12477        mut self,
12478        scope: St,
12479    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
12480    where
12481        St: AsRef<str>,
12482    {
12483        self._scopes.insert(String::from(scope.as_ref()));
12484        self
12485    }
12486    /// Identifies the authorization scope(s) for the method you are building.
12487    ///
12488    /// See [`Self::add_scope()`] for details.
12489    pub fn add_scopes<I, St>(
12490        mut self,
12491        scopes: I,
12492    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
12493    where
12494        I: IntoIterator<Item = St>,
12495        St: AsRef<str>,
12496    {
12497        self._scopes
12498            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12499        self
12500    }
12501
12502    /// Removes all scopes, and no default scope will be used either.
12503    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12504    /// for details).
12505    pub fn clear_scopes(
12506        mut self,
12507    ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
12508        self._scopes.clear();
12509        self
12510    }
12511}
12512
12513/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
12514///
12515/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *organization* resource.
12516/// It is not used directly, but through a [`OrganizationMethods`] instance.
12517///
12518/// # Example
12519///
12520/// Instantiate a resource method builder
12521///
12522/// ```test_harness,no_run
12523/// # extern crate hyper;
12524/// # extern crate hyper_rustls;
12525/// # extern crate google_recommender1 as recommender1;
12526/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationDismissedRequest;
12527/// # async fn dox() {
12528/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12529///
12530/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12531/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12532/// #     .with_native_roots()
12533/// #     .unwrap()
12534/// #     .https_only()
12535/// #     .enable_http2()
12536/// #     .build();
12537///
12538/// # let executor = hyper_util::rt::TokioExecutor::new();
12539/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12540/// #     secret,
12541/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12542/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12543/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12544/// #     ),
12545/// # ).build().await.unwrap();
12546///
12547/// # let client = hyper_util::client::legacy::Client::builder(
12548/// #     hyper_util::rt::TokioExecutor::new()
12549/// # )
12550/// # .build(
12551/// #     hyper_rustls::HttpsConnectorBuilder::new()
12552/// #         .with_native_roots()
12553/// #         .unwrap()
12554/// #         .https_or_http()
12555/// #         .enable_http2()
12556/// #         .build()
12557/// # );
12558/// # let mut hub = Recommender::new(client, auth);
12559/// // As the method needs a request, you would usually fill it with the desired information
12560/// // into the respective structure. Some of the parts shown here might not be applicable !
12561/// // Values shown here are possibly random and not representative !
12562/// let mut req = GoogleCloudRecommenderV1MarkRecommendationDismissedRequest::default();
12563///
12564/// // You can configure optional parameters by calling the respective setters at will, and
12565/// // execute the final call using `doit()`.
12566/// // Values shown here are possibly random and not representative !
12567/// let result = hub.organizations().locations_recommenders_recommendations_mark_dismissed(req, "name")
12568///              .doit().await;
12569/// # }
12570/// ```
12571pub struct OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
12572where
12573    C: 'a,
12574{
12575    hub: &'a Recommender<C>,
12576    _request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
12577    _name: String,
12578    _delegate: Option<&'a mut dyn common::Delegate>,
12579    _additional_params: HashMap<String, String>,
12580    _scopes: BTreeSet<String>,
12581}
12582
12583impl<'a, C> common::CallBuilder
12584    for OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
12585{
12586}
12587
12588impl<'a, C> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
12589where
12590    C: common::Connector,
12591{
12592    /// Perform the operation you have build so far.
12593    pub async fn doit(
12594        mut self,
12595    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
12596        use std::borrow::Cow;
12597        use std::io::{Read, Seek};
12598
12599        use common::{url::Params, ToParts};
12600        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12601
12602        let mut dd = common::DefaultDelegate;
12603        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12604        dlg.begin(common::MethodInfo {
12605            id: "recommender.organizations.locations.recommenders.recommendations.markDismissed",
12606            http_method: hyper::Method::POST,
12607        });
12608
12609        for &field in ["alt", "name"].iter() {
12610            if self._additional_params.contains_key(field) {
12611                dlg.finished(false);
12612                return Err(common::Error::FieldClash(field));
12613            }
12614        }
12615
12616        let mut params = Params::with_capacity(4 + self._additional_params.len());
12617        params.push("name", self._name);
12618
12619        params.extend(self._additional_params.iter());
12620
12621        params.push("alt", "json");
12622        let mut url = self.hub._base_url.clone() + "v1/{+name}:markDismissed";
12623        if self._scopes.is_empty() {
12624            self._scopes
12625                .insert(Scope::CloudPlatform.as_ref().to_string());
12626        }
12627
12628        #[allow(clippy::single_element_loop)]
12629        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12630            url = params.uri_replacement(url, param_name, find_this, true);
12631        }
12632        {
12633            let to_remove = ["name"];
12634            params.remove_params(&to_remove);
12635        }
12636
12637        let url = params.parse_with_url(&url);
12638
12639        let mut json_mime_type = mime::APPLICATION_JSON;
12640        let mut request_value_reader = {
12641            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12642            common::remove_json_null_values(&mut value);
12643            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12644            serde_json::to_writer(&mut dst, &value).unwrap();
12645            dst
12646        };
12647        let request_size = request_value_reader
12648            .seek(std::io::SeekFrom::End(0))
12649            .unwrap();
12650        request_value_reader
12651            .seek(std::io::SeekFrom::Start(0))
12652            .unwrap();
12653
12654        loop {
12655            let token = match self
12656                .hub
12657                .auth
12658                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12659                .await
12660            {
12661                Ok(token) => token,
12662                Err(e) => match dlg.token(e) {
12663                    Ok(token) => token,
12664                    Err(e) => {
12665                        dlg.finished(false);
12666                        return Err(common::Error::MissingToken(e));
12667                    }
12668                },
12669            };
12670            request_value_reader
12671                .seek(std::io::SeekFrom::Start(0))
12672                .unwrap();
12673            let mut req_result = {
12674                let client = &self.hub.client;
12675                dlg.pre_request();
12676                let mut req_builder = hyper::Request::builder()
12677                    .method(hyper::Method::POST)
12678                    .uri(url.as_str())
12679                    .header(USER_AGENT, self.hub._user_agent.clone());
12680
12681                if let Some(token) = token.as_ref() {
12682                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12683                }
12684
12685                let request = req_builder
12686                    .header(CONTENT_TYPE, json_mime_type.to_string())
12687                    .header(CONTENT_LENGTH, request_size as u64)
12688                    .body(common::to_body(
12689                        request_value_reader.get_ref().clone().into(),
12690                    ));
12691
12692                client.request(request.unwrap()).await
12693            };
12694
12695            match req_result {
12696                Err(err) => {
12697                    if let common::Retry::After(d) = dlg.http_error(&err) {
12698                        sleep(d).await;
12699                        continue;
12700                    }
12701                    dlg.finished(false);
12702                    return Err(common::Error::HttpError(err));
12703                }
12704                Ok(res) => {
12705                    let (mut parts, body) = res.into_parts();
12706                    let mut body = common::Body::new(body);
12707                    if !parts.status.is_success() {
12708                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12709                        let error = serde_json::from_str(&common::to_string(&bytes));
12710                        let response = common::to_response(parts, bytes.into());
12711
12712                        if let common::Retry::After(d) =
12713                            dlg.http_failure(&response, error.as_ref().ok())
12714                        {
12715                            sleep(d).await;
12716                            continue;
12717                        }
12718
12719                        dlg.finished(false);
12720
12721                        return Err(match error {
12722                            Ok(value) => common::Error::BadRequest(value),
12723                            _ => common::Error::Failure(response),
12724                        });
12725                    }
12726                    let response = {
12727                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12728                        let encoded = common::to_string(&bytes);
12729                        match serde_json::from_str(&encoded) {
12730                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12731                            Err(error) => {
12732                                dlg.response_json_decode_error(&encoded, &error);
12733                                return Err(common::Error::JsonDecodeError(
12734                                    encoded.to_string(),
12735                                    error,
12736                                ));
12737                            }
12738                        }
12739                    };
12740
12741                    dlg.finished(true);
12742                    return Ok(response);
12743                }
12744            }
12745        }
12746    }
12747
12748    ///
12749    /// Sets the *request* property to the given value.
12750    ///
12751    /// Even though the property as already been set when instantiating this call,
12752    /// we provide this method for API completeness.
12753    pub fn request(
12754        mut self,
12755        new_value: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
12756    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
12757        self._request = new_value;
12758        self
12759    }
12760    /// Required. Name of the recommendation.
12761    ///
12762    /// Sets the *name* path property to the given value.
12763    ///
12764    /// Even though the property as already been set when instantiating this call,
12765    /// we provide this method for API completeness.
12766    pub fn name(
12767        mut self,
12768        new_value: &str,
12769    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
12770        self._name = new_value.to_string();
12771        self
12772    }
12773    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12774    /// while executing the actual API request.
12775    ///
12776    /// ````text
12777    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12778    /// ````
12779    ///
12780    /// Sets the *delegate* property to the given value.
12781    pub fn delegate(
12782        mut self,
12783        new_value: &'a mut dyn common::Delegate,
12784    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
12785        self._delegate = Some(new_value);
12786        self
12787    }
12788
12789    /// Set any additional parameter of the query string used in the request.
12790    /// It should be used to set parameters which are not yet available through their own
12791    /// setters.
12792    ///
12793    /// Please note that this method must not be used to set any of the known parameters
12794    /// which have their own setter method. If done anyway, the request will fail.
12795    ///
12796    /// # Additional Parameters
12797    ///
12798    /// * *$.xgafv* (query-string) - V1 error format.
12799    /// * *access_token* (query-string) - OAuth access token.
12800    /// * *alt* (query-string) - Data format for response.
12801    /// * *callback* (query-string) - JSONP
12802    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12803    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12804    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12805    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12806    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12807    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12808    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12809    pub fn param<T>(
12810        mut self,
12811        name: T,
12812        value: T,
12813    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
12814    where
12815        T: AsRef<str>,
12816    {
12817        self._additional_params
12818            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12819        self
12820    }
12821
12822    /// Identifies the authorization scope for the method you are building.
12823    ///
12824    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12825    /// [`Scope::CloudPlatform`].
12826    ///
12827    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12828    /// tokens for more than one scope.
12829    ///
12830    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12831    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12832    /// sufficient, a read-write scope will do as well.
12833    pub fn add_scope<St>(
12834        mut self,
12835        scope: St,
12836    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
12837    where
12838        St: AsRef<str>,
12839    {
12840        self._scopes.insert(String::from(scope.as_ref()));
12841        self
12842    }
12843    /// Identifies the authorization scope(s) for the method you are building.
12844    ///
12845    /// See [`Self::add_scope()`] for details.
12846    pub fn add_scopes<I, St>(
12847        mut self,
12848        scopes: I,
12849    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
12850    where
12851        I: IntoIterator<Item = St>,
12852        St: AsRef<str>,
12853    {
12854        self._scopes
12855            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12856        self
12857    }
12858
12859    /// Removes all scopes, and no default scope will be used either.
12860    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12861    /// for details).
12862    pub fn clear_scopes(
12863        mut self,
12864    ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
12865        self._scopes.clear();
12866        self
12867    }
12868}
12869
12870/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
12871///
12872/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *organization* resource.
12873/// It is not used directly, but through a [`OrganizationMethods`] instance.
12874///
12875/// # Example
12876///
12877/// Instantiate a resource method builder
12878///
12879/// ```test_harness,no_run
12880/// # extern crate hyper;
12881/// # extern crate hyper_rustls;
12882/// # extern crate google_recommender1 as recommender1;
12883/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationFailedRequest;
12884/// # async fn dox() {
12885/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12886///
12887/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12888/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12889/// #     .with_native_roots()
12890/// #     .unwrap()
12891/// #     .https_only()
12892/// #     .enable_http2()
12893/// #     .build();
12894///
12895/// # let executor = hyper_util::rt::TokioExecutor::new();
12896/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12897/// #     secret,
12898/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12899/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12900/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12901/// #     ),
12902/// # ).build().await.unwrap();
12903///
12904/// # let client = hyper_util::client::legacy::Client::builder(
12905/// #     hyper_util::rt::TokioExecutor::new()
12906/// # )
12907/// # .build(
12908/// #     hyper_rustls::HttpsConnectorBuilder::new()
12909/// #         .with_native_roots()
12910/// #         .unwrap()
12911/// #         .https_or_http()
12912/// #         .enable_http2()
12913/// #         .build()
12914/// # );
12915/// # let mut hub = Recommender::new(client, auth);
12916/// // As the method needs a request, you would usually fill it with the desired information
12917/// // into the respective structure. Some of the parts shown here might not be applicable !
12918/// // Values shown here are possibly random and not representative !
12919/// let mut req = GoogleCloudRecommenderV1MarkRecommendationFailedRequest::default();
12920///
12921/// // You can configure optional parameters by calling the respective setters at will, and
12922/// // execute the final call using `doit()`.
12923/// // Values shown here are possibly random and not representative !
12924/// let result = hub.organizations().locations_recommenders_recommendations_mark_failed(req, "name")
12925///              .doit().await;
12926/// # }
12927/// ```
12928pub struct OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
12929where
12930    C: 'a,
12931{
12932    hub: &'a Recommender<C>,
12933    _request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
12934    _name: String,
12935    _delegate: Option<&'a mut dyn common::Delegate>,
12936    _additional_params: HashMap<String, String>,
12937    _scopes: BTreeSet<String>,
12938}
12939
12940impl<'a, C> common::CallBuilder
12941    for OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
12942{
12943}
12944
12945impl<'a, C> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
12946where
12947    C: common::Connector,
12948{
12949    /// Perform the operation you have build so far.
12950    pub async fn doit(
12951        mut self,
12952    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
12953        use std::borrow::Cow;
12954        use std::io::{Read, Seek};
12955
12956        use common::{url::Params, ToParts};
12957        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12958
12959        let mut dd = common::DefaultDelegate;
12960        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12961        dlg.begin(common::MethodInfo {
12962            id: "recommender.organizations.locations.recommenders.recommendations.markFailed",
12963            http_method: hyper::Method::POST,
12964        });
12965
12966        for &field in ["alt", "name"].iter() {
12967            if self._additional_params.contains_key(field) {
12968                dlg.finished(false);
12969                return Err(common::Error::FieldClash(field));
12970            }
12971        }
12972
12973        let mut params = Params::with_capacity(4 + self._additional_params.len());
12974        params.push("name", self._name);
12975
12976        params.extend(self._additional_params.iter());
12977
12978        params.push("alt", "json");
12979        let mut url = self.hub._base_url.clone() + "v1/{+name}:markFailed";
12980        if self._scopes.is_empty() {
12981            self._scopes
12982                .insert(Scope::CloudPlatform.as_ref().to_string());
12983        }
12984
12985        #[allow(clippy::single_element_loop)]
12986        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12987            url = params.uri_replacement(url, param_name, find_this, true);
12988        }
12989        {
12990            let to_remove = ["name"];
12991            params.remove_params(&to_remove);
12992        }
12993
12994        let url = params.parse_with_url(&url);
12995
12996        let mut json_mime_type = mime::APPLICATION_JSON;
12997        let mut request_value_reader = {
12998            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12999            common::remove_json_null_values(&mut value);
13000            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13001            serde_json::to_writer(&mut dst, &value).unwrap();
13002            dst
13003        };
13004        let request_size = request_value_reader
13005            .seek(std::io::SeekFrom::End(0))
13006            .unwrap();
13007        request_value_reader
13008            .seek(std::io::SeekFrom::Start(0))
13009            .unwrap();
13010
13011        loop {
13012            let token = match self
13013                .hub
13014                .auth
13015                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13016                .await
13017            {
13018                Ok(token) => token,
13019                Err(e) => match dlg.token(e) {
13020                    Ok(token) => token,
13021                    Err(e) => {
13022                        dlg.finished(false);
13023                        return Err(common::Error::MissingToken(e));
13024                    }
13025                },
13026            };
13027            request_value_reader
13028                .seek(std::io::SeekFrom::Start(0))
13029                .unwrap();
13030            let mut req_result = {
13031                let client = &self.hub.client;
13032                dlg.pre_request();
13033                let mut req_builder = hyper::Request::builder()
13034                    .method(hyper::Method::POST)
13035                    .uri(url.as_str())
13036                    .header(USER_AGENT, self.hub._user_agent.clone());
13037
13038                if let Some(token) = token.as_ref() {
13039                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13040                }
13041
13042                let request = req_builder
13043                    .header(CONTENT_TYPE, json_mime_type.to_string())
13044                    .header(CONTENT_LENGTH, request_size as u64)
13045                    .body(common::to_body(
13046                        request_value_reader.get_ref().clone().into(),
13047                    ));
13048
13049                client.request(request.unwrap()).await
13050            };
13051
13052            match req_result {
13053                Err(err) => {
13054                    if let common::Retry::After(d) = dlg.http_error(&err) {
13055                        sleep(d).await;
13056                        continue;
13057                    }
13058                    dlg.finished(false);
13059                    return Err(common::Error::HttpError(err));
13060                }
13061                Ok(res) => {
13062                    let (mut parts, body) = res.into_parts();
13063                    let mut body = common::Body::new(body);
13064                    if !parts.status.is_success() {
13065                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13066                        let error = serde_json::from_str(&common::to_string(&bytes));
13067                        let response = common::to_response(parts, bytes.into());
13068
13069                        if let common::Retry::After(d) =
13070                            dlg.http_failure(&response, error.as_ref().ok())
13071                        {
13072                            sleep(d).await;
13073                            continue;
13074                        }
13075
13076                        dlg.finished(false);
13077
13078                        return Err(match error {
13079                            Ok(value) => common::Error::BadRequest(value),
13080                            _ => common::Error::Failure(response),
13081                        });
13082                    }
13083                    let response = {
13084                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13085                        let encoded = common::to_string(&bytes);
13086                        match serde_json::from_str(&encoded) {
13087                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13088                            Err(error) => {
13089                                dlg.response_json_decode_error(&encoded, &error);
13090                                return Err(common::Error::JsonDecodeError(
13091                                    encoded.to_string(),
13092                                    error,
13093                                ));
13094                            }
13095                        }
13096                    };
13097
13098                    dlg.finished(true);
13099                    return Ok(response);
13100                }
13101            }
13102        }
13103    }
13104
13105    ///
13106    /// Sets the *request* property to the given value.
13107    ///
13108    /// Even though the property as already been set when instantiating this call,
13109    /// we provide this method for API completeness.
13110    pub fn request(
13111        mut self,
13112        new_value: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
13113    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
13114        self._request = new_value;
13115        self
13116    }
13117    /// Required. Name of the recommendation.
13118    ///
13119    /// Sets the *name* path property to the given value.
13120    ///
13121    /// Even though the property as already been set when instantiating this call,
13122    /// we provide this method for API completeness.
13123    pub fn name(
13124        mut self,
13125        new_value: &str,
13126    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
13127        self._name = new_value.to_string();
13128        self
13129    }
13130    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13131    /// while executing the actual API request.
13132    ///
13133    /// ````text
13134    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13135    /// ````
13136    ///
13137    /// Sets the *delegate* property to the given value.
13138    pub fn delegate(
13139        mut self,
13140        new_value: &'a mut dyn common::Delegate,
13141    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
13142        self._delegate = Some(new_value);
13143        self
13144    }
13145
13146    /// Set any additional parameter of the query string used in the request.
13147    /// It should be used to set parameters which are not yet available through their own
13148    /// setters.
13149    ///
13150    /// Please note that this method must not be used to set any of the known parameters
13151    /// which have their own setter method. If done anyway, the request will fail.
13152    ///
13153    /// # Additional Parameters
13154    ///
13155    /// * *$.xgafv* (query-string) - V1 error format.
13156    /// * *access_token* (query-string) - OAuth access token.
13157    /// * *alt* (query-string) - Data format for response.
13158    /// * *callback* (query-string) - JSONP
13159    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13160    /// * *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.
13161    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13162    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13163    /// * *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.
13164    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13165    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13166    pub fn param<T>(
13167        mut self,
13168        name: T,
13169        value: T,
13170    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
13171    where
13172        T: AsRef<str>,
13173    {
13174        self._additional_params
13175            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13176        self
13177    }
13178
13179    /// Identifies the authorization scope for the method you are building.
13180    ///
13181    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13182    /// [`Scope::CloudPlatform`].
13183    ///
13184    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13185    /// tokens for more than one scope.
13186    ///
13187    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13188    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13189    /// sufficient, a read-write scope will do as well.
13190    pub fn add_scope<St>(
13191        mut self,
13192        scope: St,
13193    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
13194    where
13195        St: AsRef<str>,
13196    {
13197        self._scopes.insert(String::from(scope.as_ref()));
13198        self
13199    }
13200    /// Identifies the authorization scope(s) for the method you are building.
13201    ///
13202    /// See [`Self::add_scope()`] for details.
13203    pub fn add_scopes<I, St>(
13204        mut self,
13205        scopes: I,
13206    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
13207    where
13208        I: IntoIterator<Item = St>,
13209        St: AsRef<str>,
13210    {
13211        self._scopes
13212            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13213        self
13214    }
13215
13216    /// Removes all scopes, and no default scope will be used either.
13217    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13218    /// for details).
13219    pub fn clear_scopes(
13220        mut self,
13221    ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
13222        self._scopes.clear();
13223        self
13224    }
13225}
13226
13227/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
13228///
13229/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *organization* resource.
13230/// It is not used directly, but through a [`OrganizationMethods`] instance.
13231///
13232/// # Example
13233///
13234/// Instantiate a resource method builder
13235///
13236/// ```test_harness,no_run
13237/// # extern crate hyper;
13238/// # extern crate hyper_rustls;
13239/// # extern crate google_recommender1 as recommender1;
13240/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationSucceededRequest;
13241/// # async fn dox() {
13242/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13243///
13244/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13245/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13246/// #     .with_native_roots()
13247/// #     .unwrap()
13248/// #     .https_only()
13249/// #     .enable_http2()
13250/// #     .build();
13251///
13252/// # let executor = hyper_util::rt::TokioExecutor::new();
13253/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13254/// #     secret,
13255/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13256/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13257/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13258/// #     ),
13259/// # ).build().await.unwrap();
13260///
13261/// # let client = hyper_util::client::legacy::Client::builder(
13262/// #     hyper_util::rt::TokioExecutor::new()
13263/// # )
13264/// # .build(
13265/// #     hyper_rustls::HttpsConnectorBuilder::new()
13266/// #         .with_native_roots()
13267/// #         .unwrap()
13268/// #         .https_or_http()
13269/// #         .enable_http2()
13270/// #         .build()
13271/// # );
13272/// # let mut hub = Recommender::new(client, auth);
13273/// // As the method needs a request, you would usually fill it with the desired information
13274/// // into the respective structure. Some of the parts shown here might not be applicable !
13275/// // Values shown here are possibly random and not representative !
13276/// let mut req = GoogleCloudRecommenderV1MarkRecommendationSucceededRequest::default();
13277///
13278/// // You can configure optional parameters by calling the respective setters at will, and
13279/// // execute the final call using `doit()`.
13280/// // Values shown here are possibly random and not representative !
13281/// let result = hub.organizations().locations_recommenders_recommendations_mark_succeeded(req, "name")
13282///              .doit().await;
13283/// # }
13284/// ```
13285pub struct OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
13286where
13287    C: 'a,
13288{
13289    hub: &'a Recommender<C>,
13290    _request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
13291    _name: String,
13292    _delegate: Option<&'a mut dyn common::Delegate>,
13293    _additional_params: HashMap<String, String>,
13294    _scopes: BTreeSet<String>,
13295}
13296
13297impl<'a, C> common::CallBuilder
13298    for OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
13299{
13300}
13301
13302impl<'a, C> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
13303where
13304    C: common::Connector,
13305{
13306    /// Perform the operation you have build so far.
13307    pub async fn doit(
13308        mut self,
13309    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
13310        use std::borrow::Cow;
13311        use std::io::{Read, Seek};
13312
13313        use common::{url::Params, ToParts};
13314        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13315
13316        let mut dd = common::DefaultDelegate;
13317        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13318        dlg.begin(common::MethodInfo {
13319            id: "recommender.organizations.locations.recommenders.recommendations.markSucceeded",
13320            http_method: hyper::Method::POST,
13321        });
13322
13323        for &field in ["alt", "name"].iter() {
13324            if self._additional_params.contains_key(field) {
13325                dlg.finished(false);
13326                return Err(common::Error::FieldClash(field));
13327            }
13328        }
13329
13330        let mut params = Params::with_capacity(4 + self._additional_params.len());
13331        params.push("name", self._name);
13332
13333        params.extend(self._additional_params.iter());
13334
13335        params.push("alt", "json");
13336        let mut url = self.hub._base_url.clone() + "v1/{+name}:markSucceeded";
13337        if self._scopes.is_empty() {
13338            self._scopes
13339                .insert(Scope::CloudPlatform.as_ref().to_string());
13340        }
13341
13342        #[allow(clippy::single_element_loop)]
13343        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13344            url = params.uri_replacement(url, param_name, find_this, true);
13345        }
13346        {
13347            let to_remove = ["name"];
13348            params.remove_params(&to_remove);
13349        }
13350
13351        let url = params.parse_with_url(&url);
13352
13353        let mut json_mime_type = mime::APPLICATION_JSON;
13354        let mut request_value_reader = {
13355            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13356            common::remove_json_null_values(&mut value);
13357            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13358            serde_json::to_writer(&mut dst, &value).unwrap();
13359            dst
13360        };
13361        let request_size = request_value_reader
13362            .seek(std::io::SeekFrom::End(0))
13363            .unwrap();
13364        request_value_reader
13365            .seek(std::io::SeekFrom::Start(0))
13366            .unwrap();
13367
13368        loop {
13369            let token = match self
13370                .hub
13371                .auth
13372                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13373                .await
13374            {
13375                Ok(token) => token,
13376                Err(e) => match dlg.token(e) {
13377                    Ok(token) => token,
13378                    Err(e) => {
13379                        dlg.finished(false);
13380                        return Err(common::Error::MissingToken(e));
13381                    }
13382                },
13383            };
13384            request_value_reader
13385                .seek(std::io::SeekFrom::Start(0))
13386                .unwrap();
13387            let mut req_result = {
13388                let client = &self.hub.client;
13389                dlg.pre_request();
13390                let mut req_builder = hyper::Request::builder()
13391                    .method(hyper::Method::POST)
13392                    .uri(url.as_str())
13393                    .header(USER_AGENT, self.hub._user_agent.clone());
13394
13395                if let Some(token) = token.as_ref() {
13396                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13397                }
13398
13399                let request = req_builder
13400                    .header(CONTENT_TYPE, json_mime_type.to_string())
13401                    .header(CONTENT_LENGTH, request_size as u64)
13402                    .body(common::to_body(
13403                        request_value_reader.get_ref().clone().into(),
13404                    ));
13405
13406                client.request(request.unwrap()).await
13407            };
13408
13409            match req_result {
13410                Err(err) => {
13411                    if let common::Retry::After(d) = dlg.http_error(&err) {
13412                        sleep(d).await;
13413                        continue;
13414                    }
13415                    dlg.finished(false);
13416                    return Err(common::Error::HttpError(err));
13417                }
13418                Ok(res) => {
13419                    let (mut parts, body) = res.into_parts();
13420                    let mut body = common::Body::new(body);
13421                    if !parts.status.is_success() {
13422                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13423                        let error = serde_json::from_str(&common::to_string(&bytes));
13424                        let response = common::to_response(parts, bytes.into());
13425
13426                        if let common::Retry::After(d) =
13427                            dlg.http_failure(&response, error.as_ref().ok())
13428                        {
13429                            sleep(d).await;
13430                            continue;
13431                        }
13432
13433                        dlg.finished(false);
13434
13435                        return Err(match error {
13436                            Ok(value) => common::Error::BadRequest(value),
13437                            _ => common::Error::Failure(response),
13438                        });
13439                    }
13440                    let response = {
13441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13442                        let encoded = common::to_string(&bytes);
13443                        match serde_json::from_str(&encoded) {
13444                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13445                            Err(error) => {
13446                                dlg.response_json_decode_error(&encoded, &error);
13447                                return Err(common::Error::JsonDecodeError(
13448                                    encoded.to_string(),
13449                                    error,
13450                                ));
13451                            }
13452                        }
13453                    };
13454
13455                    dlg.finished(true);
13456                    return Ok(response);
13457                }
13458            }
13459        }
13460    }
13461
13462    ///
13463    /// Sets the *request* property to the given value.
13464    ///
13465    /// Even though the property as already been set when instantiating this call,
13466    /// we provide this method for API completeness.
13467    pub fn request(
13468        mut self,
13469        new_value: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
13470    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
13471        self._request = new_value;
13472        self
13473    }
13474    /// Required. Name of the recommendation.
13475    ///
13476    /// Sets the *name* path property to the given value.
13477    ///
13478    /// Even though the property as already been set when instantiating this call,
13479    /// we provide this method for API completeness.
13480    pub fn name(
13481        mut self,
13482        new_value: &str,
13483    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
13484        self._name = new_value.to_string();
13485        self
13486    }
13487    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13488    /// while executing the actual API request.
13489    ///
13490    /// ````text
13491    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13492    /// ````
13493    ///
13494    /// Sets the *delegate* property to the given value.
13495    pub fn delegate(
13496        mut self,
13497        new_value: &'a mut dyn common::Delegate,
13498    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
13499        self._delegate = Some(new_value);
13500        self
13501    }
13502
13503    /// Set any additional parameter of the query string used in the request.
13504    /// It should be used to set parameters which are not yet available through their own
13505    /// setters.
13506    ///
13507    /// Please note that this method must not be used to set any of the known parameters
13508    /// which have their own setter method. If done anyway, the request will fail.
13509    ///
13510    /// # Additional Parameters
13511    ///
13512    /// * *$.xgafv* (query-string) - V1 error format.
13513    /// * *access_token* (query-string) - OAuth access token.
13514    /// * *alt* (query-string) - Data format for response.
13515    /// * *callback* (query-string) - JSONP
13516    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13517    /// * *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.
13518    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13519    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13520    /// * *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.
13521    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13522    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13523    pub fn param<T>(
13524        mut self,
13525        name: T,
13526        value: T,
13527    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
13528    where
13529        T: AsRef<str>,
13530    {
13531        self._additional_params
13532            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13533        self
13534    }
13535
13536    /// Identifies the authorization scope for the method you are building.
13537    ///
13538    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13539    /// [`Scope::CloudPlatform`].
13540    ///
13541    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13542    /// tokens for more than one scope.
13543    ///
13544    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13545    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13546    /// sufficient, a read-write scope will do as well.
13547    pub fn add_scope<St>(
13548        mut self,
13549        scope: St,
13550    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
13551    where
13552        St: AsRef<str>,
13553    {
13554        self._scopes.insert(String::from(scope.as_ref()));
13555        self
13556    }
13557    /// Identifies the authorization scope(s) for the method you are building.
13558    ///
13559    /// See [`Self::add_scope()`] for details.
13560    pub fn add_scopes<I, St>(
13561        mut self,
13562        scopes: I,
13563    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
13564    where
13565        I: IntoIterator<Item = St>,
13566        St: AsRef<str>,
13567    {
13568        self._scopes
13569            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13570        self
13571    }
13572
13573    /// Removes all scopes, and no default scope will be used either.
13574    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13575    /// for details).
13576    pub fn clear_scopes(
13577        mut self,
13578    ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
13579        self._scopes.clear();
13580        self
13581    }
13582}
13583
13584/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
13585///
13586/// A builder for the *locations.recommenders.getConfig* method supported by a *organization* resource.
13587/// It is not used directly, but through a [`OrganizationMethods`] instance.
13588///
13589/// # Example
13590///
13591/// Instantiate a resource method builder
13592///
13593/// ```test_harness,no_run
13594/// # extern crate hyper;
13595/// # extern crate hyper_rustls;
13596/// # extern crate google_recommender1 as recommender1;
13597/// # async fn dox() {
13598/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13599///
13600/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13601/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13602/// #     .with_native_roots()
13603/// #     .unwrap()
13604/// #     .https_only()
13605/// #     .enable_http2()
13606/// #     .build();
13607///
13608/// # let executor = hyper_util::rt::TokioExecutor::new();
13609/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13610/// #     secret,
13611/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13612/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13613/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13614/// #     ),
13615/// # ).build().await.unwrap();
13616///
13617/// # let client = hyper_util::client::legacy::Client::builder(
13618/// #     hyper_util::rt::TokioExecutor::new()
13619/// # )
13620/// # .build(
13621/// #     hyper_rustls::HttpsConnectorBuilder::new()
13622/// #         .with_native_roots()
13623/// #         .unwrap()
13624/// #         .https_or_http()
13625/// #         .enable_http2()
13626/// #         .build()
13627/// # );
13628/// # let mut hub = Recommender::new(client, auth);
13629/// // You can configure optional parameters by calling the respective setters at will, and
13630/// // execute the final call using `doit()`.
13631/// // Values shown here are possibly random and not representative !
13632/// let result = hub.organizations().locations_recommenders_get_config("name")
13633///              .doit().await;
13634/// # }
13635/// ```
13636pub struct OrganizationLocationRecommenderGetConfigCall<'a, C>
13637where
13638    C: 'a,
13639{
13640    hub: &'a Recommender<C>,
13641    _name: String,
13642    _delegate: Option<&'a mut dyn common::Delegate>,
13643    _additional_params: HashMap<String, String>,
13644    _scopes: BTreeSet<String>,
13645}
13646
13647impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderGetConfigCall<'a, C> {}
13648
13649impl<'a, C> OrganizationLocationRecommenderGetConfigCall<'a, C>
13650where
13651    C: common::Connector,
13652{
13653    /// Perform the operation you have build so far.
13654    pub async fn doit(
13655        mut self,
13656    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1RecommenderConfig)> {
13657        use std::borrow::Cow;
13658        use std::io::{Read, Seek};
13659
13660        use common::{url::Params, ToParts};
13661        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13662
13663        let mut dd = common::DefaultDelegate;
13664        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13665        dlg.begin(common::MethodInfo {
13666            id: "recommender.organizations.locations.recommenders.getConfig",
13667            http_method: hyper::Method::GET,
13668        });
13669
13670        for &field in ["alt", "name"].iter() {
13671            if self._additional_params.contains_key(field) {
13672                dlg.finished(false);
13673                return Err(common::Error::FieldClash(field));
13674            }
13675        }
13676
13677        let mut params = Params::with_capacity(3 + self._additional_params.len());
13678        params.push("name", self._name);
13679
13680        params.extend(self._additional_params.iter());
13681
13682        params.push("alt", "json");
13683        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13684        if self._scopes.is_empty() {
13685            self._scopes
13686                .insert(Scope::CloudPlatform.as_ref().to_string());
13687        }
13688
13689        #[allow(clippy::single_element_loop)]
13690        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13691            url = params.uri_replacement(url, param_name, find_this, true);
13692        }
13693        {
13694            let to_remove = ["name"];
13695            params.remove_params(&to_remove);
13696        }
13697
13698        let url = params.parse_with_url(&url);
13699
13700        loop {
13701            let token = match self
13702                .hub
13703                .auth
13704                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13705                .await
13706            {
13707                Ok(token) => token,
13708                Err(e) => match dlg.token(e) {
13709                    Ok(token) => token,
13710                    Err(e) => {
13711                        dlg.finished(false);
13712                        return Err(common::Error::MissingToken(e));
13713                    }
13714                },
13715            };
13716            let mut req_result = {
13717                let client = &self.hub.client;
13718                dlg.pre_request();
13719                let mut req_builder = hyper::Request::builder()
13720                    .method(hyper::Method::GET)
13721                    .uri(url.as_str())
13722                    .header(USER_AGENT, self.hub._user_agent.clone());
13723
13724                if let Some(token) = token.as_ref() {
13725                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13726                }
13727
13728                let request = req_builder
13729                    .header(CONTENT_LENGTH, 0_u64)
13730                    .body(common::to_body::<String>(None));
13731
13732                client.request(request.unwrap()).await
13733            };
13734
13735            match req_result {
13736                Err(err) => {
13737                    if let common::Retry::After(d) = dlg.http_error(&err) {
13738                        sleep(d).await;
13739                        continue;
13740                    }
13741                    dlg.finished(false);
13742                    return Err(common::Error::HttpError(err));
13743                }
13744                Ok(res) => {
13745                    let (mut parts, body) = res.into_parts();
13746                    let mut body = common::Body::new(body);
13747                    if !parts.status.is_success() {
13748                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13749                        let error = serde_json::from_str(&common::to_string(&bytes));
13750                        let response = common::to_response(parts, bytes.into());
13751
13752                        if let common::Retry::After(d) =
13753                            dlg.http_failure(&response, error.as_ref().ok())
13754                        {
13755                            sleep(d).await;
13756                            continue;
13757                        }
13758
13759                        dlg.finished(false);
13760
13761                        return Err(match error {
13762                            Ok(value) => common::Error::BadRequest(value),
13763                            _ => common::Error::Failure(response),
13764                        });
13765                    }
13766                    let response = {
13767                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13768                        let encoded = common::to_string(&bytes);
13769                        match serde_json::from_str(&encoded) {
13770                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13771                            Err(error) => {
13772                                dlg.response_json_decode_error(&encoded, &error);
13773                                return Err(common::Error::JsonDecodeError(
13774                                    encoded.to_string(),
13775                                    error,
13776                                ));
13777                            }
13778                        }
13779                    };
13780
13781                    dlg.finished(true);
13782                    return Ok(response);
13783                }
13784            }
13785        }
13786    }
13787
13788    /// Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
13789    ///
13790    /// Sets the *name* path property to the given value.
13791    ///
13792    /// Even though the property as already been set when instantiating this call,
13793    /// we provide this method for API completeness.
13794    pub fn name(mut self, new_value: &str) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
13795        self._name = new_value.to_string();
13796        self
13797    }
13798    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13799    /// while executing the actual API request.
13800    ///
13801    /// ````text
13802    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13803    /// ````
13804    ///
13805    /// Sets the *delegate* property to the given value.
13806    pub fn delegate(
13807        mut self,
13808        new_value: &'a mut dyn common::Delegate,
13809    ) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
13810        self._delegate = Some(new_value);
13811        self
13812    }
13813
13814    /// Set any additional parameter of the query string used in the request.
13815    /// It should be used to set parameters which are not yet available through their own
13816    /// setters.
13817    ///
13818    /// Please note that this method must not be used to set any of the known parameters
13819    /// which have their own setter method. If done anyway, the request will fail.
13820    ///
13821    /// # Additional Parameters
13822    ///
13823    /// * *$.xgafv* (query-string) - V1 error format.
13824    /// * *access_token* (query-string) - OAuth access token.
13825    /// * *alt* (query-string) - Data format for response.
13826    /// * *callback* (query-string) - JSONP
13827    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13828    /// * *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.
13829    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13830    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13831    /// * *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.
13832    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13833    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13834    pub fn param<T>(
13835        mut self,
13836        name: T,
13837        value: T,
13838    ) -> OrganizationLocationRecommenderGetConfigCall<'a, C>
13839    where
13840        T: AsRef<str>,
13841    {
13842        self._additional_params
13843            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13844        self
13845    }
13846
13847    /// Identifies the authorization scope for the method you are building.
13848    ///
13849    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13850    /// [`Scope::CloudPlatform`].
13851    ///
13852    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13853    /// tokens for more than one scope.
13854    ///
13855    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13856    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13857    /// sufficient, a read-write scope will do as well.
13858    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationRecommenderGetConfigCall<'a, C>
13859    where
13860        St: AsRef<str>,
13861    {
13862        self._scopes.insert(String::from(scope.as_ref()));
13863        self
13864    }
13865    /// Identifies the authorization scope(s) for the method you are building.
13866    ///
13867    /// See [`Self::add_scope()`] for details.
13868    pub fn add_scopes<I, St>(
13869        mut self,
13870        scopes: I,
13871    ) -> OrganizationLocationRecommenderGetConfigCall<'a, C>
13872    where
13873        I: IntoIterator<Item = St>,
13874        St: AsRef<str>,
13875    {
13876        self._scopes
13877            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13878        self
13879    }
13880
13881    /// Removes all scopes, and no default scope will be used either.
13882    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13883    /// for details).
13884    pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
13885        self._scopes.clear();
13886        self
13887    }
13888}
13889
13890/// Updates a Recommender Config. This will create a new revision of the config.
13891///
13892/// A builder for the *locations.recommenders.updateConfig* method supported by a *organization* resource.
13893/// It is not used directly, but through a [`OrganizationMethods`] instance.
13894///
13895/// # Example
13896///
13897/// Instantiate a resource method builder
13898///
13899/// ```test_harness,no_run
13900/// # extern crate hyper;
13901/// # extern crate hyper_rustls;
13902/// # extern crate google_recommender1 as recommender1;
13903/// use recommender1::api::GoogleCloudRecommenderV1RecommenderConfig;
13904/// # async fn dox() {
13905/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13906///
13907/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13908/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13909/// #     .with_native_roots()
13910/// #     .unwrap()
13911/// #     .https_only()
13912/// #     .enable_http2()
13913/// #     .build();
13914///
13915/// # let executor = hyper_util::rt::TokioExecutor::new();
13916/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13917/// #     secret,
13918/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13919/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13920/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13921/// #     ),
13922/// # ).build().await.unwrap();
13923///
13924/// # let client = hyper_util::client::legacy::Client::builder(
13925/// #     hyper_util::rt::TokioExecutor::new()
13926/// # )
13927/// # .build(
13928/// #     hyper_rustls::HttpsConnectorBuilder::new()
13929/// #         .with_native_roots()
13930/// #         .unwrap()
13931/// #         .https_or_http()
13932/// #         .enable_http2()
13933/// #         .build()
13934/// # );
13935/// # let mut hub = Recommender::new(client, auth);
13936/// // As the method needs a request, you would usually fill it with the desired information
13937/// // into the respective structure. Some of the parts shown here might not be applicable !
13938/// // Values shown here are possibly random and not representative !
13939/// let mut req = GoogleCloudRecommenderV1RecommenderConfig::default();
13940///
13941/// // You can configure optional parameters by calling the respective setters at will, and
13942/// // execute the final call using `doit()`.
13943/// // Values shown here are possibly random and not representative !
13944/// let result = hub.organizations().locations_recommenders_update_config(req, "name")
13945///              .validate_only(false)
13946///              .update_mask(FieldMask::new::<&str>(&[]))
13947///              .doit().await;
13948/// # }
13949/// ```
13950pub struct OrganizationLocationRecommenderUpdateConfigCall<'a, C>
13951where
13952    C: 'a,
13953{
13954    hub: &'a Recommender<C>,
13955    _request: GoogleCloudRecommenderV1RecommenderConfig,
13956    _name: String,
13957    _validate_only: Option<bool>,
13958    _update_mask: Option<common::FieldMask>,
13959    _delegate: Option<&'a mut dyn common::Delegate>,
13960    _additional_params: HashMap<String, String>,
13961    _scopes: BTreeSet<String>,
13962}
13963
13964impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderUpdateConfigCall<'a, C> {}
13965
13966impl<'a, C> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
13967where
13968    C: common::Connector,
13969{
13970    /// Perform the operation you have build so far.
13971    pub async fn doit(
13972        mut self,
13973    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1RecommenderConfig)> {
13974        use std::borrow::Cow;
13975        use std::io::{Read, Seek};
13976
13977        use common::{url::Params, ToParts};
13978        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13979
13980        let mut dd = common::DefaultDelegate;
13981        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13982        dlg.begin(common::MethodInfo {
13983            id: "recommender.organizations.locations.recommenders.updateConfig",
13984            http_method: hyper::Method::PATCH,
13985        });
13986
13987        for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
13988            if self._additional_params.contains_key(field) {
13989                dlg.finished(false);
13990                return Err(common::Error::FieldClash(field));
13991            }
13992        }
13993
13994        let mut params = Params::with_capacity(6 + self._additional_params.len());
13995        params.push("name", self._name);
13996        if let Some(value) = self._validate_only.as_ref() {
13997            params.push("validateOnly", value.to_string());
13998        }
13999        if let Some(value) = self._update_mask.as_ref() {
14000            params.push("updateMask", value.to_string());
14001        }
14002
14003        params.extend(self._additional_params.iter());
14004
14005        params.push("alt", "json");
14006        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14007        if self._scopes.is_empty() {
14008            self._scopes
14009                .insert(Scope::CloudPlatform.as_ref().to_string());
14010        }
14011
14012        #[allow(clippy::single_element_loop)]
14013        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14014            url = params.uri_replacement(url, param_name, find_this, true);
14015        }
14016        {
14017            let to_remove = ["name"];
14018            params.remove_params(&to_remove);
14019        }
14020
14021        let url = params.parse_with_url(&url);
14022
14023        let mut json_mime_type = mime::APPLICATION_JSON;
14024        let mut request_value_reader = {
14025            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14026            common::remove_json_null_values(&mut value);
14027            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14028            serde_json::to_writer(&mut dst, &value).unwrap();
14029            dst
14030        };
14031        let request_size = request_value_reader
14032            .seek(std::io::SeekFrom::End(0))
14033            .unwrap();
14034        request_value_reader
14035            .seek(std::io::SeekFrom::Start(0))
14036            .unwrap();
14037
14038        loop {
14039            let token = match self
14040                .hub
14041                .auth
14042                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14043                .await
14044            {
14045                Ok(token) => token,
14046                Err(e) => match dlg.token(e) {
14047                    Ok(token) => token,
14048                    Err(e) => {
14049                        dlg.finished(false);
14050                        return Err(common::Error::MissingToken(e));
14051                    }
14052                },
14053            };
14054            request_value_reader
14055                .seek(std::io::SeekFrom::Start(0))
14056                .unwrap();
14057            let mut req_result = {
14058                let client = &self.hub.client;
14059                dlg.pre_request();
14060                let mut req_builder = hyper::Request::builder()
14061                    .method(hyper::Method::PATCH)
14062                    .uri(url.as_str())
14063                    .header(USER_AGENT, self.hub._user_agent.clone());
14064
14065                if let Some(token) = token.as_ref() {
14066                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14067                }
14068
14069                let request = req_builder
14070                    .header(CONTENT_TYPE, json_mime_type.to_string())
14071                    .header(CONTENT_LENGTH, request_size as u64)
14072                    .body(common::to_body(
14073                        request_value_reader.get_ref().clone().into(),
14074                    ));
14075
14076                client.request(request.unwrap()).await
14077            };
14078
14079            match req_result {
14080                Err(err) => {
14081                    if let common::Retry::After(d) = dlg.http_error(&err) {
14082                        sleep(d).await;
14083                        continue;
14084                    }
14085                    dlg.finished(false);
14086                    return Err(common::Error::HttpError(err));
14087                }
14088                Ok(res) => {
14089                    let (mut parts, body) = res.into_parts();
14090                    let mut body = common::Body::new(body);
14091                    if !parts.status.is_success() {
14092                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14093                        let error = serde_json::from_str(&common::to_string(&bytes));
14094                        let response = common::to_response(parts, bytes.into());
14095
14096                        if let common::Retry::After(d) =
14097                            dlg.http_failure(&response, error.as_ref().ok())
14098                        {
14099                            sleep(d).await;
14100                            continue;
14101                        }
14102
14103                        dlg.finished(false);
14104
14105                        return Err(match error {
14106                            Ok(value) => common::Error::BadRequest(value),
14107                            _ => common::Error::Failure(response),
14108                        });
14109                    }
14110                    let response = {
14111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14112                        let encoded = common::to_string(&bytes);
14113                        match serde_json::from_str(&encoded) {
14114                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14115                            Err(error) => {
14116                                dlg.response_json_decode_error(&encoded, &error);
14117                                return Err(common::Error::JsonDecodeError(
14118                                    encoded.to_string(),
14119                                    error,
14120                                ));
14121                            }
14122                        }
14123                    };
14124
14125                    dlg.finished(true);
14126                    return Ok(response);
14127                }
14128            }
14129        }
14130    }
14131
14132    ///
14133    /// Sets the *request* property to the given value.
14134    ///
14135    /// Even though the property as already been set when instantiating this call,
14136    /// we provide this method for API completeness.
14137    pub fn request(
14138        mut self,
14139        new_value: GoogleCloudRecommenderV1RecommenderConfig,
14140    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
14141        self._request = new_value;
14142        self
14143    }
14144    /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
14145    ///
14146    /// Sets the *name* path property to the given value.
14147    ///
14148    /// Even though the property as already been set when instantiating this call,
14149    /// we provide this method for API completeness.
14150    pub fn name(
14151        mut self,
14152        new_value: &str,
14153    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
14154        self._name = new_value.to_string();
14155        self
14156    }
14157    /// If true, validate the request and preview the change, but do not actually update it.
14158    ///
14159    /// Sets the *validate only* query property to the given value.
14160    pub fn validate_only(
14161        mut self,
14162        new_value: bool,
14163    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
14164        self._validate_only = Some(new_value);
14165        self
14166    }
14167    /// The list of fields to be updated.
14168    ///
14169    /// Sets the *update mask* query property to the given value.
14170    pub fn update_mask(
14171        mut self,
14172        new_value: common::FieldMask,
14173    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
14174        self._update_mask = Some(new_value);
14175        self
14176    }
14177    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14178    /// while executing the actual API request.
14179    ///
14180    /// ````text
14181    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14182    /// ````
14183    ///
14184    /// Sets the *delegate* property to the given value.
14185    pub fn delegate(
14186        mut self,
14187        new_value: &'a mut dyn common::Delegate,
14188    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
14189        self._delegate = Some(new_value);
14190        self
14191    }
14192
14193    /// Set any additional parameter of the query string used in the request.
14194    /// It should be used to set parameters which are not yet available through their own
14195    /// setters.
14196    ///
14197    /// Please note that this method must not be used to set any of the known parameters
14198    /// which have their own setter method. If done anyway, the request will fail.
14199    ///
14200    /// # Additional Parameters
14201    ///
14202    /// * *$.xgafv* (query-string) - V1 error format.
14203    /// * *access_token* (query-string) - OAuth access token.
14204    /// * *alt* (query-string) - Data format for response.
14205    /// * *callback* (query-string) - JSONP
14206    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14207    /// * *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.
14208    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14209    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14210    /// * *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.
14211    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14212    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14213    pub fn param<T>(
14214        mut self,
14215        name: T,
14216        value: T,
14217    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
14218    where
14219        T: AsRef<str>,
14220    {
14221        self._additional_params
14222            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14223        self
14224    }
14225
14226    /// Identifies the authorization scope for the method you are building.
14227    ///
14228    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14229    /// [`Scope::CloudPlatform`].
14230    ///
14231    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14232    /// tokens for more than one scope.
14233    ///
14234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14236    /// sufficient, a read-write scope will do as well.
14237    pub fn add_scope<St>(
14238        mut self,
14239        scope: St,
14240    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
14241    where
14242        St: AsRef<str>,
14243    {
14244        self._scopes.insert(String::from(scope.as_ref()));
14245        self
14246    }
14247    /// Identifies the authorization scope(s) for the method you are building.
14248    ///
14249    /// See [`Self::add_scope()`] for details.
14250    pub fn add_scopes<I, St>(
14251        mut self,
14252        scopes: I,
14253    ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
14254    where
14255        I: IntoIterator<Item = St>,
14256        St: AsRef<str>,
14257    {
14258        self._scopes
14259            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14260        self
14261    }
14262
14263    /// Removes all scopes, and no default scope will be used either.
14264    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14265    /// for details).
14266    pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
14267        self._scopes.clear();
14268        self
14269    }
14270}
14271
14272/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
14273///
14274/// A builder for the *locations.insightTypes.insights.get* method supported by a *project* resource.
14275/// It is not used directly, but through a [`ProjectMethods`] instance.
14276///
14277/// # Example
14278///
14279/// Instantiate a resource method builder
14280///
14281/// ```test_harness,no_run
14282/// # extern crate hyper;
14283/// # extern crate hyper_rustls;
14284/// # extern crate google_recommender1 as recommender1;
14285/// # async fn dox() {
14286/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14287///
14288/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14289/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14290/// #     .with_native_roots()
14291/// #     .unwrap()
14292/// #     .https_only()
14293/// #     .enable_http2()
14294/// #     .build();
14295///
14296/// # let executor = hyper_util::rt::TokioExecutor::new();
14297/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14298/// #     secret,
14299/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14300/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14301/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14302/// #     ),
14303/// # ).build().await.unwrap();
14304///
14305/// # let client = hyper_util::client::legacy::Client::builder(
14306/// #     hyper_util::rt::TokioExecutor::new()
14307/// # )
14308/// # .build(
14309/// #     hyper_rustls::HttpsConnectorBuilder::new()
14310/// #         .with_native_roots()
14311/// #         .unwrap()
14312/// #         .https_or_http()
14313/// #         .enable_http2()
14314/// #         .build()
14315/// # );
14316/// # let mut hub = Recommender::new(client, auth);
14317/// // You can configure optional parameters by calling the respective setters at will, and
14318/// // execute the final call using `doit()`.
14319/// // Values shown here are possibly random and not representative !
14320/// let result = hub.projects().locations_insight_types_insights_get("name")
14321///              .doit().await;
14322/// # }
14323/// ```
14324pub struct ProjectLocationInsightTypeInsightGetCall<'a, C>
14325where
14326    C: 'a,
14327{
14328    hub: &'a Recommender<C>,
14329    _name: String,
14330    _delegate: Option<&'a mut dyn common::Delegate>,
14331    _additional_params: HashMap<String, String>,
14332    _scopes: BTreeSet<String>,
14333}
14334
14335impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeInsightGetCall<'a, C> {}
14336
14337impl<'a, C> ProjectLocationInsightTypeInsightGetCall<'a, C>
14338where
14339    C: common::Connector,
14340{
14341    /// Perform the operation you have build so far.
14342    pub async fn doit(
14343        mut self,
14344    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
14345        use std::borrow::Cow;
14346        use std::io::{Read, Seek};
14347
14348        use common::{url::Params, ToParts};
14349        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14350
14351        let mut dd = common::DefaultDelegate;
14352        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14353        dlg.begin(common::MethodInfo {
14354            id: "recommender.projects.locations.insightTypes.insights.get",
14355            http_method: hyper::Method::GET,
14356        });
14357
14358        for &field in ["alt", "name"].iter() {
14359            if self._additional_params.contains_key(field) {
14360                dlg.finished(false);
14361                return Err(common::Error::FieldClash(field));
14362            }
14363        }
14364
14365        let mut params = Params::with_capacity(3 + self._additional_params.len());
14366        params.push("name", self._name);
14367
14368        params.extend(self._additional_params.iter());
14369
14370        params.push("alt", "json");
14371        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14372        if self._scopes.is_empty() {
14373            self._scopes
14374                .insert(Scope::CloudPlatform.as_ref().to_string());
14375        }
14376
14377        #[allow(clippy::single_element_loop)]
14378        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14379            url = params.uri_replacement(url, param_name, find_this, true);
14380        }
14381        {
14382            let to_remove = ["name"];
14383            params.remove_params(&to_remove);
14384        }
14385
14386        let url = params.parse_with_url(&url);
14387
14388        loop {
14389            let token = match self
14390                .hub
14391                .auth
14392                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14393                .await
14394            {
14395                Ok(token) => token,
14396                Err(e) => match dlg.token(e) {
14397                    Ok(token) => token,
14398                    Err(e) => {
14399                        dlg.finished(false);
14400                        return Err(common::Error::MissingToken(e));
14401                    }
14402                },
14403            };
14404            let mut req_result = {
14405                let client = &self.hub.client;
14406                dlg.pre_request();
14407                let mut req_builder = hyper::Request::builder()
14408                    .method(hyper::Method::GET)
14409                    .uri(url.as_str())
14410                    .header(USER_AGENT, self.hub._user_agent.clone());
14411
14412                if let Some(token) = token.as_ref() {
14413                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14414                }
14415
14416                let request = req_builder
14417                    .header(CONTENT_LENGTH, 0_u64)
14418                    .body(common::to_body::<String>(None));
14419
14420                client.request(request.unwrap()).await
14421            };
14422
14423            match req_result {
14424                Err(err) => {
14425                    if let common::Retry::After(d) = dlg.http_error(&err) {
14426                        sleep(d).await;
14427                        continue;
14428                    }
14429                    dlg.finished(false);
14430                    return Err(common::Error::HttpError(err));
14431                }
14432                Ok(res) => {
14433                    let (mut parts, body) = res.into_parts();
14434                    let mut body = common::Body::new(body);
14435                    if !parts.status.is_success() {
14436                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14437                        let error = serde_json::from_str(&common::to_string(&bytes));
14438                        let response = common::to_response(parts, bytes.into());
14439
14440                        if let common::Retry::After(d) =
14441                            dlg.http_failure(&response, error.as_ref().ok())
14442                        {
14443                            sleep(d).await;
14444                            continue;
14445                        }
14446
14447                        dlg.finished(false);
14448
14449                        return Err(match error {
14450                            Ok(value) => common::Error::BadRequest(value),
14451                            _ => common::Error::Failure(response),
14452                        });
14453                    }
14454                    let response = {
14455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14456                        let encoded = common::to_string(&bytes);
14457                        match serde_json::from_str(&encoded) {
14458                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14459                            Err(error) => {
14460                                dlg.response_json_decode_error(&encoded, &error);
14461                                return Err(common::Error::JsonDecodeError(
14462                                    encoded.to_string(),
14463                                    error,
14464                                ));
14465                            }
14466                        }
14467                    };
14468
14469                    dlg.finished(true);
14470                    return Ok(response);
14471                }
14472            }
14473        }
14474    }
14475
14476    /// Required. Name of the insight.
14477    ///
14478    /// Sets the *name* path property to the given value.
14479    ///
14480    /// Even though the property as already been set when instantiating this call,
14481    /// we provide this method for API completeness.
14482    pub fn name(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
14483        self._name = new_value.to_string();
14484        self
14485    }
14486    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14487    /// while executing the actual API request.
14488    ///
14489    /// ````text
14490    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14491    /// ````
14492    ///
14493    /// Sets the *delegate* property to the given value.
14494    pub fn delegate(
14495        mut self,
14496        new_value: &'a mut dyn common::Delegate,
14497    ) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
14498        self._delegate = Some(new_value);
14499        self
14500    }
14501
14502    /// Set any additional parameter of the query string used in the request.
14503    /// It should be used to set parameters which are not yet available through their own
14504    /// setters.
14505    ///
14506    /// Please note that this method must not be used to set any of the known parameters
14507    /// which have their own setter method. If done anyway, the request will fail.
14508    ///
14509    /// # Additional Parameters
14510    ///
14511    /// * *$.xgafv* (query-string) - V1 error format.
14512    /// * *access_token* (query-string) - OAuth access token.
14513    /// * *alt* (query-string) - Data format for response.
14514    /// * *callback* (query-string) - JSONP
14515    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14516    /// * *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.
14517    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14518    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14519    /// * *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.
14520    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14521    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14522    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeInsightGetCall<'a, C>
14523    where
14524        T: AsRef<str>,
14525    {
14526        self._additional_params
14527            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14528        self
14529    }
14530
14531    /// Identifies the authorization scope for the method you are building.
14532    ///
14533    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14534    /// [`Scope::CloudPlatform`].
14535    ///
14536    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14537    /// tokens for more than one scope.
14538    ///
14539    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14540    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14541    /// sufficient, a read-write scope will do as well.
14542    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeInsightGetCall<'a, C>
14543    where
14544        St: AsRef<str>,
14545    {
14546        self._scopes.insert(String::from(scope.as_ref()));
14547        self
14548    }
14549    /// Identifies the authorization scope(s) for the method you are building.
14550    ///
14551    /// See [`Self::add_scope()`] for details.
14552    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeInsightGetCall<'a, C>
14553    where
14554        I: IntoIterator<Item = St>,
14555        St: AsRef<str>,
14556    {
14557        self._scopes
14558            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14559        self
14560    }
14561
14562    /// Removes all scopes, and no default scope will be used either.
14563    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14564    /// for details).
14565    pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
14566        self._scopes.clear();
14567        self
14568    }
14569}
14570
14571/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
14572///
14573/// A builder for the *locations.insightTypes.insights.list* method supported by a *project* resource.
14574/// It is not used directly, but through a [`ProjectMethods`] instance.
14575///
14576/// # Example
14577///
14578/// Instantiate a resource method builder
14579///
14580/// ```test_harness,no_run
14581/// # extern crate hyper;
14582/// # extern crate hyper_rustls;
14583/// # extern crate google_recommender1 as recommender1;
14584/// # async fn dox() {
14585/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14586///
14587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14588/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14589/// #     .with_native_roots()
14590/// #     .unwrap()
14591/// #     .https_only()
14592/// #     .enable_http2()
14593/// #     .build();
14594///
14595/// # let executor = hyper_util::rt::TokioExecutor::new();
14596/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14597/// #     secret,
14598/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14599/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14600/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14601/// #     ),
14602/// # ).build().await.unwrap();
14603///
14604/// # let client = hyper_util::client::legacy::Client::builder(
14605/// #     hyper_util::rt::TokioExecutor::new()
14606/// # )
14607/// # .build(
14608/// #     hyper_rustls::HttpsConnectorBuilder::new()
14609/// #         .with_native_roots()
14610/// #         .unwrap()
14611/// #         .https_or_http()
14612/// #         .enable_http2()
14613/// #         .build()
14614/// # );
14615/// # let mut hub = Recommender::new(client, auth);
14616/// // You can configure optional parameters by calling the respective setters at will, and
14617/// // execute the final call using `doit()`.
14618/// // Values shown here are possibly random and not representative !
14619/// let result = hub.projects().locations_insight_types_insights_list("parent")
14620///              .page_token("duo")
14621///              .page_size(-76)
14622///              .filter("vero")
14623///              .doit().await;
14624/// # }
14625/// ```
14626pub struct ProjectLocationInsightTypeInsightListCall<'a, C>
14627where
14628    C: 'a,
14629{
14630    hub: &'a Recommender<C>,
14631    _parent: String,
14632    _page_token: Option<String>,
14633    _page_size: Option<i32>,
14634    _filter: Option<String>,
14635    _delegate: Option<&'a mut dyn common::Delegate>,
14636    _additional_params: HashMap<String, String>,
14637    _scopes: BTreeSet<String>,
14638}
14639
14640impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeInsightListCall<'a, C> {}
14641
14642impl<'a, C> ProjectLocationInsightTypeInsightListCall<'a, C>
14643where
14644    C: common::Connector,
14645{
14646    /// Perform the operation you have build so far.
14647    pub async fn doit(
14648        mut self,
14649    ) -> common::Result<(
14650        common::Response,
14651        GoogleCloudRecommenderV1ListInsightsResponse,
14652    )> {
14653        use std::borrow::Cow;
14654        use std::io::{Read, Seek};
14655
14656        use common::{url::Params, ToParts};
14657        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14658
14659        let mut dd = common::DefaultDelegate;
14660        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14661        dlg.begin(common::MethodInfo {
14662            id: "recommender.projects.locations.insightTypes.insights.list",
14663            http_method: hyper::Method::GET,
14664        });
14665
14666        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
14667            if self._additional_params.contains_key(field) {
14668                dlg.finished(false);
14669                return Err(common::Error::FieldClash(field));
14670            }
14671        }
14672
14673        let mut params = Params::with_capacity(6 + self._additional_params.len());
14674        params.push("parent", self._parent);
14675        if let Some(value) = self._page_token.as_ref() {
14676            params.push("pageToken", value);
14677        }
14678        if let Some(value) = self._page_size.as_ref() {
14679            params.push("pageSize", value.to_string());
14680        }
14681        if let Some(value) = self._filter.as_ref() {
14682            params.push("filter", value);
14683        }
14684
14685        params.extend(self._additional_params.iter());
14686
14687        params.push("alt", "json");
14688        let mut url = self.hub._base_url.clone() + "v1/{+parent}/insights";
14689        if self._scopes.is_empty() {
14690            self._scopes
14691                .insert(Scope::CloudPlatform.as_ref().to_string());
14692        }
14693
14694        #[allow(clippy::single_element_loop)]
14695        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14696            url = params.uri_replacement(url, param_name, find_this, true);
14697        }
14698        {
14699            let to_remove = ["parent"];
14700            params.remove_params(&to_remove);
14701        }
14702
14703        let url = params.parse_with_url(&url);
14704
14705        loop {
14706            let token = match self
14707                .hub
14708                .auth
14709                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14710                .await
14711            {
14712                Ok(token) => token,
14713                Err(e) => match dlg.token(e) {
14714                    Ok(token) => token,
14715                    Err(e) => {
14716                        dlg.finished(false);
14717                        return Err(common::Error::MissingToken(e));
14718                    }
14719                },
14720            };
14721            let mut req_result = {
14722                let client = &self.hub.client;
14723                dlg.pre_request();
14724                let mut req_builder = hyper::Request::builder()
14725                    .method(hyper::Method::GET)
14726                    .uri(url.as_str())
14727                    .header(USER_AGENT, self.hub._user_agent.clone());
14728
14729                if let Some(token) = token.as_ref() {
14730                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14731                }
14732
14733                let request = req_builder
14734                    .header(CONTENT_LENGTH, 0_u64)
14735                    .body(common::to_body::<String>(None));
14736
14737                client.request(request.unwrap()).await
14738            };
14739
14740            match req_result {
14741                Err(err) => {
14742                    if let common::Retry::After(d) = dlg.http_error(&err) {
14743                        sleep(d).await;
14744                        continue;
14745                    }
14746                    dlg.finished(false);
14747                    return Err(common::Error::HttpError(err));
14748                }
14749                Ok(res) => {
14750                    let (mut parts, body) = res.into_parts();
14751                    let mut body = common::Body::new(body);
14752                    if !parts.status.is_success() {
14753                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14754                        let error = serde_json::from_str(&common::to_string(&bytes));
14755                        let response = common::to_response(parts, bytes.into());
14756
14757                        if let common::Retry::After(d) =
14758                            dlg.http_failure(&response, error.as_ref().ok())
14759                        {
14760                            sleep(d).await;
14761                            continue;
14762                        }
14763
14764                        dlg.finished(false);
14765
14766                        return Err(match error {
14767                            Ok(value) => common::Error::BadRequest(value),
14768                            _ => common::Error::Failure(response),
14769                        });
14770                    }
14771                    let response = {
14772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14773                        let encoded = common::to_string(&bytes);
14774                        match serde_json::from_str(&encoded) {
14775                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14776                            Err(error) => {
14777                                dlg.response_json_decode_error(&encoded, &error);
14778                                return Err(common::Error::JsonDecodeError(
14779                                    encoded.to_string(),
14780                                    error,
14781                                ));
14782                            }
14783                        }
14784                    };
14785
14786                    dlg.finished(true);
14787                    return Ok(response);
14788                }
14789            }
14790        }
14791    }
14792
14793    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
14794    ///
14795    /// Sets the *parent* path property to the given value.
14796    ///
14797    /// Even though the property as already been set when instantiating this call,
14798    /// we provide this method for API completeness.
14799    pub fn parent(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
14800        self._parent = new_value.to_string();
14801        self
14802    }
14803    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
14804    ///
14805    /// Sets the *page token* query property to the given value.
14806    pub fn page_token(
14807        mut self,
14808        new_value: &str,
14809    ) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
14810        self._page_token = Some(new_value.to_string());
14811        self
14812    }
14813    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
14814    ///
14815    /// Sets the *page size* query property to the given value.
14816    pub fn page_size(mut self, new_value: i32) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
14817        self._page_size = Some(new_value);
14818        self
14819    }
14820    /// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
14821    ///
14822    /// Sets the *filter* query property to the given value.
14823    pub fn filter(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
14824        self._filter = Some(new_value.to_string());
14825        self
14826    }
14827    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14828    /// while executing the actual API request.
14829    ///
14830    /// ````text
14831    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14832    /// ````
14833    ///
14834    /// Sets the *delegate* property to the given value.
14835    pub fn delegate(
14836        mut self,
14837        new_value: &'a mut dyn common::Delegate,
14838    ) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
14839        self._delegate = Some(new_value);
14840        self
14841    }
14842
14843    /// Set any additional parameter of the query string used in the request.
14844    /// It should be used to set parameters which are not yet available through their own
14845    /// setters.
14846    ///
14847    /// Please note that this method must not be used to set any of the known parameters
14848    /// which have their own setter method. If done anyway, the request will fail.
14849    ///
14850    /// # Additional Parameters
14851    ///
14852    /// * *$.xgafv* (query-string) - V1 error format.
14853    /// * *access_token* (query-string) - OAuth access token.
14854    /// * *alt* (query-string) - Data format for response.
14855    /// * *callback* (query-string) - JSONP
14856    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14857    /// * *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.
14858    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14859    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14860    /// * *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.
14861    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14862    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14863    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeInsightListCall<'a, C>
14864    where
14865        T: AsRef<str>,
14866    {
14867        self._additional_params
14868            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14869        self
14870    }
14871
14872    /// Identifies the authorization scope for the method you are building.
14873    ///
14874    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14875    /// [`Scope::CloudPlatform`].
14876    ///
14877    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14878    /// tokens for more than one scope.
14879    ///
14880    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14881    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14882    /// sufficient, a read-write scope will do as well.
14883    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeInsightListCall<'a, C>
14884    where
14885        St: AsRef<str>,
14886    {
14887        self._scopes.insert(String::from(scope.as_ref()));
14888        self
14889    }
14890    /// Identifies the authorization scope(s) for the method you are building.
14891    ///
14892    /// See [`Self::add_scope()`] for details.
14893    pub fn add_scopes<I, St>(
14894        mut self,
14895        scopes: I,
14896    ) -> ProjectLocationInsightTypeInsightListCall<'a, C>
14897    where
14898        I: IntoIterator<Item = St>,
14899        St: AsRef<str>,
14900    {
14901        self._scopes
14902            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14903        self
14904    }
14905
14906    /// Removes all scopes, and no default scope will be used either.
14907    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14908    /// for details).
14909    pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
14910        self._scopes.clear();
14911        self
14912    }
14913}
14914
14915/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
14916///
14917/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *project* resource.
14918/// It is not used directly, but through a [`ProjectMethods`] instance.
14919///
14920/// # Example
14921///
14922/// Instantiate a resource method builder
14923///
14924/// ```test_harness,no_run
14925/// # extern crate hyper;
14926/// # extern crate hyper_rustls;
14927/// # extern crate google_recommender1 as recommender1;
14928/// use recommender1::api::GoogleCloudRecommenderV1MarkInsightAcceptedRequest;
14929/// # async fn dox() {
14930/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14931///
14932/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14933/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14934/// #     .with_native_roots()
14935/// #     .unwrap()
14936/// #     .https_only()
14937/// #     .enable_http2()
14938/// #     .build();
14939///
14940/// # let executor = hyper_util::rt::TokioExecutor::new();
14941/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14942/// #     secret,
14943/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14944/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14945/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14946/// #     ),
14947/// # ).build().await.unwrap();
14948///
14949/// # let client = hyper_util::client::legacy::Client::builder(
14950/// #     hyper_util::rt::TokioExecutor::new()
14951/// # )
14952/// # .build(
14953/// #     hyper_rustls::HttpsConnectorBuilder::new()
14954/// #         .with_native_roots()
14955/// #         .unwrap()
14956/// #         .https_or_http()
14957/// #         .enable_http2()
14958/// #         .build()
14959/// # );
14960/// # let mut hub = Recommender::new(client, auth);
14961/// // As the method needs a request, you would usually fill it with the desired information
14962/// // into the respective structure. Some of the parts shown here might not be applicable !
14963/// // Values shown here are possibly random and not representative !
14964/// let mut req = GoogleCloudRecommenderV1MarkInsightAcceptedRequest::default();
14965///
14966/// // You can configure optional parameters by calling the respective setters at will, and
14967/// // execute the final call using `doit()`.
14968/// // Values shown here are possibly random and not representative !
14969/// let result = hub.projects().locations_insight_types_insights_mark_accepted(req, "name")
14970///              .doit().await;
14971/// # }
14972/// ```
14973pub struct ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
14974where
14975    C: 'a,
14976{
14977    hub: &'a Recommender<C>,
14978    _request: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
14979    _name: String,
14980    _delegate: Option<&'a mut dyn common::Delegate>,
14981    _additional_params: HashMap<String, String>,
14982    _scopes: BTreeSet<String>,
14983}
14984
14985impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {}
14986
14987impl<'a, C> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
14988where
14989    C: common::Connector,
14990{
14991    /// Perform the operation you have build so far.
14992    pub async fn doit(
14993        mut self,
14994    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Insight)> {
14995        use std::borrow::Cow;
14996        use std::io::{Read, Seek};
14997
14998        use common::{url::Params, ToParts};
14999        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15000
15001        let mut dd = common::DefaultDelegate;
15002        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15003        dlg.begin(common::MethodInfo {
15004            id: "recommender.projects.locations.insightTypes.insights.markAccepted",
15005            http_method: hyper::Method::POST,
15006        });
15007
15008        for &field in ["alt", "name"].iter() {
15009            if self._additional_params.contains_key(field) {
15010                dlg.finished(false);
15011                return Err(common::Error::FieldClash(field));
15012            }
15013        }
15014
15015        let mut params = Params::with_capacity(4 + self._additional_params.len());
15016        params.push("name", self._name);
15017
15018        params.extend(self._additional_params.iter());
15019
15020        params.push("alt", "json");
15021        let mut url = self.hub._base_url.clone() + "v1/{+name}:markAccepted";
15022        if self._scopes.is_empty() {
15023            self._scopes
15024                .insert(Scope::CloudPlatform.as_ref().to_string());
15025        }
15026
15027        #[allow(clippy::single_element_loop)]
15028        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15029            url = params.uri_replacement(url, param_name, find_this, true);
15030        }
15031        {
15032            let to_remove = ["name"];
15033            params.remove_params(&to_remove);
15034        }
15035
15036        let url = params.parse_with_url(&url);
15037
15038        let mut json_mime_type = mime::APPLICATION_JSON;
15039        let mut request_value_reader = {
15040            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15041            common::remove_json_null_values(&mut value);
15042            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15043            serde_json::to_writer(&mut dst, &value).unwrap();
15044            dst
15045        };
15046        let request_size = request_value_reader
15047            .seek(std::io::SeekFrom::End(0))
15048            .unwrap();
15049        request_value_reader
15050            .seek(std::io::SeekFrom::Start(0))
15051            .unwrap();
15052
15053        loop {
15054            let token = match self
15055                .hub
15056                .auth
15057                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15058                .await
15059            {
15060                Ok(token) => token,
15061                Err(e) => match dlg.token(e) {
15062                    Ok(token) => token,
15063                    Err(e) => {
15064                        dlg.finished(false);
15065                        return Err(common::Error::MissingToken(e));
15066                    }
15067                },
15068            };
15069            request_value_reader
15070                .seek(std::io::SeekFrom::Start(0))
15071                .unwrap();
15072            let mut req_result = {
15073                let client = &self.hub.client;
15074                dlg.pre_request();
15075                let mut req_builder = hyper::Request::builder()
15076                    .method(hyper::Method::POST)
15077                    .uri(url.as_str())
15078                    .header(USER_AGENT, self.hub._user_agent.clone());
15079
15080                if let Some(token) = token.as_ref() {
15081                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15082                }
15083
15084                let request = req_builder
15085                    .header(CONTENT_TYPE, json_mime_type.to_string())
15086                    .header(CONTENT_LENGTH, request_size as u64)
15087                    .body(common::to_body(
15088                        request_value_reader.get_ref().clone().into(),
15089                    ));
15090
15091                client.request(request.unwrap()).await
15092            };
15093
15094            match req_result {
15095                Err(err) => {
15096                    if let common::Retry::After(d) = dlg.http_error(&err) {
15097                        sleep(d).await;
15098                        continue;
15099                    }
15100                    dlg.finished(false);
15101                    return Err(common::Error::HttpError(err));
15102                }
15103                Ok(res) => {
15104                    let (mut parts, body) = res.into_parts();
15105                    let mut body = common::Body::new(body);
15106                    if !parts.status.is_success() {
15107                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15108                        let error = serde_json::from_str(&common::to_string(&bytes));
15109                        let response = common::to_response(parts, bytes.into());
15110
15111                        if let common::Retry::After(d) =
15112                            dlg.http_failure(&response, error.as_ref().ok())
15113                        {
15114                            sleep(d).await;
15115                            continue;
15116                        }
15117
15118                        dlg.finished(false);
15119
15120                        return Err(match error {
15121                            Ok(value) => common::Error::BadRequest(value),
15122                            _ => common::Error::Failure(response),
15123                        });
15124                    }
15125                    let response = {
15126                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15127                        let encoded = common::to_string(&bytes);
15128                        match serde_json::from_str(&encoded) {
15129                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15130                            Err(error) => {
15131                                dlg.response_json_decode_error(&encoded, &error);
15132                                return Err(common::Error::JsonDecodeError(
15133                                    encoded.to_string(),
15134                                    error,
15135                                ));
15136                            }
15137                        }
15138                    };
15139
15140                    dlg.finished(true);
15141                    return Ok(response);
15142                }
15143            }
15144        }
15145    }
15146
15147    ///
15148    /// Sets the *request* property to the given value.
15149    ///
15150    /// Even though the property as already been set when instantiating this call,
15151    /// we provide this method for API completeness.
15152    pub fn request(
15153        mut self,
15154        new_value: GoogleCloudRecommenderV1MarkInsightAcceptedRequest,
15155    ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
15156        self._request = new_value;
15157        self
15158    }
15159    /// Required. Name of the insight.
15160    ///
15161    /// Sets the *name* path property to the given value.
15162    ///
15163    /// Even though the property as already been set when instantiating this call,
15164    /// we provide this method for API completeness.
15165    pub fn name(
15166        mut self,
15167        new_value: &str,
15168    ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
15169        self._name = new_value.to_string();
15170        self
15171    }
15172    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15173    /// while executing the actual API request.
15174    ///
15175    /// ````text
15176    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15177    /// ````
15178    ///
15179    /// Sets the *delegate* property to the given value.
15180    pub fn delegate(
15181        mut self,
15182        new_value: &'a mut dyn common::Delegate,
15183    ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
15184        self._delegate = Some(new_value);
15185        self
15186    }
15187
15188    /// Set any additional parameter of the query string used in the request.
15189    /// It should be used to set parameters which are not yet available through their own
15190    /// setters.
15191    ///
15192    /// Please note that this method must not be used to set any of the known parameters
15193    /// which have their own setter method. If done anyway, the request will fail.
15194    ///
15195    /// # Additional Parameters
15196    ///
15197    /// * *$.xgafv* (query-string) - V1 error format.
15198    /// * *access_token* (query-string) - OAuth access token.
15199    /// * *alt* (query-string) - Data format for response.
15200    /// * *callback* (query-string) - JSONP
15201    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15202    /// * *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.
15203    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15204    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15205    /// * *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.
15206    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15207    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15208    pub fn param<T>(
15209        mut self,
15210        name: T,
15211        value: T,
15212    ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
15213    where
15214        T: AsRef<str>,
15215    {
15216        self._additional_params
15217            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15218        self
15219    }
15220
15221    /// Identifies the authorization scope for the method you are building.
15222    ///
15223    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15224    /// [`Scope::CloudPlatform`].
15225    ///
15226    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15227    /// tokens for more than one scope.
15228    ///
15229    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15230    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15231    /// sufficient, a read-write scope will do as well.
15232    pub fn add_scope<St>(
15233        mut self,
15234        scope: St,
15235    ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
15236    where
15237        St: AsRef<str>,
15238    {
15239        self._scopes.insert(String::from(scope.as_ref()));
15240        self
15241    }
15242    /// Identifies the authorization scope(s) for the method you are building.
15243    ///
15244    /// See [`Self::add_scope()`] for details.
15245    pub fn add_scopes<I, St>(
15246        mut self,
15247        scopes: I,
15248    ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
15249    where
15250        I: IntoIterator<Item = St>,
15251        St: AsRef<str>,
15252    {
15253        self._scopes
15254            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15255        self
15256    }
15257
15258    /// Removes all scopes, and no default scope will be used either.
15259    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15260    /// for details).
15261    pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
15262        self._scopes.clear();
15263        self
15264    }
15265}
15266
15267/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
15268///
15269/// A builder for the *locations.insightTypes.getConfig* method supported by a *project* resource.
15270/// It is not used directly, but through a [`ProjectMethods`] instance.
15271///
15272/// # Example
15273///
15274/// Instantiate a resource method builder
15275///
15276/// ```test_harness,no_run
15277/// # extern crate hyper;
15278/// # extern crate hyper_rustls;
15279/// # extern crate google_recommender1 as recommender1;
15280/// # async fn dox() {
15281/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15282///
15283/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15284/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15285/// #     .with_native_roots()
15286/// #     .unwrap()
15287/// #     .https_only()
15288/// #     .enable_http2()
15289/// #     .build();
15290///
15291/// # let executor = hyper_util::rt::TokioExecutor::new();
15292/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15293/// #     secret,
15294/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15295/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15296/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15297/// #     ),
15298/// # ).build().await.unwrap();
15299///
15300/// # let client = hyper_util::client::legacy::Client::builder(
15301/// #     hyper_util::rt::TokioExecutor::new()
15302/// # )
15303/// # .build(
15304/// #     hyper_rustls::HttpsConnectorBuilder::new()
15305/// #         .with_native_roots()
15306/// #         .unwrap()
15307/// #         .https_or_http()
15308/// #         .enable_http2()
15309/// #         .build()
15310/// # );
15311/// # let mut hub = Recommender::new(client, auth);
15312/// // You can configure optional parameters by calling the respective setters at will, and
15313/// // execute the final call using `doit()`.
15314/// // Values shown here are possibly random and not representative !
15315/// let result = hub.projects().locations_insight_types_get_config("name")
15316///              .doit().await;
15317/// # }
15318/// ```
15319pub struct ProjectLocationInsightTypeGetConfigCall<'a, C>
15320where
15321    C: 'a,
15322{
15323    hub: &'a Recommender<C>,
15324    _name: String,
15325    _delegate: Option<&'a mut dyn common::Delegate>,
15326    _additional_params: HashMap<String, String>,
15327    _scopes: BTreeSet<String>,
15328}
15329
15330impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeGetConfigCall<'a, C> {}
15331
15332impl<'a, C> ProjectLocationInsightTypeGetConfigCall<'a, C>
15333where
15334    C: common::Connector,
15335{
15336    /// Perform the operation you have build so far.
15337    pub async fn doit(
15338        mut self,
15339    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1InsightTypeConfig)> {
15340        use std::borrow::Cow;
15341        use std::io::{Read, Seek};
15342
15343        use common::{url::Params, ToParts};
15344        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15345
15346        let mut dd = common::DefaultDelegate;
15347        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15348        dlg.begin(common::MethodInfo {
15349            id: "recommender.projects.locations.insightTypes.getConfig",
15350            http_method: hyper::Method::GET,
15351        });
15352
15353        for &field in ["alt", "name"].iter() {
15354            if self._additional_params.contains_key(field) {
15355                dlg.finished(false);
15356                return Err(common::Error::FieldClash(field));
15357            }
15358        }
15359
15360        let mut params = Params::with_capacity(3 + self._additional_params.len());
15361        params.push("name", self._name);
15362
15363        params.extend(self._additional_params.iter());
15364
15365        params.push("alt", "json");
15366        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15367        if self._scopes.is_empty() {
15368            self._scopes
15369                .insert(Scope::CloudPlatform.as_ref().to_string());
15370        }
15371
15372        #[allow(clippy::single_element_loop)]
15373        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15374            url = params.uri_replacement(url, param_name, find_this, true);
15375        }
15376        {
15377            let to_remove = ["name"];
15378            params.remove_params(&to_remove);
15379        }
15380
15381        let url = params.parse_with_url(&url);
15382
15383        loop {
15384            let token = match self
15385                .hub
15386                .auth
15387                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15388                .await
15389            {
15390                Ok(token) => token,
15391                Err(e) => match dlg.token(e) {
15392                    Ok(token) => token,
15393                    Err(e) => {
15394                        dlg.finished(false);
15395                        return Err(common::Error::MissingToken(e));
15396                    }
15397                },
15398            };
15399            let mut req_result = {
15400                let client = &self.hub.client;
15401                dlg.pre_request();
15402                let mut req_builder = hyper::Request::builder()
15403                    .method(hyper::Method::GET)
15404                    .uri(url.as_str())
15405                    .header(USER_AGENT, self.hub._user_agent.clone());
15406
15407                if let Some(token) = token.as_ref() {
15408                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15409                }
15410
15411                let request = req_builder
15412                    .header(CONTENT_LENGTH, 0_u64)
15413                    .body(common::to_body::<String>(None));
15414
15415                client.request(request.unwrap()).await
15416            };
15417
15418            match req_result {
15419                Err(err) => {
15420                    if let common::Retry::After(d) = dlg.http_error(&err) {
15421                        sleep(d).await;
15422                        continue;
15423                    }
15424                    dlg.finished(false);
15425                    return Err(common::Error::HttpError(err));
15426                }
15427                Ok(res) => {
15428                    let (mut parts, body) = res.into_parts();
15429                    let mut body = common::Body::new(body);
15430                    if !parts.status.is_success() {
15431                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15432                        let error = serde_json::from_str(&common::to_string(&bytes));
15433                        let response = common::to_response(parts, bytes.into());
15434
15435                        if let common::Retry::After(d) =
15436                            dlg.http_failure(&response, error.as_ref().ok())
15437                        {
15438                            sleep(d).await;
15439                            continue;
15440                        }
15441
15442                        dlg.finished(false);
15443
15444                        return Err(match error {
15445                            Ok(value) => common::Error::BadRequest(value),
15446                            _ => common::Error::Failure(response),
15447                        });
15448                    }
15449                    let response = {
15450                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15451                        let encoded = common::to_string(&bytes);
15452                        match serde_json::from_str(&encoded) {
15453                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15454                            Err(error) => {
15455                                dlg.response_json_decode_error(&encoded, &error);
15456                                return Err(common::Error::JsonDecodeError(
15457                                    encoded.to_string(),
15458                                    error,
15459                                ));
15460                            }
15461                        }
15462                    };
15463
15464                    dlg.finished(true);
15465                    return Ok(response);
15466                }
15467            }
15468        }
15469    }
15470
15471    /// Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
15472    ///
15473    /// Sets the *name* path property to the given value.
15474    ///
15475    /// Even though the property as already been set when instantiating this call,
15476    /// we provide this method for API completeness.
15477    pub fn name(mut self, new_value: &str) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
15478        self._name = new_value.to_string();
15479        self
15480    }
15481    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15482    /// while executing the actual API request.
15483    ///
15484    /// ````text
15485    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15486    /// ````
15487    ///
15488    /// Sets the *delegate* property to the given value.
15489    pub fn delegate(
15490        mut self,
15491        new_value: &'a mut dyn common::Delegate,
15492    ) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
15493        self._delegate = Some(new_value);
15494        self
15495    }
15496
15497    /// Set any additional parameter of the query string used in the request.
15498    /// It should be used to set parameters which are not yet available through their own
15499    /// setters.
15500    ///
15501    /// Please note that this method must not be used to set any of the known parameters
15502    /// which have their own setter method. If done anyway, the request will fail.
15503    ///
15504    /// # Additional Parameters
15505    ///
15506    /// * *$.xgafv* (query-string) - V1 error format.
15507    /// * *access_token* (query-string) - OAuth access token.
15508    /// * *alt* (query-string) - Data format for response.
15509    /// * *callback* (query-string) - JSONP
15510    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15511    /// * *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.
15512    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15513    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15514    /// * *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.
15515    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15516    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15517    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeGetConfigCall<'a, C>
15518    where
15519        T: AsRef<str>,
15520    {
15521        self._additional_params
15522            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15523        self
15524    }
15525
15526    /// Identifies the authorization scope for the method you are building.
15527    ///
15528    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15529    /// [`Scope::CloudPlatform`].
15530    ///
15531    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15532    /// tokens for more than one scope.
15533    ///
15534    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15535    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15536    /// sufficient, a read-write scope will do as well.
15537    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeGetConfigCall<'a, C>
15538    where
15539        St: AsRef<str>,
15540    {
15541        self._scopes.insert(String::from(scope.as_ref()));
15542        self
15543    }
15544    /// Identifies the authorization scope(s) for the method you are building.
15545    ///
15546    /// See [`Self::add_scope()`] for details.
15547    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeGetConfigCall<'a, C>
15548    where
15549        I: IntoIterator<Item = St>,
15550        St: AsRef<str>,
15551    {
15552        self._scopes
15553            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15554        self
15555    }
15556
15557    /// Removes all scopes, and no default scope will be used either.
15558    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15559    /// for details).
15560    pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
15561        self._scopes.clear();
15562        self
15563    }
15564}
15565
15566/// Updates an InsightTypeConfig change. This will create a new revision of the config.
15567///
15568/// A builder for the *locations.insightTypes.updateConfig* method supported by a *project* resource.
15569/// It is not used directly, but through a [`ProjectMethods`] instance.
15570///
15571/// # Example
15572///
15573/// Instantiate a resource method builder
15574///
15575/// ```test_harness,no_run
15576/// # extern crate hyper;
15577/// # extern crate hyper_rustls;
15578/// # extern crate google_recommender1 as recommender1;
15579/// use recommender1::api::GoogleCloudRecommenderV1InsightTypeConfig;
15580/// # async fn dox() {
15581/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15582///
15583/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15584/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15585/// #     .with_native_roots()
15586/// #     .unwrap()
15587/// #     .https_only()
15588/// #     .enable_http2()
15589/// #     .build();
15590///
15591/// # let executor = hyper_util::rt::TokioExecutor::new();
15592/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15593/// #     secret,
15594/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15595/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15596/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15597/// #     ),
15598/// # ).build().await.unwrap();
15599///
15600/// # let client = hyper_util::client::legacy::Client::builder(
15601/// #     hyper_util::rt::TokioExecutor::new()
15602/// # )
15603/// # .build(
15604/// #     hyper_rustls::HttpsConnectorBuilder::new()
15605/// #         .with_native_roots()
15606/// #         .unwrap()
15607/// #         .https_or_http()
15608/// #         .enable_http2()
15609/// #         .build()
15610/// # );
15611/// # let mut hub = Recommender::new(client, auth);
15612/// // As the method needs a request, you would usually fill it with the desired information
15613/// // into the respective structure. Some of the parts shown here might not be applicable !
15614/// // Values shown here are possibly random and not representative !
15615/// let mut req = GoogleCloudRecommenderV1InsightTypeConfig::default();
15616///
15617/// // You can configure optional parameters by calling the respective setters at will, and
15618/// // execute the final call using `doit()`.
15619/// // Values shown here are possibly random and not representative !
15620/// let result = hub.projects().locations_insight_types_update_config(req, "name")
15621///              .validate_only(true)
15622///              .update_mask(FieldMask::new::<&str>(&[]))
15623///              .doit().await;
15624/// # }
15625/// ```
15626pub struct ProjectLocationInsightTypeUpdateConfigCall<'a, C>
15627where
15628    C: 'a,
15629{
15630    hub: &'a Recommender<C>,
15631    _request: GoogleCloudRecommenderV1InsightTypeConfig,
15632    _name: String,
15633    _validate_only: Option<bool>,
15634    _update_mask: Option<common::FieldMask>,
15635    _delegate: Option<&'a mut dyn common::Delegate>,
15636    _additional_params: HashMap<String, String>,
15637    _scopes: BTreeSet<String>,
15638}
15639
15640impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeUpdateConfigCall<'a, C> {}
15641
15642impl<'a, C> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
15643where
15644    C: common::Connector,
15645{
15646    /// Perform the operation you have build so far.
15647    pub async fn doit(
15648        mut self,
15649    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1InsightTypeConfig)> {
15650        use std::borrow::Cow;
15651        use std::io::{Read, Seek};
15652
15653        use common::{url::Params, ToParts};
15654        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15655
15656        let mut dd = common::DefaultDelegate;
15657        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15658        dlg.begin(common::MethodInfo {
15659            id: "recommender.projects.locations.insightTypes.updateConfig",
15660            http_method: hyper::Method::PATCH,
15661        });
15662
15663        for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
15664            if self._additional_params.contains_key(field) {
15665                dlg.finished(false);
15666                return Err(common::Error::FieldClash(field));
15667            }
15668        }
15669
15670        let mut params = Params::with_capacity(6 + self._additional_params.len());
15671        params.push("name", self._name);
15672        if let Some(value) = self._validate_only.as_ref() {
15673            params.push("validateOnly", value.to_string());
15674        }
15675        if let Some(value) = self._update_mask.as_ref() {
15676            params.push("updateMask", value.to_string());
15677        }
15678
15679        params.extend(self._additional_params.iter());
15680
15681        params.push("alt", "json");
15682        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15683        if self._scopes.is_empty() {
15684            self._scopes
15685                .insert(Scope::CloudPlatform.as_ref().to_string());
15686        }
15687
15688        #[allow(clippy::single_element_loop)]
15689        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15690            url = params.uri_replacement(url, param_name, find_this, true);
15691        }
15692        {
15693            let to_remove = ["name"];
15694            params.remove_params(&to_remove);
15695        }
15696
15697        let url = params.parse_with_url(&url);
15698
15699        let mut json_mime_type = mime::APPLICATION_JSON;
15700        let mut request_value_reader = {
15701            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15702            common::remove_json_null_values(&mut value);
15703            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15704            serde_json::to_writer(&mut dst, &value).unwrap();
15705            dst
15706        };
15707        let request_size = request_value_reader
15708            .seek(std::io::SeekFrom::End(0))
15709            .unwrap();
15710        request_value_reader
15711            .seek(std::io::SeekFrom::Start(0))
15712            .unwrap();
15713
15714        loop {
15715            let token = match self
15716                .hub
15717                .auth
15718                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15719                .await
15720            {
15721                Ok(token) => token,
15722                Err(e) => match dlg.token(e) {
15723                    Ok(token) => token,
15724                    Err(e) => {
15725                        dlg.finished(false);
15726                        return Err(common::Error::MissingToken(e));
15727                    }
15728                },
15729            };
15730            request_value_reader
15731                .seek(std::io::SeekFrom::Start(0))
15732                .unwrap();
15733            let mut req_result = {
15734                let client = &self.hub.client;
15735                dlg.pre_request();
15736                let mut req_builder = hyper::Request::builder()
15737                    .method(hyper::Method::PATCH)
15738                    .uri(url.as_str())
15739                    .header(USER_AGENT, self.hub._user_agent.clone());
15740
15741                if let Some(token) = token.as_ref() {
15742                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15743                }
15744
15745                let request = req_builder
15746                    .header(CONTENT_TYPE, json_mime_type.to_string())
15747                    .header(CONTENT_LENGTH, request_size as u64)
15748                    .body(common::to_body(
15749                        request_value_reader.get_ref().clone().into(),
15750                    ));
15751
15752                client.request(request.unwrap()).await
15753            };
15754
15755            match req_result {
15756                Err(err) => {
15757                    if let common::Retry::After(d) = dlg.http_error(&err) {
15758                        sleep(d).await;
15759                        continue;
15760                    }
15761                    dlg.finished(false);
15762                    return Err(common::Error::HttpError(err));
15763                }
15764                Ok(res) => {
15765                    let (mut parts, body) = res.into_parts();
15766                    let mut body = common::Body::new(body);
15767                    if !parts.status.is_success() {
15768                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15769                        let error = serde_json::from_str(&common::to_string(&bytes));
15770                        let response = common::to_response(parts, bytes.into());
15771
15772                        if let common::Retry::After(d) =
15773                            dlg.http_failure(&response, error.as_ref().ok())
15774                        {
15775                            sleep(d).await;
15776                            continue;
15777                        }
15778
15779                        dlg.finished(false);
15780
15781                        return Err(match error {
15782                            Ok(value) => common::Error::BadRequest(value),
15783                            _ => common::Error::Failure(response),
15784                        });
15785                    }
15786                    let response = {
15787                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15788                        let encoded = common::to_string(&bytes);
15789                        match serde_json::from_str(&encoded) {
15790                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15791                            Err(error) => {
15792                                dlg.response_json_decode_error(&encoded, &error);
15793                                return Err(common::Error::JsonDecodeError(
15794                                    encoded.to_string(),
15795                                    error,
15796                                ));
15797                            }
15798                        }
15799                    };
15800
15801                    dlg.finished(true);
15802                    return Ok(response);
15803                }
15804            }
15805        }
15806    }
15807
15808    ///
15809    /// Sets the *request* property to the given value.
15810    ///
15811    /// Even though the property as already been set when instantiating this call,
15812    /// we provide this method for API completeness.
15813    pub fn request(
15814        mut self,
15815        new_value: GoogleCloudRecommenderV1InsightTypeConfig,
15816    ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
15817        self._request = new_value;
15818        self
15819    }
15820    /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
15821    ///
15822    /// Sets the *name* path property to the given value.
15823    ///
15824    /// Even though the property as already been set when instantiating this call,
15825    /// we provide this method for API completeness.
15826    pub fn name(mut self, new_value: &str) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
15827        self._name = new_value.to_string();
15828        self
15829    }
15830    /// If true, validate the request and preview the change, but do not actually update it.
15831    ///
15832    /// Sets the *validate only* query property to the given value.
15833    pub fn validate_only(
15834        mut self,
15835        new_value: bool,
15836    ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
15837        self._validate_only = Some(new_value);
15838        self
15839    }
15840    /// The list of fields to be updated.
15841    ///
15842    /// Sets the *update mask* query property to the given value.
15843    pub fn update_mask(
15844        mut self,
15845        new_value: common::FieldMask,
15846    ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
15847        self._update_mask = Some(new_value);
15848        self
15849    }
15850    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15851    /// while executing the actual API request.
15852    ///
15853    /// ````text
15854    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15855    /// ````
15856    ///
15857    /// Sets the *delegate* property to the given value.
15858    pub fn delegate(
15859        mut self,
15860        new_value: &'a mut dyn common::Delegate,
15861    ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
15862        self._delegate = Some(new_value);
15863        self
15864    }
15865
15866    /// Set any additional parameter of the query string used in the request.
15867    /// It should be used to set parameters which are not yet available through their own
15868    /// setters.
15869    ///
15870    /// Please note that this method must not be used to set any of the known parameters
15871    /// which have their own setter method. If done anyway, the request will fail.
15872    ///
15873    /// # Additional Parameters
15874    ///
15875    /// * *$.xgafv* (query-string) - V1 error format.
15876    /// * *access_token* (query-string) - OAuth access token.
15877    /// * *alt* (query-string) - Data format for response.
15878    /// * *callback* (query-string) - JSONP
15879    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15880    /// * *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.
15881    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15882    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15883    /// * *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.
15884    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15885    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15886    pub fn param<T>(
15887        mut self,
15888        name: T,
15889        value: T,
15890    ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
15891    where
15892        T: AsRef<str>,
15893    {
15894        self._additional_params
15895            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15896        self
15897    }
15898
15899    /// Identifies the authorization scope for the method you are building.
15900    ///
15901    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15902    /// [`Scope::CloudPlatform`].
15903    ///
15904    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15905    /// tokens for more than one scope.
15906    ///
15907    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15908    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15909    /// sufficient, a read-write scope will do as well.
15910    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
15911    where
15912        St: AsRef<str>,
15913    {
15914        self._scopes.insert(String::from(scope.as_ref()));
15915        self
15916    }
15917    /// Identifies the authorization scope(s) for the method you are building.
15918    ///
15919    /// See [`Self::add_scope()`] for details.
15920    pub fn add_scopes<I, St>(
15921        mut self,
15922        scopes: I,
15923    ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
15924    where
15925        I: IntoIterator<Item = St>,
15926        St: AsRef<str>,
15927    {
15928        self._scopes
15929            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15930        self
15931    }
15932
15933    /// Removes all scopes, and no default scope will be used either.
15934    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15935    /// for details).
15936    pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
15937        self._scopes.clear();
15938        self
15939    }
15940}
15941
15942/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
15943///
15944/// A builder for the *locations.recommenders.recommendations.get* method supported by a *project* resource.
15945/// It is not used directly, but through a [`ProjectMethods`] instance.
15946///
15947/// # Example
15948///
15949/// Instantiate a resource method builder
15950///
15951/// ```test_harness,no_run
15952/// # extern crate hyper;
15953/// # extern crate hyper_rustls;
15954/// # extern crate google_recommender1 as recommender1;
15955/// # async fn dox() {
15956/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15957///
15958/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15959/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15960/// #     .with_native_roots()
15961/// #     .unwrap()
15962/// #     .https_only()
15963/// #     .enable_http2()
15964/// #     .build();
15965///
15966/// # let executor = hyper_util::rt::TokioExecutor::new();
15967/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15968/// #     secret,
15969/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15970/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15971/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15972/// #     ),
15973/// # ).build().await.unwrap();
15974///
15975/// # let client = hyper_util::client::legacy::Client::builder(
15976/// #     hyper_util::rt::TokioExecutor::new()
15977/// # )
15978/// # .build(
15979/// #     hyper_rustls::HttpsConnectorBuilder::new()
15980/// #         .with_native_roots()
15981/// #         .unwrap()
15982/// #         .https_or_http()
15983/// #         .enable_http2()
15984/// #         .build()
15985/// # );
15986/// # let mut hub = Recommender::new(client, auth);
15987/// // You can configure optional parameters by calling the respective setters at will, and
15988/// // execute the final call using `doit()`.
15989/// // Values shown here are possibly random and not representative !
15990/// let result = hub.projects().locations_recommenders_recommendations_get("name")
15991///              .doit().await;
15992/// # }
15993/// ```
15994pub struct ProjectLocationRecommenderRecommendationGetCall<'a, C>
15995where
15996    C: 'a,
15997{
15998    hub: &'a Recommender<C>,
15999    _name: String,
16000    _delegate: Option<&'a mut dyn common::Delegate>,
16001    _additional_params: HashMap<String, String>,
16002    _scopes: BTreeSet<String>,
16003}
16004
16005impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationGetCall<'a, C> {}
16006
16007impl<'a, C> ProjectLocationRecommenderRecommendationGetCall<'a, C>
16008where
16009    C: common::Connector,
16010{
16011    /// Perform the operation you have build so far.
16012    pub async fn doit(
16013        mut self,
16014    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
16015        use std::borrow::Cow;
16016        use std::io::{Read, Seek};
16017
16018        use common::{url::Params, ToParts};
16019        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16020
16021        let mut dd = common::DefaultDelegate;
16022        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16023        dlg.begin(common::MethodInfo {
16024            id: "recommender.projects.locations.recommenders.recommendations.get",
16025            http_method: hyper::Method::GET,
16026        });
16027
16028        for &field in ["alt", "name"].iter() {
16029            if self._additional_params.contains_key(field) {
16030                dlg.finished(false);
16031                return Err(common::Error::FieldClash(field));
16032            }
16033        }
16034
16035        let mut params = Params::with_capacity(3 + self._additional_params.len());
16036        params.push("name", self._name);
16037
16038        params.extend(self._additional_params.iter());
16039
16040        params.push("alt", "json");
16041        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16042        if self._scopes.is_empty() {
16043            self._scopes
16044                .insert(Scope::CloudPlatform.as_ref().to_string());
16045        }
16046
16047        #[allow(clippy::single_element_loop)]
16048        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16049            url = params.uri_replacement(url, param_name, find_this, true);
16050        }
16051        {
16052            let to_remove = ["name"];
16053            params.remove_params(&to_remove);
16054        }
16055
16056        let url = params.parse_with_url(&url);
16057
16058        loop {
16059            let token = match self
16060                .hub
16061                .auth
16062                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16063                .await
16064            {
16065                Ok(token) => token,
16066                Err(e) => match dlg.token(e) {
16067                    Ok(token) => token,
16068                    Err(e) => {
16069                        dlg.finished(false);
16070                        return Err(common::Error::MissingToken(e));
16071                    }
16072                },
16073            };
16074            let mut req_result = {
16075                let client = &self.hub.client;
16076                dlg.pre_request();
16077                let mut req_builder = hyper::Request::builder()
16078                    .method(hyper::Method::GET)
16079                    .uri(url.as_str())
16080                    .header(USER_AGENT, self.hub._user_agent.clone());
16081
16082                if let Some(token) = token.as_ref() {
16083                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16084                }
16085
16086                let request = req_builder
16087                    .header(CONTENT_LENGTH, 0_u64)
16088                    .body(common::to_body::<String>(None));
16089
16090                client.request(request.unwrap()).await
16091            };
16092
16093            match req_result {
16094                Err(err) => {
16095                    if let common::Retry::After(d) = dlg.http_error(&err) {
16096                        sleep(d).await;
16097                        continue;
16098                    }
16099                    dlg.finished(false);
16100                    return Err(common::Error::HttpError(err));
16101                }
16102                Ok(res) => {
16103                    let (mut parts, body) = res.into_parts();
16104                    let mut body = common::Body::new(body);
16105                    if !parts.status.is_success() {
16106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16107                        let error = serde_json::from_str(&common::to_string(&bytes));
16108                        let response = common::to_response(parts, bytes.into());
16109
16110                        if let common::Retry::After(d) =
16111                            dlg.http_failure(&response, error.as_ref().ok())
16112                        {
16113                            sleep(d).await;
16114                            continue;
16115                        }
16116
16117                        dlg.finished(false);
16118
16119                        return Err(match error {
16120                            Ok(value) => common::Error::BadRequest(value),
16121                            _ => common::Error::Failure(response),
16122                        });
16123                    }
16124                    let response = {
16125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16126                        let encoded = common::to_string(&bytes);
16127                        match serde_json::from_str(&encoded) {
16128                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16129                            Err(error) => {
16130                                dlg.response_json_decode_error(&encoded, &error);
16131                                return Err(common::Error::JsonDecodeError(
16132                                    encoded.to_string(),
16133                                    error,
16134                                ));
16135                            }
16136                        }
16137                    };
16138
16139                    dlg.finished(true);
16140                    return Ok(response);
16141                }
16142            }
16143        }
16144    }
16145
16146    /// Required. Name of the recommendation.
16147    ///
16148    /// Sets the *name* path property to the given value.
16149    ///
16150    /// Even though the property as already been set when instantiating this call,
16151    /// we provide this method for API completeness.
16152    pub fn name(
16153        mut self,
16154        new_value: &str,
16155    ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
16156        self._name = new_value.to_string();
16157        self
16158    }
16159    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16160    /// while executing the actual API request.
16161    ///
16162    /// ````text
16163    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16164    /// ````
16165    ///
16166    /// Sets the *delegate* property to the given value.
16167    pub fn delegate(
16168        mut self,
16169        new_value: &'a mut dyn common::Delegate,
16170    ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
16171        self._delegate = Some(new_value);
16172        self
16173    }
16174
16175    /// Set any additional parameter of the query string used in the request.
16176    /// It should be used to set parameters which are not yet available through their own
16177    /// setters.
16178    ///
16179    /// Please note that this method must not be used to set any of the known parameters
16180    /// which have their own setter method. If done anyway, the request will fail.
16181    ///
16182    /// # Additional Parameters
16183    ///
16184    /// * *$.xgafv* (query-string) - V1 error format.
16185    /// * *access_token* (query-string) - OAuth access token.
16186    /// * *alt* (query-string) - Data format for response.
16187    /// * *callback* (query-string) - JSONP
16188    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16189    /// * *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.
16190    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16191    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16192    /// * *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.
16193    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16194    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16195    pub fn param<T>(
16196        mut self,
16197        name: T,
16198        value: T,
16199    ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C>
16200    where
16201        T: AsRef<str>,
16202    {
16203        self._additional_params
16204            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16205        self
16206    }
16207
16208    /// Identifies the authorization scope for the method you are building.
16209    ///
16210    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16211    /// [`Scope::CloudPlatform`].
16212    ///
16213    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16214    /// tokens for more than one scope.
16215    ///
16216    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16217    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16218    /// sufficient, a read-write scope will do as well.
16219    pub fn add_scope<St>(
16220        mut self,
16221        scope: St,
16222    ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C>
16223    where
16224        St: AsRef<str>,
16225    {
16226        self._scopes.insert(String::from(scope.as_ref()));
16227        self
16228    }
16229    /// Identifies the authorization scope(s) for the method you are building.
16230    ///
16231    /// See [`Self::add_scope()`] for details.
16232    pub fn add_scopes<I, St>(
16233        mut self,
16234        scopes: I,
16235    ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C>
16236    where
16237        I: IntoIterator<Item = St>,
16238        St: AsRef<str>,
16239    {
16240        self._scopes
16241            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16242        self
16243    }
16244
16245    /// Removes all scopes, and no default scope will be used either.
16246    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16247    /// for details).
16248    pub fn clear_scopes(mut self) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
16249        self._scopes.clear();
16250        self
16251    }
16252}
16253
16254/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
16255///
16256/// A builder for the *locations.recommenders.recommendations.list* method supported by a *project* resource.
16257/// It is not used directly, but through a [`ProjectMethods`] instance.
16258///
16259/// # Example
16260///
16261/// Instantiate a resource method builder
16262///
16263/// ```test_harness,no_run
16264/// # extern crate hyper;
16265/// # extern crate hyper_rustls;
16266/// # extern crate google_recommender1 as recommender1;
16267/// # async fn dox() {
16268/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16269///
16270/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16271/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16272/// #     .with_native_roots()
16273/// #     .unwrap()
16274/// #     .https_only()
16275/// #     .enable_http2()
16276/// #     .build();
16277///
16278/// # let executor = hyper_util::rt::TokioExecutor::new();
16279/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16280/// #     secret,
16281/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16282/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16283/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16284/// #     ),
16285/// # ).build().await.unwrap();
16286///
16287/// # let client = hyper_util::client::legacy::Client::builder(
16288/// #     hyper_util::rt::TokioExecutor::new()
16289/// # )
16290/// # .build(
16291/// #     hyper_rustls::HttpsConnectorBuilder::new()
16292/// #         .with_native_roots()
16293/// #         .unwrap()
16294/// #         .https_or_http()
16295/// #         .enable_http2()
16296/// #         .build()
16297/// # );
16298/// # let mut hub = Recommender::new(client, auth);
16299/// // You can configure optional parameters by calling the respective setters at will, and
16300/// // execute the final call using `doit()`.
16301/// // Values shown here are possibly random and not representative !
16302/// let result = hub.projects().locations_recommenders_recommendations_list("parent")
16303///              .page_token("no")
16304///              .page_size(-100)
16305///              .filter("accusam")
16306///              .doit().await;
16307/// # }
16308/// ```
16309pub struct ProjectLocationRecommenderRecommendationListCall<'a, C>
16310where
16311    C: 'a,
16312{
16313    hub: &'a Recommender<C>,
16314    _parent: String,
16315    _page_token: Option<String>,
16316    _page_size: Option<i32>,
16317    _filter: Option<String>,
16318    _delegate: Option<&'a mut dyn common::Delegate>,
16319    _additional_params: HashMap<String, String>,
16320    _scopes: BTreeSet<String>,
16321}
16322
16323impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationListCall<'a, C> {}
16324
16325impl<'a, C> ProjectLocationRecommenderRecommendationListCall<'a, C>
16326where
16327    C: common::Connector,
16328{
16329    /// Perform the operation you have build so far.
16330    pub async fn doit(
16331        mut self,
16332    ) -> common::Result<(
16333        common::Response,
16334        GoogleCloudRecommenderV1ListRecommendationsResponse,
16335    )> {
16336        use std::borrow::Cow;
16337        use std::io::{Read, Seek};
16338
16339        use common::{url::Params, ToParts};
16340        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16341
16342        let mut dd = common::DefaultDelegate;
16343        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16344        dlg.begin(common::MethodInfo {
16345            id: "recommender.projects.locations.recommenders.recommendations.list",
16346            http_method: hyper::Method::GET,
16347        });
16348
16349        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
16350            if self._additional_params.contains_key(field) {
16351                dlg.finished(false);
16352                return Err(common::Error::FieldClash(field));
16353            }
16354        }
16355
16356        let mut params = Params::with_capacity(6 + self._additional_params.len());
16357        params.push("parent", self._parent);
16358        if let Some(value) = self._page_token.as_ref() {
16359            params.push("pageToken", value);
16360        }
16361        if let Some(value) = self._page_size.as_ref() {
16362            params.push("pageSize", value.to_string());
16363        }
16364        if let Some(value) = self._filter.as_ref() {
16365            params.push("filter", value);
16366        }
16367
16368        params.extend(self._additional_params.iter());
16369
16370        params.push("alt", "json");
16371        let mut url = self.hub._base_url.clone() + "v1/{+parent}/recommendations";
16372        if self._scopes.is_empty() {
16373            self._scopes
16374                .insert(Scope::CloudPlatform.as_ref().to_string());
16375        }
16376
16377        #[allow(clippy::single_element_loop)]
16378        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16379            url = params.uri_replacement(url, param_name, find_this, true);
16380        }
16381        {
16382            let to_remove = ["parent"];
16383            params.remove_params(&to_remove);
16384        }
16385
16386        let url = params.parse_with_url(&url);
16387
16388        loop {
16389            let token = match self
16390                .hub
16391                .auth
16392                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16393                .await
16394            {
16395                Ok(token) => token,
16396                Err(e) => match dlg.token(e) {
16397                    Ok(token) => token,
16398                    Err(e) => {
16399                        dlg.finished(false);
16400                        return Err(common::Error::MissingToken(e));
16401                    }
16402                },
16403            };
16404            let mut req_result = {
16405                let client = &self.hub.client;
16406                dlg.pre_request();
16407                let mut req_builder = hyper::Request::builder()
16408                    .method(hyper::Method::GET)
16409                    .uri(url.as_str())
16410                    .header(USER_AGENT, self.hub._user_agent.clone());
16411
16412                if let Some(token) = token.as_ref() {
16413                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16414                }
16415
16416                let request = req_builder
16417                    .header(CONTENT_LENGTH, 0_u64)
16418                    .body(common::to_body::<String>(None));
16419
16420                client.request(request.unwrap()).await
16421            };
16422
16423            match req_result {
16424                Err(err) => {
16425                    if let common::Retry::After(d) = dlg.http_error(&err) {
16426                        sleep(d).await;
16427                        continue;
16428                    }
16429                    dlg.finished(false);
16430                    return Err(common::Error::HttpError(err));
16431                }
16432                Ok(res) => {
16433                    let (mut parts, body) = res.into_parts();
16434                    let mut body = common::Body::new(body);
16435                    if !parts.status.is_success() {
16436                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16437                        let error = serde_json::from_str(&common::to_string(&bytes));
16438                        let response = common::to_response(parts, bytes.into());
16439
16440                        if let common::Retry::After(d) =
16441                            dlg.http_failure(&response, error.as_ref().ok())
16442                        {
16443                            sleep(d).await;
16444                            continue;
16445                        }
16446
16447                        dlg.finished(false);
16448
16449                        return Err(match error {
16450                            Ok(value) => common::Error::BadRequest(value),
16451                            _ => common::Error::Failure(response),
16452                        });
16453                    }
16454                    let response = {
16455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16456                        let encoded = common::to_string(&bytes);
16457                        match serde_json::from_str(&encoded) {
16458                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16459                            Err(error) => {
16460                                dlg.response_json_decode_error(&encoded, &error);
16461                                return Err(common::Error::JsonDecodeError(
16462                                    encoded.to_string(),
16463                                    error,
16464                                ));
16465                            }
16466                        }
16467                    };
16468
16469                    dlg.finished(true);
16470                    return Ok(response);
16471                }
16472            }
16473        }
16474    }
16475
16476    /// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
16477    ///
16478    /// Sets the *parent* path property to the given value.
16479    ///
16480    /// Even though the property as already been set when instantiating this call,
16481    /// we provide this method for API completeness.
16482    pub fn parent(
16483        mut self,
16484        new_value: &str,
16485    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
16486        self._parent = new_value.to_string();
16487        self
16488    }
16489    /// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
16490    ///
16491    /// Sets the *page token* query property to the given value.
16492    pub fn page_token(
16493        mut self,
16494        new_value: &str,
16495    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
16496        self._page_token = Some(new_value.to_string());
16497        self
16498    }
16499    /// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
16500    ///
16501    /// Sets the *page size* query property to the given value.
16502    pub fn page_size(
16503        mut self,
16504        new_value: i32,
16505    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
16506        self._page_size = Some(new_value);
16507        self
16508    }
16509    /// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` * `targetResources` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` The max allowed filter length is 500 characters. (These expressions are based on the filter language described at https://google.aip.dev/160)
16510    ///
16511    /// Sets the *filter* query property to the given value.
16512    pub fn filter(
16513        mut self,
16514        new_value: &str,
16515    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
16516        self._filter = Some(new_value.to_string());
16517        self
16518    }
16519    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16520    /// while executing the actual API request.
16521    ///
16522    /// ````text
16523    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16524    /// ````
16525    ///
16526    /// Sets the *delegate* property to the given value.
16527    pub fn delegate(
16528        mut self,
16529        new_value: &'a mut dyn common::Delegate,
16530    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
16531        self._delegate = Some(new_value);
16532        self
16533    }
16534
16535    /// Set any additional parameter of the query string used in the request.
16536    /// It should be used to set parameters which are not yet available through their own
16537    /// setters.
16538    ///
16539    /// Please note that this method must not be used to set any of the known parameters
16540    /// which have their own setter method. If done anyway, the request will fail.
16541    ///
16542    /// # Additional Parameters
16543    ///
16544    /// * *$.xgafv* (query-string) - V1 error format.
16545    /// * *access_token* (query-string) - OAuth access token.
16546    /// * *alt* (query-string) - Data format for response.
16547    /// * *callback* (query-string) - JSONP
16548    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16549    /// * *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.
16550    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16551    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16552    /// * *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.
16553    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16554    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16555    pub fn param<T>(
16556        mut self,
16557        name: T,
16558        value: T,
16559    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C>
16560    where
16561        T: AsRef<str>,
16562    {
16563        self._additional_params
16564            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16565        self
16566    }
16567
16568    /// Identifies the authorization scope for the method you are building.
16569    ///
16570    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16571    /// [`Scope::CloudPlatform`].
16572    ///
16573    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16574    /// tokens for more than one scope.
16575    ///
16576    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16577    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16578    /// sufficient, a read-write scope will do as well.
16579    pub fn add_scope<St>(
16580        mut self,
16581        scope: St,
16582    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C>
16583    where
16584        St: AsRef<str>,
16585    {
16586        self._scopes.insert(String::from(scope.as_ref()));
16587        self
16588    }
16589    /// Identifies the authorization scope(s) for the method you are building.
16590    ///
16591    /// See [`Self::add_scope()`] for details.
16592    pub fn add_scopes<I, St>(
16593        mut self,
16594        scopes: I,
16595    ) -> ProjectLocationRecommenderRecommendationListCall<'a, C>
16596    where
16597        I: IntoIterator<Item = St>,
16598        St: AsRef<str>,
16599    {
16600        self._scopes
16601            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16602        self
16603    }
16604
16605    /// Removes all scopes, and no default scope will be used either.
16606    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16607    /// for details).
16608    pub fn clear_scopes(mut self) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
16609        self._scopes.clear();
16610        self
16611    }
16612}
16613
16614/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
16615///
16616/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *project* resource.
16617/// It is not used directly, but through a [`ProjectMethods`] instance.
16618///
16619/// # Example
16620///
16621/// Instantiate a resource method builder
16622///
16623/// ```test_harness,no_run
16624/// # extern crate hyper;
16625/// # extern crate hyper_rustls;
16626/// # extern crate google_recommender1 as recommender1;
16627/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationClaimedRequest;
16628/// # async fn dox() {
16629/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16630///
16631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16632/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16633/// #     .with_native_roots()
16634/// #     .unwrap()
16635/// #     .https_only()
16636/// #     .enable_http2()
16637/// #     .build();
16638///
16639/// # let executor = hyper_util::rt::TokioExecutor::new();
16640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16641/// #     secret,
16642/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16643/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16644/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16645/// #     ),
16646/// # ).build().await.unwrap();
16647///
16648/// # let client = hyper_util::client::legacy::Client::builder(
16649/// #     hyper_util::rt::TokioExecutor::new()
16650/// # )
16651/// # .build(
16652/// #     hyper_rustls::HttpsConnectorBuilder::new()
16653/// #         .with_native_roots()
16654/// #         .unwrap()
16655/// #         .https_or_http()
16656/// #         .enable_http2()
16657/// #         .build()
16658/// # );
16659/// # let mut hub = Recommender::new(client, auth);
16660/// // As the method needs a request, you would usually fill it with the desired information
16661/// // into the respective structure. Some of the parts shown here might not be applicable !
16662/// // Values shown here are possibly random and not representative !
16663/// let mut req = GoogleCloudRecommenderV1MarkRecommendationClaimedRequest::default();
16664///
16665/// // You can configure optional parameters by calling the respective setters at will, and
16666/// // execute the final call using `doit()`.
16667/// // Values shown here are possibly random and not representative !
16668/// let result = hub.projects().locations_recommenders_recommendations_mark_claimed(req, "name")
16669///              .doit().await;
16670/// # }
16671/// ```
16672pub struct ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
16673where
16674    C: 'a,
16675{
16676    hub: &'a Recommender<C>,
16677    _request: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
16678    _name: String,
16679    _delegate: Option<&'a mut dyn common::Delegate>,
16680    _additional_params: HashMap<String, String>,
16681    _scopes: BTreeSet<String>,
16682}
16683
16684impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {}
16685
16686impl<'a, C> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
16687where
16688    C: common::Connector,
16689{
16690    /// Perform the operation you have build so far.
16691    pub async fn doit(
16692        mut self,
16693    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
16694        use std::borrow::Cow;
16695        use std::io::{Read, Seek};
16696
16697        use common::{url::Params, ToParts};
16698        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16699
16700        let mut dd = common::DefaultDelegate;
16701        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16702        dlg.begin(common::MethodInfo {
16703            id: "recommender.projects.locations.recommenders.recommendations.markClaimed",
16704            http_method: hyper::Method::POST,
16705        });
16706
16707        for &field in ["alt", "name"].iter() {
16708            if self._additional_params.contains_key(field) {
16709                dlg.finished(false);
16710                return Err(common::Error::FieldClash(field));
16711            }
16712        }
16713
16714        let mut params = Params::with_capacity(4 + self._additional_params.len());
16715        params.push("name", self._name);
16716
16717        params.extend(self._additional_params.iter());
16718
16719        params.push("alt", "json");
16720        let mut url = self.hub._base_url.clone() + "v1/{+name}:markClaimed";
16721        if self._scopes.is_empty() {
16722            self._scopes
16723                .insert(Scope::CloudPlatform.as_ref().to_string());
16724        }
16725
16726        #[allow(clippy::single_element_loop)]
16727        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16728            url = params.uri_replacement(url, param_name, find_this, true);
16729        }
16730        {
16731            let to_remove = ["name"];
16732            params.remove_params(&to_remove);
16733        }
16734
16735        let url = params.parse_with_url(&url);
16736
16737        let mut json_mime_type = mime::APPLICATION_JSON;
16738        let mut request_value_reader = {
16739            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16740            common::remove_json_null_values(&mut value);
16741            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16742            serde_json::to_writer(&mut dst, &value).unwrap();
16743            dst
16744        };
16745        let request_size = request_value_reader
16746            .seek(std::io::SeekFrom::End(0))
16747            .unwrap();
16748        request_value_reader
16749            .seek(std::io::SeekFrom::Start(0))
16750            .unwrap();
16751
16752        loop {
16753            let token = match self
16754                .hub
16755                .auth
16756                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16757                .await
16758            {
16759                Ok(token) => token,
16760                Err(e) => match dlg.token(e) {
16761                    Ok(token) => token,
16762                    Err(e) => {
16763                        dlg.finished(false);
16764                        return Err(common::Error::MissingToken(e));
16765                    }
16766                },
16767            };
16768            request_value_reader
16769                .seek(std::io::SeekFrom::Start(0))
16770                .unwrap();
16771            let mut req_result = {
16772                let client = &self.hub.client;
16773                dlg.pre_request();
16774                let mut req_builder = hyper::Request::builder()
16775                    .method(hyper::Method::POST)
16776                    .uri(url.as_str())
16777                    .header(USER_AGENT, self.hub._user_agent.clone());
16778
16779                if let Some(token) = token.as_ref() {
16780                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16781                }
16782
16783                let request = req_builder
16784                    .header(CONTENT_TYPE, json_mime_type.to_string())
16785                    .header(CONTENT_LENGTH, request_size as u64)
16786                    .body(common::to_body(
16787                        request_value_reader.get_ref().clone().into(),
16788                    ));
16789
16790                client.request(request.unwrap()).await
16791            };
16792
16793            match req_result {
16794                Err(err) => {
16795                    if let common::Retry::After(d) = dlg.http_error(&err) {
16796                        sleep(d).await;
16797                        continue;
16798                    }
16799                    dlg.finished(false);
16800                    return Err(common::Error::HttpError(err));
16801                }
16802                Ok(res) => {
16803                    let (mut parts, body) = res.into_parts();
16804                    let mut body = common::Body::new(body);
16805                    if !parts.status.is_success() {
16806                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16807                        let error = serde_json::from_str(&common::to_string(&bytes));
16808                        let response = common::to_response(parts, bytes.into());
16809
16810                        if let common::Retry::After(d) =
16811                            dlg.http_failure(&response, error.as_ref().ok())
16812                        {
16813                            sleep(d).await;
16814                            continue;
16815                        }
16816
16817                        dlg.finished(false);
16818
16819                        return Err(match error {
16820                            Ok(value) => common::Error::BadRequest(value),
16821                            _ => common::Error::Failure(response),
16822                        });
16823                    }
16824                    let response = {
16825                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16826                        let encoded = common::to_string(&bytes);
16827                        match serde_json::from_str(&encoded) {
16828                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16829                            Err(error) => {
16830                                dlg.response_json_decode_error(&encoded, &error);
16831                                return Err(common::Error::JsonDecodeError(
16832                                    encoded.to_string(),
16833                                    error,
16834                                ));
16835                            }
16836                        }
16837                    };
16838
16839                    dlg.finished(true);
16840                    return Ok(response);
16841                }
16842            }
16843        }
16844    }
16845
16846    ///
16847    /// Sets the *request* property to the given value.
16848    ///
16849    /// Even though the property as already been set when instantiating this call,
16850    /// we provide this method for API completeness.
16851    pub fn request(
16852        mut self,
16853        new_value: GoogleCloudRecommenderV1MarkRecommendationClaimedRequest,
16854    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
16855        self._request = new_value;
16856        self
16857    }
16858    /// Required. Name of the recommendation.
16859    ///
16860    /// Sets the *name* path property to the given value.
16861    ///
16862    /// Even though the property as already been set when instantiating this call,
16863    /// we provide this method for API completeness.
16864    pub fn name(
16865        mut self,
16866        new_value: &str,
16867    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
16868        self._name = new_value.to_string();
16869        self
16870    }
16871    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16872    /// while executing the actual API request.
16873    ///
16874    /// ````text
16875    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16876    /// ````
16877    ///
16878    /// Sets the *delegate* property to the given value.
16879    pub fn delegate(
16880        mut self,
16881        new_value: &'a mut dyn common::Delegate,
16882    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
16883        self._delegate = Some(new_value);
16884        self
16885    }
16886
16887    /// Set any additional parameter of the query string used in the request.
16888    /// It should be used to set parameters which are not yet available through their own
16889    /// setters.
16890    ///
16891    /// Please note that this method must not be used to set any of the known parameters
16892    /// which have their own setter method. If done anyway, the request will fail.
16893    ///
16894    /// # Additional Parameters
16895    ///
16896    /// * *$.xgafv* (query-string) - V1 error format.
16897    /// * *access_token* (query-string) - OAuth access token.
16898    /// * *alt* (query-string) - Data format for response.
16899    /// * *callback* (query-string) - JSONP
16900    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16901    /// * *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.
16902    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16903    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16904    /// * *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.
16905    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16906    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16907    pub fn param<T>(
16908        mut self,
16909        name: T,
16910        value: T,
16911    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
16912    where
16913        T: AsRef<str>,
16914    {
16915        self._additional_params
16916            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16917        self
16918    }
16919
16920    /// Identifies the authorization scope for the method you are building.
16921    ///
16922    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16923    /// [`Scope::CloudPlatform`].
16924    ///
16925    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16926    /// tokens for more than one scope.
16927    ///
16928    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16929    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16930    /// sufficient, a read-write scope will do as well.
16931    pub fn add_scope<St>(
16932        mut self,
16933        scope: St,
16934    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
16935    where
16936        St: AsRef<str>,
16937    {
16938        self._scopes.insert(String::from(scope.as_ref()));
16939        self
16940    }
16941    /// Identifies the authorization scope(s) for the method you are building.
16942    ///
16943    /// See [`Self::add_scope()`] for details.
16944    pub fn add_scopes<I, St>(
16945        mut self,
16946        scopes: I,
16947    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
16948    where
16949        I: IntoIterator<Item = St>,
16950        St: AsRef<str>,
16951    {
16952        self._scopes
16953            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16954        self
16955    }
16956
16957    /// Removes all scopes, and no default scope will be used either.
16958    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16959    /// for details).
16960    pub fn clear_scopes(
16961        mut self,
16962    ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
16963        self._scopes.clear();
16964        self
16965    }
16966}
16967
16968/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
16969///
16970/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *project* resource.
16971/// It is not used directly, but through a [`ProjectMethods`] instance.
16972///
16973/// # Example
16974///
16975/// Instantiate a resource method builder
16976///
16977/// ```test_harness,no_run
16978/// # extern crate hyper;
16979/// # extern crate hyper_rustls;
16980/// # extern crate google_recommender1 as recommender1;
16981/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationDismissedRequest;
16982/// # async fn dox() {
16983/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16984///
16985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16986/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16987/// #     .with_native_roots()
16988/// #     .unwrap()
16989/// #     .https_only()
16990/// #     .enable_http2()
16991/// #     .build();
16992///
16993/// # let executor = hyper_util::rt::TokioExecutor::new();
16994/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16995/// #     secret,
16996/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16997/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16998/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16999/// #     ),
17000/// # ).build().await.unwrap();
17001///
17002/// # let client = hyper_util::client::legacy::Client::builder(
17003/// #     hyper_util::rt::TokioExecutor::new()
17004/// # )
17005/// # .build(
17006/// #     hyper_rustls::HttpsConnectorBuilder::new()
17007/// #         .with_native_roots()
17008/// #         .unwrap()
17009/// #         .https_or_http()
17010/// #         .enable_http2()
17011/// #         .build()
17012/// # );
17013/// # let mut hub = Recommender::new(client, auth);
17014/// // As the method needs a request, you would usually fill it with the desired information
17015/// // into the respective structure. Some of the parts shown here might not be applicable !
17016/// // Values shown here are possibly random and not representative !
17017/// let mut req = GoogleCloudRecommenderV1MarkRecommendationDismissedRequest::default();
17018///
17019/// // You can configure optional parameters by calling the respective setters at will, and
17020/// // execute the final call using `doit()`.
17021/// // Values shown here are possibly random and not representative !
17022/// let result = hub.projects().locations_recommenders_recommendations_mark_dismissed(req, "name")
17023///              .doit().await;
17024/// # }
17025/// ```
17026pub struct ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
17027where
17028    C: 'a,
17029{
17030    hub: &'a Recommender<C>,
17031    _request: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
17032    _name: String,
17033    _delegate: Option<&'a mut dyn common::Delegate>,
17034    _additional_params: HashMap<String, String>,
17035    _scopes: BTreeSet<String>,
17036}
17037
17038impl<'a, C> common::CallBuilder
17039    for ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
17040{
17041}
17042
17043impl<'a, C> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
17044where
17045    C: common::Connector,
17046{
17047    /// Perform the operation you have build so far.
17048    pub async fn doit(
17049        mut self,
17050    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
17051        use std::borrow::Cow;
17052        use std::io::{Read, Seek};
17053
17054        use common::{url::Params, ToParts};
17055        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17056
17057        let mut dd = common::DefaultDelegate;
17058        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17059        dlg.begin(common::MethodInfo {
17060            id: "recommender.projects.locations.recommenders.recommendations.markDismissed",
17061            http_method: hyper::Method::POST,
17062        });
17063
17064        for &field in ["alt", "name"].iter() {
17065            if self._additional_params.contains_key(field) {
17066                dlg.finished(false);
17067                return Err(common::Error::FieldClash(field));
17068            }
17069        }
17070
17071        let mut params = Params::with_capacity(4 + self._additional_params.len());
17072        params.push("name", self._name);
17073
17074        params.extend(self._additional_params.iter());
17075
17076        params.push("alt", "json");
17077        let mut url = self.hub._base_url.clone() + "v1/{+name}:markDismissed";
17078        if self._scopes.is_empty() {
17079            self._scopes
17080                .insert(Scope::CloudPlatform.as_ref().to_string());
17081        }
17082
17083        #[allow(clippy::single_element_loop)]
17084        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17085            url = params.uri_replacement(url, param_name, find_this, true);
17086        }
17087        {
17088            let to_remove = ["name"];
17089            params.remove_params(&to_remove);
17090        }
17091
17092        let url = params.parse_with_url(&url);
17093
17094        let mut json_mime_type = mime::APPLICATION_JSON;
17095        let mut request_value_reader = {
17096            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17097            common::remove_json_null_values(&mut value);
17098            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17099            serde_json::to_writer(&mut dst, &value).unwrap();
17100            dst
17101        };
17102        let request_size = request_value_reader
17103            .seek(std::io::SeekFrom::End(0))
17104            .unwrap();
17105        request_value_reader
17106            .seek(std::io::SeekFrom::Start(0))
17107            .unwrap();
17108
17109        loop {
17110            let token = match self
17111                .hub
17112                .auth
17113                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17114                .await
17115            {
17116                Ok(token) => token,
17117                Err(e) => match dlg.token(e) {
17118                    Ok(token) => token,
17119                    Err(e) => {
17120                        dlg.finished(false);
17121                        return Err(common::Error::MissingToken(e));
17122                    }
17123                },
17124            };
17125            request_value_reader
17126                .seek(std::io::SeekFrom::Start(0))
17127                .unwrap();
17128            let mut req_result = {
17129                let client = &self.hub.client;
17130                dlg.pre_request();
17131                let mut req_builder = hyper::Request::builder()
17132                    .method(hyper::Method::POST)
17133                    .uri(url.as_str())
17134                    .header(USER_AGENT, self.hub._user_agent.clone());
17135
17136                if let Some(token) = token.as_ref() {
17137                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17138                }
17139
17140                let request = req_builder
17141                    .header(CONTENT_TYPE, json_mime_type.to_string())
17142                    .header(CONTENT_LENGTH, request_size as u64)
17143                    .body(common::to_body(
17144                        request_value_reader.get_ref().clone().into(),
17145                    ));
17146
17147                client.request(request.unwrap()).await
17148            };
17149
17150            match req_result {
17151                Err(err) => {
17152                    if let common::Retry::After(d) = dlg.http_error(&err) {
17153                        sleep(d).await;
17154                        continue;
17155                    }
17156                    dlg.finished(false);
17157                    return Err(common::Error::HttpError(err));
17158                }
17159                Ok(res) => {
17160                    let (mut parts, body) = res.into_parts();
17161                    let mut body = common::Body::new(body);
17162                    if !parts.status.is_success() {
17163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17164                        let error = serde_json::from_str(&common::to_string(&bytes));
17165                        let response = common::to_response(parts, bytes.into());
17166
17167                        if let common::Retry::After(d) =
17168                            dlg.http_failure(&response, error.as_ref().ok())
17169                        {
17170                            sleep(d).await;
17171                            continue;
17172                        }
17173
17174                        dlg.finished(false);
17175
17176                        return Err(match error {
17177                            Ok(value) => common::Error::BadRequest(value),
17178                            _ => common::Error::Failure(response),
17179                        });
17180                    }
17181                    let response = {
17182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17183                        let encoded = common::to_string(&bytes);
17184                        match serde_json::from_str(&encoded) {
17185                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17186                            Err(error) => {
17187                                dlg.response_json_decode_error(&encoded, &error);
17188                                return Err(common::Error::JsonDecodeError(
17189                                    encoded.to_string(),
17190                                    error,
17191                                ));
17192                            }
17193                        }
17194                    };
17195
17196                    dlg.finished(true);
17197                    return Ok(response);
17198                }
17199            }
17200        }
17201    }
17202
17203    ///
17204    /// Sets the *request* property to the given value.
17205    ///
17206    /// Even though the property as already been set when instantiating this call,
17207    /// we provide this method for API completeness.
17208    pub fn request(
17209        mut self,
17210        new_value: GoogleCloudRecommenderV1MarkRecommendationDismissedRequest,
17211    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
17212        self._request = new_value;
17213        self
17214    }
17215    /// Required. Name of the recommendation.
17216    ///
17217    /// Sets the *name* path property to the given value.
17218    ///
17219    /// Even though the property as already been set when instantiating this call,
17220    /// we provide this method for API completeness.
17221    pub fn name(
17222        mut self,
17223        new_value: &str,
17224    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
17225        self._name = new_value.to_string();
17226        self
17227    }
17228    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17229    /// while executing the actual API request.
17230    ///
17231    /// ````text
17232    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17233    /// ````
17234    ///
17235    /// Sets the *delegate* property to the given value.
17236    pub fn delegate(
17237        mut self,
17238        new_value: &'a mut dyn common::Delegate,
17239    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
17240        self._delegate = Some(new_value);
17241        self
17242    }
17243
17244    /// Set any additional parameter of the query string used in the request.
17245    /// It should be used to set parameters which are not yet available through their own
17246    /// setters.
17247    ///
17248    /// Please note that this method must not be used to set any of the known parameters
17249    /// which have their own setter method. If done anyway, the request will fail.
17250    ///
17251    /// # Additional Parameters
17252    ///
17253    /// * *$.xgafv* (query-string) - V1 error format.
17254    /// * *access_token* (query-string) - OAuth access token.
17255    /// * *alt* (query-string) - Data format for response.
17256    /// * *callback* (query-string) - JSONP
17257    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17258    /// * *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.
17259    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17260    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17261    /// * *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.
17262    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17263    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17264    pub fn param<T>(
17265        mut self,
17266        name: T,
17267        value: T,
17268    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
17269    where
17270        T: AsRef<str>,
17271    {
17272        self._additional_params
17273            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17274        self
17275    }
17276
17277    /// Identifies the authorization scope for the method you are building.
17278    ///
17279    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17280    /// [`Scope::CloudPlatform`].
17281    ///
17282    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17283    /// tokens for more than one scope.
17284    ///
17285    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17286    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17287    /// sufficient, a read-write scope will do as well.
17288    pub fn add_scope<St>(
17289        mut self,
17290        scope: St,
17291    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
17292    where
17293        St: AsRef<str>,
17294    {
17295        self._scopes.insert(String::from(scope.as_ref()));
17296        self
17297    }
17298    /// Identifies the authorization scope(s) for the method you are building.
17299    ///
17300    /// See [`Self::add_scope()`] for details.
17301    pub fn add_scopes<I, St>(
17302        mut self,
17303        scopes: I,
17304    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
17305    where
17306        I: IntoIterator<Item = St>,
17307        St: AsRef<str>,
17308    {
17309        self._scopes
17310            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17311        self
17312    }
17313
17314    /// Removes all scopes, and no default scope will be used either.
17315    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17316    /// for details).
17317    pub fn clear_scopes(
17318        mut self,
17319    ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
17320        self._scopes.clear();
17321        self
17322    }
17323}
17324
17325/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
17326///
17327/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *project* resource.
17328/// It is not used directly, but through a [`ProjectMethods`] instance.
17329///
17330/// # Example
17331///
17332/// Instantiate a resource method builder
17333///
17334/// ```test_harness,no_run
17335/// # extern crate hyper;
17336/// # extern crate hyper_rustls;
17337/// # extern crate google_recommender1 as recommender1;
17338/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationFailedRequest;
17339/// # async fn dox() {
17340/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17341///
17342/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17343/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17344/// #     .with_native_roots()
17345/// #     .unwrap()
17346/// #     .https_only()
17347/// #     .enable_http2()
17348/// #     .build();
17349///
17350/// # let executor = hyper_util::rt::TokioExecutor::new();
17351/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17352/// #     secret,
17353/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17354/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17355/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17356/// #     ),
17357/// # ).build().await.unwrap();
17358///
17359/// # let client = hyper_util::client::legacy::Client::builder(
17360/// #     hyper_util::rt::TokioExecutor::new()
17361/// # )
17362/// # .build(
17363/// #     hyper_rustls::HttpsConnectorBuilder::new()
17364/// #         .with_native_roots()
17365/// #         .unwrap()
17366/// #         .https_or_http()
17367/// #         .enable_http2()
17368/// #         .build()
17369/// # );
17370/// # let mut hub = Recommender::new(client, auth);
17371/// // As the method needs a request, you would usually fill it with the desired information
17372/// // into the respective structure. Some of the parts shown here might not be applicable !
17373/// // Values shown here are possibly random and not representative !
17374/// let mut req = GoogleCloudRecommenderV1MarkRecommendationFailedRequest::default();
17375///
17376/// // You can configure optional parameters by calling the respective setters at will, and
17377/// // execute the final call using `doit()`.
17378/// // Values shown here are possibly random and not representative !
17379/// let result = hub.projects().locations_recommenders_recommendations_mark_failed(req, "name")
17380///              .doit().await;
17381/// # }
17382/// ```
17383pub struct ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
17384where
17385    C: 'a,
17386{
17387    hub: &'a Recommender<C>,
17388    _request: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
17389    _name: String,
17390    _delegate: Option<&'a mut dyn common::Delegate>,
17391    _additional_params: HashMap<String, String>,
17392    _scopes: BTreeSet<String>,
17393}
17394
17395impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {}
17396
17397impl<'a, C> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
17398where
17399    C: common::Connector,
17400{
17401    /// Perform the operation you have build so far.
17402    pub async fn doit(
17403        mut self,
17404    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
17405        use std::borrow::Cow;
17406        use std::io::{Read, Seek};
17407
17408        use common::{url::Params, ToParts};
17409        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17410
17411        let mut dd = common::DefaultDelegate;
17412        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17413        dlg.begin(common::MethodInfo {
17414            id: "recommender.projects.locations.recommenders.recommendations.markFailed",
17415            http_method: hyper::Method::POST,
17416        });
17417
17418        for &field in ["alt", "name"].iter() {
17419            if self._additional_params.contains_key(field) {
17420                dlg.finished(false);
17421                return Err(common::Error::FieldClash(field));
17422            }
17423        }
17424
17425        let mut params = Params::with_capacity(4 + self._additional_params.len());
17426        params.push("name", self._name);
17427
17428        params.extend(self._additional_params.iter());
17429
17430        params.push("alt", "json");
17431        let mut url = self.hub._base_url.clone() + "v1/{+name}:markFailed";
17432        if self._scopes.is_empty() {
17433            self._scopes
17434                .insert(Scope::CloudPlatform.as_ref().to_string());
17435        }
17436
17437        #[allow(clippy::single_element_loop)]
17438        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17439            url = params.uri_replacement(url, param_name, find_this, true);
17440        }
17441        {
17442            let to_remove = ["name"];
17443            params.remove_params(&to_remove);
17444        }
17445
17446        let url = params.parse_with_url(&url);
17447
17448        let mut json_mime_type = mime::APPLICATION_JSON;
17449        let mut request_value_reader = {
17450            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17451            common::remove_json_null_values(&mut value);
17452            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17453            serde_json::to_writer(&mut dst, &value).unwrap();
17454            dst
17455        };
17456        let request_size = request_value_reader
17457            .seek(std::io::SeekFrom::End(0))
17458            .unwrap();
17459        request_value_reader
17460            .seek(std::io::SeekFrom::Start(0))
17461            .unwrap();
17462
17463        loop {
17464            let token = match self
17465                .hub
17466                .auth
17467                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17468                .await
17469            {
17470                Ok(token) => token,
17471                Err(e) => match dlg.token(e) {
17472                    Ok(token) => token,
17473                    Err(e) => {
17474                        dlg.finished(false);
17475                        return Err(common::Error::MissingToken(e));
17476                    }
17477                },
17478            };
17479            request_value_reader
17480                .seek(std::io::SeekFrom::Start(0))
17481                .unwrap();
17482            let mut req_result = {
17483                let client = &self.hub.client;
17484                dlg.pre_request();
17485                let mut req_builder = hyper::Request::builder()
17486                    .method(hyper::Method::POST)
17487                    .uri(url.as_str())
17488                    .header(USER_AGENT, self.hub._user_agent.clone());
17489
17490                if let Some(token) = token.as_ref() {
17491                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17492                }
17493
17494                let request = req_builder
17495                    .header(CONTENT_TYPE, json_mime_type.to_string())
17496                    .header(CONTENT_LENGTH, request_size as u64)
17497                    .body(common::to_body(
17498                        request_value_reader.get_ref().clone().into(),
17499                    ));
17500
17501                client.request(request.unwrap()).await
17502            };
17503
17504            match req_result {
17505                Err(err) => {
17506                    if let common::Retry::After(d) = dlg.http_error(&err) {
17507                        sleep(d).await;
17508                        continue;
17509                    }
17510                    dlg.finished(false);
17511                    return Err(common::Error::HttpError(err));
17512                }
17513                Ok(res) => {
17514                    let (mut parts, body) = res.into_parts();
17515                    let mut body = common::Body::new(body);
17516                    if !parts.status.is_success() {
17517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17518                        let error = serde_json::from_str(&common::to_string(&bytes));
17519                        let response = common::to_response(parts, bytes.into());
17520
17521                        if let common::Retry::After(d) =
17522                            dlg.http_failure(&response, error.as_ref().ok())
17523                        {
17524                            sleep(d).await;
17525                            continue;
17526                        }
17527
17528                        dlg.finished(false);
17529
17530                        return Err(match error {
17531                            Ok(value) => common::Error::BadRequest(value),
17532                            _ => common::Error::Failure(response),
17533                        });
17534                    }
17535                    let response = {
17536                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17537                        let encoded = common::to_string(&bytes);
17538                        match serde_json::from_str(&encoded) {
17539                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17540                            Err(error) => {
17541                                dlg.response_json_decode_error(&encoded, &error);
17542                                return Err(common::Error::JsonDecodeError(
17543                                    encoded.to_string(),
17544                                    error,
17545                                ));
17546                            }
17547                        }
17548                    };
17549
17550                    dlg.finished(true);
17551                    return Ok(response);
17552                }
17553            }
17554        }
17555    }
17556
17557    ///
17558    /// Sets the *request* property to the given value.
17559    ///
17560    /// Even though the property as already been set when instantiating this call,
17561    /// we provide this method for API completeness.
17562    pub fn request(
17563        mut self,
17564        new_value: GoogleCloudRecommenderV1MarkRecommendationFailedRequest,
17565    ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
17566        self._request = new_value;
17567        self
17568    }
17569    /// Required. Name of the recommendation.
17570    ///
17571    /// Sets the *name* path property to the given value.
17572    ///
17573    /// Even though the property as already been set when instantiating this call,
17574    /// we provide this method for API completeness.
17575    pub fn name(
17576        mut self,
17577        new_value: &str,
17578    ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
17579        self._name = new_value.to_string();
17580        self
17581    }
17582    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17583    /// while executing the actual API request.
17584    ///
17585    /// ````text
17586    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17587    /// ````
17588    ///
17589    /// Sets the *delegate* property to the given value.
17590    pub fn delegate(
17591        mut self,
17592        new_value: &'a mut dyn common::Delegate,
17593    ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
17594        self._delegate = Some(new_value);
17595        self
17596    }
17597
17598    /// Set any additional parameter of the query string used in the request.
17599    /// It should be used to set parameters which are not yet available through their own
17600    /// setters.
17601    ///
17602    /// Please note that this method must not be used to set any of the known parameters
17603    /// which have their own setter method. If done anyway, the request will fail.
17604    ///
17605    /// # Additional Parameters
17606    ///
17607    /// * *$.xgafv* (query-string) - V1 error format.
17608    /// * *access_token* (query-string) - OAuth access token.
17609    /// * *alt* (query-string) - Data format for response.
17610    /// * *callback* (query-string) - JSONP
17611    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17612    /// * *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.
17613    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17614    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17615    /// * *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.
17616    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17617    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17618    pub fn param<T>(
17619        mut self,
17620        name: T,
17621        value: T,
17622    ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
17623    where
17624        T: AsRef<str>,
17625    {
17626        self._additional_params
17627            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17628        self
17629    }
17630
17631    /// Identifies the authorization scope for the method you are building.
17632    ///
17633    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17634    /// [`Scope::CloudPlatform`].
17635    ///
17636    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17637    /// tokens for more than one scope.
17638    ///
17639    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17640    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17641    /// sufficient, a read-write scope will do as well.
17642    pub fn add_scope<St>(
17643        mut self,
17644        scope: St,
17645    ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
17646    where
17647        St: AsRef<str>,
17648    {
17649        self._scopes.insert(String::from(scope.as_ref()));
17650        self
17651    }
17652    /// Identifies the authorization scope(s) for the method you are building.
17653    ///
17654    /// See [`Self::add_scope()`] for details.
17655    pub fn add_scopes<I, St>(
17656        mut self,
17657        scopes: I,
17658    ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
17659    where
17660        I: IntoIterator<Item = St>,
17661        St: AsRef<str>,
17662    {
17663        self._scopes
17664            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17665        self
17666    }
17667
17668    /// Removes all scopes, and no default scope will be used either.
17669    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17670    /// for details).
17671    pub fn clear_scopes(mut self) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
17672        self._scopes.clear();
17673        self
17674    }
17675}
17676
17677/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
17678///
17679/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *project* resource.
17680/// It is not used directly, but through a [`ProjectMethods`] instance.
17681///
17682/// # Example
17683///
17684/// Instantiate a resource method builder
17685///
17686/// ```test_harness,no_run
17687/// # extern crate hyper;
17688/// # extern crate hyper_rustls;
17689/// # extern crate google_recommender1 as recommender1;
17690/// use recommender1::api::GoogleCloudRecommenderV1MarkRecommendationSucceededRequest;
17691/// # async fn dox() {
17692/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17693///
17694/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17695/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17696/// #     .with_native_roots()
17697/// #     .unwrap()
17698/// #     .https_only()
17699/// #     .enable_http2()
17700/// #     .build();
17701///
17702/// # let executor = hyper_util::rt::TokioExecutor::new();
17703/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17704/// #     secret,
17705/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17706/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17707/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17708/// #     ),
17709/// # ).build().await.unwrap();
17710///
17711/// # let client = hyper_util::client::legacy::Client::builder(
17712/// #     hyper_util::rt::TokioExecutor::new()
17713/// # )
17714/// # .build(
17715/// #     hyper_rustls::HttpsConnectorBuilder::new()
17716/// #         .with_native_roots()
17717/// #         .unwrap()
17718/// #         .https_or_http()
17719/// #         .enable_http2()
17720/// #         .build()
17721/// # );
17722/// # let mut hub = Recommender::new(client, auth);
17723/// // As the method needs a request, you would usually fill it with the desired information
17724/// // into the respective structure. Some of the parts shown here might not be applicable !
17725/// // Values shown here are possibly random and not representative !
17726/// let mut req = GoogleCloudRecommenderV1MarkRecommendationSucceededRequest::default();
17727///
17728/// // You can configure optional parameters by calling the respective setters at will, and
17729/// // execute the final call using `doit()`.
17730/// // Values shown here are possibly random and not representative !
17731/// let result = hub.projects().locations_recommenders_recommendations_mark_succeeded(req, "name")
17732///              .doit().await;
17733/// # }
17734/// ```
17735pub struct ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
17736where
17737    C: 'a,
17738{
17739    hub: &'a Recommender<C>,
17740    _request: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
17741    _name: String,
17742    _delegate: Option<&'a mut dyn common::Delegate>,
17743    _additional_params: HashMap<String, String>,
17744    _scopes: BTreeSet<String>,
17745}
17746
17747impl<'a, C> common::CallBuilder
17748    for ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
17749{
17750}
17751
17752impl<'a, C> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
17753where
17754    C: common::Connector,
17755{
17756    /// Perform the operation you have build so far.
17757    pub async fn doit(
17758        mut self,
17759    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1Recommendation)> {
17760        use std::borrow::Cow;
17761        use std::io::{Read, Seek};
17762
17763        use common::{url::Params, ToParts};
17764        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17765
17766        let mut dd = common::DefaultDelegate;
17767        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17768        dlg.begin(common::MethodInfo {
17769            id: "recommender.projects.locations.recommenders.recommendations.markSucceeded",
17770            http_method: hyper::Method::POST,
17771        });
17772
17773        for &field in ["alt", "name"].iter() {
17774            if self._additional_params.contains_key(field) {
17775                dlg.finished(false);
17776                return Err(common::Error::FieldClash(field));
17777            }
17778        }
17779
17780        let mut params = Params::with_capacity(4 + self._additional_params.len());
17781        params.push("name", self._name);
17782
17783        params.extend(self._additional_params.iter());
17784
17785        params.push("alt", "json");
17786        let mut url = self.hub._base_url.clone() + "v1/{+name}:markSucceeded";
17787        if self._scopes.is_empty() {
17788            self._scopes
17789                .insert(Scope::CloudPlatform.as_ref().to_string());
17790        }
17791
17792        #[allow(clippy::single_element_loop)]
17793        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17794            url = params.uri_replacement(url, param_name, find_this, true);
17795        }
17796        {
17797            let to_remove = ["name"];
17798            params.remove_params(&to_remove);
17799        }
17800
17801        let url = params.parse_with_url(&url);
17802
17803        let mut json_mime_type = mime::APPLICATION_JSON;
17804        let mut request_value_reader = {
17805            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17806            common::remove_json_null_values(&mut value);
17807            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17808            serde_json::to_writer(&mut dst, &value).unwrap();
17809            dst
17810        };
17811        let request_size = request_value_reader
17812            .seek(std::io::SeekFrom::End(0))
17813            .unwrap();
17814        request_value_reader
17815            .seek(std::io::SeekFrom::Start(0))
17816            .unwrap();
17817
17818        loop {
17819            let token = match self
17820                .hub
17821                .auth
17822                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17823                .await
17824            {
17825                Ok(token) => token,
17826                Err(e) => match dlg.token(e) {
17827                    Ok(token) => token,
17828                    Err(e) => {
17829                        dlg.finished(false);
17830                        return Err(common::Error::MissingToken(e));
17831                    }
17832                },
17833            };
17834            request_value_reader
17835                .seek(std::io::SeekFrom::Start(0))
17836                .unwrap();
17837            let mut req_result = {
17838                let client = &self.hub.client;
17839                dlg.pre_request();
17840                let mut req_builder = hyper::Request::builder()
17841                    .method(hyper::Method::POST)
17842                    .uri(url.as_str())
17843                    .header(USER_AGENT, self.hub._user_agent.clone());
17844
17845                if let Some(token) = token.as_ref() {
17846                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17847                }
17848
17849                let request = req_builder
17850                    .header(CONTENT_TYPE, json_mime_type.to_string())
17851                    .header(CONTENT_LENGTH, request_size as u64)
17852                    .body(common::to_body(
17853                        request_value_reader.get_ref().clone().into(),
17854                    ));
17855
17856                client.request(request.unwrap()).await
17857            };
17858
17859            match req_result {
17860                Err(err) => {
17861                    if let common::Retry::After(d) = dlg.http_error(&err) {
17862                        sleep(d).await;
17863                        continue;
17864                    }
17865                    dlg.finished(false);
17866                    return Err(common::Error::HttpError(err));
17867                }
17868                Ok(res) => {
17869                    let (mut parts, body) = res.into_parts();
17870                    let mut body = common::Body::new(body);
17871                    if !parts.status.is_success() {
17872                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17873                        let error = serde_json::from_str(&common::to_string(&bytes));
17874                        let response = common::to_response(parts, bytes.into());
17875
17876                        if let common::Retry::After(d) =
17877                            dlg.http_failure(&response, error.as_ref().ok())
17878                        {
17879                            sleep(d).await;
17880                            continue;
17881                        }
17882
17883                        dlg.finished(false);
17884
17885                        return Err(match error {
17886                            Ok(value) => common::Error::BadRequest(value),
17887                            _ => common::Error::Failure(response),
17888                        });
17889                    }
17890                    let response = {
17891                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17892                        let encoded = common::to_string(&bytes);
17893                        match serde_json::from_str(&encoded) {
17894                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17895                            Err(error) => {
17896                                dlg.response_json_decode_error(&encoded, &error);
17897                                return Err(common::Error::JsonDecodeError(
17898                                    encoded.to_string(),
17899                                    error,
17900                                ));
17901                            }
17902                        }
17903                    };
17904
17905                    dlg.finished(true);
17906                    return Ok(response);
17907                }
17908            }
17909        }
17910    }
17911
17912    ///
17913    /// Sets the *request* property to the given value.
17914    ///
17915    /// Even though the property as already been set when instantiating this call,
17916    /// we provide this method for API completeness.
17917    pub fn request(
17918        mut self,
17919        new_value: GoogleCloudRecommenderV1MarkRecommendationSucceededRequest,
17920    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
17921        self._request = new_value;
17922        self
17923    }
17924    /// Required. Name of the recommendation.
17925    ///
17926    /// Sets the *name* path property to the given value.
17927    ///
17928    /// Even though the property as already been set when instantiating this call,
17929    /// we provide this method for API completeness.
17930    pub fn name(
17931        mut self,
17932        new_value: &str,
17933    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
17934        self._name = new_value.to_string();
17935        self
17936    }
17937    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17938    /// while executing the actual API request.
17939    ///
17940    /// ````text
17941    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17942    /// ````
17943    ///
17944    /// Sets the *delegate* property to the given value.
17945    pub fn delegate(
17946        mut self,
17947        new_value: &'a mut dyn common::Delegate,
17948    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
17949        self._delegate = Some(new_value);
17950        self
17951    }
17952
17953    /// Set any additional parameter of the query string used in the request.
17954    /// It should be used to set parameters which are not yet available through their own
17955    /// setters.
17956    ///
17957    /// Please note that this method must not be used to set any of the known parameters
17958    /// which have their own setter method. If done anyway, the request will fail.
17959    ///
17960    /// # Additional Parameters
17961    ///
17962    /// * *$.xgafv* (query-string) - V1 error format.
17963    /// * *access_token* (query-string) - OAuth access token.
17964    /// * *alt* (query-string) - Data format for response.
17965    /// * *callback* (query-string) - JSONP
17966    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17967    /// * *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.
17968    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17969    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17970    /// * *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.
17971    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17972    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17973    pub fn param<T>(
17974        mut self,
17975        name: T,
17976        value: T,
17977    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
17978    where
17979        T: AsRef<str>,
17980    {
17981        self._additional_params
17982            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17983        self
17984    }
17985
17986    /// Identifies the authorization scope for the method you are building.
17987    ///
17988    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17989    /// [`Scope::CloudPlatform`].
17990    ///
17991    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17992    /// tokens for more than one scope.
17993    ///
17994    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17995    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17996    /// sufficient, a read-write scope will do as well.
17997    pub fn add_scope<St>(
17998        mut self,
17999        scope: St,
18000    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
18001    where
18002        St: AsRef<str>,
18003    {
18004        self._scopes.insert(String::from(scope.as_ref()));
18005        self
18006    }
18007    /// Identifies the authorization scope(s) for the method you are building.
18008    ///
18009    /// See [`Self::add_scope()`] for details.
18010    pub fn add_scopes<I, St>(
18011        mut self,
18012        scopes: I,
18013    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
18014    where
18015        I: IntoIterator<Item = St>,
18016        St: AsRef<str>,
18017    {
18018        self._scopes
18019            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18020        self
18021    }
18022
18023    /// Removes all scopes, and no default scope will be used either.
18024    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18025    /// for details).
18026    pub fn clear_scopes(
18027        mut self,
18028    ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
18029        self._scopes.clear();
18030        self
18031    }
18032}
18033
18034/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
18035///
18036/// A builder for the *locations.recommenders.getConfig* method supported by a *project* resource.
18037/// It is not used directly, but through a [`ProjectMethods`] instance.
18038///
18039/// # Example
18040///
18041/// Instantiate a resource method builder
18042///
18043/// ```test_harness,no_run
18044/// # extern crate hyper;
18045/// # extern crate hyper_rustls;
18046/// # extern crate google_recommender1 as recommender1;
18047/// # async fn dox() {
18048/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18049///
18050/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18051/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18052/// #     .with_native_roots()
18053/// #     .unwrap()
18054/// #     .https_only()
18055/// #     .enable_http2()
18056/// #     .build();
18057///
18058/// # let executor = hyper_util::rt::TokioExecutor::new();
18059/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18060/// #     secret,
18061/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18062/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18063/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18064/// #     ),
18065/// # ).build().await.unwrap();
18066///
18067/// # let client = hyper_util::client::legacy::Client::builder(
18068/// #     hyper_util::rt::TokioExecutor::new()
18069/// # )
18070/// # .build(
18071/// #     hyper_rustls::HttpsConnectorBuilder::new()
18072/// #         .with_native_roots()
18073/// #         .unwrap()
18074/// #         .https_or_http()
18075/// #         .enable_http2()
18076/// #         .build()
18077/// # );
18078/// # let mut hub = Recommender::new(client, auth);
18079/// // You can configure optional parameters by calling the respective setters at will, and
18080/// // execute the final call using `doit()`.
18081/// // Values shown here are possibly random and not representative !
18082/// let result = hub.projects().locations_recommenders_get_config("name")
18083///              .doit().await;
18084/// # }
18085/// ```
18086pub struct ProjectLocationRecommenderGetConfigCall<'a, C>
18087where
18088    C: 'a,
18089{
18090    hub: &'a Recommender<C>,
18091    _name: String,
18092    _delegate: Option<&'a mut dyn common::Delegate>,
18093    _additional_params: HashMap<String, String>,
18094    _scopes: BTreeSet<String>,
18095}
18096
18097impl<'a, C> common::CallBuilder for ProjectLocationRecommenderGetConfigCall<'a, C> {}
18098
18099impl<'a, C> ProjectLocationRecommenderGetConfigCall<'a, C>
18100where
18101    C: common::Connector,
18102{
18103    /// Perform the operation you have build so far.
18104    pub async fn doit(
18105        mut self,
18106    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1RecommenderConfig)> {
18107        use std::borrow::Cow;
18108        use std::io::{Read, Seek};
18109
18110        use common::{url::Params, ToParts};
18111        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18112
18113        let mut dd = common::DefaultDelegate;
18114        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18115        dlg.begin(common::MethodInfo {
18116            id: "recommender.projects.locations.recommenders.getConfig",
18117            http_method: hyper::Method::GET,
18118        });
18119
18120        for &field in ["alt", "name"].iter() {
18121            if self._additional_params.contains_key(field) {
18122                dlg.finished(false);
18123                return Err(common::Error::FieldClash(field));
18124            }
18125        }
18126
18127        let mut params = Params::with_capacity(3 + self._additional_params.len());
18128        params.push("name", self._name);
18129
18130        params.extend(self._additional_params.iter());
18131
18132        params.push("alt", "json");
18133        let mut url = self.hub._base_url.clone() + "v1/{+name}";
18134        if self._scopes.is_empty() {
18135            self._scopes
18136                .insert(Scope::CloudPlatform.as_ref().to_string());
18137        }
18138
18139        #[allow(clippy::single_element_loop)]
18140        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18141            url = params.uri_replacement(url, param_name, find_this, true);
18142        }
18143        {
18144            let to_remove = ["name"];
18145            params.remove_params(&to_remove);
18146        }
18147
18148        let url = params.parse_with_url(&url);
18149
18150        loop {
18151            let token = match self
18152                .hub
18153                .auth
18154                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18155                .await
18156            {
18157                Ok(token) => token,
18158                Err(e) => match dlg.token(e) {
18159                    Ok(token) => token,
18160                    Err(e) => {
18161                        dlg.finished(false);
18162                        return Err(common::Error::MissingToken(e));
18163                    }
18164                },
18165            };
18166            let mut req_result = {
18167                let client = &self.hub.client;
18168                dlg.pre_request();
18169                let mut req_builder = hyper::Request::builder()
18170                    .method(hyper::Method::GET)
18171                    .uri(url.as_str())
18172                    .header(USER_AGENT, self.hub._user_agent.clone());
18173
18174                if let Some(token) = token.as_ref() {
18175                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18176                }
18177
18178                let request = req_builder
18179                    .header(CONTENT_LENGTH, 0_u64)
18180                    .body(common::to_body::<String>(None));
18181
18182                client.request(request.unwrap()).await
18183            };
18184
18185            match req_result {
18186                Err(err) => {
18187                    if let common::Retry::After(d) = dlg.http_error(&err) {
18188                        sleep(d).await;
18189                        continue;
18190                    }
18191                    dlg.finished(false);
18192                    return Err(common::Error::HttpError(err));
18193                }
18194                Ok(res) => {
18195                    let (mut parts, body) = res.into_parts();
18196                    let mut body = common::Body::new(body);
18197                    if !parts.status.is_success() {
18198                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18199                        let error = serde_json::from_str(&common::to_string(&bytes));
18200                        let response = common::to_response(parts, bytes.into());
18201
18202                        if let common::Retry::After(d) =
18203                            dlg.http_failure(&response, error.as_ref().ok())
18204                        {
18205                            sleep(d).await;
18206                            continue;
18207                        }
18208
18209                        dlg.finished(false);
18210
18211                        return Err(match error {
18212                            Ok(value) => common::Error::BadRequest(value),
18213                            _ => common::Error::Failure(response),
18214                        });
18215                    }
18216                    let response = {
18217                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18218                        let encoded = common::to_string(&bytes);
18219                        match serde_json::from_str(&encoded) {
18220                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18221                            Err(error) => {
18222                                dlg.response_json_decode_error(&encoded, &error);
18223                                return Err(common::Error::JsonDecodeError(
18224                                    encoded.to_string(),
18225                                    error,
18226                                ));
18227                            }
18228                        }
18229                    };
18230
18231                    dlg.finished(true);
18232                    return Ok(response);
18233                }
18234            }
18235        }
18236    }
18237
18238    /// Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
18239    ///
18240    /// Sets the *name* path property to the given value.
18241    ///
18242    /// Even though the property as already been set when instantiating this call,
18243    /// we provide this method for API completeness.
18244    pub fn name(mut self, new_value: &str) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
18245        self._name = new_value.to_string();
18246        self
18247    }
18248    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18249    /// while executing the actual API request.
18250    ///
18251    /// ````text
18252    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18253    /// ````
18254    ///
18255    /// Sets the *delegate* property to the given value.
18256    pub fn delegate(
18257        mut self,
18258        new_value: &'a mut dyn common::Delegate,
18259    ) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
18260        self._delegate = Some(new_value);
18261        self
18262    }
18263
18264    /// Set any additional parameter of the query string used in the request.
18265    /// It should be used to set parameters which are not yet available through their own
18266    /// setters.
18267    ///
18268    /// Please note that this method must not be used to set any of the known parameters
18269    /// which have their own setter method. If done anyway, the request will fail.
18270    ///
18271    /// # Additional Parameters
18272    ///
18273    /// * *$.xgafv* (query-string) - V1 error format.
18274    /// * *access_token* (query-string) - OAuth access token.
18275    /// * *alt* (query-string) - Data format for response.
18276    /// * *callback* (query-string) - JSONP
18277    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18278    /// * *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.
18279    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18280    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18281    /// * *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.
18282    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18283    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18284    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderGetConfigCall<'a, C>
18285    where
18286        T: AsRef<str>,
18287    {
18288        self._additional_params
18289            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18290        self
18291    }
18292
18293    /// Identifies the authorization scope for the method you are building.
18294    ///
18295    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18296    /// [`Scope::CloudPlatform`].
18297    ///
18298    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18299    /// tokens for more than one scope.
18300    ///
18301    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18302    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18303    /// sufficient, a read-write scope will do as well.
18304    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRecommenderGetConfigCall<'a, C>
18305    where
18306        St: AsRef<str>,
18307    {
18308        self._scopes.insert(String::from(scope.as_ref()));
18309        self
18310    }
18311    /// Identifies the authorization scope(s) for the method you are building.
18312    ///
18313    /// See [`Self::add_scope()`] for details.
18314    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderGetConfigCall<'a, C>
18315    where
18316        I: IntoIterator<Item = St>,
18317        St: AsRef<str>,
18318    {
18319        self._scopes
18320            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18321        self
18322    }
18323
18324    /// Removes all scopes, and no default scope will be used either.
18325    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18326    /// for details).
18327    pub fn clear_scopes(mut self) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
18328        self._scopes.clear();
18329        self
18330    }
18331}
18332
18333/// Updates a Recommender Config. This will create a new revision of the config.
18334///
18335/// A builder for the *locations.recommenders.updateConfig* method supported by a *project* resource.
18336/// It is not used directly, but through a [`ProjectMethods`] instance.
18337///
18338/// # Example
18339///
18340/// Instantiate a resource method builder
18341///
18342/// ```test_harness,no_run
18343/// # extern crate hyper;
18344/// # extern crate hyper_rustls;
18345/// # extern crate google_recommender1 as recommender1;
18346/// use recommender1::api::GoogleCloudRecommenderV1RecommenderConfig;
18347/// # async fn dox() {
18348/// # use recommender1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18349///
18350/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18351/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18352/// #     .with_native_roots()
18353/// #     .unwrap()
18354/// #     .https_only()
18355/// #     .enable_http2()
18356/// #     .build();
18357///
18358/// # let executor = hyper_util::rt::TokioExecutor::new();
18359/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18360/// #     secret,
18361/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18362/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18363/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18364/// #     ),
18365/// # ).build().await.unwrap();
18366///
18367/// # let client = hyper_util::client::legacy::Client::builder(
18368/// #     hyper_util::rt::TokioExecutor::new()
18369/// # )
18370/// # .build(
18371/// #     hyper_rustls::HttpsConnectorBuilder::new()
18372/// #         .with_native_roots()
18373/// #         .unwrap()
18374/// #         .https_or_http()
18375/// #         .enable_http2()
18376/// #         .build()
18377/// # );
18378/// # let mut hub = Recommender::new(client, auth);
18379/// // As the method needs a request, you would usually fill it with the desired information
18380/// // into the respective structure. Some of the parts shown here might not be applicable !
18381/// // Values shown here are possibly random and not representative !
18382/// let mut req = GoogleCloudRecommenderV1RecommenderConfig::default();
18383///
18384/// // You can configure optional parameters by calling the respective setters at will, and
18385/// // execute the final call using `doit()`.
18386/// // Values shown here are possibly random and not representative !
18387/// let result = hub.projects().locations_recommenders_update_config(req, "name")
18388///              .validate_only(true)
18389///              .update_mask(FieldMask::new::<&str>(&[]))
18390///              .doit().await;
18391/// # }
18392/// ```
18393pub struct ProjectLocationRecommenderUpdateConfigCall<'a, C>
18394where
18395    C: 'a,
18396{
18397    hub: &'a Recommender<C>,
18398    _request: GoogleCloudRecommenderV1RecommenderConfig,
18399    _name: String,
18400    _validate_only: Option<bool>,
18401    _update_mask: Option<common::FieldMask>,
18402    _delegate: Option<&'a mut dyn common::Delegate>,
18403    _additional_params: HashMap<String, String>,
18404    _scopes: BTreeSet<String>,
18405}
18406
18407impl<'a, C> common::CallBuilder for ProjectLocationRecommenderUpdateConfigCall<'a, C> {}
18408
18409impl<'a, C> ProjectLocationRecommenderUpdateConfigCall<'a, C>
18410where
18411    C: common::Connector,
18412{
18413    /// Perform the operation you have build so far.
18414    pub async fn doit(
18415        mut self,
18416    ) -> common::Result<(common::Response, GoogleCloudRecommenderV1RecommenderConfig)> {
18417        use std::borrow::Cow;
18418        use std::io::{Read, Seek};
18419
18420        use common::{url::Params, ToParts};
18421        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18422
18423        let mut dd = common::DefaultDelegate;
18424        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18425        dlg.begin(common::MethodInfo {
18426            id: "recommender.projects.locations.recommenders.updateConfig",
18427            http_method: hyper::Method::PATCH,
18428        });
18429
18430        for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
18431            if self._additional_params.contains_key(field) {
18432                dlg.finished(false);
18433                return Err(common::Error::FieldClash(field));
18434            }
18435        }
18436
18437        let mut params = Params::with_capacity(6 + self._additional_params.len());
18438        params.push("name", self._name);
18439        if let Some(value) = self._validate_only.as_ref() {
18440            params.push("validateOnly", value.to_string());
18441        }
18442        if let Some(value) = self._update_mask.as_ref() {
18443            params.push("updateMask", value.to_string());
18444        }
18445
18446        params.extend(self._additional_params.iter());
18447
18448        params.push("alt", "json");
18449        let mut url = self.hub._base_url.clone() + "v1/{+name}";
18450        if self._scopes.is_empty() {
18451            self._scopes
18452                .insert(Scope::CloudPlatform.as_ref().to_string());
18453        }
18454
18455        #[allow(clippy::single_element_loop)]
18456        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18457            url = params.uri_replacement(url, param_name, find_this, true);
18458        }
18459        {
18460            let to_remove = ["name"];
18461            params.remove_params(&to_remove);
18462        }
18463
18464        let url = params.parse_with_url(&url);
18465
18466        let mut json_mime_type = mime::APPLICATION_JSON;
18467        let mut request_value_reader = {
18468            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18469            common::remove_json_null_values(&mut value);
18470            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18471            serde_json::to_writer(&mut dst, &value).unwrap();
18472            dst
18473        };
18474        let request_size = request_value_reader
18475            .seek(std::io::SeekFrom::End(0))
18476            .unwrap();
18477        request_value_reader
18478            .seek(std::io::SeekFrom::Start(0))
18479            .unwrap();
18480
18481        loop {
18482            let token = match self
18483                .hub
18484                .auth
18485                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18486                .await
18487            {
18488                Ok(token) => token,
18489                Err(e) => match dlg.token(e) {
18490                    Ok(token) => token,
18491                    Err(e) => {
18492                        dlg.finished(false);
18493                        return Err(common::Error::MissingToken(e));
18494                    }
18495                },
18496            };
18497            request_value_reader
18498                .seek(std::io::SeekFrom::Start(0))
18499                .unwrap();
18500            let mut req_result = {
18501                let client = &self.hub.client;
18502                dlg.pre_request();
18503                let mut req_builder = hyper::Request::builder()
18504                    .method(hyper::Method::PATCH)
18505                    .uri(url.as_str())
18506                    .header(USER_AGENT, self.hub._user_agent.clone());
18507
18508                if let Some(token) = token.as_ref() {
18509                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18510                }
18511
18512                let request = req_builder
18513                    .header(CONTENT_TYPE, json_mime_type.to_string())
18514                    .header(CONTENT_LENGTH, request_size as u64)
18515                    .body(common::to_body(
18516                        request_value_reader.get_ref().clone().into(),
18517                    ));
18518
18519                client.request(request.unwrap()).await
18520            };
18521
18522            match req_result {
18523                Err(err) => {
18524                    if let common::Retry::After(d) = dlg.http_error(&err) {
18525                        sleep(d).await;
18526                        continue;
18527                    }
18528                    dlg.finished(false);
18529                    return Err(common::Error::HttpError(err));
18530                }
18531                Ok(res) => {
18532                    let (mut parts, body) = res.into_parts();
18533                    let mut body = common::Body::new(body);
18534                    if !parts.status.is_success() {
18535                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18536                        let error = serde_json::from_str(&common::to_string(&bytes));
18537                        let response = common::to_response(parts, bytes.into());
18538
18539                        if let common::Retry::After(d) =
18540                            dlg.http_failure(&response, error.as_ref().ok())
18541                        {
18542                            sleep(d).await;
18543                            continue;
18544                        }
18545
18546                        dlg.finished(false);
18547
18548                        return Err(match error {
18549                            Ok(value) => common::Error::BadRequest(value),
18550                            _ => common::Error::Failure(response),
18551                        });
18552                    }
18553                    let response = {
18554                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18555                        let encoded = common::to_string(&bytes);
18556                        match serde_json::from_str(&encoded) {
18557                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18558                            Err(error) => {
18559                                dlg.response_json_decode_error(&encoded, &error);
18560                                return Err(common::Error::JsonDecodeError(
18561                                    encoded.to_string(),
18562                                    error,
18563                                ));
18564                            }
18565                        }
18566                    };
18567
18568                    dlg.finished(true);
18569                    return Ok(response);
18570                }
18571            }
18572        }
18573    }
18574
18575    ///
18576    /// Sets the *request* property to the given value.
18577    ///
18578    /// Even though the property as already been set when instantiating this call,
18579    /// we provide this method for API completeness.
18580    pub fn request(
18581        mut self,
18582        new_value: GoogleCloudRecommenderV1RecommenderConfig,
18583    ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
18584        self._request = new_value;
18585        self
18586    }
18587    /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
18588    ///
18589    /// Sets the *name* path property to the given value.
18590    ///
18591    /// Even though the property as already been set when instantiating this call,
18592    /// we provide this method for API completeness.
18593    pub fn name(mut self, new_value: &str) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
18594        self._name = new_value.to_string();
18595        self
18596    }
18597    /// If true, validate the request and preview the change, but do not actually update it.
18598    ///
18599    /// Sets the *validate only* query property to the given value.
18600    pub fn validate_only(
18601        mut self,
18602        new_value: bool,
18603    ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
18604        self._validate_only = Some(new_value);
18605        self
18606    }
18607    /// The list of fields to be updated.
18608    ///
18609    /// Sets the *update mask* query property to the given value.
18610    pub fn update_mask(
18611        mut self,
18612        new_value: common::FieldMask,
18613    ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
18614        self._update_mask = Some(new_value);
18615        self
18616    }
18617    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18618    /// while executing the actual API request.
18619    ///
18620    /// ````text
18621    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18622    /// ````
18623    ///
18624    /// Sets the *delegate* property to the given value.
18625    pub fn delegate(
18626        mut self,
18627        new_value: &'a mut dyn common::Delegate,
18628    ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
18629        self._delegate = Some(new_value);
18630        self
18631    }
18632
18633    /// Set any additional parameter of the query string used in the request.
18634    /// It should be used to set parameters which are not yet available through their own
18635    /// setters.
18636    ///
18637    /// Please note that this method must not be used to set any of the known parameters
18638    /// which have their own setter method. If done anyway, the request will fail.
18639    ///
18640    /// # Additional Parameters
18641    ///
18642    /// * *$.xgafv* (query-string) - V1 error format.
18643    /// * *access_token* (query-string) - OAuth access token.
18644    /// * *alt* (query-string) - Data format for response.
18645    /// * *callback* (query-string) - JSONP
18646    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18647    /// * *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.
18648    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18649    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18650    /// * *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.
18651    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18652    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18653    pub fn param<T>(
18654        mut self,
18655        name: T,
18656        value: T,
18657    ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C>
18658    where
18659        T: AsRef<str>,
18660    {
18661        self._additional_params
18662            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18663        self
18664    }
18665
18666    /// Identifies the authorization scope for the method you are building.
18667    ///
18668    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18669    /// [`Scope::CloudPlatform`].
18670    ///
18671    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18672    /// tokens for more than one scope.
18673    ///
18674    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18675    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18676    /// sufficient, a read-write scope will do as well.
18677    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRecommenderUpdateConfigCall<'a, C>
18678    where
18679        St: AsRef<str>,
18680    {
18681        self._scopes.insert(String::from(scope.as_ref()));
18682        self
18683    }
18684    /// Identifies the authorization scope(s) for the method you are building.
18685    ///
18686    /// See [`Self::add_scope()`] for details.
18687    pub fn add_scopes<I, St>(
18688        mut self,
18689        scopes: I,
18690    ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C>
18691    where
18692        I: IntoIterator<Item = St>,
18693        St: AsRef<str>,
18694    {
18695        self._scopes
18696            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18697        self
18698    }
18699
18700    /// Removes all scopes, and no default scope will be used either.
18701    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18702    /// for details).
18703    pub fn clear_scopes(mut self) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
18704        self._scopes.clear();
18705        self
18706    }
18707}