google_recommender1_beta1/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_beta1 as recommender1_beta1;
49/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
50/// use recommender1_beta1::{Result, Error};
51/// # async fn dox() {
52/// use recommender1_beta1::{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 = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::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 insight_types(&'a self) -> InsightTypeMethods<'a, C> {
152 InsightTypeMethods { hub: self }
153 }
154 pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
155 OrganizationMethods { hub: self }
156 }
157 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
158 ProjectMethods { hub: self }
159 }
160 pub fn recommenders(&'a self) -> RecommenderMethods<'a, C> {
161 RecommenderMethods { hub: self }
162 }
163
164 /// Set the user-agent header field to use in all requests to the server.
165 /// It defaults to `google-api-rust-client/7.0.0`.
166 ///
167 /// Returns the previously set user-agent.
168 pub fn user_agent(&mut self, agent_name: String) -> String {
169 std::mem::replace(&mut self._user_agent, agent_name)
170 }
171
172 /// Set the base url to use in all requests to the server.
173 /// It defaults to `https://recommender.googleapis.com/`.
174 ///
175 /// Returns the previously set base url.
176 pub fn base_url(&mut self, new_base_url: String) -> String {
177 std::mem::replace(&mut self._base_url, new_base_url)
178 }
179
180 /// Set the root url to use in all requests to the server.
181 /// It defaults to `https://recommender.googleapis.com/`.
182 ///
183 /// Returns the previously set root url.
184 pub fn root_url(&mut self, new_root_url: String) -> String {
185 std::mem::replace(&mut self._root_url, new_root_url)
186 }
187}
188
189// ############
190// SCHEMAS ###
191// ##########
192/// The response message for Locations.ListLocations.
193///
194/// # Activities
195///
196/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
197/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
198///
199/// * [locations list billing accounts](BillingAccountLocationListCall) (response)
200/// * [locations list folders](FolderLocationListCall) (response)
201/// * [locations list organizations](OrganizationLocationListCall) (response)
202/// * [locations list projects](ProjectLocationListCall) (response)
203#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
204#[serde_with::serde_as]
205#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
206pub struct GoogleCloudLocationListLocationsResponse {
207 /// A list of locations that matches the specified filter in the request.
208 pub locations: Option<Vec<GoogleCloudLocationLocation>>,
209 /// The standard List next-page token.
210 #[serde(rename = "nextPageToken")]
211 pub next_page_token: Option<String>,
212}
213
214impl common::ResponseResult for GoogleCloudLocationListLocationsResponse {}
215
216/// A resource that represents a Google Cloud location.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct GoogleCloudLocationLocation {
224 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
225 #[serde(rename = "displayName")]
226 pub display_name: Option<String>,
227 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
228 pub labels: Option<HashMap<String, String>>,
229 /// The canonical id for this location. For example: `"us-east1"`.
230 #[serde(rename = "locationId")]
231 pub location_id: Option<String>,
232 /// Service-specific metadata. For example the available capacity at the given location.
233 pub metadata: Option<HashMap<String, serde_json::Value>>,
234 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
235 pub name: Option<String>,
236}
237
238impl common::Part for GoogleCloudLocationLocation {}
239
240/// Contains metadata about how much money a recommendation can save or incur.
241///
242/// This type is not used in any activity, and only used as *part* of another schema.
243///
244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
245#[serde_with::serde_as]
246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
247pub struct GoogleCloudRecommenderV1beta1CostProjection {
248 /// 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.
249 pub cost: Option<GoogleTypeMoney>,
250 /// The approximate cost savings in the billing account's local currency.
251 #[serde(rename = "costInLocalCurrency")]
252 pub cost_in_local_currency: Option<GoogleTypeMoney>,
253 /// Duration for which this cost applies.
254 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
255 pub duration: Option<chrono::Duration>,
256 /// How the cost is calculated.
257 #[serde(rename = "pricingType")]
258 pub pricing_type: Option<String>,
259}
260
261impl common::Part for GoogleCloudRecommenderV1beta1CostProjection {}
262
263/// Contains the impact a recommendation can have for a given category.
264///
265/// This type is not used in any activity, and only used as *part* of another schema.
266///
267#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
268#[serde_with::serde_as]
269#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
270pub struct GoogleCloudRecommenderV1beta1Impact {
271 /// Category that is being targeted.
272 pub category: Option<String>,
273 /// Use with CategoryType.COST
274 #[serde(rename = "costProjection")]
275 pub cost_projection: Option<GoogleCloudRecommenderV1beta1CostProjection>,
276 /// If populated, the impact contains multiple components. In this case, the top-level impact contains aggregated values and each component contains per-service details.
277 #[serde(rename = "impactComponents")]
278 pub impact_components: Option<Vec<GoogleCloudRecommenderV1beta1Impact>>,
279 /// Use with CategoryType.RELIABILITY
280 #[serde(rename = "reliabilityProjection")]
281 pub reliability_projection: Option<GoogleCloudRecommenderV1beta1ReliabilityProjection>,
282 /// Use with CategoryType.SECURITY
283 #[serde(rename = "securityProjection")]
284 pub security_projection: Option<GoogleCloudRecommenderV1beta1SecurityProjection>,
285 /// The service that this impact is associated with.
286 pub service: Option<String>,
287 /// Use with CategoryType.SUSTAINABILITY
288 #[serde(rename = "sustainabilityProjection")]
289 pub sustainability_projection: Option<GoogleCloudRecommenderV1beta1SustainabilityProjection>,
290}
291
292impl common::Part for GoogleCloudRecommenderV1beta1Impact {}
293
294/// An insight along with the information used to derive the insight. The insight may have associated recommendations as well.
295///
296/// # Activities
297///
298/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
299/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
300///
301/// * [locations insight types insights get billing accounts](BillingAccountLocationInsightTypeInsightGetCall) (response)
302/// * [locations insight types insights mark accepted billing accounts](BillingAccountLocationInsightTypeInsightMarkAcceptedCall) (response)
303/// * [locations insight types insights get folders](FolderLocationInsightTypeInsightGetCall) (response)
304/// * [locations insight types insights mark accepted folders](FolderLocationInsightTypeInsightMarkAcceptedCall) (response)
305/// * [locations insight types insights get organizations](OrganizationLocationInsightTypeInsightGetCall) (response)
306/// * [locations insight types insights mark accepted organizations](OrganizationLocationInsightTypeInsightMarkAcceptedCall) (response)
307/// * [locations insight types insights get projects](ProjectLocationInsightTypeInsightGetCall) (response)
308/// * [locations insight types insights mark accepted projects](ProjectLocationInsightTypeInsightMarkAcceptedCall) (response)
309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
310#[serde_with::serde_as]
311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
312pub struct GoogleCloudRecommenderV1beta1Insight {
313 /// Recommendations derived from this insight.
314 #[serde(rename = "associatedRecommendations")]
315 pub associated_recommendations:
316 Option<Vec<GoogleCloudRecommenderV1beta1InsightRecommendationReference>>,
317 /// Category being targeted by the insight.
318 pub category: Option<String>,
319 /// A struct of custom fields to explain the insight. Example: "grantedPermissionsCount": "1000"
320 pub content: Option<HashMap<String, serde_json::Value>>,
321 /// Free-form human readable summary in English. The maximum length is 500 characters.
322 pub description: Option<String>,
323 /// Fingerprint of the Insight. Provides optimistic locking when updating states.
324 pub etag: Option<String>,
325 /// Insight subtype. Insight content schema will be stable for a given subtype.
326 #[serde(rename = "insightSubtype")]
327 pub insight_subtype: Option<String>,
328 /// Timestamp of the latest data used to generate the insight.
329 #[serde(rename = "lastRefreshTime")]
330 pub last_refresh_time: Option<chrono::DateTime<chrono::offset::Utc>>,
331 /// Identifier. Name of the insight.
332 pub name: Option<String>,
333 /// 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).
334 #[serde(rename = "observationPeriod")]
335 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
336 pub observation_period: Option<chrono::Duration>,
337 /// Insight's severity.
338 pub severity: Option<String>,
339 /// Information state and metadata.
340 #[serde(rename = "stateInfo")]
341 pub state_info: Option<GoogleCloudRecommenderV1beta1InsightStateInfo>,
342 /// Fully qualified resource names that this insight is targeting.
343 #[serde(rename = "targetResources")]
344 pub target_resources: Option<Vec<String>>,
345}
346
347impl common::ResponseResult for GoogleCloudRecommenderV1beta1Insight {}
348
349/// Reference to an associated recommendation.
350///
351/// This type is not used in any activity, and only used as *part* of another schema.
352///
353#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
354#[serde_with::serde_as]
355#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
356pub struct GoogleCloudRecommenderV1beta1InsightRecommendationReference {
357 /// Recommendation resource name, e.g. projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID]
358 pub recommendation: Option<String>,
359}
360
361impl common::Part for GoogleCloudRecommenderV1beta1InsightRecommendationReference {}
362
363/// Information related to insight state.
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 GoogleCloudRecommenderV1beta1InsightStateInfo {
371 /// Insight state.
372 pub state: Option<String>,
373 /// A map of metadata for the state, provided by user or automations systems.
374 #[serde(rename = "stateMetadata")]
375 pub state_metadata: Option<HashMap<String, String>>,
376}
377
378impl common::Part for GoogleCloudRecommenderV1beta1InsightStateInfo {}
379
380/// The type of insight.
381///
382/// This type is not used in any activity, and only used as *part* of another schema.
383///
384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
385#[serde_with::serde_as]
386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
387pub struct GoogleCloudRecommenderV1beta1InsightType {
388 /// The insight_type's name in format insightTypes/{insight_type} eg: insightTypes/google.iam.policy.Insight
389 pub name: Option<String>,
390}
391
392impl common::Part for GoogleCloudRecommenderV1beta1InsightType {}
393
394/// Configuration for an InsightType.
395///
396/// # Activities
397///
398/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
399/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
400///
401/// * [locations insight types get config billing accounts](BillingAccountLocationInsightTypeGetConfigCall) (response)
402/// * [locations insight types update config billing accounts](BillingAccountLocationInsightTypeUpdateConfigCall) (request|response)
403/// * [locations insight types get config organizations](OrganizationLocationInsightTypeGetConfigCall) (response)
404/// * [locations insight types update config organizations](OrganizationLocationInsightTypeUpdateConfigCall) (request|response)
405/// * [locations insight types get config projects](ProjectLocationInsightTypeGetConfigCall) (response)
406/// * [locations insight types update config projects](ProjectLocationInsightTypeUpdateConfigCall) (request|response)
407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
408#[serde_with::serde_as]
409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
410pub struct GoogleCloudRecommenderV1beta1InsightTypeConfig {
411 /// 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.
412 pub annotations: Option<HashMap<String, String>>,
413 /// A user-settable field to provide a human-readable name to be used in user interfaces.
414 #[serde(rename = "displayName")]
415 pub display_name: Option<String>,
416 /// Fingerprint of the InsightTypeConfig. Provides optimistic locking when updating.
417 pub etag: Option<String>,
418 /// InsightTypeGenerationConfig which configures the generation of insights for this insight type.
419 #[serde(rename = "insightTypeGenerationConfig")]
420 pub insight_type_generation_config:
421 Option<GoogleCloudRecommenderV1beta1InsightTypeGenerationConfig>,
422 /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
423 pub name: Option<String>,
424 /// 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.
425 #[serde(rename = "revisionId")]
426 pub revision_id: Option<String>,
427 /// Last time when the config was updated.
428 #[serde(rename = "updateTime")]
429 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
430}
431
432impl common::RequestValue for GoogleCloudRecommenderV1beta1InsightTypeConfig {}
433impl common::ResponseResult for GoogleCloudRecommenderV1beta1InsightTypeConfig {}
434
435/// A configuration to customize the generation of insights. Eg, customizing the lookback period considered when generating a insight.
436///
437/// This type is not used in any activity, and only used as *part* of another schema.
438///
439#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
440#[serde_with::serde_as]
441#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
442pub struct GoogleCloudRecommenderV1beta1InsightTypeGenerationConfig {
443 /// Parameters for this InsightTypeGenerationConfig. These configs can be used by or are applied to all subtypes.
444 pub params: Option<HashMap<String, serde_json::Value>>,
445}
446
447impl common::Part for GoogleCloudRecommenderV1beta1InsightTypeGenerationConfig {}
448
449/// Response for the `ListInsightTypes` method. Next ID: 3
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/// * [list insight types](InsightTypeListCall) (response)
457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
458#[serde_with::serde_as]
459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
460pub struct GoogleCloudRecommenderV1beta1ListInsightTypesResponse {
461 /// The set of recommenders available
462 #[serde(rename = "insightTypes")]
463 pub insight_types: Option<Vec<GoogleCloudRecommenderV1beta1InsightType>>,
464 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
465 #[serde(rename = "nextPageToken")]
466 pub next_page_token: Option<String>,
467}
468
469impl common::ResponseResult for GoogleCloudRecommenderV1beta1ListInsightTypesResponse {}
470
471/// Response to the `ListInsights` method.
472///
473/// # Activities
474///
475/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
476/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
477///
478/// * [locations insight types insights list billing accounts](BillingAccountLocationInsightTypeInsightListCall) (response)
479/// * [locations insight types insights list folders](FolderLocationInsightTypeInsightListCall) (response)
480/// * [locations insight types insights list organizations](OrganizationLocationInsightTypeInsightListCall) (response)
481/// * [locations insight types insights list projects](ProjectLocationInsightTypeInsightListCall) (response)
482#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
483#[serde_with::serde_as]
484#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
485pub struct GoogleCloudRecommenderV1beta1ListInsightsResponse {
486 /// The set of insights for the `parent` resource.
487 pub insights: Option<Vec<GoogleCloudRecommenderV1beta1Insight>>,
488 /// A token that can be used to request the next page of results. This field is empty if there are no additional results.
489 #[serde(rename = "nextPageToken")]
490 pub next_page_token: Option<String>,
491}
492
493impl common::ResponseResult for GoogleCloudRecommenderV1beta1ListInsightsResponse {}
494
495/// Response to the `ListRecommendations` method.
496///
497/// # Activities
498///
499/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
500/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
501///
502/// * [locations recommenders recommendations list billing accounts](BillingAccountLocationRecommenderRecommendationListCall) (response)
503/// * [locations recommenders recommendations list folders](FolderLocationRecommenderRecommendationListCall) (response)
504/// * [locations recommenders recommendations list organizations](OrganizationLocationRecommenderRecommendationListCall) (response)
505/// * [locations recommenders recommendations list projects](ProjectLocationRecommenderRecommendationListCall) (response)
506#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
507#[serde_with::serde_as]
508#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
509pub struct GoogleCloudRecommenderV1beta1ListRecommendationsResponse {
510 /// A token that can be used to request the next page of results. This field is empty if there are no additional results.
511 #[serde(rename = "nextPageToken")]
512 pub next_page_token: Option<String>,
513 /// The set of recommendations for the `parent` resource.
514 pub recommendations: Option<Vec<GoogleCloudRecommenderV1beta1Recommendation>>,
515}
516
517impl common::ResponseResult for GoogleCloudRecommenderV1beta1ListRecommendationsResponse {}
518
519/// Response for the `ListRecommender` method. Next ID: 3
520///
521/// # Activities
522///
523/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
524/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
525///
526/// * [list recommenders](RecommenderListCall) (response)
527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
528#[serde_with::serde_as]
529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
530pub struct GoogleCloudRecommenderV1beta1ListRecommendersResponse {
531 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
532 #[serde(rename = "nextPageToken")]
533 pub next_page_token: Option<String>,
534 /// The set of recommenders available
535 pub recommenders: Option<Vec<GoogleCloudRecommenderV1beta1RecommenderType>>,
536}
537
538impl common::ResponseResult for GoogleCloudRecommenderV1beta1ListRecommendersResponse {}
539
540/// Request for the `MarkInsightAccepted` method.
541///
542/// # Activities
543///
544/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
545/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
546///
547/// * [locations insight types insights mark accepted billing accounts](BillingAccountLocationInsightTypeInsightMarkAcceptedCall) (request)
548/// * [locations insight types insights mark accepted folders](FolderLocationInsightTypeInsightMarkAcceptedCall) (request)
549/// * [locations insight types insights mark accepted organizations](OrganizationLocationInsightTypeInsightMarkAcceptedCall) (request)
550/// * [locations insight types insights mark accepted projects](ProjectLocationInsightTypeInsightMarkAcceptedCall) (request)
551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
552#[serde_with::serde_as]
553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
554pub struct GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest {
555 /// Required. Fingerprint of the Insight. Provides optimistic locking.
556 pub etag: Option<String>,
557 /// Optional. State properties user wish to include with this state. Full replace of the current state_metadata.
558 #[serde(rename = "stateMetadata")]
559 pub state_metadata: Option<HashMap<String, String>>,
560}
561
562impl common::RequestValue for GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest {}
563
564/// Request for the `MarkRecommendationClaimed` Method.
565///
566/// # Activities
567///
568/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
569/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
570///
571/// * [locations recommenders recommendations mark claimed billing accounts](BillingAccountLocationRecommenderRecommendationMarkClaimedCall) (request)
572/// * [locations recommenders recommendations mark claimed folders](FolderLocationRecommenderRecommendationMarkClaimedCall) (request)
573/// * [locations recommenders recommendations mark claimed organizations](OrganizationLocationRecommenderRecommendationMarkClaimedCall) (request)
574/// * [locations recommenders recommendations mark claimed projects](ProjectLocationRecommenderRecommendationMarkClaimedCall) (request)
575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
576#[serde_with::serde_as]
577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
578pub struct GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest {
579 /// Required. Fingerprint of the Recommendation. Provides optimistic locking.
580 pub etag: Option<String>,
581 /// 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}$/`.
582 #[serde(rename = "stateMetadata")]
583 pub state_metadata: Option<HashMap<String, String>>,
584}
585
586impl common::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest {}
587
588/// Request for the `MarkRecommendationDismissed` Method.
589///
590/// # Activities
591///
592/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
593/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
594///
595/// * [locations recommenders recommendations mark dismissed billing accounts](BillingAccountLocationRecommenderRecommendationMarkDismissedCall) (request)
596/// * [locations recommenders recommendations mark dismissed folders](FolderLocationRecommenderRecommendationMarkDismissedCall) (request)
597/// * [locations recommenders recommendations mark dismissed organizations](OrganizationLocationRecommenderRecommendationMarkDismissedCall) (request)
598/// * [locations recommenders recommendations mark dismissed projects](ProjectLocationRecommenderRecommendationMarkDismissedCall) (request)
599#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
600#[serde_with::serde_as]
601#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
602pub struct GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest {
603 /// Fingerprint of the Recommendation. Provides optimistic locking.
604 pub etag: Option<String>,
605}
606
607impl common::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest {}
608
609/// Request for the `MarkRecommendationFailed` Method.
610///
611/// # Activities
612///
613/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
614/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
615///
616/// * [locations recommenders recommendations mark failed billing accounts](BillingAccountLocationRecommenderRecommendationMarkFailedCall) (request)
617/// * [locations recommenders recommendations mark failed folders](FolderLocationRecommenderRecommendationMarkFailedCall) (request)
618/// * [locations recommenders recommendations mark failed organizations](OrganizationLocationRecommenderRecommendationMarkFailedCall) (request)
619/// * [locations recommenders recommendations mark failed projects](ProjectLocationRecommenderRecommendationMarkFailedCall) (request)
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest {
624 /// Required. Fingerprint of the Recommendation. Provides optimistic locking.
625 pub etag: Option<String>,
626 /// 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}$/`.
627 #[serde(rename = "stateMetadata")]
628 pub state_metadata: Option<HashMap<String, String>>,
629}
630
631impl common::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest {}
632
633/// Request for the `MarkRecommendationSucceeded` Method.
634///
635/// # Activities
636///
637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
639///
640/// * [locations recommenders recommendations mark succeeded billing accounts](BillingAccountLocationRecommenderRecommendationMarkSucceededCall) (request)
641/// * [locations recommenders recommendations mark succeeded folders](FolderLocationRecommenderRecommendationMarkSucceededCall) (request)
642/// * [locations recommenders recommendations mark succeeded organizations](OrganizationLocationRecommenderRecommendationMarkSucceededCall) (request)
643/// * [locations recommenders recommendations mark succeeded projects](ProjectLocationRecommenderRecommendationMarkSucceededCall) (request)
644#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
645#[serde_with::serde_as]
646#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
647pub struct GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest {
648 /// Required. Fingerprint of the Recommendation. Provides optimistic locking.
649 pub etag: Option<String>,
650 /// 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}$/`.
651 #[serde(rename = "stateMetadata")]
652 pub state_metadata: Option<HashMap<String, String>>,
653}
654
655impl common::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest {}
656
657/// 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.
658///
659/// This type is not used in any activity, and only used as *part* of another schema.
660///
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct GoogleCloudRecommenderV1beta1Operation {
665 /// Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', 'copy', 'test' and 'custom' operations. This field is case-insensitive and always populated.
666 pub action: Option<String>,
667 /// 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.
668 pub path: Option<String>,
669 /// 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.
670 #[serde(rename = "pathFilters")]
671 pub path_filters: Option<HashMap<String, serde_json::Value>>,
672 /// 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.
673 #[serde(rename = "pathValueMatchers")]
674 pub path_value_matchers: Option<HashMap<String, GoogleCloudRecommenderV1beta1ValueMatcher>>,
675 /// Contains the fully qualified resource name. This field is always populated. ex: //cloudresourcemanager.googleapis.com/projects/foo.
676 pub resource: Option<String>,
677 /// Type of GCP resource being modified/tested. This field is always populated. Example: cloudresourcemanager.googleapis.com/Project, compute.googleapis.com/Instance
678 #[serde(rename = "resourceType")]
679 pub resource_type: Option<String>,
680 /// 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.
681 #[serde(rename = "sourcePath")]
682 pub source_path: Option<String>,
683 /// 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`.
684 #[serde(rename = "sourceResource")]
685 pub source_resource: Option<String>,
686 /// 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.
687 pub value: Option<serde_json::Value>,
688 /// 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.
689 #[serde(rename = "valueMatcher")]
690 pub value_matcher: Option<GoogleCloudRecommenderV1beta1ValueMatcher>,
691}
692
693impl common::Part for GoogleCloudRecommenderV1beta1Operation {}
694
695/// Group of operations that need to be performed atomically.
696///
697/// This type is not used in any activity, and only used as *part* of another schema.
698///
699#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
700#[serde_with::serde_as]
701#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
702pub struct GoogleCloudRecommenderV1beta1OperationGroup {
703 /// 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.
704 pub operations: Option<Vec<GoogleCloudRecommenderV1beta1Operation>>,
705}
706
707impl common::Part for GoogleCloudRecommenderV1beta1OperationGroup {}
708
709/// A recommendation along with a suggested action. E.g., a rightsizing recommendation for an underutilized VM, IAM role recommendations, etc
710///
711/// # Activities
712///
713/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
714/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
715///
716/// * [locations recommenders recommendations get billing accounts](BillingAccountLocationRecommenderRecommendationGetCall) (response)
717/// * [locations recommenders recommendations mark claimed billing accounts](BillingAccountLocationRecommenderRecommendationMarkClaimedCall) (response)
718/// * [locations recommenders recommendations mark dismissed billing accounts](BillingAccountLocationRecommenderRecommendationMarkDismissedCall) (response)
719/// * [locations recommenders recommendations mark failed billing accounts](BillingAccountLocationRecommenderRecommendationMarkFailedCall) (response)
720/// * [locations recommenders recommendations mark succeeded billing accounts](BillingAccountLocationRecommenderRecommendationMarkSucceededCall) (response)
721/// * [locations recommenders recommendations get folders](FolderLocationRecommenderRecommendationGetCall) (response)
722/// * [locations recommenders recommendations mark claimed folders](FolderLocationRecommenderRecommendationMarkClaimedCall) (response)
723/// * [locations recommenders recommendations mark dismissed folders](FolderLocationRecommenderRecommendationMarkDismissedCall) (response)
724/// * [locations recommenders recommendations mark failed folders](FolderLocationRecommenderRecommendationMarkFailedCall) (response)
725/// * [locations recommenders recommendations mark succeeded folders](FolderLocationRecommenderRecommendationMarkSucceededCall) (response)
726/// * [locations recommenders recommendations get organizations](OrganizationLocationRecommenderRecommendationGetCall) (response)
727/// * [locations recommenders recommendations mark claimed organizations](OrganizationLocationRecommenderRecommendationMarkClaimedCall) (response)
728/// * [locations recommenders recommendations mark dismissed organizations](OrganizationLocationRecommenderRecommendationMarkDismissedCall) (response)
729/// * [locations recommenders recommendations mark failed organizations](OrganizationLocationRecommenderRecommendationMarkFailedCall) (response)
730/// * [locations recommenders recommendations mark succeeded organizations](OrganizationLocationRecommenderRecommendationMarkSucceededCall) (response)
731/// * [locations recommenders recommendations get projects](ProjectLocationRecommenderRecommendationGetCall) (response)
732/// * [locations recommenders recommendations mark claimed projects](ProjectLocationRecommenderRecommendationMarkClaimedCall) (response)
733/// * [locations recommenders recommendations mark dismissed projects](ProjectLocationRecommenderRecommendationMarkDismissedCall) (response)
734/// * [locations recommenders recommendations mark failed projects](ProjectLocationRecommenderRecommendationMarkFailedCall) (response)
735/// * [locations recommenders recommendations mark succeeded projects](ProjectLocationRecommenderRecommendationMarkSucceededCall) (response)
736#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
737#[serde_with::serde_as]
738#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
739pub struct GoogleCloudRecommenderV1beta1Recommendation {
740 /// Optional set of additional impact that this recommendation may have when trying to optimize for the primary category. These may be positive or negative.
741 #[serde(rename = "additionalImpact")]
742 pub additional_impact: Option<Vec<GoogleCloudRecommenderV1beta1Impact>>,
743 /// Insights that led to this recommendation.
744 #[serde(rename = "associatedInsights")]
745 pub associated_insights:
746 Option<Vec<GoogleCloudRecommenderV1beta1RecommendationInsightReference>>,
747 /// Content of the recommendation describing recommended changes to resources.
748 pub content: Option<GoogleCloudRecommenderV1beta1RecommendationContent>,
749 /// Free-form human readable summary in English. The maximum length is 500 characters.
750 pub description: Option<String>,
751 /// Fingerprint of the Recommendation. Provides optimistic locking when updating states.
752 pub etag: Option<String>,
753 /// Last time this recommendation was refreshed by the system that created it in the first place.
754 #[serde(rename = "lastRefreshTime")]
755 pub last_refresh_time: Option<chrono::DateTime<chrono::offset::Utc>>,
756 /// Identifier. Name of recommendation.
757 pub name: Option<String>,
758 /// The primary impact that this recommendation can have while trying to optimize for one category.
759 #[serde(rename = "primaryImpact")]
760 pub primary_impact: Option<GoogleCloudRecommenderV1beta1Impact>,
761 /// Recommendation's priority.
762 pub priority: Option<String>,
763 /// 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"
764 #[serde(rename = "recommenderSubtype")]
765 pub recommender_subtype: Option<String>,
766 /// Information for state. Contains state and metadata.
767 #[serde(rename = "stateInfo")]
768 pub state_info: Option<GoogleCloudRecommenderV1beta1RecommendationStateInfo>,
769 /// Fully qualified resource names that this recommendation is targeting.
770 #[serde(rename = "targetResources")]
771 pub target_resources: Option<Vec<String>>,
772 /// 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.
773 #[serde(rename = "xorGroupId")]
774 pub xor_group_id: Option<String>,
775}
776
777impl common::ResponseResult for GoogleCloudRecommenderV1beta1Recommendation {}
778
779/// Contains what resources are changing and how they are changing.
780///
781/// This type is not used in any activity, and only used as *part* of another schema.
782///
783#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
784#[serde_with::serde_as]
785#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
786pub struct GoogleCloudRecommenderV1beta1RecommendationContent {
787 /// 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.
788 #[serde(rename = "operationGroups")]
789 pub operation_groups: Option<Vec<GoogleCloudRecommenderV1beta1OperationGroup>>,
790 /// Condensed overview information about the recommendation.
791 pub overview: Option<HashMap<String, serde_json::Value>>,
792}
793
794impl common::Part for GoogleCloudRecommenderV1beta1RecommendationContent {}
795
796/// Reference to an associated insight.
797///
798/// This type is not used in any activity, and only used as *part* of another schema.
799///
800#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
801#[serde_with::serde_as]
802#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
803pub struct GoogleCloudRecommenderV1beta1RecommendationInsightReference {
804 /// Insight resource name, e.g. projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID]
805 pub insight: Option<String>,
806}
807
808impl common::Part for GoogleCloudRecommenderV1beta1RecommendationInsightReference {}
809
810/// Information for state. Contains state and metadata.
811///
812/// This type is not used in any activity, and only used as *part* of another schema.
813///
814#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
815#[serde_with::serde_as]
816#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
817pub struct GoogleCloudRecommenderV1beta1RecommendationStateInfo {
818 /// The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED.
819 pub state: Option<String>,
820 /// A map of metadata for the state, provided by user or automations systems.
821 #[serde(rename = "stateMetadata")]
822 pub state_metadata: Option<HashMap<String, String>>,
823}
824
825impl common::Part for GoogleCloudRecommenderV1beta1RecommendationStateInfo {}
826
827/// Configuration for a Recommender.
828///
829/// # Activities
830///
831/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
832/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
833///
834/// * [locations recommenders get config billing accounts](BillingAccountLocationRecommenderGetConfigCall) (response)
835/// * [locations recommenders update config billing accounts](BillingAccountLocationRecommenderUpdateConfigCall) (request|response)
836/// * [locations recommenders get config organizations](OrganizationLocationRecommenderGetConfigCall) (response)
837/// * [locations recommenders update config organizations](OrganizationLocationRecommenderUpdateConfigCall) (request|response)
838/// * [locations recommenders get config projects](ProjectLocationRecommenderGetConfigCall) (response)
839/// * [locations recommenders update config projects](ProjectLocationRecommenderUpdateConfigCall) (request|response)
840#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
841#[serde_with::serde_as]
842#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
843pub struct GoogleCloudRecommenderV1beta1RecommenderConfig {
844 /// 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.
845 pub annotations: Option<HashMap<String, String>>,
846 /// A user-settable field to provide a human-readable name to be used in user interfaces.
847 #[serde(rename = "displayName")]
848 pub display_name: Option<String>,
849 /// Fingerprint of the RecommenderConfig. Provides optimistic locking when updating.
850 pub etag: Option<String>,
851 /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
852 pub name: Option<String>,
853 /// RecommenderGenerationConfig which configures the Generation of recommendations for this recommender.
854 #[serde(rename = "recommenderGenerationConfig")]
855 pub recommender_generation_config:
856 Option<GoogleCloudRecommenderV1beta1RecommenderGenerationConfig>,
857 /// 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.
858 #[serde(rename = "revisionId")]
859 pub revision_id: Option<String>,
860 /// Last time when the config was updated.
861 #[serde(rename = "updateTime")]
862 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
863}
864
865impl common::RequestValue for GoogleCloudRecommenderV1beta1RecommenderConfig {}
866impl common::ResponseResult for GoogleCloudRecommenderV1beta1RecommenderConfig {}
867
868/// A Configuration to customize the generation of recommendations. Eg, customizing the lookback period considered when generating a recommendation.
869///
870/// This type is not used in any activity, and only used as *part* of another schema.
871///
872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
873#[serde_with::serde_as]
874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
875pub struct GoogleCloudRecommenderV1beta1RecommenderGenerationConfig {
876 /// Parameters for this RecommenderGenerationConfig. These configs can be used by or are applied to all subtypes.
877 pub params: Option<HashMap<String, serde_json::Value>>,
878}
879
880impl common::Part for GoogleCloudRecommenderV1beta1RecommenderGenerationConfig {}
881
882/// The type of a recommender.
883///
884/// This type is not used in any activity, and only used as *part* of another schema.
885///
886#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
887#[serde_with::serde_as]
888#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
889pub struct GoogleCloudRecommenderV1beta1RecommenderType {
890 /// The recommender's name in format RecommenderTypes/{recommender_type} eg: recommenderTypes/google.iam.policy.Recommender
891 pub name: Option<String>,
892}
893
894impl common::Part for GoogleCloudRecommenderV1beta1RecommenderType {}
895
896/// Contains information on the impact of a reliability recommendation.
897///
898/// This type is not used in any activity, and only used as *part* of another schema.
899///
900#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
901#[serde_with::serde_as]
902#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
903pub struct GoogleCloudRecommenderV1beta1ReliabilityProjection {
904 /// Per-recommender projection.
905 pub details: Option<HashMap<String, serde_json::Value>>,
906 /// Reliability risks mitigated by this recommendation.
907 pub risks: Option<Vec<String>>,
908}
909
910impl common::Part for GoogleCloudRecommenderV1beta1ReliabilityProjection {}
911
912/// Contains various ways of describing the impact on Security.
913///
914/// This type is not used in any activity, and only used as *part* of another schema.
915///
916#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
917#[serde_with::serde_as]
918#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
919pub struct GoogleCloudRecommenderV1beta1SecurityProjection {
920 /// This field can be used by the recommender to define details specific to security impact.
921 pub details: Option<HashMap<String, serde_json::Value>>,
922}
923
924impl common::Part for GoogleCloudRecommenderV1beta1SecurityProjection {}
925
926/// Contains metadata about how much sustainability a recommendation can save or incur.
927///
928/// This type is not used in any activity, and only used as *part* of another schema.
929///
930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
931#[serde_with::serde_as]
932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
933pub struct GoogleCloudRecommenderV1beta1SustainabilityProjection {
934 /// Duration for which this sustanability applies.
935 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
936 pub duration: Option<chrono::Duration>,
937 /// Carbon Footprint generated in kg of CO2 equivalent. Chose kg_c_o2e so that the name renders correctly in camelCase (kgCO2e).
938 #[serde(rename = "kgCO2e")]
939 pub kg_co2e: Option<f64>,
940}
941
942impl common::Part for GoogleCloudRecommenderV1beta1SustainabilityProjection {}
943
944/// Contains various matching options for values for a GCP resource field.
945///
946/// This type is not used in any activity, and only used as *part* of another schema.
947///
948#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
949#[serde_with::serde_as]
950#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
951pub struct GoogleCloudRecommenderV1beta1ValueMatcher {
952 /// 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
953 #[serde(rename = "matchesPattern")]
954 pub matches_pattern: Option<String>,
955}
956
957impl common::Part for GoogleCloudRecommenderV1beta1ValueMatcher {}
958
959/// Represents an amount of money with its currency type.
960///
961/// This type is not used in any activity, and only used as *part* of another schema.
962///
963#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
964#[serde_with::serde_as]
965#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
966pub struct GoogleTypeMoney {
967 /// The three-letter currency code defined in ISO 4217.
968 #[serde(rename = "currencyCode")]
969 pub currency_code: Option<String>,
970 /// 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.
971 pub nanos: Option<i32>,
972 /// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
973 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
974 pub units: Option<i64>,
975}
976
977impl common::Part for GoogleTypeMoney {}
978
979// ###################
980// MethodBuilders ###
981// #################
982
983/// A builder providing access to all methods supported on *billingAccount* resources.
984/// It is not used directly, but through the [`Recommender`] hub.
985///
986/// # Example
987///
988/// Instantiate a resource builder
989///
990/// ```test_harness,no_run
991/// extern crate hyper;
992/// extern crate hyper_rustls;
993/// extern crate google_recommender1_beta1 as recommender1_beta1;
994///
995/// # async fn dox() {
996/// use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
997///
998/// let secret: yup_oauth2::ApplicationSecret = Default::default();
999/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1000/// .with_native_roots()
1001/// .unwrap()
1002/// .https_only()
1003/// .enable_http2()
1004/// .build();
1005///
1006/// let executor = hyper_util::rt::TokioExecutor::new();
1007/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1008/// secret,
1009/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1010/// yup_oauth2::client::CustomHyperClientBuilder::from(
1011/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1012/// ),
1013/// ).build().await.unwrap();
1014///
1015/// let client = hyper_util::client::legacy::Client::builder(
1016/// hyper_util::rt::TokioExecutor::new()
1017/// )
1018/// .build(
1019/// hyper_rustls::HttpsConnectorBuilder::new()
1020/// .with_native_roots()
1021/// .unwrap()
1022/// .https_or_http()
1023/// .enable_http2()
1024/// .build()
1025/// );
1026/// let mut hub = Recommender::new(client, auth);
1027/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1028/// // 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_list(...)`, `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(...)`
1029/// // to build up your call.
1030/// let rb = hub.billing_accounts();
1031/// # }
1032/// ```
1033pub struct BillingAccountMethods<'a, C>
1034where
1035 C: 'a,
1036{
1037 hub: &'a Recommender<C>,
1038}
1039
1040impl<'a, C> common::MethodsBuilder for BillingAccountMethods<'a, C> {}
1041
1042impl<'a, C> BillingAccountMethods<'a, C> {
1043 /// Create a builder to help you perform the following task:
1044 ///
1045 /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
1046 ///
1047 /// # Arguments
1048 ///
1049 /// * `name` - Required. Name of the insight.
1050 pub fn locations_insight_types_insights_get(
1051 &self,
1052 name: &str,
1053 ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
1054 BillingAccountLocationInsightTypeInsightGetCall {
1055 hub: self.hub,
1056 _name: name.to_string(),
1057 _delegate: Default::default(),
1058 _additional_params: Default::default(),
1059 _scopes: Default::default(),
1060 }
1061 }
1062
1063 /// Create a builder to help you perform the following task:
1064 ///
1065 /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
1066 ///
1067 /// # Arguments
1068 ///
1069 /// * `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.
1070 pub fn locations_insight_types_insights_list(
1071 &self,
1072 parent: &str,
1073 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
1074 BillingAccountLocationInsightTypeInsightListCall {
1075 hub: self.hub,
1076 _parent: parent.to_string(),
1077 _page_token: Default::default(),
1078 _page_size: Default::default(),
1079 _filter: Default::default(),
1080 _delegate: Default::default(),
1081 _additional_params: Default::default(),
1082 _scopes: Default::default(),
1083 }
1084 }
1085
1086 /// Create a builder to help you perform the following task:
1087 ///
1088 /// 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.
1089 ///
1090 /// # Arguments
1091 ///
1092 /// * `request` - No description provided.
1093 /// * `name` - Required. Name of the insight.
1094 pub fn locations_insight_types_insights_mark_accepted(
1095 &self,
1096 request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
1097 name: &str,
1098 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
1099 BillingAccountLocationInsightTypeInsightMarkAcceptedCall {
1100 hub: self.hub,
1101 _request: request,
1102 _name: name.to_string(),
1103 _delegate: Default::default(),
1104 _additional_params: Default::default(),
1105 _scopes: Default::default(),
1106 }
1107 }
1108
1109 /// Create a builder to help you perform the following task:
1110 ///
1111 /// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
1112 ///
1113 /// # Arguments
1114 ///
1115 /// * `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`
1116 pub fn locations_insight_types_get_config(
1117 &self,
1118 name: &str,
1119 ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
1120 BillingAccountLocationInsightTypeGetConfigCall {
1121 hub: self.hub,
1122 _name: name.to_string(),
1123 _delegate: Default::default(),
1124 _additional_params: Default::default(),
1125 _scopes: Default::default(),
1126 }
1127 }
1128
1129 /// Create a builder to help you perform the following task:
1130 ///
1131 /// Updates an InsightTypeConfig change. This will create a new revision of the config.
1132 ///
1133 /// # Arguments
1134 ///
1135 /// * `request` - No description provided.
1136 /// * `name` - Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
1137 pub fn locations_insight_types_update_config(
1138 &self,
1139 request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
1140 name: &str,
1141 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
1142 BillingAccountLocationInsightTypeUpdateConfigCall {
1143 hub: self.hub,
1144 _request: request,
1145 _name: name.to_string(),
1146 _validate_only: Default::default(),
1147 _update_mask: Default::default(),
1148 _delegate: Default::default(),
1149 _additional_params: Default::default(),
1150 _scopes: Default::default(),
1151 }
1152 }
1153
1154 /// Create a builder to help you perform the following task:
1155 ///
1156 /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
1157 ///
1158 /// # Arguments
1159 ///
1160 /// * `name` - Required. Name of the recommendation.
1161 pub fn locations_recommenders_recommendations_get(
1162 &self,
1163 name: &str,
1164 ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
1165 BillingAccountLocationRecommenderRecommendationGetCall {
1166 hub: self.hub,
1167 _name: name.to_string(),
1168 _delegate: Default::default(),
1169 _additional_params: Default::default(),
1170 _scopes: Default::default(),
1171 }
1172 }
1173
1174 /// Create a builder to help you perform the following task:
1175 ///
1176 /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
1177 ///
1178 /// # Arguments
1179 ///
1180 /// * `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.
1181 pub fn locations_recommenders_recommendations_list(
1182 &self,
1183 parent: &str,
1184 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
1185 BillingAccountLocationRecommenderRecommendationListCall {
1186 hub: self.hub,
1187 _parent: parent.to_string(),
1188 _page_token: Default::default(),
1189 _page_size: Default::default(),
1190 _filter: Default::default(),
1191 _delegate: Default::default(),
1192 _additional_params: Default::default(),
1193 _scopes: Default::default(),
1194 }
1195 }
1196
1197 /// Create a builder to help you perform the following task:
1198 ///
1199 /// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1200 ///
1201 /// # Arguments
1202 ///
1203 /// * `request` - No description provided.
1204 /// * `name` - Required. Name of the recommendation.
1205 pub fn locations_recommenders_recommendations_mark_claimed(
1206 &self,
1207 request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
1208 name: &str,
1209 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
1210 BillingAccountLocationRecommenderRecommendationMarkClaimedCall {
1211 hub: self.hub,
1212 _request: request,
1213 _name: name.to_string(),
1214 _delegate: Default::default(),
1215 _additional_params: Default::default(),
1216 _scopes: Default::default(),
1217 }
1218 }
1219
1220 /// Create a builder to help you perform the following task:
1221 ///
1222 /// 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.
1223 ///
1224 /// # Arguments
1225 ///
1226 /// * `request` - No description provided.
1227 /// * `name` - Required. Name of the recommendation.
1228 pub fn locations_recommenders_recommendations_mark_dismissed(
1229 &self,
1230 request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
1231 name: &str,
1232 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
1233 BillingAccountLocationRecommenderRecommendationMarkDismissedCall {
1234 hub: self.hub,
1235 _request: request,
1236 _name: name.to_string(),
1237 _delegate: Default::default(),
1238 _additional_params: Default::default(),
1239 _scopes: Default::default(),
1240 }
1241 }
1242
1243 /// Create a builder to help you perform the following task:
1244 ///
1245 /// 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.
1246 ///
1247 /// # Arguments
1248 ///
1249 /// * `request` - No description provided.
1250 /// * `name` - Required. Name of the recommendation.
1251 pub fn locations_recommenders_recommendations_mark_failed(
1252 &self,
1253 request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
1254 name: &str,
1255 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
1256 BillingAccountLocationRecommenderRecommendationMarkFailedCall {
1257 hub: self.hub,
1258 _request: request,
1259 _name: name.to_string(),
1260 _delegate: Default::default(),
1261 _additional_params: Default::default(),
1262 _scopes: Default::default(),
1263 }
1264 }
1265
1266 /// Create a builder to help you perform the following task:
1267 ///
1268 /// 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.
1269 ///
1270 /// # Arguments
1271 ///
1272 /// * `request` - No description provided.
1273 /// * `name` - Required. Name of the recommendation.
1274 pub fn locations_recommenders_recommendations_mark_succeeded(
1275 &self,
1276 request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
1277 name: &str,
1278 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
1279 BillingAccountLocationRecommenderRecommendationMarkSucceededCall {
1280 hub: self.hub,
1281 _request: request,
1282 _name: name.to_string(),
1283 _delegate: Default::default(),
1284 _additional_params: Default::default(),
1285 _scopes: Default::default(),
1286 }
1287 }
1288
1289 /// Create a builder to help you perform the following task:
1290 ///
1291 /// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
1292 ///
1293 /// # Arguments
1294 ///
1295 /// * `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`
1296 pub fn locations_recommenders_get_config(
1297 &self,
1298 name: &str,
1299 ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
1300 BillingAccountLocationRecommenderGetConfigCall {
1301 hub: self.hub,
1302 _name: name.to_string(),
1303 _delegate: Default::default(),
1304 _additional_params: Default::default(),
1305 _scopes: Default::default(),
1306 }
1307 }
1308
1309 /// Create a builder to help you perform the following task:
1310 ///
1311 /// Updates a Recommender Config. This will create a new revision of the config.
1312 ///
1313 /// # Arguments
1314 ///
1315 /// * `request` - No description provided.
1316 /// * `name` - Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
1317 pub fn locations_recommenders_update_config(
1318 &self,
1319 request: GoogleCloudRecommenderV1beta1RecommenderConfig,
1320 name: &str,
1321 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
1322 BillingAccountLocationRecommenderUpdateConfigCall {
1323 hub: self.hub,
1324 _request: request,
1325 _name: name.to_string(),
1326 _validate_only: Default::default(),
1327 _update_mask: Default::default(),
1328 _delegate: Default::default(),
1329 _additional_params: Default::default(),
1330 _scopes: Default::default(),
1331 }
1332 }
1333
1334 /// Create a builder to help you perform the following task:
1335 ///
1336 /// Lists locations with recommendations or insights.
1337 ///
1338 /// # Arguments
1339 ///
1340 /// * `name` - The resource that owns the locations collection, if applicable.
1341 pub fn locations_list(&self, name: &str) -> BillingAccountLocationListCall<'a, C> {
1342 BillingAccountLocationListCall {
1343 hub: self.hub,
1344 _name: name.to_string(),
1345 _page_token: Default::default(),
1346 _page_size: Default::default(),
1347 _filter: Default::default(),
1348 _extra_location_types: Default::default(),
1349 _delegate: Default::default(),
1350 _additional_params: Default::default(),
1351 _scopes: Default::default(),
1352 }
1353 }
1354}
1355
1356/// A builder providing access to all methods supported on *folder* resources.
1357/// It is not used directly, but through the [`Recommender`] hub.
1358///
1359/// # Example
1360///
1361/// Instantiate a resource builder
1362///
1363/// ```test_harness,no_run
1364/// extern crate hyper;
1365/// extern crate hyper_rustls;
1366/// extern crate google_recommender1_beta1 as recommender1_beta1;
1367///
1368/// # async fn dox() {
1369/// use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1370///
1371/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1372/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1373/// .with_native_roots()
1374/// .unwrap()
1375/// .https_only()
1376/// .enable_http2()
1377/// .build();
1378///
1379/// let executor = hyper_util::rt::TokioExecutor::new();
1380/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1381/// secret,
1382/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1383/// yup_oauth2::client::CustomHyperClientBuilder::from(
1384/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1385/// ),
1386/// ).build().await.unwrap();
1387///
1388/// let client = hyper_util::client::legacy::Client::builder(
1389/// hyper_util::rt::TokioExecutor::new()
1390/// )
1391/// .build(
1392/// hyper_rustls::HttpsConnectorBuilder::new()
1393/// .with_native_roots()
1394/// .unwrap()
1395/// .https_or_http()
1396/// .enable_http2()
1397/// .build()
1398/// );
1399/// let mut hub = Recommender::new(client, auth);
1400/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1401/// // like `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_list(...)`, `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(...)`
1402/// // to build up your call.
1403/// let rb = hub.folders();
1404/// # }
1405/// ```
1406pub struct FolderMethods<'a, C>
1407where
1408 C: 'a,
1409{
1410 hub: &'a Recommender<C>,
1411}
1412
1413impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
1414
1415impl<'a, C> FolderMethods<'a, C> {
1416 /// Create a builder to help you perform the following task:
1417 ///
1418 /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
1419 ///
1420 /// # Arguments
1421 ///
1422 /// * `name` - Required. Name of the insight.
1423 pub fn locations_insight_types_insights_get(
1424 &self,
1425 name: &str,
1426 ) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
1427 FolderLocationInsightTypeInsightGetCall {
1428 hub: self.hub,
1429 _name: name.to_string(),
1430 _delegate: Default::default(),
1431 _additional_params: Default::default(),
1432 _scopes: Default::default(),
1433 }
1434 }
1435
1436 /// Create a builder to help you perform the following task:
1437 ///
1438 /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
1439 ///
1440 /// # Arguments
1441 ///
1442 /// * `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.
1443 pub fn locations_insight_types_insights_list(
1444 &self,
1445 parent: &str,
1446 ) -> FolderLocationInsightTypeInsightListCall<'a, C> {
1447 FolderLocationInsightTypeInsightListCall {
1448 hub: self.hub,
1449 _parent: parent.to_string(),
1450 _page_token: Default::default(),
1451 _page_size: Default::default(),
1452 _filter: Default::default(),
1453 _delegate: Default::default(),
1454 _additional_params: Default::default(),
1455 _scopes: Default::default(),
1456 }
1457 }
1458
1459 /// Create a builder to help you perform the following task:
1460 ///
1461 /// 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.
1462 ///
1463 /// # Arguments
1464 ///
1465 /// * `request` - No description provided.
1466 /// * `name` - Required. Name of the insight.
1467 pub fn locations_insight_types_insights_mark_accepted(
1468 &self,
1469 request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
1470 name: &str,
1471 ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
1472 FolderLocationInsightTypeInsightMarkAcceptedCall {
1473 hub: self.hub,
1474 _request: request,
1475 _name: name.to_string(),
1476 _delegate: Default::default(),
1477 _additional_params: Default::default(),
1478 _scopes: Default::default(),
1479 }
1480 }
1481
1482 /// Create a builder to help you perform the following task:
1483 ///
1484 /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
1485 ///
1486 /// # Arguments
1487 ///
1488 /// * `name` - Required. Name of the recommendation.
1489 pub fn locations_recommenders_recommendations_get(
1490 &self,
1491 name: &str,
1492 ) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
1493 FolderLocationRecommenderRecommendationGetCall {
1494 hub: self.hub,
1495 _name: name.to_string(),
1496 _delegate: Default::default(),
1497 _additional_params: Default::default(),
1498 _scopes: Default::default(),
1499 }
1500 }
1501
1502 /// Create a builder to help you perform the following task:
1503 ///
1504 /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
1505 ///
1506 /// # Arguments
1507 ///
1508 /// * `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.
1509 pub fn locations_recommenders_recommendations_list(
1510 &self,
1511 parent: &str,
1512 ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
1513 FolderLocationRecommenderRecommendationListCall {
1514 hub: self.hub,
1515 _parent: parent.to_string(),
1516 _page_token: Default::default(),
1517 _page_size: Default::default(),
1518 _filter: Default::default(),
1519 _delegate: Default::default(),
1520 _additional_params: Default::default(),
1521 _scopes: Default::default(),
1522 }
1523 }
1524
1525 /// Create a builder to help you perform the following task:
1526 ///
1527 /// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1528 ///
1529 /// # Arguments
1530 ///
1531 /// * `request` - No description provided.
1532 /// * `name` - Required. Name of the recommendation.
1533 pub fn locations_recommenders_recommendations_mark_claimed(
1534 &self,
1535 request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
1536 name: &str,
1537 ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
1538 FolderLocationRecommenderRecommendationMarkClaimedCall {
1539 hub: self.hub,
1540 _request: request,
1541 _name: name.to_string(),
1542 _delegate: Default::default(),
1543 _additional_params: Default::default(),
1544 _scopes: Default::default(),
1545 }
1546 }
1547
1548 /// Create a builder to help you perform the following task:
1549 ///
1550 /// 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.
1551 ///
1552 /// # Arguments
1553 ///
1554 /// * `request` - No description provided.
1555 /// * `name` - Required. Name of the recommendation.
1556 pub fn locations_recommenders_recommendations_mark_dismissed(
1557 &self,
1558 request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
1559 name: &str,
1560 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
1561 FolderLocationRecommenderRecommendationMarkDismissedCall {
1562 hub: self.hub,
1563 _request: request,
1564 _name: name.to_string(),
1565 _delegate: Default::default(),
1566 _additional_params: Default::default(),
1567 _scopes: Default::default(),
1568 }
1569 }
1570
1571 /// Create a builder to help you perform the following task:
1572 ///
1573 /// 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.
1574 ///
1575 /// # Arguments
1576 ///
1577 /// * `request` - No description provided.
1578 /// * `name` - Required. Name of the recommendation.
1579 pub fn locations_recommenders_recommendations_mark_failed(
1580 &self,
1581 request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
1582 name: &str,
1583 ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
1584 FolderLocationRecommenderRecommendationMarkFailedCall {
1585 hub: self.hub,
1586 _request: request,
1587 _name: name.to_string(),
1588 _delegate: Default::default(),
1589 _additional_params: Default::default(),
1590 _scopes: Default::default(),
1591 }
1592 }
1593
1594 /// Create a builder to help you perform the following task:
1595 ///
1596 /// 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.
1597 ///
1598 /// # Arguments
1599 ///
1600 /// * `request` - No description provided.
1601 /// * `name` - Required. Name of the recommendation.
1602 pub fn locations_recommenders_recommendations_mark_succeeded(
1603 &self,
1604 request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
1605 name: &str,
1606 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
1607 FolderLocationRecommenderRecommendationMarkSucceededCall {
1608 hub: self.hub,
1609 _request: request,
1610 _name: name.to_string(),
1611 _delegate: Default::default(),
1612 _additional_params: Default::default(),
1613 _scopes: Default::default(),
1614 }
1615 }
1616
1617 /// Create a builder to help you perform the following task:
1618 ///
1619 /// Lists locations with recommendations or insights.
1620 ///
1621 /// # Arguments
1622 ///
1623 /// * `name` - The resource that owns the locations collection, if applicable.
1624 pub fn locations_list(&self, name: &str) -> FolderLocationListCall<'a, C> {
1625 FolderLocationListCall {
1626 hub: self.hub,
1627 _name: name.to_string(),
1628 _page_token: Default::default(),
1629 _page_size: Default::default(),
1630 _filter: Default::default(),
1631 _extra_location_types: Default::default(),
1632 _delegate: Default::default(),
1633 _additional_params: Default::default(),
1634 _scopes: Default::default(),
1635 }
1636 }
1637}
1638
1639/// A builder providing access to all methods supported on *insightType* resources.
1640/// It is not used directly, but through the [`Recommender`] hub.
1641///
1642/// # Example
1643///
1644/// Instantiate a resource builder
1645///
1646/// ```test_harness,no_run
1647/// extern crate hyper;
1648/// extern crate hyper_rustls;
1649/// extern crate google_recommender1_beta1 as recommender1_beta1;
1650///
1651/// # async fn dox() {
1652/// use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1653///
1654/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1655/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1656/// .with_native_roots()
1657/// .unwrap()
1658/// .https_only()
1659/// .enable_http2()
1660/// .build();
1661///
1662/// let executor = hyper_util::rt::TokioExecutor::new();
1663/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1664/// secret,
1665/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1666/// yup_oauth2::client::CustomHyperClientBuilder::from(
1667/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1668/// ),
1669/// ).build().await.unwrap();
1670///
1671/// let client = hyper_util::client::legacy::Client::builder(
1672/// hyper_util::rt::TokioExecutor::new()
1673/// )
1674/// .build(
1675/// hyper_rustls::HttpsConnectorBuilder::new()
1676/// .with_native_roots()
1677/// .unwrap()
1678/// .https_or_http()
1679/// .enable_http2()
1680/// .build()
1681/// );
1682/// let mut hub = Recommender::new(client, auth);
1683/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1684/// // like `list(...)`
1685/// // to build up your call.
1686/// let rb = hub.insight_types();
1687/// # }
1688/// ```
1689pub struct InsightTypeMethods<'a, C>
1690where
1691 C: 'a,
1692{
1693 hub: &'a Recommender<C>,
1694}
1695
1696impl<'a, C> common::MethodsBuilder for InsightTypeMethods<'a, C> {}
1697
1698impl<'a, C> InsightTypeMethods<'a, C> {
1699 /// Create a builder to help you perform the following task:
1700 ///
1701 /// Lists available InsightTypes. No IAM permissions are required.
1702 pub fn list(&self) -> InsightTypeListCall<'a, C> {
1703 InsightTypeListCall {
1704 hub: self.hub,
1705 _page_token: Default::default(),
1706 _page_size: Default::default(),
1707 _delegate: Default::default(),
1708 _additional_params: Default::default(),
1709 _scopes: Default::default(),
1710 }
1711 }
1712}
1713
1714/// A builder providing access to all methods supported on *organization* resources.
1715/// It is not used directly, but through the [`Recommender`] hub.
1716///
1717/// # Example
1718///
1719/// Instantiate a resource builder
1720///
1721/// ```test_harness,no_run
1722/// extern crate hyper;
1723/// extern crate hyper_rustls;
1724/// extern crate google_recommender1_beta1 as recommender1_beta1;
1725///
1726/// # async fn dox() {
1727/// use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1728///
1729/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1730/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1731/// .with_native_roots()
1732/// .unwrap()
1733/// .https_only()
1734/// .enable_http2()
1735/// .build();
1736///
1737/// let executor = hyper_util::rt::TokioExecutor::new();
1738/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1739/// secret,
1740/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1741/// yup_oauth2::client::CustomHyperClientBuilder::from(
1742/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1743/// ),
1744/// ).build().await.unwrap();
1745///
1746/// let client = hyper_util::client::legacy::Client::builder(
1747/// hyper_util::rt::TokioExecutor::new()
1748/// )
1749/// .build(
1750/// hyper_rustls::HttpsConnectorBuilder::new()
1751/// .with_native_roots()
1752/// .unwrap()
1753/// .https_or_http()
1754/// .enable_http2()
1755/// .build()
1756/// );
1757/// let mut hub = Recommender::new(client, auth);
1758/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1759/// // 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_list(...)`, `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(...)`
1760/// // to build up your call.
1761/// let rb = hub.organizations();
1762/// # }
1763/// ```
1764pub struct OrganizationMethods<'a, C>
1765where
1766 C: 'a,
1767{
1768 hub: &'a Recommender<C>,
1769}
1770
1771impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
1772
1773impl<'a, C> OrganizationMethods<'a, C> {
1774 /// Create a builder to help you perform the following task:
1775 ///
1776 /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
1777 ///
1778 /// # Arguments
1779 ///
1780 /// * `name` - Required. Name of the insight.
1781 pub fn locations_insight_types_insights_get(
1782 &self,
1783 name: &str,
1784 ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
1785 OrganizationLocationInsightTypeInsightGetCall {
1786 hub: self.hub,
1787 _name: name.to_string(),
1788 _delegate: Default::default(),
1789 _additional_params: Default::default(),
1790 _scopes: Default::default(),
1791 }
1792 }
1793
1794 /// Create a builder to help you perform the following task:
1795 ///
1796 /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
1797 ///
1798 /// # Arguments
1799 ///
1800 /// * `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.
1801 pub fn locations_insight_types_insights_list(
1802 &self,
1803 parent: &str,
1804 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
1805 OrganizationLocationInsightTypeInsightListCall {
1806 hub: self.hub,
1807 _parent: parent.to_string(),
1808 _page_token: Default::default(),
1809 _page_size: Default::default(),
1810 _filter: Default::default(),
1811 _delegate: Default::default(),
1812 _additional_params: Default::default(),
1813 _scopes: Default::default(),
1814 }
1815 }
1816
1817 /// Create a builder to help you perform the following task:
1818 ///
1819 /// 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.
1820 ///
1821 /// # Arguments
1822 ///
1823 /// * `request` - No description provided.
1824 /// * `name` - Required. Name of the insight.
1825 pub fn locations_insight_types_insights_mark_accepted(
1826 &self,
1827 request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
1828 name: &str,
1829 ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
1830 OrganizationLocationInsightTypeInsightMarkAcceptedCall {
1831 hub: self.hub,
1832 _request: request,
1833 _name: name.to_string(),
1834 _delegate: Default::default(),
1835 _additional_params: Default::default(),
1836 _scopes: Default::default(),
1837 }
1838 }
1839
1840 /// Create a builder to help you perform the following task:
1841 ///
1842 /// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
1843 ///
1844 /// # Arguments
1845 ///
1846 /// * `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`
1847 pub fn locations_insight_types_get_config(
1848 &self,
1849 name: &str,
1850 ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
1851 OrganizationLocationInsightTypeGetConfigCall {
1852 hub: self.hub,
1853 _name: name.to_string(),
1854 _delegate: Default::default(),
1855 _additional_params: Default::default(),
1856 _scopes: Default::default(),
1857 }
1858 }
1859
1860 /// Create a builder to help you perform the following task:
1861 ///
1862 /// Updates an InsightTypeConfig change. This will create a new revision of the config.
1863 ///
1864 /// # Arguments
1865 ///
1866 /// * `request` - No description provided.
1867 /// * `name` - Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
1868 pub fn locations_insight_types_update_config(
1869 &self,
1870 request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
1871 name: &str,
1872 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
1873 OrganizationLocationInsightTypeUpdateConfigCall {
1874 hub: self.hub,
1875 _request: request,
1876 _name: name.to_string(),
1877 _validate_only: Default::default(),
1878 _update_mask: Default::default(),
1879 _delegate: Default::default(),
1880 _additional_params: Default::default(),
1881 _scopes: Default::default(),
1882 }
1883 }
1884
1885 /// Create a builder to help you perform the following task:
1886 ///
1887 /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
1888 ///
1889 /// # Arguments
1890 ///
1891 /// * `name` - Required. Name of the recommendation.
1892 pub fn locations_recommenders_recommendations_get(
1893 &self,
1894 name: &str,
1895 ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
1896 OrganizationLocationRecommenderRecommendationGetCall {
1897 hub: self.hub,
1898 _name: name.to_string(),
1899 _delegate: Default::default(),
1900 _additional_params: Default::default(),
1901 _scopes: Default::default(),
1902 }
1903 }
1904
1905 /// Create a builder to help you perform the following task:
1906 ///
1907 /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
1908 ///
1909 /// # Arguments
1910 ///
1911 /// * `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.
1912 pub fn locations_recommenders_recommendations_list(
1913 &self,
1914 parent: &str,
1915 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
1916 OrganizationLocationRecommenderRecommendationListCall {
1917 hub: self.hub,
1918 _parent: parent.to_string(),
1919 _page_token: Default::default(),
1920 _page_size: Default::default(),
1921 _filter: Default::default(),
1922 _delegate: Default::default(),
1923 _additional_params: Default::default(),
1924 _scopes: Default::default(),
1925 }
1926 }
1927
1928 /// Create a builder to help you perform the following task:
1929 ///
1930 /// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
1931 ///
1932 /// # Arguments
1933 ///
1934 /// * `request` - No description provided.
1935 /// * `name` - Required. Name of the recommendation.
1936 pub fn locations_recommenders_recommendations_mark_claimed(
1937 &self,
1938 request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
1939 name: &str,
1940 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
1941 OrganizationLocationRecommenderRecommendationMarkClaimedCall {
1942 hub: self.hub,
1943 _request: request,
1944 _name: name.to_string(),
1945 _delegate: Default::default(),
1946 _additional_params: Default::default(),
1947 _scopes: Default::default(),
1948 }
1949 }
1950
1951 /// Create a builder to help you perform the following task:
1952 ///
1953 /// 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.
1954 ///
1955 /// # Arguments
1956 ///
1957 /// * `request` - No description provided.
1958 /// * `name` - Required. Name of the recommendation.
1959 pub fn locations_recommenders_recommendations_mark_dismissed(
1960 &self,
1961 request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
1962 name: &str,
1963 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
1964 OrganizationLocationRecommenderRecommendationMarkDismissedCall {
1965 hub: self.hub,
1966 _request: request,
1967 _name: name.to_string(),
1968 _delegate: Default::default(),
1969 _additional_params: Default::default(),
1970 _scopes: Default::default(),
1971 }
1972 }
1973
1974 /// Create a builder to help you perform the following task:
1975 ///
1976 /// 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.
1977 ///
1978 /// # Arguments
1979 ///
1980 /// * `request` - No description provided.
1981 /// * `name` - Required. Name of the recommendation.
1982 pub fn locations_recommenders_recommendations_mark_failed(
1983 &self,
1984 request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
1985 name: &str,
1986 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
1987 OrganizationLocationRecommenderRecommendationMarkFailedCall {
1988 hub: self.hub,
1989 _request: request,
1990 _name: name.to_string(),
1991 _delegate: Default::default(),
1992 _additional_params: Default::default(),
1993 _scopes: Default::default(),
1994 }
1995 }
1996
1997 /// Create a builder to help you perform the following task:
1998 ///
1999 /// 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.
2000 ///
2001 /// # Arguments
2002 ///
2003 /// * `request` - No description provided.
2004 /// * `name` - Required. Name of the recommendation.
2005 pub fn locations_recommenders_recommendations_mark_succeeded(
2006 &self,
2007 request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
2008 name: &str,
2009 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
2010 OrganizationLocationRecommenderRecommendationMarkSucceededCall {
2011 hub: self.hub,
2012 _request: request,
2013 _name: name.to_string(),
2014 _delegate: Default::default(),
2015 _additional_params: Default::default(),
2016 _scopes: Default::default(),
2017 }
2018 }
2019
2020 /// Create a builder to help you perform the following task:
2021 ///
2022 /// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
2023 ///
2024 /// # Arguments
2025 ///
2026 /// * `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`
2027 pub fn locations_recommenders_get_config(
2028 &self,
2029 name: &str,
2030 ) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
2031 OrganizationLocationRecommenderGetConfigCall {
2032 hub: self.hub,
2033 _name: name.to_string(),
2034 _delegate: Default::default(),
2035 _additional_params: Default::default(),
2036 _scopes: Default::default(),
2037 }
2038 }
2039
2040 /// Create a builder to help you perform the following task:
2041 ///
2042 /// Updates a Recommender Config. This will create a new revision of the config.
2043 ///
2044 /// # Arguments
2045 ///
2046 /// * `request` - No description provided.
2047 /// * `name` - Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
2048 pub fn locations_recommenders_update_config(
2049 &self,
2050 request: GoogleCloudRecommenderV1beta1RecommenderConfig,
2051 name: &str,
2052 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
2053 OrganizationLocationRecommenderUpdateConfigCall {
2054 hub: self.hub,
2055 _request: request,
2056 _name: name.to_string(),
2057 _validate_only: Default::default(),
2058 _update_mask: Default::default(),
2059 _delegate: Default::default(),
2060 _additional_params: Default::default(),
2061 _scopes: Default::default(),
2062 }
2063 }
2064
2065 /// Create a builder to help you perform the following task:
2066 ///
2067 /// Lists locations with recommendations or insights.
2068 ///
2069 /// # Arguments
2070 ///
2071 /// * `name` - The resource that owns the locations collection, if applicable.
2072 pub fn locations_list(&self, name: &str) -> OrganizationLocationListCall<'a, C> {
2073 OrganizationLocationListCall {
2074 hub: self.hub,
2075 _name: name.to_string(),
2076 _page_token: Default::default(),
2077 _page_size: Default::default(),
2078 _filter: Default::default(),
2079 _extra_location_types: Default::default(),
2080 _delegate: Default::default(),
2081 _additional_params: Default::default(),
2082 _scopes: Default::default(),
2083 }
2084 }
2085}
2086
2087/// A builder providing access to all methods supported on *project* resources.
2088/// It is not used directly, but through the [`Recommender`] hub.
2089///
2090/// # Example
2091///
2092/// Instantiate a resource builder
2093///
2094/// ```test_harness,no_run
2095/// extern crate hyper;
2096/// extern crate hyper_rustls;
2097/// extern crate google_recommender1_beta1 as recommender1_beta1;
2098///
2099/// # async fn dox() {
2100/// use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2101///
2102/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2103/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2104/// .with_native_roots()
2105/// .unwrap()
2106/// .https_only()
2107/// .enable_http2()
2108/// .build();
2109///
2110/// let executor = hyper_util::rt::TokioExecutor::new();
2111/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2112/// secret,
2113/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2114/// yup_oauth2::client::CustomHyperClientBuilder::from(
2115/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2116/// ),
2117/// ).build().await.unwrap();
2118///
2119/// let client = hyper_util::client::legacy::Client::builder(
2120/// hyper_util::rt::TokioExecutor::new()
2121/// )
2122/// .build(
2123/// hyper_rustls::HttpsConnectorBuilder::new()
2124/// .with_native_roots()
2125/// .unwrap()
2126/// .https_or_http()
2127/// .enable_http2()
2128/// .build()
2129/// );
2130/// let mut hub = Recommender::new(client, auth);
2131/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2132/// // 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_list(...)`, `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(...)`
2133/// // to build up your call.
2134/// let rb = hub.projects();
2135/// # }
2136/// ```
2137pub struct ProjectMethods<'a, C>
2138where
2139 C: 'a,
2140{
2141 hub: &'a Recommender<C>,
2142}
2143
2144impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2145
2146impl<'a, C> ProjectMethods<'a, C> {
2147 /// Create a builder to help you perform the following task:
2148 ///
2149 /// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
2150 ///
2151 /// # Arguments
2152 ///
2153 /// * `name` - Required. Name of the insight.
2154 pub fn locations_insight_types_insights_get(
2155 &self,
2156 name: &str,
2157 ) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
2158 ProjectLocationInsightTypeInsightGetCall {
2159 hub: self.hub,
2160 _name: name.to_string(),
2161 _delegate: Default::default(),
2162 _additional_params: Default::default(),
2163 _scopes: Default::default(),
2164 }
2165 }
2166
2167 /// Create a builder to help you perform the following task:
2168 ///
2169 /// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
2170 ///
2171 /// # Arguments
2172 ///
2173 /// * `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.
2174 pub fn locations_insight_types_insights_list(
2175 &self,
2176 parent: &str,
2177 ) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
2178 ProjectLocationInsightTypeInsightListCall {
2179 hub: self.hub,
2180 _parent: parent.to_string(),
2181 _page_token: Default::default(),
2182 _page_size: Default::default(),
2183 _filter: Default::default(),
2184 _delegate: Default::default(),
2185 _additional_params: Default::default(),
2186 _scopes: Default::default(),
2187 }
2188 }
2189
2190 /// Create a builder to help you perform the following task:
2191 ///
2192 /// 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.
2193 ///
2194 /// # Arguments
2195 ///
2196 /// * `request` - No description provided.
2197 /// * `name` - Required. Name of the insight.
2198 pub fn locations_insight_types_insights_mark_accepted(
2199 &self,
2200 request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
2201 name: &str,
2202 ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
2203 ProjectLocationInsightTypeInsightMarkAcceptedCall {
2204 hub: self.hub,
2205 _request: request,
2206 _name: name.to_string(),
2207 _delegate: Default::default(),
2208 _additional_params: Default::default(),
2209 _scopes: Default::default(),
2210 }
2211 }
2212
2213 /// Create a builder to help you perform the following task:
2214 ///
2215 /// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
2216 ///
2217 /// # Arguments
2218 ///
2219 /// * `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`
2220 pub fn locations_insight_types_get_config(
2221 &self,
2222 name: &str,
2223 ) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
2224 ProjectLocationInsightTypeGetConfigCall {
2225 hub: self.hub,
2226 _name: name.to_string(),
2227 _delegate: Default::default(),
2228 _additional_params: Default::default(),
2229 _scopes: Default::default(),
2230 }
2231 }
2232
2233 /// Create a builder to help you perform the following task:
2234 ///
2235 /// Updates an InsightTypeConfig change. This will create a new revision of the config.
2236 ///
2237 /// # Arguments
2238 ///
2239 /// * `request` - No description provided.
2240 /// * `name` - Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
2241 pub fn locations_insight_types_update_config(
2242 &self,
2243 request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
2244 name: &str,
2245 ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
2246 ProjectLocationInsightTypeUpdateConfigCall {
2247 hub: self.hub,
2248 _request: request,
2249 _name: name.to_string(),
2250 _validate_only: Default::default(),
2251 _update_mask: Default::default(),
2252 _delegate: Default::default(),
2253 _additional_params: Default::default(),
2254 _scopes: Default::default(),
2255 }
2256 }
2257
2258 /// Create a builder to help you perform the following task:
2259 ///
2260 /// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
2261 ///
2262 /// # Arguments
2263 ///
2264 /// * `name` - Required. Name of the recommendation.
2265 pub fn locations_recommenders_recommendations_get(
2266 &self,
2267 name: &str,
2268 ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
2269 ProjectLocationRecommenderRecommendationGetCall {
2270 hub: self.hub,
2271 _name: name.to_string(),
2272 _delegate: Default::default(),
2273 _additional_params: Default::default(),
2274 _scopes: Default::default(),
2275 }
2276 }
2277
2278 /// Create a builder to help you perform the following task:
2279 ///
2280 /// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
2281 ///
2282 /// # Arguments
2283 ///
2284 /// * `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.
2285 pub fn locations_recommenders_recommendations_list(
2286 &self,
2287 parent: &str,
2288 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
2289 ProjectLocationRecommenderRecommendationListCall {
2290 hub: self.hub,
2291 _parent: parent.to_string(),
2292 _page_token: Default::default(),
2293 _page_size: Default::default(),
2294 _filter: Default::default(),
2295 _delegate: Default::default(),
2296 _additional_params: Default::default(),
2297 _scopes: Default::default(),
2298 }
2299 }
2300
2301 /// Create a builder to help you perform the following task:
2302 ///
2303 /// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
2304 ///
2305 /// # Arguments
2306 ///
2307 /// * `request` - No description provided.
2308 /// * `name` - Required. Name of the recommendation.
2309 pub fn locations_recommenders_recommendations_mark_claimed(
2310 &self,
2311 request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
2312 name: &str,
2313 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
2314 ProjectLocationRecommenderRecommendationMarkClaimedCall {
2315 hub: self.hub,
2316 _request: request,
2317 _name: name.to_string(),
2318 _delegate: Default::default(),
2319 _additional_params: Default::default(),
2320 _scopes: Default::default(),
2321 }
2322 }
2323
2324 /// Create a builder to help you perform the following task:
2325 ///
2326 /// 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.
2327 ///
2328 /// # Arguments
2329 ///
2330 /// * `request` - No description provided.
2331 /// * `name` - Required. Name of the recommendation.
2332 pub fn locations_recommenders_recommendations_mark_dismissed(
2333 &self,
2334 request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
2335 name: &str,
2336 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
2337 ProjectLocationRecommenderRecommendationMarkDismissedCall {
2338 hub: self.hub,
2339 _request: request,
2340 _name: name.to_string(),
2341 _delegate: Default::default(),
2342 _additional_params: Default::default(),
2343 _scopes: Default::default(),
2344 }
2345 }
2346
2347 /// Create a builder to help you perform the following task:
2348 ///
2349 /// 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.
2350 ///
2351 /// # Arguments
2352 ///
2353 /// * `request` - No description provided.
2354 /// * `name` - Required. Name of the recommendation.
2355 pub fn locations_recommenders_recommendations_mark_failed(
2356 &self,
2357 request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
2358 name: &str,
2359 ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
2360 ProjectLocationRecommenderRecommendationMarkFailedCall {
2361 hub: self.hub,
2362 _request: request,
2363 _name: name.to_string(),
2364 _delegate: Default::default(),
2365 _additional_params: Default::default(),
2366 _scopes: Default::default(),
2367 }
2368 }
2369
2370 /// Create a builder to help you perform the following task:
2371 ///
2372 /// 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.
2373 ///
2374 /// # Arguments
2375 ///
2376 /// * `request` - No description provided.
2377 /// * `name` - Required. Name of the recommendation.
2378 pub fn locations_recommenders_recommendations_mark_succeeded(
2379 &self,
2380 request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
2381 name: &str,
2382 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
2383 ProjectLocationRecommenderRecommendationMarkSucceededCall {
2384 hub: self.hub,
2385 _request: request,
2386 _name: name.to_string(),
2387 _delegate: Default::default(),
2388 _additional_params: Default::default(),
2389 _scopes: Default::default(),
2390 }
2391 }
2392
2393 /// Create a builder to help you perform the following task:
2394 ///
2395 /// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
2396 ///
2397 /// # Arguments
2398 ///
2399 /// * `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`
2400 pub fn locations_recommenders_get_config(
2401 &self,
2402 name: &str,
2403 ) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
2404 ProjectLocationRecommenderGetConfigCall {
2405 hub: self.hub,
2406 _name: name.to_string(),
2407 _delegate: Default::default(),
2408 _additional_params: Default::default(),
2409 _scopes: Default::default(),
2410 }
2411 }
2412
2413 /// Create a builder to help you perform the following task:
2414 ///
2415 /// Updates a Recommender Config. This will create a new revision of the config.
2416 ///
2417 /// # Arguments
2418 ///
2419 /// * `request` - No description provided.
2420 /// * `name` - Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
2421 pub fn locations_recommenders_update_config(
2422 &self,
2423 request: GoogleCloudRecommenderV1beta1RecommenderConfig,
2424 name: &str,
2425 ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
2426 ProjectLocationRecommenderUpdateConfigCall {
2427 hub: self.hub,
2428 _request: request,
2429 _name: name.to_string(),
2430 _validate_only: Default::default(),
2431 _update_mask: Default::default(),
2432 _delegate: Default::default(),
2433 _additional_params: Default::default(),
2434 _scopes: Default::default(),
2435 }
2436 }
2437
2438 /// Create a builder to help you perform the following task:
2439 ///
2440 /// Lists locations with recommendations or insights.
2441 ///
2442 /// # Arguments
2443 ///
2444 /// * `name` - The resource that owns the locations collection, if applicable.
2445 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
2446 ProjectLocationListCall {
2447 hub: self.hub,
2448 _name: name.to_string(),
2449 _page_token: Default::default(),
2450 _page_size: Default::default(),
2451 _filter: Default::default(),
2452 _extra_location_types: Default::default(),
2453 _delegate: Default::default(),
2454 _additional_params: Default::default(),
2455 _scopes: Default::default(),
2456 }
2457 }
2458}
2459
2460/// A builder providing access to all methods supported on *recommender* resources.
2461/// It is not used directly, but through the [`Recommender`] hub.
2462///
2463/// # Example
2464///
2465/// Instantiate a resource builder
2466///
2467/// ```test_harness,no_run
2468/// extern crate hyper;
2469/// extern crate hyper_rustls;
2470/// extern crate google_recommender1_beta1 as recommender1_beta1;
2471///
2472/// # async fn dox() {
2473/// use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2474///
2475/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2476/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2477/// .with_native_roots()
2478/// .unwrap()
2479/// .https_only()
2480/// .enable_http2()
2481/// .build();
2482///
2483/// let executor = hyper_util::rt::TokioExecutor::new();
2484/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2485/// secret,
2486/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2487/// yup_oauth2::client::CustomHyperClientBuilder::from(
2488/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2489/// ),
2490/// ).build().await.unwrap();
2491///
2492/// let client = hyper_util::client::legacy::Client::builder(
2493/// hyper_util::rt::TokioExecutor::new()
2494/// )
2495/// .build(
2496/// hyper_rustls::HttpsConnectorBuilder::new()
2497/// .with_native_roots()
2498/// .unwrap()
2499/// .https_or_http()
2500/// .enable_http2()
2501/// .build()
2502/// );
2503/// let mut hub = Recommender::new(client, auth);
2504/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2505/// // like `list(...)`
2506/// // to build up your call.
2507/// let rb = hub.recommenders();
2508/// # }
2509/// ```
2510pub struct RecommenderMethods<'a, C>
2511where
2512 C: 'a,
2513{
2514 hub: &'a Recommender<C>,
2515}
2516
2517impl<'a, C> common::MethodsBuilder for RecommenderMethods<'a, C> {}
2518
2519impl<'a, C> RecommenderMethods<'a, C> {
2520 /// Create a builder to help you perform the following task:
2521 ///
2522 /// Lists all available Recommenders. No IAM permissions are required.
2523 pub fn list(&self) -> RecommenderListCall<'a, C> {
2524 RecommenderListCall {
2525 hub: self.hub,
2526 _page_token: Default::default(),
2527 _page_size: Default::default(),
2528 _delegate: Default::default(),
2529 _additional_params: Default::default(),
2530 _scopes: Default::default(),
2531 }
2532 }
2533}
2534
2535// ###################
2536// CallBuilders ###
2537// #################
2538
2539/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
2540///
2541/// A builder for the *locations.insightTypes.insights.get* method supported by a *billingAccount* resource.
2542/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2543///
2544/// # Example
2545///
2546/// Instantiate a resource method builder
2547///
2548/// ```test_harness,no_run
2549/// # extern crate hyper;
2550/// # extern crate hyper_rustls;
2551/// # extern crate google_recommender1_beta1 as recommender1_beta1;
2552/// # async fn dox() {
2553/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2554///
2555/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2556/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2557/// # .with_native_roots()
2558/// # .unwrap()
2559/// # .https_only()
2560/// # .enable_http2()
2561/// # .build();
2562///
2563/// # let executor = hyper_util::rt::TokioExecutor::new();
2564/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2565/// # secret,
2566/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2567/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2568/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2569/// # ),
2570/// # ).build().await.unwrap();
2571///
2572/// # let client = hyper_util::client::legacy::Client::builder(
2573/// # hyper_util::rt::TokioExecutor::new()
2574/// # )
2575/// # .build(
2576/// # hyper_rustls::HttpsConnectorBuilder::new()
2577/// # .with_native_roots()
2578/// # .unwrap()
2579/// # .https_or_http()
2580/// # .enable_http2()
2581/// # .build()
2582/// # );
2583/// # let mut hub = Recommender::new(client, auth);
2584/// // You can configure optional parameters by calling the respective setters at will, and
2585/// // execute the final call using `doit()`.
2586/// // Values shown here are possibly random and not representative !
2587/// let result = hub.billing_accounts().locations_insight_types_insights_get("name")
2588/// .doit().await;
2589/// # }
2590/// ```
2591pub struct BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2592where
2593 C: 'a,
2594{
2595 hub: &'a Recommender<C>,
2596 _name: String,
2597 _delegate: Option<&'a mut dyn common::Delegate>,
2598 _additional_params: HashMap<String, String>,
2599 _scopes: BTreeSet<String>,
2600}
2601
2602impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeInsightGetCall<'a, C> {}
2603
2604impl<'a, C> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2605where
2606 C: common::Connector,
2607{
2608 /// Perform the operation you have build so far.
2609 pub async fn doit(
2610 mut self,
2611 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
2612 use std::borrow::Cow;
2613 use std::io::{Read, Seek};
2614
2615 use common::{url::Params, ToParts};
2616 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2617
2618 let mut dd = common::DefaultDelegate;
2619 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2620 dlg.begin(common::MethodInfo {
2621 id: "recommender.billingAccounts.locations.insightTypes.insights.get",
2622 http_method: hyper::Method::GET,
2623 });
2624
2625 for &field in ["alt", "name"].iter() {
2626 if self._additional_params.contains_key(field) {
2627 dlg.finished(false);
2628 return Err(common::Error::FieldClash(field));
2629 }
2630 }
2631
2632 let mut params = Params::with_capacity(3 + self._additional_params.len());
2633 params.push("name", self._name);
2634
2635 params.extend(self._additional_params.iter());
2636
2637 params.push("alt", "json");
2638 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2639 if self._scopes.is_empty() {
2640 self._scopes
2641 .insert(Scope::CloudPlatform.as_ref().to_string());
2642 }
2643
2644 #[allow(clippy::single_element_loop)]
2645 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2646 url = params.uri_replacement(url, param_name, find_this, true);
2647 }
2648 {
2649 let to_remove = ["name"];
2650 params.remove_params(&to_remove);
2651 }
2652
2653 let url = params.parse_with_url(&url);
2654
2655 loop {
2656 let token = match self
2657 .hub
2658 .auth
2659 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2660 .await
2661 {
2662 Ok(token) => token,
2663 Err(e) => match dlg.token(e) {
2664 Ok(token) => token,
2665 Err(e) => {
2666 dlg.finished(false);
2667 return Err(common::Error::MissingToken(e));
2668 }
2669 },
2670 };
2671 let mut req_result = {
2672 let client = &self.hub.client;
2673 dlg.pre_request();
2674 let mut req_builder = hyper::Request::builder()
2675 .method(hyper::Method::GET)
2676 .uri(url.as_str())
2677 .header(USER_AGENT, self.hub._user_agent.clone());
2678
2679 if let Some(token) = token.as_ref() {
2680 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2681 }
2682
2683 let request = req_builder
2684 .header(CONTENT_LENGTH, 0_u64)
2685 .body(common::to_body::<String>(None));
2686
2687 client.request(request.unwrap()).await
2688 };
2689
2690 match req_result {
2691 Err(err) => {
2692 if let common::Retry::After(d) = dlg.http_error(&err) {
2693 sleep(d).await;
2694 continue;
2695 }
2696 dlg.finished(false);
2697 return Err(common::Error::HttpError(err));
2698 }
2699 Ok(res) => {
2700 let (mut parts, body) = res.into_parts();
2701 let mut body = common::Body::new(body);
2702 if !parts.status.is_success() {
2703 let bytes = common::to_bytes(body).await.unwrap_or_default();
2704 let error = serde_json::from_str(&common::to_string(&bytes));
2705 let response = common::to_response(parts, bytes.into());
2706
2707 if let common::Retry::After(d) =
2708 dlg.http_failure(&response, error.as_ref().ok())
2709 {
2710 sleep(d).await;
2711 continue;
2712 }
2713
2714 dlg.finished(false);
2715
2716 return Err(match error {
2717 Ok(value) => common::Error::BadRequest(value),
2718 _ => common::Error::Failure(response),
2719 });
2720 }
2721 let response = {
2722 let bytes = common::to_bytes(body).await.unwrap_or_default();
2723 let encoded = common::to_string(&bytes);
2724 match serde_json::from_str(&encoded) {
2725 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2726 Err(error) => {
2727 dlg.response_json_decode_error(&encoded, &error);
2728 return Err(common::Error::JsonDecodeError(
2729 encoded.to_string(),
2730 error,
2731 ));
2732 }
2733 }
2734 };
2735
2736 dlg.finished(true);
2737 return Ok(response);
2738 }
2739 }
2740 }
2741 }
2742
2743 /// Required. Name of the insight.
2744 ///
2745 /// Sets the *name* path property to the given value.
2746 ///
2747 /// Even though the property as already been set when instantiating this call,
2748 /// we provide this method for API completeness.
2749 pub fn name(
2750 mut self,
2751 new_value: &str,
2752 ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
2753 self._name = new_value.to_string();
2754 self
2755 }
2756 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2757 /// while executing the actual API request.
2758 ///
2759 /// ````text
2760 /// It should be used to handle progress information, and to implement a certain level of resilience.
2761 /// ````
2762 ///
2763 /// Sets the *delegate* property to the given value.
2764 pub fn delegate(
2765 mut self,
2766 new_value: &'a mut dyn common::Delegate,
2767 ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
2768 self._delegate = Some(new_value);
2769 self
2770 }
2771
2772 /// Set any additional parameter of the query string used in the request.
2773 /// It should be used to set parameters which are not yet available through their own
2774 /// setters.
2775 ///
2776 /// Please note that this method must not be used to set any of the known parameters
2777 /// which have their own setter method. If done anyway, the request will fail.
2778 ///
2779 /// # Additional Parameters
2780 ///
2781 /// * *$.xgafv* (query-string) - V1 error format.
2782 /// * *access_token* (query-string) - OAuth access token.
2783 /// * *alt* (query-string) - Data format for response.
2784 /// * *callback* (query-string) - JSONP
2785 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2786 /// * *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.
2787 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2788 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2789 /// * *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.
2790 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2791 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2792 pub fn param<T>(
2793 mut self,
2794 name: T,
2795 value: T,
2796 ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2797 where
2798 T: AsRef<str>,
2799 {
2800 self._additional_params
2801 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2802 self
2803 }
2804
2805 /// Identifies the authorization scope for the method you are building.
2806 ///
2807 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2808 /// [`Scope::CloudPlatform`].
2809 ///
2810 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2811 /// tokens for more than one scope.
2812 ///
2813 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2814 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2815 /// sufficient, a read-write scope will do as well.
2816 pub fn add_scope<St>(
2817 mut self,
2818 scope: St,
2819 ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2820 where
2821 St: AsRef<str>,
2822 {
2823 self._scopes.insert(String::from(scope.as_ref()));
2824 self
2825 }
2826 /// Identifies the authorization scope(s) for the method you are building.
2827 ///
2828 /// See [`Self::add_scope()`] for details.
2829 pub fn add_scopes<I, St>(
2830 mut self,
2831 scopes: I,
2832 ) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C>
2833 where
2834 I: IntoIterator<Item = St>,
2835 St: AsRef<str>,
2836 {
2837 self._scopes
2838 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2839 self
2840 }
2841
2842 /// Removes all scopes, and no default scope will be used either.
2843 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2844 /// for details).
2845 pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeInsightGetCall<'a, C> {
2846 self._scopes.clear();
2847 self
2848 }
2849}
2850
2851/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
2852///
2853/// A builder for the *locations.insightTypes.insights.list* method supported by a *billingAccount* resource.
2854/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2855///
2856/// # Example
2857///
2858/// Instantiate a resource method builder
2859///
2860/// ```test_harness,no_run
2861/// # extern crate hyper;
2862/// # extern crate hyper_rustls;
2863/// # extern crate google_recommender1_beta1 as recommender1_beta1;
2864/// # async fn dox() {
2865/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2866///
2867/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2868/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2869/// # .with_native_roots()
2870/// # .unwrap()
2871/// # .https_only()
2872/// # .enable_http2()
2873/// # .build();
2874///
2875/// # let executor = hyper_util::rt::TokioExecutor::new();
2876/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2877/// # secret,
2878/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2879/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2880/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2881/// # ),
2882/// # ).build().await.unwrap();
2883///
2884/// # let client = hyper_util::client::legacy::Client::builder(
2885/// # hyper_util::rt::TokioExecutor::new()
2886/// # )
2887/// # .build(
2888/// # hyper_rustls::HttpsConnectorBuilder::new()
2889/// # .with_native_roots()
2890/// # .unwrap()
2891/// # .https_or_http()
2892/// # .enable_http2()
2893/// # .build()
2894/// # );
2895/// # let mut hub = Recommender::new(client, auth);
2896/// // You can configure optional parameters by calling the respective setters at will, and
2897/// // execute the final call using `doit()`.
2898/// // Values shown here are possibly random and not representative !
2899/// let result = hub.billing_accounts().locations_insight_types_insights_list("parent")
2900/// .page_token("At")
2901/// .page_size(-8)
2902/// .filter("sed")
2903/// .doit().await;
2904/// # }
2905/// ```
2906pub struct BillingAccountLocationInsightTypeInsightListCall<'a, C>
2907where
2908 C: 'a,
2909{
2910 hub: &'a Recommender<C>,
2911 _parent: String,
2912 _page_token: Option<String>,
2913 _page_size: Option<i32>,
2914 _filter: Option<String>,
2915 _delegate: Option<&'a mut dyn common::Delegate>,
2916 _additional_params: HashMap<String, String>,
2917 _scopes: BTreeSet<String>,
2918}
2919
2920impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeInsightListCall<'a, C> {}
2921
2922impl<'a, C> BillingAccountLocationInsightTypeInsightListCall<'a, C>
2923where
2924 C: common::Connector,
2925{
2926 /// Perform the operation you have build so far.
2927 pub async fn doit(
2928 mut self,
2929 ) -> common::Result<(
2930 common::Response,
2931 GoogleCloudRecommenderV1beta1ListInsightsResponse,
2932 )> {
2933 use std::borrow::Cow;
2934 use std::io::{Read, Seek};
2935
2936 use common::{url::Params, ToParts};
2937 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2938
2939 let mut dd = common::DefaultDelegate;
2940 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2941 dlg.begin(common::MethodInfo {
2942 id: "recommender.billingAccounts.locations.insightTypes.insights.list",
2943 http_method: hyper::Method::GET,
2944 });
2945
2946 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
2947 if self._additional_params.contains_key(field) {
2948 dlg.finished(false);
2949 return Err(common::Error::FieldClash(field));
2950 }
2951 }
2952
2953 let mut params = Params::with_capacity(6 + self._additional_params.len());
2954 params.push("parent", self._parent);
2955 if let Some(value) = self._page_token.as_ref() {
2956 params.push("pageToken", value);
2957 }
2958 if let Some(value) = self._page_size.as_ref() {
2959 params.push("pageSize", value.to_string());
2960 }
2961 if let Some(value) = self._filter.as_ref() {
2962 params.push("filter", value);
2963 }
2964
2965 params.extend(self._additional_params.iter());
2966
2967 params.push("alt", "json");
2968 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/insights";
2969 if self._scopes.is_empty() {
2970 self._scopes
2971 .insert(Scope::CloudPlatform.as_ref().to_string());
2972 }
2973
2974 #[allow(clippy::single_element_loop)]
2975 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2976 url = params.uri_replacement(url, param_name, find_this, true);
2977 }
2978 {
2979 let to_remove = ["parent"];
2980 params.remove_params(&to_remove);
2981 }
2982
2983 let url = params.parse_with_url(&url);
2984
2985 loop {
2986 let token = match self
2987 .hub
2988 .auth
2989 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2990 .await
2991 {
2992 Ok(token) => token,
2993 Err(e) => match dlg.token(e) {
2994 Ok(token) => token,
2995 Err(e) => {
2996 dlg.finished(false);
2997 return Err(common::Error::MissingToken(e));
2998 }
2999 },
3000 };
3001 let mut req_result = {
3002 let client = &self.hub.client;
3003 dlg.pre_request();
3004 let mut req_builder = hyper::Request::builder()
3005 .method(hyper::Method::GET)
3006 .uri(url.as_str())
3007 .header(USER_AGENT, self.hub._user_agent.clone());
3008
3009 if let Some(token) = token.as_ref() {
3010 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3011 }
3012
3013 let request = req_builder
3014 .header(CONTENT_LENGTH, 0_u64)
3015 .body(common::to_body::<String>(None));
3016
3017 client.request(request.unwrap()).await
3018 };
3019
3020 match req_result {
3021 Err(err) => {
3022 if let common::Retry::After(d) = dlg.http_error(&err) {
3023 sleep(d).await;
3024 continue;
3025 }
3026 dlg.finished(false);
3027 return Err(common::Error::HttpError(err));
3028 }
3029 Ok(res) => {
3030 let (mut parts, body) = res.into_parts();
3031 let mut body = common::Body::new(body);
3032 if !parts.status.is_success() {
3033 let bytes = common::to_bytes(body).await.unwrap_or_default();
3034 let error = serde_json::from_str(&common::to_string(&bytes));
3035 let response = common::to_response(parts, bytes.into());
3036
3037 if let common::Retry::After(d) =
3038 dlg.http_failure(&response, error.as_ref().ok())
3039 {
3040 sleep(d).await;
3041 continue;
3042 }
3043
3044 dlg.finished(false);
3045
3046 return Err(match error {
3047 Ok(value) => common::Error::BadRequest(value),
3048 _ => common::Error::Failure(response),
3049 });
3050 }
3051 let response = {
3052 let bytes = common::to_bytes(body).await.unwrap_or_default();
3053 let encoded = common::to_string(&bytes);
3054 match serde_json::from_str(&encoded) {
3055 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3056 Err(error) => {
3057 dlg.response_json_decode_error(&encoded, &error);
3058 return Err(common::Error::JsonDecodeError(
3059 encoded.to_string(),
3060 error,
3061 ));
3062 }
3063 }
3064 };
3065
3066 dlg.finished(true);
3067 return Ok(response);
3068 }
3069 }
3070 }
3071 }
3072
3073 /// 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.
3074 ///
3075 /// Sets the *parent* path property to the given value.
3076 ///
3077 /// Even though the property as already been set when instantiating this call,
3078 /// we provide this method for API completeness.
3079 pub fn parent(
3080 mut self,
3081 new_value: &str,
3082 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
3083 self._parent = new_value.to_string();
3084 self
3085 }
3086 /// 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.
3087 ///
3088 /// Sets the *page token* query property to the given value.
3089 pub fn page_token(
3090 mut self,
3091 new_value: &str,
3092 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
3093 self._page_token = Some(new_value.to_string());
3094 self
3095 }
3096 /// 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.
3097 ///
3098 /// Sets the *page size* query property to the given value.
3099 pub fn page_size(
3100 mut self,
3101 new_value: i32,
3102 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
3103 self._page_size = Some(new_value);
3104 self
3105 }
3106 /// 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)
3107 ///
3108 /// Sets the *filter* query property to the given value.
3109 pub fn filter(
3110 mut self,
3111 new_value: &str,
3112 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
3113 self._filter = Some(new_value.to_string());
3114 self
3115 }
3116 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3117 /// while executing the actual API request.
3118 ///
3119 /// ````text
3120 /// It should be used to handle progress information, and to implement a certain level of resilience.
3121 /// ````
3122 ///
3123 /// Sets the *delegate* property to the given value.
3124 pub fn delegate(
3125 mut self,
3126 new_value: &'a mut dyn common::Delegate,
3127 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
3128 self._delegate = Some(new_value);
3129 self
3130 }
3131
3132 /// Set any additional parameter of the query string used in the request.
3133 /// It should be used to set parameters which are not yet available through their own
3134 /// setters.
3135 ///
3136 /// Please note that this method must not be used to set any of the known parameters
3137 /// which have their own setter method. If done anyway, the request will fail.
3138 ///
3139 /// # Additional Parameters
3140 ///
3141 /// * *$.xgafv* (query-string) - V1 error format.
3142 /// * *access_token* (query-string) - OAuth access token.
3143 /// * *alt* (query-string) - Data format for response.
3144 /// * *callback* (query-string) - JSONP
3145 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3146 /// * *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.
3147 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3148 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3149 /// * *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.
3150 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3151 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3152 pub fn param<T>(
3153 mut self,
3154 name: T,
3155 value: T,
3156 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C>
3157 where
3158 T: AsRef<str>,
3159 {
3160 self._additional_params
3161 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3162 self
3163 }
3164
3165 /// Identifies the authorization scope for the method you are building.
3166 ///
3167 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3168 /// [`Scope::CloudPlatform`].
3169 ///
3170 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3171 /// tokens for more than one scope.
3172 ///
3173 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3174 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3175 /// sufficient, a read-write scope will do as well.
3176 pub fn add_scope<St>(
3177 mut self,
3178 scope: St,
3179 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C>
3180 where
3181 St: AsRef<str>,
3182 {
3183 self._scopes.insert(String::from(scope.as_ref()));
3184 self
3185 }
3186 /// Identifies the authorization scope(s) for the method you are building.
3187 ///
3188 /// See [`Self::add_scope()`] for details.
3189 pub fn add_scopes<I, St>(
3190 mut self,
3191 scopes: I,
3192 ) -> BillingAccountLocationInsightTypeInsightListCall<'a, C>
3193 where
3194 I: IntoIterator<Item = St>,
3195 St: AsRef<str>,
3196 {
3197 self._scopes
3198 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3199 self
3200 }
3201
3202 /// Removes all scopes, and no default scope will be used either.
3203 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3204 /// for details).
3205 pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeInsightListCall<'a, C> {
3206 self._scopes.clear();
3207 self
3208 }
3209}
3210
3211/// 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.
3212///
3213/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *billingAccount* resource.
3214/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3215///
3216/// # Example
3217///
3218/// Instantiate a resource method builder
3219///
3220/// ```test_harness,no_run
3221/// # extern crate hyper;
3222/// # extern crate hyper_rustls;
3223/// # extern crate google_recommender1_beta1 as recommender1_beta1;
3224/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
3225/// # async fn dox() {
3226/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3227///
3228/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3229/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3230/// # .with_native_roots()
3231/// # .unwrap()
3232/// # .https_only()
3233/// # .enable_http2()
3234/// # .build();
3235///
3236/// # let executor = hyper_util::rt::TokioExecutor::new();
3237/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3238/// # secret,
3239/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3240/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3241/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3242/// # ),
3243/// # ).build().await.unwrap();
3244///
3245/// # let client = hyper_util::client::legacy::Client::builder(
3246/// # hyper_util::rt::TokioExecutor::new()
3247/// # )
3248/// # .build(
3249/// # hyper_rustls::HttpsConnectorBuilder::new()
3250/// # .with_native_roots()
3251/// # .unwrap()
3252/// # .https_or_http()
3253/// # .enable_http2()
3254/// # .build()
3255/// # );
3256/// # let mut hub = Recommender::new(client, auth);
3257/// // As the method needs a request, you would usually fill it with the desired information
3258/// // into the respective structure. Some of the parts shown here might not be applicable !
3259/// // Values shown here are possibly random and not representative !
3260/// let mut req = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::default();
3261///
3262/// // You can configure optional parameters by calling the respective setters at will, and
3263/// // execute the final call using `doit()`.
3264/// // Values shown here are possibly random and not representative !
3265/// let result = hub.billing_accounts().locations_insight_types_insights_mark_accepted(req, "name")
3266/// .doit().await;
3267/// # }
3268/// ```
3269pub struct BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3270where
3271 C: 'a,
3272{
3273 hub: &'a Recommender<C>,
3274 _request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
3275 _name: String,
3276 _delegate: Option<&'a mut dyn common::Delegate>,
3277 _additional_params: HashMap<String, String>,
3278 _scopes: BTreeSet<String>,
3279}
3280
3281impl<'a, C> common::CallBuilder
3282 for BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3283{
3284}
3285
3286impl<'a, C> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3287where
3288 C: common::Connector,
3289{
3290 /// Perform the operation you have build so far.
3291 pub async fn doit(
3292 mut self,
3293 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
3294 use std::borrow::Cow;
3295 use std::io::{Read, Seek};
3296
3297 use common::{url::Params, ToParts};
3298 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3299
3300 let mut dd = common::DefaultDelegate;
3301 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3302 dlg.begin(common::MethodInfo {
3303 id: "recommender.billingAccounts.locations.insightTypes.insights.markAccepted",
3304 http_method: hyper::Method::POST,
3305 });
3306
3307 for &field in ["alt", "name"].iter() {
3308 if self._additional_params.contains_key(field) {
3309 dlg.finished(false);
3310 return Err(common::Error::FieldClash(field));
3311 }
3312 }
3313
3314 let mut params = Params::with_capacity(4 + self._additional_params.len());
3315 params.push("name", self._name);
3316
3317 params.extend(self._additional_params.iter());
3318
3319 params.push("alt", "json");
3320 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markAccepted";
3321 if self._scopes.is_empty() {
3322 self._scopes
3323 .insert(Scope::CloudPlatform.as_ref().to_string());
3324 }
3325
3326 #[allow(clippy::single_element_loop)]
3327 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3328 url = params.uri_replacement(url, param_name, find_this, true);
3329 }
3330 {
3331 let to_remove = ["name"];
3332 params.remove_params(&to_remove);
3333 }
3334
3335 let url = params.parse_with_url(&url);
3336
3337 let mut json_mime_type = mime::APPLICATION_JSON;
3338 let mut request_value_reader = {
3339 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3340 common::remove_json_null_values(&mut value);
3341 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3342 serde_json::to_writer(&mut dst, &value).unwrap();
3343 dst
3344 };
3345 let request_size = request_value_reader
3346 .seek(std::io::SeekFrom::End(0))
3347 .unwrap();
3348 request_value_reader
3349 .seek(std::io::SeekFrom::Start(0))
3350 .unwrap();
3351
3352 loop {
3353 let token = match self
3354 .hub
3355 .auth
3356 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3357 .await
3358 {
3359 Ok(token) => token,
3360 Err(e) => match dlg.token(e) {
3361 Ok(token) => token,
3362 Err(e) => {
3363 dlg.finished(false);
3364 return Err(common::Error::MissingToken(e));
3365 }
3366 },
3367 };
3368 request_value_reader
3369 .seek(std::io::SeekFrom::Start(0))
3370 .unwrap();
3371 let mut req_result = {
3372 let client = &self.hub.client;
3373 dlg.pre_request();
3374 let mut req_builder = hyper::Request::builder()
3375 .method(hyper::Method::POST)
3376 .uri(url.as_str())
3377 .header(USER_AGENT, self.hub._user_agent.clone());
3378
3379 if let Some(token) = token.as_ref() {
3380 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3381 }
3382
3383 let request = req_builder
3384 .header(CONTENT_TYPE, json_mime_type.to_string())
3385 .header(CONTENT_LENGTH, request_size as u64)
3386 .body(common::to_body(
3387 request_value_reader.get_ref().clone().into(),
3388 ));
3389
3390 client.request(request.unwrap()).await
3391 };
3392
3393 match req_result {
3394 Err(err) => {
3395 if let common::Retry::After(d) = dlg.http_error(&err) {
3396 sleep(d).await;
3397 continue;
3398 }
3399 dlg.finished(false);
3400 return Err(common::Error::HttpError(err));
3401 }
3402 Ok(res) => {
3403 let (mut parts, body) = res.into_parts();
3404 let mut body = common::Body::new(body);
3405 if !parts.status.is_success() {
3406 let bytes = common::to_bytes(body).await.unwrap_or_default();
3407 let error = serde_json::from_str(&common::to_string(&bytes));
3408 let response = common::to_response(parts, bytes.into());
3409
3410 if let common::Retry::After(d) =
3411 dlg.http_failure(&response, error.as_ref().ok())
3412 {
3413 sleep(d).await;
3414 continue;
3415 }
3416
3417 dlg.finished(false);
3418
3419 return Err(match error {
3420 Ok(value) => common::Error::BadRequest(value),
3421 _ => common::Error::Failure(response),
3422 });
3423 }
3424 let response = {
3425 let bytes = common::to_bytes(body).await.unwrap_or_default();
3426 let encoded = common::to_string(&bytes);
3427 match serde_json::from_str(&encoded) {
3428 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3429 Err(error) => {
3430 dlg.response_json_decode_error(&encoded, &error);
3431 return Err(common::Error::JsonDecodeError(
3432 encoded.to_string(),
3433 error,
3434 ));
3435 }
3436 }
3437 };
3438
3439 dlg.finished(true);
3440 return Ok(response);
3441 }
3442 }
3443 }
3444 }
3445
3446 ///
3447 /// Sets the *request* property to the given value.
3448 ///
3449 /// Even though the property as already been set when instantiating this call,
3450 /// we provide this method for API completeness.
3451 pub fn request(
3452 mut self,
3453 new_value: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
3454 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3455 self._request = new_value;
3456 self
3457 }
3458 /// Required. Name of the insight.
3459 ///
3460 /// Sets the *name* path property to the given value.
3461 ///
3462 /// Even though the property as already been set when instantiating this call,
3463 /// we provide this method for API completeness.
3464 pub fn name(
3465 mut self,
3466 new_value: &str,
3467 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3468 self._name = new_value.to_string();
3469 self
3470 }
3471 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3472 /// while executing the actual API request.
3473 ///
3474 /// ````text
3475 /// It should be used to handle progress information, and to implement a certain level of resilience.
3476 /// ````
3477 ///
3478 /// Sets the *delegate* property to the given value.
3479 pub fn delegate(
3480 mut self,
3481 new_value: &'a mut dyn common::Delegate,
3482 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3483 self._delegate = Some(new_value);
3484 self
3485 }
3486
3487 /// Set any additional parameter of the query string used in the request.
3488 /// It should be used to set parameters which are not yet available through their own
3489 /// setters.
3490 ///
3491 /// Please note that this method must not be used to set any of the known parameters
3492 /// which have their own setter method. If done anyway, the request will fail.
3493 ///
3494 /// # Additional Parameters
3495 ///
3496 /// * *$.xgafv* (query-string) - V1 error format.
3497 /// * *access_token* (query-string) - OAuth access token.
3498 /// * *alt* (query-string) - Data format for response.
3499 /// * *callback* (query-string) - JSONP
3500 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3501 /// * *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.
3502 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3503 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3504 /// * *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.
3505 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3506 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3507 pub fn param<T>(
3508 mut self,
3509 name: T,
3510 value: T,
3511 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3512 where
3513 T: AsRef<str>,
3514 {
3515 self._additional_params
3516 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3517 self
3518 }
3519
3520 /// Identifies the authorization scope for the method you are building.
3521 ///
3522 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3523 /// [`Scope::CloudPlatform`].
3524 ///
3525 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3526 /// tokens for more than one scope.
3527 ///
3528 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3529 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3530 /// sufficient, a read-write scope will do as well.
3531 pub fn add_scope<St>(
3532 mut self,
3533 scope: St,
3534 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3535 where
3536 St: AsRef<str>,
3537 {
3538 self._scopes.insert(String::from(scope.as_ref()));
3539 self
3540 }
3541 /// Identifies the authorization scope(s) for the method you are building.
3542 ///
3543 /// See [`Self::add_scope()`] for details.
3544 pub fn add_scopes<I, St>(
3545 mut self,
3546 scopes: I,
3547 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C>
3548 where
3549 I: IntoIterator<Item = St>,
3550 St: AsRef<str>,
3551 {
3552 self._scopes
3553 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3554 self
3555 }
3556
3557 /// Removes all scopes, and no default scope will be used either.
3558 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3559 /// for details).
3560 pub fn clear_scopes(
3561 mut self,
3562 ) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
3563 self._scopes.clear();
3564 self
3565 }
3566}
3567
3568/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
3569///
3570/// A builder for the *locations.insightTypes.getConfig* method supported by a *billingAccount* resource.
3571/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3572///
3573/// # Example
3574///
3575/// Instantiate a resource method builder
3576///
3577/// ```test_harness,no_run
3578/// # extern crate hyper;
3579/// # extern crate hyper_rustls;
3580/// # extern crate google_recommender1_beta1 as recommender1_beta1;
3581/// # async fn dox() {
3582/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3583///
3584/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3585/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3586/// # .with_native_roots()
3587/// # .unwrap()
3588/// # .https_only()
3589/// # .enable_http2()
3590/// # .build();
3591///
3592/// # let executor = hyper_util::rt::TokioExecutor::new();
3593/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3594/// # secret,
3595/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3596/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3597/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3598/// # ),
3599/// # ).build().await.unwrap();
3600///
3601/// # let client = hyper_util::client::legacy::Client::builder(
3602/// # hyper_util::rt::TokioExecutor::new()
3603/// # )
3604/// # .build(
3605/// # hyper_rustls::HttpsConnectorBuilder::new()
3606/// # .with_native_roots()
3607/// # .unwrap()
3608/// # .https_or_http()
3609/// # .enable_http2()
3610/// # .build()
3611/// # );
3612/// # let mut hub = Recommender::new(client, auth);
3613/// // You can configure optional parameters by calling the respective setters at will, and
3614/// // execute the final call using `doit()`.
3615/// // Values shown here are possibly random and not representative !
3616/// let result = hub.billing_accounts().locations_insight_types_get_config("name")
3617/// .doit().await;
3618/// # }
3619/// ```
3620pub struct BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3621where
3622 C: 'a,
3623{
3624 hub: &'a Recommender<C>,
3625 _name: String,
3626 _delegate: Option<&'a mut dyn common::Delegate>,
3627 _additional_params: HashMap<String, String>,
3628 _scopes: BTreeSet<String>,
3629}
3630
3631impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeGetConfigCall<'a, C> {}
3632
3633impl<'a, C> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3634where
3635 C: common::Connector,
3636{
3637 /// Perform the operation you have build so far.
3638 pub async fn doit(
3639 mut self,
3640 ) -> common::Result<(
3641 common::Response,
3642 GoogleCloudRecommenderV1beta1InsightTypeConfig,
3643 )> {
3644 use std::borrow::Cow;
3645 use std::io::{Read, Seek};
3646
3647 use common::{url::Params, ToParts};
3648 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3649
3650 let mut dd = common::DefaultDelegate;
3651 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3652 dlg.begin(common::MethodInfo {
3653 id: "recommender.billingAccounts.locations.insightTypes.getConfig",
3654 http_method: hyper::Method::GET,
3655 });
3656
3657 for &field in ["alt", "name"].iter() {
3658 if self._additional_params.contains_key(field) {
3659 dlg.finished(false);
3660 return Err(common::Error::FieldClash(field));
3661 }
3662 }
3663
3664 let mut params = Params::with_capacity(3 + self._additional_params.len());
3665 params.push("name", self._name);
3666
3667 params.extend(self._additional_params.iter());
3668
3669 params.push("alt", "json");
3670 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3671 if self._scopes.is_empty() {
3672 self._scopes
3673 .insert(Scope::CloudPlatform.as_ref().to_string());
3674 }
3675
3676 #[allow(clippy::single_element_loop)]
3677 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3678 url = params.uri_replacement(url, param_name, find_this, true);
3679 }
3680 {
3681 let to_remove = ["name"];
3682 params.remove_params(&to_remove);
3683 }
3684
3685 let url = params.parse_with_url(&url);
3686
3687 loop {
3688 let token = match self
3689 .hub
3690 .auth
3691 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3692 .await
3693 {
3694 Ok(token) => token,
3695 Err(e) => match dlg.token(e) {
3696 Ok(token) => token,
3697 Err(e) => {
3698 dlg.finished(false);
3699 return Err(common::Error::MissingToken(e));
3700 }
3701 },
3702 };
3703 let mut req_result = {
3704 let client = &self.hub.client;
3705 dlg.pre_request();
3706 let mut req_builder = hyper::Request::builder()
3707 .method(hyper::Method::GET)
3708 .uri(url.as_str())
3709 .header(USER_AGENT, self.hub._user_agent.clone());
3710
3711 if let Some(token) = token.as_ref() {
3712 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3713 }
3714
3715 let request = req_builder
3716 .header(CONTENT_LENGTH, 0_u64)
3717 .body(common::to_body::<String>(None));
3718
3719 client.request(request.unwrap()).await
3720 };
3721
3722 match req_result {
3723 Err(err) => {
3724 if let common::Retry::After(d) = dlg.http_error(&err) {
3725 sleep(d).await;
3726 continue;
3727 }
3728 dlg.finished(false);
3729 return Err(common::Error::HttpError(err));
3730 }
3731 Ok(res) => {
3732 let (mut parts, body) = res.into_parts();
3733 let mut body = common::Body::new(body);
3734 if !parts.status.is_success() {
3735 let bytes = common::to_bytes(body).await.unwrap_or_default();
3736 let error = serde_json::from_str(&common::to_string(&bytes));
3737 let response = common::to_response(parts, bytes.into());
3738
3739 if let common::Retry::After(d) =
3740 dlg.http_failure(&response, error.as_ref().ok())
3741 {
3742 sleep(d).await;
3743 continue;
3744 }
3745
3746 dlg.finished(false);
3747
3748 return Err(match error {
3749 Ok(value) => common::Error::BadRequest(value),
3750 _ => common::Error::Failure(response),
3751 });
3752 }
3753 let response = {
3754 let bytes = common::to_bytes(body).await.unwrap_or_default();
3755 let encoded = common::to_string(&bytes);
3756 match serde_json::from_str(&encoded) {
3757 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3758 Err(error) => {
3759 dlg.response_json_decode_error(&encoded, &error);
3760 return Err(common::Error::JsonDecodeError(
3761 encoded.to_string(),
3762 error,
3763 ));
3764 }
3765 }
3766 };
3767
3768 dlg.finished(true);
3769 return Ok(response);
3770 }
3771 }
3772 }
3773 }
3774
3775 /// 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`
3776 ///
3777 /// Sets the *name* path property to the given value.
3778 ///
3779 /// Even though the property as already been set when instantiating this call,
3780 /// we provide this method for API completeness.
3781 pub fn name(
3782 mut self,
3783 new_value: &str,
3784 ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
3785 self._name = new_value.to_string();
3786 self
3787 }
3788 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3789 /// while executing the actual API request.
3790 ///
3791 /// ````text
3792 /// It should be used to handle progress information, and to implement a certain level of resilience.
3793 /// ````
3794 ///
3795 /// Sets the *delegate* property to the given value.
3796 pub fn delegate(
3797 mut self,
3798 new_value: &'a mut dyn common::Delegate,
3799 ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
3800 self._delegate = Some(new_value);
3801 self
3802 }
3803
3804 /// Set any additional parameter of the query string used in the request.
3805 /// It should be used to set parameters which are not yet available through their own
3806 /// setters.
3807 ///
3808 /// Please note that this method must not be used to set any of the known parameters
3809 /// which have their own setter method. If done anyway, the request will fail.
3810 ///
3811 /// # Additional Parameters
3812 ///
3813 /// * *$.xgafv* (query-string) - V1 error format.
3814 /// * *access_token* (query-string) - OAuth access token.
3815 /// * *alt* (query-string) - Data format for response.
3816 /// * *callback* (query-string) - JSONP
3817 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3818 /// * *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.
3819 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3820 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3821 /// * *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.
3822 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3823 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3824 pub fn param<T>(
3825 mut self,
3826 name: T,
3827 value: T,
3828 ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3829 where
3830 T: AsRef<str>,
3831 {
3832 self._additional_params
3833 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3834 self
3835 }
3836
3837 /// Identifies the authorization scope for the method you are building.
3838 ///
3839 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3840 /// [`Scope::CloudPlatform`].
3841 ///
3842 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3843 /// tokens for more than one scope.
3844 ///
3845 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3846 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3847 /// sufficient, a read-write scope will do as well.
3848 pub fn add_scope<St>(
3849 mut self,
3850 scope: St,
3851 ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3852 where
3853 St: AsRef<str>,
3854 {
3855 self._scopes.insert(String::from(scope.as_ref()));
3856 self
3857 }
3858 /// Identifies the authorization scope(s) for the method you are building.
3859 ///
3860 /// See [`Self::add_scope()`] for details.
3861 pub fn add_scopes<I, St>(
3862 mut self,
3863 scopes: I,
3864 ) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C>
3865 where
3866 I: IntoIterator<Item = St>,
3867 St: AsRef<str>,
3868 {
3869 self._scopes
3870 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3871 self
3872 }
3873
3874 /// Removes all scopes, and no default scope will be used either.
3875 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3876 /// for details).
3877 pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeGetConfigCall<'a, C> {
3878 self._scopes.clear();
3879 self
3880 }
3881}
3882
3883/// Updates an InsightTypeConfig change. This will create a new revision of the config.
3884///
3885/// A builder for the *locations.insightTypes.updateConfig* method supported by a *billingAccount* resource.
3886/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3887///
3888/// # Example
3889///
3890/// Instantiate a resource method builder
3891///
3892/// ```test_harness,no_run
3893/// # extern crate hyper;
3894/// # extern crate hyper_rustls;
3895/// # extern crate google_recommender1_beta1 as recommender1_beta1;
3896/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1InsightTypeConfig;
3897/// # async fn dox() {
3898/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3899///
3900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3901/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3902/// # .with_native_roots()
3903/// # .unwrap()
3904/// # .https_only()
3905/// # .enable_http2()
3906/// # .build();
3907///
3908/// # let executor = hyper_util::rt::TokioExecutor::new();
3909/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3910/// # secret,
3911/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3912/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3913/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3914/// # ),
3915/// # ).build().await.unwrap();
3916///
3917/// # let client = hyper_util::client::legacy::Client::builder(
3918/// # hyper_util::rt::TokioExecutor::new()
3919/// # )
3920/// # .build(
3921/// # hyper_rustls::HttpsConnectorBuilder::new()
3922/// # .with_native_roots()
3923/// # .unwrap()
3924/// # .https_or_http()
3925/// # .enable_http2()
3926/// # .build()
3927/// # );
3928/// # let mut hub = Recommender::new(client, auth);
3929/// // As the method needs a request, you would usually fill it with the desired information
3930/// // into the respective structure. Some of the parts shown here might not be applicable !
3931/// // Values shown here are possibly random and not representative !
3932/// let mut req = GoogleCloudRecommenderV1beta1InsightTypeConfig::default();
3933///
3934/// // You can configure optional parameters by calling the respective setters at will, and
3935/// // execute the final call using `doit()`.
3936/// // Values shown here are possibly random and not representative !
3937/// let result = hub.billing_accounts().locations_insight_types_update_config(req, "name")
3938/// .validate_only(true)
3939/// .update_mask(FieldMask::new::<&str>(&[]))
3940/// .doit().await;
3941/// # }
3942/// ```
3943pub struct BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
3944where
3945 C: 'a,
3946{
3947 hub: &'a Recommender<C>,
3948 _request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
3949 _name: String,
3950 _validate_only: Option<bool>,
3951 _update_mask: Option<common::FieldMask>,
3952 _delegate: Option<&'a mut dyn common::Delegate>,
3953 _additional_params: HashMap<String, String>,
3954 _scopes: BTreeSet<String>,
3955}
3956
3957impl<'a, C> common::CallBuilder for BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {}
3958
3959impl<'a, C> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
3960where
3961 C: common::Connector,
3962{
3963 /// Perform the operation you have build so far.
3964 pub async fn doit(
3965 mut self,
3966 ) -> common::Result<(
3967 common::Response,
3968 GoogleCloudRecommenderV1beta1InsightTypeConfig,
3969 )> {
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.insightTypes.updateConfig",
3980 http_method: hyper::Method::PATCH,
3981 });
3982
3983 for &field in ["alt", "name", "validateOnly", "updateMask"].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(6 + self._additional_params.len());
3991 params.push("name", self._name);
3992 if let Some(value) = self._validate_only.as_ref() {
3993 params.push("validateOnly", value.to_string());
3994 }
3995 if let Some(value) = self._update_mask.as_ref() {
3996 params.push("updateMask", value.to_string());
3997 }
3998
3999 params.extend(self._additional_params.iter());
4000
4001 params.push("alt", "json");
4002 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4003 if self._scopes.is_empty() {
4004 self._scopes
4005 .insert(Scope::CloudPlatform.as_ref().to_string());
4006 }
4007
4008 #[allow(clippy::single_element_loop)]
4009 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4010 url = params.uri_replacement(url, param_name, find_this, true);
4011 }
4012 {
4013 let to_remove = ["name"];
4014 params.remove_params(&to_remove);
4015 }
4016
4017 let url = params.parse_with_url(&url);
4018
4019 let mut json_mime_type = mime::APPLICATION_JSON;
4020 let mut request_value_reader = {
4021 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4022 common::remove_json_null_values(&mut value);
4023 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4024 serde_json::to_writer(&mut dst, &value).unwrap();
4025 dst
4026 };
4027 let request_size = request_value_reader
4028 .seek(std::io::SeekFrom::End(0))
4029 .unwrap();
4030 request_value_reader
4031 .seek(std::io::SeekFrom::Start(0))
4032 .unwrap();
4033
4034 loop {
4035 let token = match self
4036 .hub
4037 .auth
4038 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4039 .await
4040 {
4041 Ok(token) => token,
4042 Err(e) => match dlg.token(e) {
4043 Ok(token) => token,
4044 Err(e) => {
4045 dlg.finished(false);
4046 return Err(common::Error::MissingToken(e));
4047 }
4048 },
4049 };
4050 request_value_reader
4051 .seek(std::io::SeekFrom::Start(0))
4052 .unwrap();
4053 let mut req_result = {
4054 let client = &self.hub.client;
4055 dlg.pre_request();
4056 let mut req_builder = hyper::Request::builder()
4057 .method(hyper::Method::PATCH)
4058 .uri(url.as_str())
4059 .header(USER_AGENT, self.hub._user_agent.clone());
4060
4061 if let Some(token) = token.as_ref() {
4062 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4063 }
4064
4065 let request = req_builder
4066 .header(CONTENT_TYPE, json_mime_type.to_string())
4067 .header(CONTENT_LENGTH, request_size as u64)
4068 .body(common::to_body(
4069 request_value_reader.get_ref().clone().into(),
4070 ));
4071
4072 client.request(request.unwrap()).await
4073 };
4074
4075 match req_result {
4076 Err(err) => {
4077 if let common::Retry::After(d) = dlg.http_error(&err) {
4078 sleep(d).await;
4079 continue;
4080 }
4081 dlg.finished(false);
4082 return Err(common::Error::HttpError(err));
4083 }
4084 Ok(res) => {
4085 let (mut parts, body) = res.into_parts();
4086 let mut body = common::Body::new(body);
4087 if !parts.status.is_success() {
4088 let bytes = common::to_bytes(body).await.unwrap_or_default();
4089 let error = serde_json::from_str(&common::to_string(&bytes));
4090 let response = common::to_response(parts, bytes.into());
4091
4092 if let common::Retry::After(d) =
4093 dlg.http_failure(&response, error.as_ref().ok())
4094 {
4095 sleep(d).await;
4096 continue;
4097 }
4098
4099 dlg.finished(false);
4100
4101 return Err(match error {
4102 Ok(value) => common::Error::BadRequest(value),
4103 _ => common::Error::Failure(response),
4104 });
4105 }
4106 let response = {
4107 let bytes = common::to_bytes(body).await.unwrap_or_default();
4108 let encoded = common::to_string(&bytes);
4109 match serde_json::from_str(&encoded) {
4110 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4111 Err(error) => {
4112 dlg.response_json_decode_error(&encoded, &error);
4113 return Err(common::Error::JsonDecodeError(
4114 encoded.to_string(),
4115 error,
4116 ));
4117 }
4118 }
4119 };
4120
4121 dlg.finished(true);
4122 return Ok(response);
4123 }
4124 }
4125 }
4126 }
4127
4128 ///
4129 /// Sets the *request* property to the given value.
4130 ///
4131 /// Even though the property as already been set when instantiating this call,
4132 /// we provide this method for API completeness.
4133 pub fn request(
4134 mut self,
4135 new_value: GoogleCloudRecommenderV1beta1InsightTypeConfig,
4136 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
4137 self._request = new_value;
4138 self
4139 }
4140 /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
4141 ///
4142 /// Sets the *name* path property to the given value.
4143 ///
4144 /// Even though the property as already been set when instantiating this call,
4145 /// we provide this method for API completeness.
4146 pub fn name(
4147 mut self,
4148 new_value: &str,
4149 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
4150 self._name = new_value.to_string();
4151 self
4152 }
4153 /// If true, validate the request and preview the change, but do not actually update it.
4154 ///
4155 /// Sets the *validate only* query property to the given value.
4156 pub fn validate_only(
4157 mut self,
4158 new_value: bool,
4159 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
4160 self._validate_only = Some(new_value);
4161 self
4162 }
4163 /// The list of fields to be updated.
4164 ///
4165 /// Sets the *update mask* query property to the given value.
4166 pub fn update_mask(
4167 mut self,
4168 new_value: common::FieldMask,
4169 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
4170 self._update_mask = Some(new_value);
4171 self
4172 }
4173 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4174 /// while executing the actual API request.
4175 ///
4176 /// ````text
4177 /// It should be used to handle progress information, and to implement a certain level of resilience.
4178 /// ````
4179 ///
4180 /// Sets the *delegate* property to the given value.
4181 pub fn delegate(
4182 mut self,
4183 new_value: &'a mut dyn common::Delegate,
4184 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
4185 self._delegate = Some(new_value);
4186 self
4187 }
4188
4189 /// Set any additional parameter of the query string used in the request.
4190 /// It should be used to set parameters which are not yet available through their own
4191 /// setters.
4192 ///
4193 /// Please note that this method must not be used to set any of the known parameters
4194 /// which have their own setter method. If done anyway, the request will fail.
4195 ///
4196 /// # Additional Parameters
4197 ///
4198 /// * *$.xgafv* (query-string) - V1 error format.
4199 /// * *access_token* (query-string) - OAuth access token.
4200 /// * *alt* (query-string) - Data format for response.
4201 /// * *callback* (query-string) - JSONP
4202 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4203 /// * *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.
4204 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4205 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4206 /// * *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.
4207 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4208 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4209 pub fn param<T>(
4210 mut self,
4211 name: T,
4212 value: T,
4213 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
4214 where
4215 T: AsRef<str>,
4216 {
4217 self._additional_params
4218 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4219 self
4220 }
4221
4222 /// Identifies the authorization scope for the method you are building.
4223 ///
4224 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4225 /// [`Scope::CloudPlatform`].
4226 ///
4227 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4228 /// tokens for more than one scope.
4229 ///
4230 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4231 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4232 /// sufficient, a read-write scope will do as well.
4233 pub fn add_scope<St>(
4234 mut self,
4235 scope: St,
4236 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
4237 where
4238 St: AsRef<str>,
4239 {
4240 self._scopes.insert(String::from(scope.as_ref()));
4241 self
4242 }
4243 /// Identifies the authorization scope(s) for the method you are building.
4244 ///
4245 /// See [`Self::add_scope()`] for details.
4246 pub fn add_scopes<I, St>(
4247 mut self,
4248 scopes: I,
4249 ) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C>
4250 where
4251 I: IntoIterator<Item = St>,
4252 St: AsRef<str>,
4253 {
4254 self._scopes
4255 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4256 self
4257 }
4258
4259 /// Removes all scopes, and no default scope will be used either.
4260 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4261 /// for details).
4262 pub fn clear_scopes(mut self) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, C> {
4263 self._scopes.clear();
4264 self
4265 }
4266}
4267
4268/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
4269///
4270/// A builder for the *locations.recommenders.recommendations.get* method supported by a *billingAccount* resource.
4271/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4272///
4273/// # Example
4274///
4275/// Instantiate a resource method builder
4276///
4277/// ```test_harness,no_run
4278/// # extern crate hyper;
4279/// # extern crate hyper_rustls;
4280/// # extern crate google_recommender1_beta1 as recommender1_beta1;
4281/// # async fn dox() {
4282/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4283///
4284/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4285/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4286/// # .with_native_roots()
4287/// # .unwrap()
4288/// # .https_only()
4289/// # .enable_http2()
4290/// # .build();
4291///
4292/// # let executor = hyper_util::rt::TokioExecutor::new();
4293/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4294/// # secret,
4295/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4296/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4297/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4298/// # ),
4299/// # ).build().await.unwrap();
4300///
4301/// # let client = hyper_util::client::legacy::Client::builder(
4302/// # hyper_util::rt::TokioExecutor::new()
4303/// # )
4304/// # .build(
4305/// # hyper_rustls::HttpsConnectorBuilder::new()
4306/// # .with_native_roots()
4307/// # .unwrap()
4308/// # .https_or_http()
4309/// # .enable_http2()
4310/// # .build()
4311/// # );
4312/// # let mut hub = Recommender::new(client, auth);
4313/// // You can configure optional parameters by calling the respective setters at will, and
4314/// // execute the final call using `doit()`.
4315/// // Values shown here are possibly random and not representative !
4316/// let result = hub.billing_accounts().locations_recommenders_recommendations_get("name")
4317/// .doit().await;
4318/// # }
4319/// ```
4320pub struct BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4321where
4322 C: 'a,
4323{
4324 hub: &'a Recommender<C>,
4325 _name: String,
4326 _delegate: Option<&'a mut dyn common::Delegate>,
4327 _additional_params: HashMap<String, String>,
4328 _scopes: BTreeSet<String>,
4329}
4330
4331impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {}
4332
4333impl<'a, C> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4334where
4335 C: common::Connector,
4336{
4337 /// Perform the operation you have build so far.
4338 pub async fn doit(
4339 mut self,
4340 ) -> common::Result<(
4341 common::Response,
4342 GoogleCloudRecommenderV1beta1Recommendation,
4343 )> {
4344 use std::borrow::Cow;
4345 use std::io::{Read, Seek};
4346
4347 use common::{url::Params, ToParts};
4348 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4349
4350 let mut dd = common::DefaultDelegate;
4351 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4352 dlg.begin(common::MethodInfo {
4353 id: "recommender.billingAccounts.locations.recommenders.recommendations.get",
4354 http_method: hyper::Method::GET,
4355 });
4356
4357 for &field in ["alt", "name"].iter() {
4358 if self._additional_params.contains_key(field) {
4359 dlg.finished(false);
4360 return Err(common::Error::FieldClash(field));
4361 }
4362 }
4363
4364 let mut params = Params::with_capacity(3 + self._additional_params.len());
4365 params.push("name", self._name);
4366
4367 params.extend(self._additional_params.iter());
4368
4369 params.push("alt", "json");
4370 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4371 if self._scopes.is_empty() {
4372 self._scopes
4373 .insert(Scope::CloudPlatform.as_ref().to_string());
4374 }
4375
4376 #[allow(clippy::single_element_loop)]
4377 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4378 url = params.uri_replacement(url, param_name, find_this, true);
4379 }
4380 {
4381 let to_remove = ["name"];
4382 params.remove_params(&to_remove);
4383 }
4384
4385 let url = params.parse_with_url(&url);
4386
4387 loop {
4388 let token = match self
4389 .hub
4390 .auth
4391 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4392 .await
4393 {
4394 Ok(token) => token,
4395 Err(e) => match dlg.token(e) {
4396 Ok(token) => token,
4397 Err(e) => {
4398 dlg.finished(false);
4399 return Err(common::Error::MissingToken(e));
4400 }
4401 },
4402 };
4403 let mut req_result = {
4404 let client = &self.hub.client;
4405 dlg.pre_request();
4406 let mut req_builder = hyper::Request::builder()
4407 .method(hyper::Method::GET)
4408 .uri(url.as_str())
4409 .header(USER_AGENT, self.hub._user_agent.clone());
4410
4411 if let Some(token) = token.as_ref() {
4412 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4413 }
4414
4415 let request = req_builder
4416 .header(CONTENT_LENGTH, 0_u64)
4417 .body(common::to_body::<String>(None));
4418
4419 client.request(request.unwrap()).await
4420 };
4421
4422 match req_result {
4423 Err(err) => {
4424 if let common::Retry::After(d) = dlg.http_error(&err) {
4425 sleep(d).await;
4426 continue;
4427 }
4428 dlg.finished(false);
4429 return Err(common::Error::HttpError(err));
4430 }
4431 Ok(res) => {
4432 let (mut parts, body) = res.into_parts();
4433 let mut body = common::Body::new(body);
4434 if !parts.status.is_success() {
4435 let bytes = common::to_bytes(body).await.unwrap_or_default();
4436 let error = serde_json::from_str(&common::to_string(&bytes));
4437 let response = common::to_response(parts, bytes.into());
4438
4439 if let common::Retry::After(d) =
4440 dlg.http_failure(&response, error.as_ref().ok())
4441 {
4442 sleep(d).await;
4443 continue;
4444 }
4445
4446 dlg.finished(false);
4447
4448 return Err(match error {
4449 Ok(value) => common::Error::BadRequest(value),
4450 _ => common::Error::Failure(response),
4451 });
4452 }
4453 let response = {
4454 let bytes = common::to_bytes(body).await.unwrap_or_default();
4455 let encoded = common::to_string(&bytes);
4456 match serde_json::from_str(&encoded) {
4457 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4458 Err(error) => {
4459 dlg.response_json_decode_error(&encoded, &error);
4460 return Err(common::Error::JsonDecodeError(
4461 encoded.to_string(),
4462 error,
4463 ));
4464 }
4465 }
4466 };
4467
4468 dlg.finished(true);
4469 return Ok(response);
4470 }
4471 }
4472 }
4473 }
4474
4475 /// Required. Name of the recommendation.
4476 ///
4477 /// Sets the *name* path property to the given value.
4478 ///
4479 /// Even though the property as already been set when instantiating this call,
4480 /// we provide this method for API completeness.
4481 pub fn name(
4482 mut self,
4483 new_value: &str,
4484 ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
4485 self._name = new_value.to_string();
4486 self
4487 }
4488 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4489 /// while executing the actual API request.
4490 ///
4491 /// ````text
4492 /// It should be used to handle progress information, and to implement a certain level of resilience.
4493 /// ````
4494 ///
4495 /// Sets the *delegate* property to the given value.
4496 pub fn delegate(
4497 mut self,
4498 new_value: &'a mut dyn common::Delegate,
4499 ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
4500 self._delegate = Some(new_value);
4501 self
4502 }
4503
4504 /// Set any additional parameter of the query string used in the request.
4505 /// It should be used to set parameters which are not yet available through their own
4506 /// setters.
4507 ///
4508 /// Please note that this method must not be used to set any of the known parameters
4509 /// which have their own setter method. If done anyway, the request will fail.
4510 ///
4511 /// # Additional Parameters
4512 ///
4513 /// * *$.xgafv* (query-string) - V1 error format.
4514 /// * *access_token* (query-string) - OAuth access token.
4515 /// * *alt* (query-string) - Data format for response.
4516 /// * *callback* (query-string) - JSONP
4517 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4518 /// * *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.
4519 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4520 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4521 /// * *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.
4522 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4523 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4524 pub fn param<T>(
4525 mut self,
4526 name: T,
4527 value: T,
4528 ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4529 where
4530 T: AsRef<str>,
4531 {
4532 self._additional_params
4533 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4534 self
4535 }
4536
4537 /// Identifies the authorization scope for the method you are building.
4538 ///
4539 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4540 /// [`Scope::CloudPlatform`].
4541 ///
4542 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4543 /// tokens for more than one scope.
4544 ///
4545 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4546 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4547 /// sufficient, a read-write scope will do as well.
4548 pub fn add_scope<St>(
4549 mut self,
4550 scope: St,
4551 ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4552 where
4553 St: AsRef<str>,
4554 {
4555 self._scopes.insert(String::from(scope.as_ref()));
4556 self
4557 }
4558 /// Identifies the authorization scope(s) for the method you are building.
4559 ///
4560 /// See [`Self::add_scope()`] for details.
4561 pub fn add_scopes<I, St>(
4562 mut self,
4563 scopes: I,
4564 ) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C>
4565 where
4566 I: IntoIterator<Item = St>,
4567 St: AsRef<str>,
4568 {
4569 self._scopes
4570 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4571 self
4572 }
4573
4574 /// Removes all scopes, and no default scope will be used either.
4575 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4576 /// for details).
4577 pub fn clear_scopes(mut self) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, C> {
4578 self._scopes.clear();
4579 self
4580 }
4581}
4582
4583/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
4584///
4585/// A builder for the *locations.recommenders.recommendations.list* method supported by a *billingAccount* resource.
4586/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4587///
4588/// # Example
4589///
4590/// Instantiate a resource method builder
4591///
4592/// ```test_harness,no_run
4593/// # extern crate hyper;
4594/// # extern crate hyper_rustls;
4595/// # extern crate google_recommender1_beta1 as recommender1_beta1;
4596/// # async fn dox() {
4597/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4598///
4599/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4600/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4601/// # .with_native_roots()
4602/// # .unwrap()
4603/// # .https_only()
4604/// # .enable_http2()
4605/// # .build();
4606///
4607/// # let executor = hyper_util::rt::TokioExecutor::new();
4608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4609/// # secret,
4610/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4611/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4612/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4613/// # ),
4614/// # ).build().await.unwrap();
4615///
4616/// # let client = hyper_util::client::legacy::Client::builder(
4617/// # hyper_util::rt::TokioExecutor::new()
4618/// # )
4619/// # .build(
4620/// # hyper_rustls::HttpsConnectorBuilder::new()
4621/// # .with_native_roots()
4622/// # .unwrap()
4623/// # .https_or_http()
4624/// # .enable_http2()
4625/// # .build()
4626/// # );
4627/// # let mut hub = Recommender::new(client, auth);
4628/// // You can configure optional parameters by calling the respective setters at will, and
4629/// // execute the final call using `doit()`.
4630/// // Values shown here are possibly random and not representative !
4631/// let result = hub.billing_accounts().locations_recommenders_recommendations_list("parent")
4632/// .page_token("gubergren")
4633/// .page_size(-75)
4634/// .filter("dolor")
4635/// .doit().await;
4636/// # }
4637/// ```
4638pub struct BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4639where
4640 C: 'a,
4641{
4642 hub: &'a Recommender<C>,
4643 _parent: String,
4644 _page_token: Option<String>,
4645 _page_size: Option<i32>,
4646 _filter: Option<String>,
4647 _delegate: Option<&'a mut dyn common::Delegate>,
4648 _additional_params: HashMap<String, String>,
4649 _scopes: BTreeSet<String>,
4650}
4651
4652impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderRecommendationListCall<'a, C> {}
4653
4654impl<'a, C> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4655where
4656 C: common::Connector,
4657{
4658 /// Perform the operation you have build so far.
4659 pub async fn doit(
4660 mut self,
4661 ) -> common::Result<(
4662 common::Response,
4663 GoogleCloudRecommenderV1beta1ListRecommendationsResponse,
4664 )> {
4665 use std::borrow::Cow;
4666 use std::io::{Read, Seek};
4667
4668 use common::{url::Params, ToParts};
4669 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4670
4671 let mut dd = common::DefaultDelegate;
4672 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4673 dlg.begin(common::MethodInfo {
4674 id: "recommender.billingAccounts.locations.recommenders.recommendations.list",
4675 http_method: hyper::Method::GET,
4676 });
4677
4678 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
4679 if self._additional_params.contains_key(field) {
4680 dlg.finished(false);
4681 return Err(common::Error::FieldClash(field));
4682 }
4683 }
4684
4685 let mut params = Params::with_capacity(6 + self._additional_params.len());
4686 params.push("parent", self._parent);
4687 if let Some(value) = self._page_token.as_ref() {
4688 params.push("pageToken", value);
4689 }
4690 if let Some(value) = self._page_size.as_ref() {
4691 params.push("pageSize", value.to_string());
4692 }
4693 if let Some(value) = self._filter.as_ref() {
4694 params.push("filter", value);
4695 }
4696
4697 params.extend(self._additional_params.iter());
4698
4699 params.push("alt", "json");
4700 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/recommendations";
4701 if self._scopes.is_empty() {
4702 self._scopes
4703 .insert(Scope::CloudPlatform.as_ref().to_string());
4704 }
4705
4706 #[allow(clippy::single_element_loop)]
4707 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4708 url = params.uri_replacement(url, param_name, find_this, true);
4709 }
4710 {
4711 let to_remove = ["parent"];
4712 params.remove_params(&to_remove);
4713 }
4714
4715 let url = params.parse_with_url(&url);
4716
4717 loop {
4718 let token = match self
4719 .hub
4720 .auth
4721 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4722 .await
4723 {
4724 Ok(token) => token,
4725 Err(e) => match dlg.token(e) {
4726 Ok(token) => token,
4727 Err(e) => {
4728 dlg.finished(false);
4729 return Err(common::Error::MissingToken(e));
4730 }
4731 },
4732 };
4733 let mut req_result = {
4734 let client = &self.hub.client;
4735 dlg.pre_request();
4736 let mut req_builder = hyper::Request::builder()
4737 .method(hyper::Method::GET)
4738 .uri(url.as_str())
4739 .header(USER_AGENT, self.hub._user_agent.clone());
4740
4741 if let Some(token) = token.as_ref() {
4742 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4743 }
4744
4745 let request = req_builder
4746 .header(CONTENT_LENGTH, 0_u64)
4747 .body(common::to_body::<String>(None));
4748
4749 client.request(request.unwrap()).await
4750 };
4751
4752 match req_result {
4753 Err(err) => {
4754 if let common::Retry::After(d) = dlg.http_error(&err) {
4755 sleep(d).await;
4756 continue;
4757 }
4758 dlg.finished(false);
4759 return Err(common::Error::HttpError(err));
4760 }
4761 Ok(res) => {
4762 let (mut parts, body) = res.into_parts();
4763 let mut body = common::Body::new(body);
4764 if !parts.status.is_success() {
4765 let bytes = common::to_bytes(body).await.unwrap_or_default();
4766 let error = serde_json::from_str(&common::to_string(&bytes));
4767 let response = common::to_response(parts, bytes.into());
4768
4769 if let common::Retry::After(d) =
4770 dlg.http_failure(&response, error.as_ref().ok())
4771 {
4772 sleep(d).await;
4773 continue;
4774 }
4775
4776 dlg.finished(false);
4777
4778 return Err(match error {
4779 Ok(value) => common::Error::BadRequest(value),
4780 _ => common::Error::Failure(response),
4781 });
4782 }
4783 let response = {
4784 let bytes = common::to_bytes(body).await.unwrap_or_default();
4785 let encoded = common::to_string(&bytes);
4786 match serde_json::from_str(&encoded) {
4787 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4788 Err(error) => {
4789 dlg.response_json_decode_error(&encoded, &error);
4790 return Err(common::Error::JsonDecodeError(
4791 encoded.to_string(),
4792 error,
4793 ));
4794 }
4795 }
4796 };
4797
4798 dlg.finished(true);
4799 return Ok(response);
4800 }
4801 }
4802 }
4803 }
4804
4805 /// 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.
4806 ///
4807 /// Sets the *parent* path 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 parent(
4812 mut self,
4813 new_value: &str,
4814 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4815 self._parent = new_value.to_string();
4816 self
4817 }
4818 /// 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.
4819 ///
4820 /// Sets the *page token* query property to the given value.
4821 pub fn page_token(
4822 mut self,
4823 new_value: &str,
4824 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4825 self._page_token = Some(new_value.to_string());
4826 self
4827 }
4828 /// 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.
4829 ///
4830 /// Sets the *page size* query property to the given value.
4831 pub fn page_size(
4832 mut self,
4833 new_value: i32,
4834 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4835 self._page_size = Some(new_value);
4836 self
4837 }
4838 /// 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)
4839 ///
4840 /// Sets the *filter* query property to the given value.
4841 pub fn filter(
4842 mut self,
4843 new_value: &str,
4844 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4845 self._filter = Some(new_value.to_string());
4846 self
4847 }
4848 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4849 /// while executing the actual API request.
4850 ///
4851 /// ````text
4852 /// It should be used to handle progress information, and to implement a certain level of resilience.
4853 /// ````
4854 ///
4855 /// Sets the *delegate* property to the given value.
4856 pub fn delegate(
4857 mut self,
4858 new_value: &'a mut dyn common::Delegate,
4859 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4860 self._delegate = Some(new_value);
4861 self
4862 }
4863
4864 /// Set any additional parameter of the query string used in the request.
4865 /// It should be used to set parameters which are not yet available through their own
4866 /// setters.
4867 ///
4868 /// Please note that this method must not be used to set any of the known parameters
4869 /// which have their own setter method. If done anyway, the request will fail.
4870 ///
4871 /// # Additional Parameters
4872 ///
4873 /// * *$.xgafv* (query-string) - V1 error format.
4874 /// * *access_token* (query-string) - OAuth access token.
4875 /// * *alt* (query-string) - Data format for response.
4876 /// * *callback* (query-string) - JSONP
4877 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4878 /// * *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.
4879 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4880 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4881 /// * *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.
4882 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4883 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4884 pub fn param<T>(
4885 mut self,
4886 name: T,
4887 value: T,
4888 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4889 where
4890 T: AsRef<str>,
4891 {
4892 self._additional_params
4893 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4894 self
4895 }
4896
4897 /// Identifies the authorization scope for the method you are building.
4898 ///
4899 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4900 /// [`Scope::CloudPlatform`].
4901 ///
4902 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4903 /// tokens for more than one scope.
4904 ///
4905 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4906 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4907 /// sufficient, a read-write scope will do as well.
4908 pub fn add_scope<St>(
4909 mut self,
4910 scope: St,
4911 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4912 where
4913 St: AsRef<str>,
4914 {
4915 self._scopes.insert(String::from(scope.as_ref()));
4916 self
4917 }
4918 /// Identifies the authorization scope(s) for the method you are building.
4919 ///
4920 /// See [`Self::add_scope()`] for details.
4921 pub fn add_scopes<I, St>(
4922 mut self,
4923 scopes: I,
4924 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C>
4925 where
4926 I: IntoIterator<Item = St>,
4927 St: AsRef<str>,
4928 {
4929 self._scopes
4930 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4931 self
4932 }
4933
4934 /// Removes all scopes, and no default scope will be used either.
4935 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4936 /// for details).
4937 pub fn clear_scopes(
4938 mut self,
4939 ) -> BillingAccountLocationRecommenderRecommendationListCall<'a, C> {
4940 self._scopes.clear();
4941 self
4942 }
4943}
4944
4945/// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
4946///
4947/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *billingAccount* resource.
4948/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4949///
4950/// # Example
4951///
4952/// Instantiate a resource method builder
4953///
4954/// ```test_harness,no_run
4955/// # extern crate hyper;
4956/// # extern crate hyper_rustls;
4957/// # extern crate google_recommender1_beta1 as recommender1_beta1;
4958/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
4959/// # async fn dox() {
4960/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4961///
4962/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4963/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4964/// # .with_native_roots()
4965/// # .unwrap()
4966/// # .https_only()
4967/// # .enable_http2()
4968/// # .build();
4969///
4970/// # let executor = hyper_util::rt::TokioExecutor::new();
4971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4972/// # secret,
4973/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4974/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4975/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4976/// # ),
4977/// # ).build().await.unwrap();
4978///
4979/// # let client = hyper_util::client::legacy::Client::builder(
4980/// # hyper_util::rt::TokioExecutor::new()
4981/// # )
4982/// # .build(
4983/// # hyper_rustls::HttpsConnectorBuilder::new()
4984/// # .with_native_roots()
4985/// # .unwrap()
4986/// # .https_or_http()
4987/// # .enable_http2()
4988/// # .build()
4989/// # );
4990/// # let mut hub = Recommender::new(client, auth);
4991/// // As the method needs a request, you would usually fill it with the desired information
4992/// // into the respective structure. Some of the parts shown here might not be applicable !
4993/// // Values shown here are possibly random and not representative !
4994/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::default();
4995///
4996/// // You can configure optional parameters by calling the respective setters at will, and
4997/// // execute the final call using `doit()`.
4998/// // Values shown here are possibly random and not representative !
4999/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_claimed(req, "name")
5000/// .doit().await;
5001/// # }
5002/// ```
5003pub struct BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
5004where
5005 C: 'a,
5006{
5007 hub: &'a Recommender<C>,
5008 _request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
5009 _name: String,
5010 _delegate: Option<&'a mut dyn common::Delegate>,
5011 _additional_params: HashMap<String, String>,
5012 _scopes: BTreeSet<String>,
5013}
5014
5015impl<'a, C> common::CallBuilder
5016 for BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
5017{
5018}
5019
5020impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
5021where
5022 C: common::Connector,
5023{
5024 /// Perform the operation you have build so far.
5025 pub async fn doit(
5026 mut self,
5027 ) -> common::Result<(
5028 common::Response,
5029 GoogleCloudRecommenderV1beta1Recommendation,
5030 )> {
5031 use std::borrow::Cow;
5032 use std::io::{Read, Seek};
5033
5034 use common::{url::Params, ToParts};
5035 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5036
5037 let mut dd = common::DefaultDelegate;
5038 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5039 dlg.begin(common::MethodInfo {
5040 id: "recommender.billingAccounts.locations.recommenders.recommendations.markClaimed",
5041 http_method: hyper::Method::POST,
5042 });
5043
5044 for &field in ["alt", "name"].iter() {
5045 if self._additional_params.contains_key(field) {
5046 dlg.finished(false);
5047 return Err(common::Error::FieldClash(field));
5048 }
5049 }
5050
5051 let mut params = Params::with_capacity(4 + self._additional_params.len());
5052 params.push("name", self._name);
5053
5054 params.extend(self._additional_params.iter());
5055
5056 params.push("alt", "json");
5057 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markClaimed";
5058 if self._scopes.is_empty() {
5059 self._scopes
5060 .insert(Scope::CloudPlatform.as_ref().to_string());
5061 }
5062
5063 #[allow(clippy::single_element_loop)]
5064 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5065 url = params.uri_replacement(url, param_name, find_this, true);
5066 }
5067 {
5068 let to_remove = ["name"];
5069 params.remove_params(&to_remove);
5070 }
5071
5072 let url = params.parse_with_url(&url);
5073
5074 let mut json_mime_type = mime::APPLICATION_JSON;
5075 let mut request_value_reader = {
5076 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5077 common::remove_json_null_values(&mut value);
5078 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5079 serde_json::to_writer(&mut dst, &value).unwrap();
5080 dst
5081 };
5082 let request_size = request_value_reader
5083 .seek(std::io::SeekFrom::End(0))
5084 .unwrap();
5085 request_value_reader
5086 .seek(std::io::SeekFrom::Start(0))
5087 .unwrap();
5088
5089 loop {
5090 let token = match self
5091 .hub
5092 .auth
5093 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5094 .await
5095 {
5096 Ok(token) => token,
5097 Err(e) => match dlg.token(e) {
5098 Ok(token) => token,
5099 Err(e) => {
5100 dlg.finished(false);
5101 return Err(common::Error::MissingToken(e));
5102 }
5103 },
5104 };
5105 request_value_reader
5106 .seek(std::io::SeekFrom::Start(0))
5107 .unwrap();
5108 let mut req_result = {
5109 let client = &self.hub.client;
5110 dlg.pre_request();
5111 let mut req_builder = hyper::Request::builder()
5112 .method(hyper::Method::POST)
5113 .uri(url.as_str())
5114 .header(USER_AGENT, self.hub._user_agent.clone());
5115
5116 if let Some(token) = token.as_ref() {
5117 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5118 }
5119
5120 let request = req_builder
5121 .header(CONTENT_TYPE, json_mime_type.to_string())
5122 .header(CONTENT_LENGTH, request_size as u64)
5123 .body(common::to_body(
5124 request_value_reader.get_ref().clone().into(),
5125 ));
5126
5127 client.request(request.unwrap()).await
5128 };
5129
5130 match req_result {
5131 Err(err) => {
5132 if let common::Retry::After(d) = dlg.http_error(&err) {
5133 sleep(d).await;
5134 continue;
5135 }
5136 dlg.finished(false);
5137 return Err(common::Error::HttpError(err));
5138 }
5139 Ok(res) => {
5140 let (mut parts, body) = res.into_parts();
5141 let mut body = common::Body::new(body);
5142 if !parts.status.is_success() {
5143 let bytes = common::to_bytes(body).await.unwrap_or_default();
5144 let error = serde_json::from_str(&common::to_string(&bytes));
5145 let response = common::to_response(parts, bytes.into());
5146
5147 if let common::Retry::After(d) =
5148 dlg.http_failure(&response, error.as_ref().ok())
5149 {
5150 sleep(d).await;
5151 continue;
5152 }
5153
5154 dlg.finished(false);
5155
5156 return Err(match error {
5157 Ok(value) => common::Error::BadRequest(value),
5158 _ => common::Error::Failure(response),
5159 });
5160 }
5161 let response = {
5162 let bytes = common::to_bytes(body).await.unwrap_or_default();
5163 let encoded = common::to_string(&bytes);
5164 match serde_json::from_str(&encoded) {
5165 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5166 Err(error) => {
5167 dlg.response_json_decode_error(&encoded, &error);
5168 return Err(common::Error::JsonDecodeError(
5169 encoded.to_string(),
5170 error,
5171 ));
5172 }
5173 }
5174 };
5175
5176 dlg.finished(true);
5177 return Ok(response);
5178 }
5179 }
5180 }
5181 }
5182
5183 ///
5184 /// Sets the *request* property to the given value.
5185 ///
5186 /// Even though the property as already been set when instantiating this call,
5187 /// we provide this method for API completeness.
5188 pub fn request(
5189 mut self,
5190 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
5191 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
5192 self._request = new_value;
5193 self
5194 }
5195 /// Required. Name of the recommendation.
5196 ///
5197 /// Sets the *name* path property to the given value.
5198 ///
5199 /// Even though the property as already been set when instantiating this call,
5200 /// we provide this method for API completeness.
5201 pub fn name(
5202 mut self,
5203 new_value: &str,
5204 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
5205 self._name = new_value.to_string();
5206 self
5207 }
5208 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5209 /// while executing the actual API request.
5210 ///
5211 /// ````text
5212 /// It should be used to handle progress information, and to implement a certain level of resilience.
5213 /// ````
5214 ///
5215 /// Sets the *delegate* property to the given value.
5216 pub fn delegate(
5217 mut self,
5218 new_value: &'a mut dyn common::Delegate,
5219 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
5220 self._delegate = Some(new_value);
5221 self
5222 }
5223
5224 /// Set any additional parameter of the query string used in the request.
5225 /// It should be used to set parameters which are not yet available through their own
5226 /// setters.
5227 ///
5228 /// Please note that this method must not be used to set any of the known parameters
5229 /// which have their own setter method. If done anyway, the request will fail.
5230 ///
5231 /// # Additional Parameters
5232 ///
5233 /// * *$.xgafv* (query-string) - V1 error format.
5234 /// * *access_token* (query-string) - OAuth access token.
5235 /// * *alt* (query-string) - Data format for response.
5236 /// * *callback* (query-string) - JSONP
5237 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5238 /// * *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.
5239 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5240 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5241 /// * *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.
5242 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5243 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5244 pub fn param<T>(
5245 mut self,
5246 name: T,
5247 value: T,
5248 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
5249 where
5250 T: AsRef<str>,
5251 {
5252 self._additional_params
5253 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5254 self
5255 }
5256
5257 /// Identifies the authorization scope for the method you are building.
5258 ///
5259 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5260 /// [`Scope::CloudPlatform`].
5261 ///
5262 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5263 /// tokens for more than one scope.
5264 ///
5265 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5266 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5267 /// sufficient, a read-write scope will do as well.
5268 pub fn add_scope<St>(
5269 mut self,
5270 scope: St,
5271 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
5272 where
5273 St: AsRef<str>,
5274 {
5275 self._scopes.insert(String::from(scope.as_ref()));
5276 self
5277 }
5278 /// Identifies the authorization scope(s) for the method you are building.
5279 ///
5280 /// See [`Self::add_scope()`] for details.
5281 pub fn add_scopes<I, St>(
5282 mut self,
5283 scopes: I,
5284 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C>
5285 where
5286 I: IntoIterator<Item = St>,
5287 St: AsRef<str>,
5288 {
5289 self._scopes
5290 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5291 self
5292 }
5293
5294 /// Removes all scopes, and no default scope will be used either.
5295 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5296 /// for details).
5297 pub fn clear_scopes(
5298 mut self,
5299 ) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
5300 self._scopes.clear();
5301 self
5302 }
5303}
5304
5305/// 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.
5306///
5307/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *billingAccount* resource.
5308/// It is not used directly, but through a [`BillingAccountMethods`] instance.
5309///
5310/// # Example
5311///
5312/// Instantiate a resource method builder
5313///
5314/// ```test_harness,no_run
5315/// # extern crate hyper;
5316/// # extern crate hyper_rustls;
5317/// # extern crate google_recommender1_beta1 as recommender1_beta1;
5318/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
5319/// # async fn dox() {
5320/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5321///
5322/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5323/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5324/// # .with_native_roots()
5325/// # .unwrap()
5326/// # .https_only()
5327/// # .enable_http2()
5328/// # .build();
5329///
5330/// # let executor = hyper_util::rt::TokioExecutor::new();
5331/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5332/// # secret,
5333/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5334/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5335/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5336/// # ),
5337/// # ).build().await.unwrap();
5338///
5339/// # let client = hyper_util::client::legacy::Client::builder(
5340/// # hyper_util::rt::TokioExecutor::new()
5341/// # )
5342/// # .build(
5343/// # hyper_rustls::HttpsConnectorBuilder::new()
5344/// # .with_native_roots()
5345/// # .unwrap()
5346/// # .https_or_http()
5347/// # .enable_http2()
5348/// # .build()
5349/// # );
5350/// # let mut hub = Recommender::new(client, auth);
5351/// // As the method needs a request, you would usually fill it with the desired information
5352/// // into the respective structure. Some of the parts shown here might not be applicable !
5353/// // Values shown here are possibly random and not representative !
5354/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::default();
5355///
5356/// // You can configure optional parameters by calling the respective setters at will, and
5357/// // execute the final call using `doit()`.
5358/// // Values shown here are possibly random and not representative !
5359/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_dismissed(req, "name")
5360/// .doit().await;
5361/// # }
5362/// ```
5363pub struct BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5364where
5365 C: 'a,
5366{
5367 hub: &'a Recommender<C>,
5368 _request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
5369 _name: String,
5370 _delegate: Option<&'a mut dyn common::Delegate>,
5371 _additional_params: HashMap<String, String>,
5372 _scopes: BTreeSet<String>,
5373}
5374
5375impl<'a, C> common::CallBuilder
5376 for BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5377{
5378}
5379
5380impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5381where
5382 C: common::Connector,
5383{
5384 /// Perform the operation you have build so far.
5385 pub async fn doit(
5386 mut self,
5387 ) -> common::Result<(
5388 common::Response,
5389 GoogleCloudRecommenderV1beta1Recommendation,
5390 )> {
5391 use std::borrow::Cow;
5392 use std::io::{Read, Seek};
5393
5394 use common::{url::Params, ToParts};
5395 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5396
5397 let mut dd = common::DefaultDelegate;
5398 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5399 dlg.begin(common::MethodInfo {
5400 id: "recommender.billingAccounts.locations.recommenders.recommendations.markDismissed",
5401 http_method: hyper::Method::POST,
5402 });
5403
5404 for &field in ["alt", "name"].iter() {
5405 if self._additional_params.contains_key(field) {
5406 dlg.finished(false);
5407 return Err(common::Error::FieldClash(field));
5408 }
5409 }
5410
5411 let mut params = Params::with_capacity(4 + self._additional_params.len());
5412 params.push("name", self._name);
5413
5414 params.extend(self._additional_params.iter());
5415
5416 params.push("alt", "json");
5417 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markDismissed";
5418 if self._scopes.is_empty() {
5419 self._scopes
5420 .insert(Scope::CloudPlatform.as_ref().to_string());
5421 }
5422
5423 #[allow(clippy::single_element_loop)]
5424 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5425 url = params.uri_replacement(url, param_name, find_this, true);
5426 }
5427 {
5428 let to_remove = ["name"];
5429 params.remove_params(&to_remove);
5430 }
5431
5432 let url = params.parse_with_url(&url);
5433
5434 let mut json_mime_type = mime::APPLICATION_JSON;
5435 let mut request_value_reader = {
5436 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5437 common::remove_json_null_values(&mut value);
5438 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5439 serde_json::to_writer(&mut dst, &value).unwrap();
5440 dst
5441 };
5442 let request_size = request_value_reader
5443 .seek(std::io::SeekFrom::End(0))
5444 .unwrap();
5445 request_value_reader
5446 .seek(std::io::SeekFrom::Start(0))
5447 .unwrap();
5448
5449 loop {
5450 let token = match self
5451 .hub
5452 .auth
5453 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5454 .await
5455 {
5456 Ok(token) => token,
5457 Err(e) => match dlg.token(e) {
5458 Ok(token) => token,
5459 Err(e) => {
5460 dlg.finished(false);
5461 return Err(common::Error::MissingToken(e));
5462 }
5463 },
5464 };
5465 request_value_reader
5466 .seek(std::io::SeekFrom::Start(0))
5467 .unwrap();
5468 let mut req_result = {
5469 let client = &self.hub.client;
5470 dlg.pre_request();
5471 let mut req_builder = hyper::Request::builder()
5472 .method(hyper::Method::POST)
5473 .uri(url.as_str())
5474 .header(USER_AGENT, self.hub._user_agent.clone());
5475
5476 if let Some(token) = token.as_ref() {
5477 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5478 }
5479
5480 let request = req_builder
5481 .header(CONTENT_TYPE, json_mime_type.to_string())
5482 .header(CONTENT_LENGTH, request_size as u64)
5483 .body(common::to_body(
5484 request_value_reader.get_ref().clone().into(),
5485 ));
5486
5487 client.request(request.unwrap()).await
5488 };
5489
5490 match req_result {
5491 Err(err) => {
5492 if let common::Retry::After(d) = dlg.http_error(&err) {
5493 sleep(d).await;
5494 continue;
5495 }
5496 dlg.finished(false);
5497 return Err(common::Error::HttpError(err));
5498 }
5499 Ok(res) => {
5500 let (mut parts, body) = res.into_parts();
5501 let mut body = common::Body::new(body);
5502 if !parts.status.is_success() {
5503 let bytes = common::to_bytes(body).await.unwrap_or_default();
5504 let error = serde_json::from_str(&common::to_string(&bytes));
5505 let response = common::to_response(parts, bytes.into());
5506
5507 if let common::Retry::After(d) =
5508 dlg.http_failure(&response, error.as_ref().ok())
5509 {
5510 sleep(d).await;
5511 continue;
5512 }
5513
5514 dlg.finished(false);
5515
5516 return Err(match error {
5517 Ok(value) => common::Error::BadRequest(value),
5518 _ => common::Error::Failure(response),
5519 });
5520 }
5521 let response = {
5522 let bytes = common::to_bytes(body).await.unwrap_or_default();
5523 let encoded = common::to_string(&bytes);
5524 match serde_json::from_str(&encoded) {
5525 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5526 Err(error) => {
5527 dlg.response_json_decode_error(&encoded, &error);
5528 return Err(common::Error::JsonDecodeError(
5529 encoded.to_string(),
5530 error,
5531 ));
5532 }
5533 }
5534 };
5535
5536 dlg.finished(true);
5537 return Ok(response);
5538 }
5539 }
5540 }
5541 }
5542
5543 ///
5544 /// Sets the *request* property to the given value.
5545 ///
5546 /// Even though the property as already been set when instantiating this call,
5547 /// we provide this method for API completeness.
5548 pub fn request(
5549 mut self,
5550 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
5551 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5552 self._request = new_value;
5553 self
5554 }
5555 /// Required. Name of the recommendation.
5556 ///
5557 /// Sets the *name* path property to the given value.
5558 ///
5559 /// Even though the property as already been set when instantiating this call,
5560 /// we provide this method for API completeness.
5561 pub fn name(
5562 mut self,
5563 new_value: &str,
5564 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5565 self._name = new_value.to_string();
5566 self
5567 }
5568 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5569 /// while executing the actual API request.
5570 ///
5571 /// ````text
5572 /// It should be used to handle progress information, and to implement a certain level of resilience.
5573 /// ````
5574 ///
5575 /// Sets the *delegate* property to the given value.
5576 pub fn delegate(
5577 mut self,
5578 new_value: &'a mut dyn common::Delegate,
5579 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5580 self._delegate = Some(new_value);
5581 self
5582 }
5583
5584 /// Set any additional parameter of the query string used in the request.
5585 /// It should be used to set parameters which are not yet available through their own
5586 /// setters.
5587 ///
5588 /// Please note that this method must not be used to set any of the known parameters
5589 /// which have their own setter method. If done anyway, the request will fail.
5590 ///
5591 /// # Additional Parameters
5592 ///
5593 /// * *$.xgafv* (query-string) - V1 error format.
5594 /// * *access_token* (query-string) - OAuth access token.
5595 /// * *alt* (query-string) - Data format for response.
5596 /// * *callback* (query-string) - JSONP
5597 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5598 /// * *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.
5599 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5600 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5601 /// * *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.
5602 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5603 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5604 pub fn param<T>(
5605 mut self,
5606 name: T,
5607 value: T,
5608 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5609 where
5610 T: AsRef<str>,
5611 {
5612 self._additional_params
5613 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5614 self
5615 }
5616
5617 /// Identifies the authorization scope for the method you are building.
5618 ///
5619 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5620 /// [`Scope::CloudPlatform`].
5621 ///
5622 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5623 /// tokens for more than one scope.
5624 ///
5625 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5626 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5627 /// sufficient, a read-write scope will do as well.
5628 pub fn add_scope<St>(
5629 mut self,
5630 scope: St,
5631 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5632 where
5633 St: AsRef<str>,
5634 {
5635 self._scopes.insert(String::from(scope.as_ref()));
5636 self
5637 }
5638 /// Identifies the authorization scope(s) for the method you are building.
5639 ///
5640 /// See [`Self::add_scope()`] for details.
5641 pub fn add_scopes<I, St>(
5642 mut self,
5643 scopes: I,
5644 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C>
5645 where
5646 I: IntoIterator<Item = St>,
5647 St: AsRef<str>,
5648 {
5649 self._scopes
5650 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5651 self
5652 }
5653
5654 /// Removes all scopes, and no default scope will be used either.
5655 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5656 /// for details).
5657 pub fn clear_scopes(
5658 mut self,
5659 ) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
5660 self._scopes.clear();
5661 self
5662 }
5663}
5664
5665/// 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.
5666///
5667/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *billingAccount* resource.
5668/// It is not used directly, but through a [`BillingAccountMethods`] instance.
5669///
5670/// # Example
5671///
5672/// Instantiate a resource method builder
5673///
5674/// ```test_harness,no_run
5675/// # extern crate hyper;
5676/// # extern crate hyper_rustls;
5677/// # extern crate google_recommender1_beta1 as recommender1_beta1;
5678/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
5679/// # async fn dox() {
5680/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5681///
5682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5683/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5684/// # .with_native_roots()
5685/// # .unwrap()
5686/// # .https_only()
5687/// # .enable_http2()
5688/// # .build();
5689///
5690/// # let executor = hyper_util::rt::TokioExecutor::new();
5691/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5692/// # secret,
5693/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5694/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5695/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5696/// # ),
5697/// # ).build().await.unwrap();
5698///
5699/// # let client = hyper_util::client::legacy::Client::builder(
5700/// # hyper_util::rt::TokioExecutor::new()
5701/// # )
5702/// # .build(
5703/// # hyper_rustls::HttpsConnectorBuilder::new()
5704/// # .with_native_roots()
5705/// # .unwrap()
5706/// # .https_or_http()
5707/// # .enable_http2()
5708/// # .build()
5709/// # );
5710/// # let mut hub = Recommender::new(client, auth);
5711/// // As the method needs a request, you would usually fill it with the desired information
5712/// // into the respective structure. Some of the parts shown here might not be applicable !
5713/// // Values shown here are possibly random and not representative !
5714/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::default();
5715///
5716/// // You can configure optional parameters by calling the respective setters at will, and
5717/// // execute the final call using `doit()`.
5718/// // Values shown here are possibly random and not representative !
5719/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_failed(req, "name")
5720/// .doit().await;
5721/// # }
5722/// ```
5723pub struct BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5724where
5725 C: 'a,
5726{
5727 hub: &'a Recommender<C>,
5728 _request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
5729 _name: String,
5730 _delegate: Option<&'a mut dyn common::Delegate>,
5731 _additional_params: HashMap<String, String>,
5732 _scopes: BTreeSet<String>,
5733}
5734
5735impl<'a, C> common::CallBuilder
5736 for BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5737{
5738}
5739
5740impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5741where
5742 C: common::Connector,
5743{
5744 /// Perform the operation you have build so far.
5745 pub async fn doit(
5746 mut self,
5747 ) -> common::Result<(
5748 common::Response,
5749 GoogleCloudRecommenderV1beta1Recommendation,
5750 )> {
5751 use std::borrow::Cow;
5752 use std::io::{Read, Seek};
5753
5754 use common::{url::Params, ToParts};
5755 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5756
5757 let mut dd = common::DefaultDelegate;
5758 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5759 dlg.begin(common::MethodInfo {
5760 id: "recommender.billingAccounts.locations.recommenders.recommendations.markFailed",
5761 http_method: hyper::Method::POST,
5762 });
5763
5764 for &field in ["alt", "name"].iter() {
5765 if self._additional_params.contains_key(field) {
5766 dlg.finished(false);
5767 return Err(common::Error::FieldClash(field));
5768 }
5769 }
5770
5771 let mut params = Params::with_capacity(4 + self._additional_params.len());
5772 params.push("name", self._name);
5773
5774 params.extend(self._additional_params.iter());
5775
5776 params.push("alt", "json");
5777 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markFailed";
5778 if self._scopes.is_empty() {
5779 self._scopes
5780 .insert(Scope::CloudPlatform.as_ref().to_string());
5781 }
5782
5783 #[allow(clippy::single_element_loop)]
5784 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5785 url = params.uri_replacement(url, param_name, find_this, true);
5786 }
5787 {
5788 let to_remove = ["name"];
5789 params.remove_params(&to_remove);
5790 }
5791
5792 let url = params.parse_with_url(&url);
5793
5794 let mut json_mime_type = mime::APPLICATION_JSON;
5795 let mut request_value_reader = {
5796 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5797 common::remove_json_null_values(&mut value);
5798 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5799 serde_json::to_writer(&mut dst, &value).unwrap();
5800 dst
5801 };
5802 let request_size = request_value_reader
5803 .seek(std::io::SeekFrom::End(0))
5804 .unwrap();
5805 request_value_reader
5806 .seek(std::io::SeekFrom::Start(0))
5807 .unwrap();
5808
5809 loop {
5810 let token = match self
5811 .hub
5812 .auth
5813 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5814 .await
5815 {
5816 Ok(token) => token,
5817 Err(e) => match dlg.token(e) {
5818 Ok(token) => token,
5819 Err(e) => {
5820 dlg.finished(false);
5821 return Err(common::Error::MissingToken(e));
5822 }
5823 },
5824 };
5825 request_value_reader
5826 .seek(std::io::SeekFrom::Start(0))
5827 .unwrap();
5828 let mut req_result = {
5829 let client = &self.hub.client;
5830 dlg.pre_request();
5831 let mut req_builder = hyper::Request::builder()
5832 .method(hyper::Method::POST)
5833 .uri(url.as_str())
5834 .header(USER_AGENT, self.hub._user_agent.clone());
5835
5836 if let Some(token) = token.as_ref() {
5837 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5838 }
5839
5840 let request = req_builder
5841 .header(CONTENT_TYPE, json_mime_type.to_string())
5842 .header(CONTENT_LENGTH, request_size as u64)
5843 .body(common::to_body(
5844 request_value_reader.get_ref().clone().into(),
5845 ));
5846
5847 client.request(request.unwrap()).await
5848 };
5849
5850 match req_result {
5851 Err(err) => {
5852 if let common::Retry::After(d) = dlg.http_error(&err) {
5853 sleep(d).await;
5854 continue;
5855 }
5856 dlg.finished(false);
5857 return Err(common::Error::HttpError(err));
5858 }
5859 Ok(res) => {
5860 let (mut parts, body) = res.into_parts();
5861 let mut body = common::Body::new(body);
5862 if !parts.status.is_success() {
5863 let bytes = common::to_bytes(body).await.unwrap_or_default();
5864 let error = serde_json::from_str(&common::to_string(&bytes));
5865 let response = common::to_response(parts, bytes.into());
5866
5867 if let common::Retry::After(d) =
5868 dlg.http_failure(&response, error.as_ref().ok())
5869 {
5870 sleep(d).await;
5871 continue;
5872 }
5873
5874 dlg.finished(false);
5875
5876 return Err(match error {
5877 Ok(value) => common::Error::BadRequest(value),
5878 _ => common::Error::Failure(response),
5879 });
5880 }
5881 let response = {
5882 let bytes = common::to_bytes(body).await.unwrap_or_default();
5883 let encoded = common::to_string(&bytes);
5884 match serde_json::from_str(&encoded) {
5885 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5886 Err(error) => {
5887 dlg.response_json_decode_error(&encoded, &error);
5888 return Err(common::Error::JsonDecodeError(
5889 encoded.to_string(),
5890 error,
5891 ));
5892 }
5893 }
5894 };
5895
5896 dlg.finished(true);
5897 return Ok(response);
5898 }
5899 }
5900 }
5901 }
5902
5903 ///
5904 /// Sets the *request* property to the given value.
5905 ///
5906 /// Even though the property as already been set when instantiating this call,
5907 /// we provide this method for API completeness.
5908 pub fn request(
5909 mut self,
5910 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
5911 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
5912 self._request = new_value;
5913 self
5914 }
5915 /// Required. Name of the recommendation.
5916 ///
5917 /// Sets the *name* path property to the given value.
5918 ///
5919 /// Even though the property as already been set when instantiating this call,
5920 /// we provide this method for API completeness.
5921 pub fn name(
5922 mut self,
5923 new_value: &str,
5924 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
5925 self._name = new_value.to_string();
5926 self
5927 }
5928 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5929 /// while executing the actual API request.
5930 ///
5931 /// ````text
5932 /// It should be used to handle progress information, and to implement a certain level of resilience.
5933 /// ````
5934 ///
5935 /// Sets the *delegate* property to the given value.
5936 pub fn delegate(
5937 mut self,
5938 new_value: &'a mut dyn common::Delegate,
5939 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
5940 self._delegate = Some(new_value);
5941 self
5942 }
5943
5944 /// Set any additional parameter of the query string used in the request.
5945 /// It should be used to set parameters which are not yet available through their own
5946 /// setters.
5947 ///
5948 /// Please note that this method must not be used to set any of the known parameters
5949 /// which have their own setter method. If done anyway, the request will fail.
5950 ///
5951 /// # Additional Parameters
5952 ///
5953 /// * *$.xgafv* (query-string) - V1 error format.
5954 /// * *access_token* (query-string) - OAuth access token.
5955 /// * *alt* (query-string) - Data format for response.
5956 /// * *callback* (query-string) - JSONP
5957 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5958 /// * *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.
5959 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5960 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5961 /// * *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.
5962 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5963 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5964 pub fn param<T>(
5965 mut self,
5966 name: T,
5967 value: T,
5968 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5969 where
5970 T: AsRef<str>,
5971 {
5972 self._additional_params
5973 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5974 self
5975 }
5976
5977 /// Identifies the authorization scope for the method you are building.
5978 ///
5979 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5980 /// [`Scope::CloudPlatform`].
5981 ///
5982 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5983 /// tokens for more than one scope.
5984 ///
5985 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5986 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5987 /// sufficient, a read-write scope will do as well.
5988 pub fn add_scope<St>(
5989 mut self,
5990 scope: St,
5991 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
5992 where
5993 St: AsRef<str>,
5994 {
5995 self._scopes.insert(String::from(scope.as_ref()));
5996 self
5997 }
5998 /// Identifies the authorization scope(s) for the method you are building.
5999 ///
6000 /// See [`Self::add_scope()`] for details.
6001 pub fn add_scopes<I, St>(
6002 mut self,
6003 scopes: I,
6004 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C>
6005 where
6006 I: IntoIterator<Item = St>,
6007 St: AsRef<str>,
6008 {
6009 self._scopes
6010 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6011 self
6012 }
6013
6014 /// Removes all scopes, and no default scope will be used either.
6015 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6016 /// for details).
6017 pub fn clear_scopes(
6018 mut self,
6019 ) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, C> {
6020 self._scopes.clear();
6021 self
6022 }
6023}
6024
6025/// 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.
6026///
6027/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *billingAccount* resource.
6028/// It is not used directly, but through a [`BillingAccountMethods`] instance.
6029///
6030/// # Example
6031///
6032/// Instantiate a resource method builder
6033///
6034/// ```test_harness,no_run
6035/// # extern crate hyper;
6036/// # extern crate hyper_rustls;
6037/// # extern crate google_recommender1_beta1 as recommender1_beta1;
6038/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
6039/// # async fn dox() {
6040/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6041///
6042/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6043/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6044/// # .with_native_roots()
6045/// # .unwrap()
6046/// # .https_only()
6047/// # .enable_http2()
6048/// # .build();
6049///
6050/// # let executor = hyper_util::rt::TokioExecutor::new();
6051/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6052/// # secret,
6053/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6054/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6055/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6056/// # ),
6057/// # ).build().await.unwrap();
6058///
6059/// # let client = hyper_util::client::legacy::Client::builder(
6060/// # hyper_util::rt::TokioExecutor::new()
6061/// # )
6062/// # .build(
6063/// # hyper_rustls::HttpsConnectorBuilder::new()
6064/// # .with_native_roots()
6065/// # .unwrap()
6066/// # .https_or_http()
6067/// # .enable_http2()
6068/// # .build()
6069/// # );
6070/// # let mut hub = Recommender::new(client, auth);
6071/// // As the method needs a request, you would usually fill it with the desired information
6072/// // into the respective structure. Some of the parts shown here might not be applicable !
6073/// // Values shown here are possibly random and not representative !
6074/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::default();
6075///
6076/// // You can configure optional parameters by calling the respective setters at will, and
6077/// // execute the final call using `doit()`.
6078/// // Values shown here are possibly random and not representative !
6079/// let result = hub.billing_accounts().locations_recommenders_recommendations_mark_succeeded(req, "name")
6080/// .doit().await;
6081/// # }
6082/// ```
6083pub struct BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
6084where
6085 C: 'a,
6086{
6087 hub: &'a Recommender<C>,
6088 _request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
6089 _name: String,
6090 _delegate: Option<&'a mut dyn common::Delegate>,
6091 _additional_params: HashMap<String, String>,
6092 _scopes: BTreeSet<String>,
6093}
6094
6095impl<'a, C> common::CallBuilder
6096 for BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
6097{
6098}
6099
6100impl<'a, C> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
6101where
6102 C: common::Connector,
6103{
6104 /// Perform the operation you have build so far.
6105 pub async fn doit(
6106 mut self,
6107 ) -> common::Result<(
6108 common::Response,
6109 GoogleCloudRecommenderV1beta1Recommendation,
6110 )> {
6111 use std::borrow::Cow;
6112 use std::io::{Read, Seek};
6113
6114 use common::{url::Params, ToParts};
6115 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6116
6117 let mut dd = common::DefaultDelegate;
6118 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6119 dlg.begin(common::MethodInfo {
6120 id: "recommender.billingAccounts.locations.recommenders.recommendations.markSucceeded",
6121 http_method: hyper::Method::POST,
6122 });
6123
6124 for &field in ["alt", "name"].iter() {
6125 if self._additional_params.contains_key(field) {
6126 dlg.finished(false);
6127 return Err(common::Error::FieldClash(field));
6128 }
6129 }
6130
6131 let mut params = Params::with_capacity(4 + self._additional_params.len());
6132 params.push("name", self._name);
6133
6134 params.extend(self._additional_params.iter());
6135
6136 params.push("alt", "json");
6137 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markSucceeded";
6138 if self._scopes.is_empty() {
6139 self._scopes
6140 .insert(Scope::CloudPlatform.as_ref().to_string());
6141 }
6142
6143 #[allow(clippy::single_element_loop)]
6144 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6145 url = params.uri_replacement(url, param_name, find_this, true);
6146 }
6147 {
6148 let to_remove = ["name"];
6149 params.remove_params(&to_remove);
6150 }
6151
6152 let url = params.parse_with_url(&url);
6153
6154 let mut json_mime_type = mime::APPLICATION_JSON;
6155 let mut request_value_reader = {
6156 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6157 common::remove_json_null_values(&mut value);
6158 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6159 serde_json::to_writer(&mut dst, &value).unwrap();
6160 dst
6161 };
6162 let request_size = request_value_reader
6163 .seek(std::io::SeekFrom::End(0))
6164 .unwrap();
6165 request_value_reader
6166 .seek(std::io::SeekFrom::Start(0))
6167 .unwrap();
6168
6169 loop {
6170 let token = match self
6171 .hub
6172 .auth
6173 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6174 .await
6175 {
6176 Ok(token) => token,
6177 Err(e) => match dlg.token(e) {
6178 Ok(token) => token,
6179 Err(e) => {
6180 dlg.finished(false);
6181 return Err(common::Error::MissingToken(e));
6182 }
6183 },
6184 };
6185 request_value_reader
6186 .seek(std::io::SeekFrom::Start(0))
6187 .unwrap();
6188 let mut req_result = {
6189 let client = &self.hub.client;
6190 dlg.pre_request();
6191 let mut req_builder = hyper::Request::builder()
6192 .method(hyper::Method::POST)
6193 .uri(url.as_str())
6194 .header(USER_AGENT, self.hub._user_agent.clone());
6195
6196 if let Some(token) = token.as_ref() {
6197 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6198 }
6199
6200 let request = req_builder
6201 .header(CONTENT_TYPE, json_mime_type.to_string())
6202 .header(CONTENT_LENGTH, request_size as u64)
6203 .body(common::to_body(
6204 request_value_reader.get_ref().clone().into(),
6205 ));
6206
6207 client.request(request.unwrap()).await
6208 };
6209
6210 match req_result {
6211 Err(err) => {
6212 if let common::Retry::After(d) = dlg.http_error(&err) {
6213 sleep(d).await;
6214 continue;
6215 }
6216 dlg.finished(false);
6217 return Err(common::Error::HttpError(err));
6218 }
6219 Ok(res) => {
6220 let (mut parts, body) = res.into_parts();
6221 let mut body = common::Body::new(body);
6222 if !parts.status.is_success() {
6223 let bytes = common::to_bytes(body).await.unwrap_or_default();
6224 let error = serde_json::from_str(&common::to_string(&bytes));
6225 let response = common::to_response(parts, bytes.into());
6226
6227 if let common::Retry::After(d) =
6228 dlg.http_failure(&response, error.as_ref().ok())
6229 {
6230 sleep(d).await;
6231 continue;
6232 }
6233
6234 dlg.finished(false);
6235
6236 return Err(match error {
6237 Ok(value) => common::Error::BadRequest(value),
6238 _ => common::Error::Failure(response),
6239 });
6240 }
6241 let response = {
6242 let bytes = common::to_bytes(body).await.unwrap_or_default();
6243 let encoded = common::to_string(&bytes);
6244 match serde_json::from_str(&encoded) {
6245 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6246 Err(error) => {
6247 dlg.response_json_decode_error(&encoded, &error);
6248 return Err(common::Error::JsonDecodeError(
6249 encoded.to_string(),
6250 error,
6251 ));
6252 }
6253 }
6254 };
6255
6256 dlg.finished(true);
6257 return Ok(response);
6258 }
6259 }
6260 }
6261 }
6262
6263 ///
6264 /// Sets the *request* property to the given value.
6265 ///
6266 /// Even though the property as already been set when instantiating this call,
6267 /// we provide this method for API completeness.
6268 pub fn request(
6269 mut self,
6270 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
6271 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
6272 self._request = new_value;
6273 self
6274 }
6275 /// Required. Name of the recommendation.
6276 ///
6277 /// Sets the *name* path property to the given value.
6278 ///
6279 /// Even though the property as already been set when instantiating this call,
6280 /// we provide this method for API completeness.
6281 pub fn name(
6282 mut self,
6283 new_value: &str,
6284 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
6285 self._name = new_value.to_string();
6286 self
6287 }
6288 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6289 /// while executing the actual API request.
6290 ///
6291 /// ````text
6292 /// It should be used to handle progress information, and to implement a certain level of resilience.
6293 /// ````
6294 ///
6295 /// Sets the *delegate* property to the given value.
6296 pub fn delegate(
6297 mut self,
6298 new_value: &'a mut dyn common::Delegate,
6299 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
6300 self._delegate = Some(new_value);
6301 self
6302 }
6303
6304 /// Set any additional parameter of the query string used in the request.
6305 /// It should be used to set parameters which are not yet available through their own
6306 /// setters.
6307 ///
6308 /// Please note that this method must not be used to set any of the known parameters
6309 /// which have their own setter method. If done anyway, the request will fail.
6310 ///
6311 /// # Additional Parameters
6312 ///
6313 /// * *$.xgafv* (query-string) - V1 error format.
6314 /// * *access_token* (query-string) - OAuth access token.
6315 /// * *alt* (query-string) - Data format for response.
6316 /// * *callback* (query-string) - JSONP
6317 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6318 /// * *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.
6319 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6320 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6321 /// * *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.
6322 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6323 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6324 pub fn param<T>(
6325 mut self,
6326 name: T,
6327 value: T,
6328 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
6329 where
6330 T: AsRef<str>,
6331 {
6332 self._additional_params
6333 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6334 self
6335 }
6336
6337 /// Identifies the authorization scope for the method you are building.
6338 ///
6339 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6340 /// [`Scope::CloudPlatform`].
6341 ///
6342 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6343 /// tokens for more than one scope.
6344 ///
6345 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6346 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6347 /// sufficient, a read-write scope will do as well.
6348 pub fn add_scope<St>(
6349 mut self,
6350 scope: St,
6351 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
6352 where
6353 St: AsRef<str>,
6354 {
6355 self._scopes.insert(String::from(scope.as_ref()));
6356 self
6357 }
6358 /// Identifies the authorization scope(s) for the method you are building.
6359 ///
6360 /// See [`Self::add_scope()`] for details.
6361 pub fn add_scopes<I, St>(
6362 mut self,
6363 scopes: I,
6364 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C>
6365 where
6366 I: IntoIterator<Item = St>,
6367 St: AsRef<str>,
6368 {
6369 self._scopes
6370 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6371 self
6372 }
6373
6374 /// Removes all scopes, and no default scope will be used either.
6375 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6376 /// for details).
6377 pub fn clear_scopes(
6378 mut self,
6379 ) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
6380 self._scopes.clear();
6381 self
6382 }
6383}
6384
6385/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
6386///
6387/// A builder for the *locations.recommenders.getConfig* method supported by a *billingAccount* resource.
6388/// It is not used directly, but through a [`BillingAccountMethods`] instance.
6389///
6390/// # Example
6391///
6392/// Instantiate a resource method builder
6393///
6394/// ```test_harness,no_run
6395/// # extern crate hyper;
6396/// # extern crate hyper_rustls;
6397/// # extern crate google_recommender1_beta1 as recommender1_beta1;
6398/// # async fn dox() {
6399/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6400///
6401/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6402/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6403/// # .with_native_roots()
6404/// # .unwrap()
6405/// # .https_only()
6406/// # .enable_http2()
6407/// # .build();
6408///
6409/// # let executor = hyper_util::rt::TokioExecutor::new();
6410/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6411/// # secret,
6412/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6413/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6414/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6415/// # ),
6416/// # ).build().await.unwrap();
6417///
6418/// # let client = hyper_util::client::legacy::Client::builder(
6419/// # hyper_util::rt::TokioExecutor::new()
6420/// # )
6421/// # .build(
6422/// # hyper_rustls::HttpsConnectorBuilder::new()
6423/// # .with_native_roots()
6424/// # .unwrap()
6425/// # .https_or_http()
6426/// # .enable_http2()
6427/// # .build()
6428/// # );
6429/// # let mut hub = Recommender::new(client, auth);
6430/// // You can configure optional parameters by calling the respective setters at will, and
6431/// // execute the final call using `doit()`.
6432/// // Values shown here are possibly random and not representative !
6433/// let result = hub.billing_accounts().locations_recommenders_get_config("name")
6434/// .doit().await;
6435/// # }
6436/// ```
6437pub struct BillingAccountLocationRecommenderGetConfigCall<'a, C>
6438where
6439 C: 'a,
6440{
6441 hub: &'a Recommender<C>,
6442 _name: String,
6443 _delegate: Option<&'a mut dyn common::Delegate>,
6444 _additional_params: HashMap<String, String>,
6445 _scopes: BTreeSet<String>,
6446}
6447
6448impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderGetConfigCall<'a, C> {}
6449
6450impl<'a, C> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6451where
6452 C: common::Connector,
6453{
6454 /// Perform the operation you have build so far.
6455 pub async fn doit(
6456 mut self,
6457 ) -> common::Result<(
6458 common::Response,
6459 GoogleCloudRecommenderV1beta1RecommenderConfig,
6460 )> {
6461 use std::borrow::Cow;
6462 use std::io::{Read, Seek};
6463
6464 use common::{url::Params, ToParts};
6465 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6466
6467 let mut dd = common::DefaultDelegate;
6468 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6469 dlg.begin(common::MethodInfo {
6470 id: "recommender.billingAccounts.locations.recommenders.getConfig",
6471 http_method: hyper::Method::GET,
6472 });
6473
6474 for &field in ["alt", "name"].iter() {
6475 if self._additional_params.contains_key(field) {
6476 dlg.finished(false);
6477 return Err(common::Error::FieldClash(field));
6478 }
6479 }
6480
6481 let mut params = Params::with_capacity(3 + self._additional_params.len());
6482 params.push("name", self._name);
6483
6484 params.extend(self._additional_params.iter());
6485
6486 params.push("alt", "json");
6487 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
6488 if self._scopes.is_empty() {
6489 self._scopes
6490 .insert(Scope::CloudPlatform.as_ref().to_string());
6491 }
6492
6493 #[allow(clippy::single_element_loop)]
6494 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6495 url = params.uri_replacement(url, param_name, find_this, true);
6496 }
6497 {
6498 let to_remove = ["name"];
6499 params.remove_params(&to_remove);
6500 }
6501
6502 let url = params.parse_with_url(&url);
6503
6504 loop {
6505 let token = match self
6506 .hub
6507 .auth
6508 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6509 .await
6510 {
6511 Ok(token) => token,
6512 Err(e) => match dlg.token(e) {
6513 Ok(token) => token,
6514 Err(e) => {
6515 dlg.finished(false);
6516 return Err(common::Error::MissingToken(e));
6517 }
6518 },
6519 };
6520 let mut req_result = {
6521 let client = &self.hub.client;
6522 dlg.pre_request();
6523 let mut req_builder = hyper::Request::builder()
6524 .method(hyper::Method::GET)
6525 .uri(url.as_str())
6526 .header(USER_AGENT, self.hub._user_agent.clone());
6527
6528 if let Some(token) = token.as_ref() {
6529 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6530 }
6531
6532 let request = req_builder
6533 .header(CONTENT_LENGTH, 0_u64)
6534 .body(common::to_body::<String>(None));
6535
6536 client.request(request.unwrap()).await
6537 };
6538
6539 match req_result {
6540 Err(err) => {
6541 if let common::Retry::After(d) = dlg.http_error(&err) {
6542 sleep(d).await;
6543 continue;
6544 }
6545 dlg.finished(false);
6546 return Err(common::Error::HttpError(err));
6547 }
6548 Ok(res) => {
6549 let (mut parts, body) = res.into_parts();
6550 let mut body = common::Body::new(body);
6551 if !parts.status.is_success() {
6552 let bytes = common::to_bytes(body).await.unwrap_or_default();
6553 let error = serde_json::from_str(&common::to_string(&bytes));
6554 let response = common::to_response(parts, bytes.into());
6555
6556 if let common::Retry::After(d) =
6557 dlg.http_failure(&response, error.as_ref().ok())
6558 {
6559 sleep(d).await;
6560 continue;
6561 }
6562
6563 dlg.finished(false);
6564
6565 return Err(match error {
6566 Ok(value) => common::Error::BadRequest(value),
6567 _ => common::Error::Failure(response),
6568 });
6569 }
6570 let response = {
6571 let bytes = common::to_bytes(body).await.unwrap_or_default();
6572 let encoded = common::to_string(&bytes);
6573 match serde_json::from_str(&encoded) {
6574 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6575 Err(error) => {
6576 dlg.response_json_decode_error(&encoded, &error);
6577 return Err(common::Error::JsonDecodeError(
6578 encoded.to_string(),
6579 error,
6580 ));
6581 }
6582 }
6583 };
6584
6585 dlg.finished(true);
6586 return Ok(response);
6587 }
6588 }
6589 }
6590 }
6591
6592 /// 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`
6593 ///
6594 /// Sets the *name* path property to the given value.
6595 ///
6596 /// Even though the property as already been set when instantiating this call,
6597 /// we provide this method for API completeness.
6598 pub fn name(
6599 mut self,
6600 new_value: &str,
6601 ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
6602 self._name = new_value.to_string();
6603 self
6604 }
6605 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6606 /// while executing the actual API request.
6607 ///
6608 /// ````text
6609 /// It should be used to handle progress information, and to implement a certain level of resilience.
6610 /// ````
6611 ///
6612 /// Sets the *delegate* property to the given value.
6613 pub fn delegate(
6614 mut self,
6615 new_value: &'a mut dyn common::Delegate,
6616 ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
6617 self._delegate = Some(new_value);
6618 self
6619 }
6620
6621 /// Set any additional parameter of the query string used in the request.
6622 /// It should be used to set parameters which are not yet available through their own
6623 /// setters.
6624 ///
6625 /// Please note that this method must not be used to set any of the known parameters
6626 /// which have their own setter method. If done anyway, the request will fail.
6627 ///
6628 /// # Additional Parameters
6629 ///
6630 /// * *$.xgafv* (query-string) - V1 error format.
6631 /// * *access_token* (query-string) - OAuth access token.
6632 /// * *alt* (query-string) - Data format for response.
6633 /// * *callback* (query-string) - JSONP
6634 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6635 /// * *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.
6636 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6637 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6638 /// * *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.
6639 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6640 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6641 pub fn param<T>(
6642 mut self,
6643 name: T,
6644 value: T,
6645 ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6646 where
6647 T: AsRef<str>,
6648 {
6649 self._additional_params
6650 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6651 self
6652 }
6653
6654 /// Identifies the authorization scope for the method you are building.
6655 ///
6656 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6657 /// [`Scope::CloudPlatform`].
6658 ///
6659 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6660 /// tokens for more than one scope.
6661 ///
6662 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6663 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6664 /// sufficient, a read-write scope will do as well.
6665 pub fn add_scope<St>(
6666 mut self,
6667 scope: St,
6668 ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6669 where
6670 St: AsRef<str>,
6671 {
6672 self._scopes.insert(String::from(scope.as_ref()));
6673 self
6674 }
6675 /// Identifies the authorization scope(s) for the method you are building.
6676 ///
6677 /// See [`Self::add_scope()`] for details.
6678 pub fn add_scopes<I, St>(
6679 mut self,
6680 scopes: I,
6681 ) -> BillingAccountLocationRecommenderGetConfigCall<'a, C>
6682 where
6683 I: IntoIterator<Item = St>,
6684 St: AsRef<str>,
6685 {
6686 self._scopes
6687 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6688 self
6689 }
6690
6691 /// Removes all scopes, and no default scope will be used either.
6692 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6693 /// for details).
6694 pub fn clear_scopes(mut self) -> BillingAccountLocationRecommenderGetConfigCall<'a, C> {
6695 self._scopes.clear();
6696 self
6697 }
6698}
6699
6700/// Updates a Recommender Config. This will create a new revision of the config.
6701///
6702/// A builder for the *locations.recommenders.updateConfig* method supported by a *billingAccount* resource.
6703/// It is not used directly, but through a [`BillingAccountMethods`] instance.
6704///
6705/// # Example
6706///
6707/// Instantiate a resource method builder
6708///
6709/// ```test_harness,no_run
6710/// # extern crate hyper;
6711/// # extern crate hyper_rustls;
6712/// # extern crate google_recommender1_beta1 as recommender1_beta1;
6713/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1RecommenderConfig;
6714/// # async fn dox() {
6715/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6716///
6717/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6718/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6719/// # .with_native_roots()
6720/// # .unwrap()
6721/// # .https_only()
6722/// # .enable_http2()
6723/// # .build();
6724///
6725/// # let executor = hyper_util::rt::TokioExecutor::new();
6726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6727/// # secret,
6728/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6729/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6730/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6731/// # ),
6732/// # ).build().await.unwrap();
6733///
6734/// # let client = hyper_util::client::legacy::Client::builder(
6735/// # hyper_util::rt::TokioExecutor::new()
6736/// # )
6737/// # .build(
6738/// # hyper_rustls::HttpsConnectorBuilder::new()
6739/// # .with_native_roots()
6740/// # .unwrap()
6741/// # .https_or_http()
6742/// # .enable_http2()
6743/// # .build()
6744/// # );
6745/// # let mut hub = Recommender::new(client, auth);
6746/// // As the method needs a request, you would usually fill it with the desired information
6747/// // into the respective structure. Some of the parts shown here might not be applicable !
6748/// // Values shown here are possibly random and not representative !
6749/// let mut req = GoogleCloudRecommenderV1beta1RecommenderConfig::default();
6750///
6751/// // You can configure optional parameters by calling the respective setters at will, and
6752/// // execute the final call using `doit()`.
6753/// // Values shown here are possibly random and not representative !
6754/// let result = hub.billing_accounts().locations_recommenders_update_config(req, "name")
6755/// .validate_only(false)
6756/// .update_mask(FieldMask::new::<&str>(&[]))
6757/// .doit().await;
6758/// # }
6759/// ```
6760pub struct BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
6761where
6762 C: 'a,
6763{
6764 hub: &'a Recommender<C>,
6765 _request: GoogleCloudRecommenderV1beta1RecommenderConfig,
6766 _name: String,
6767 _validate_only: Option<bool>,
6768 _update_mask: Option<common::FieldMask>,
6769 _delegate: Option<&'a mut dyn common::Delegate>,
6770 _additional_params: HashMap<String, String>,
6771 _scopes: BTreeSet<String>,
6772}
6773
6774impl<'a, C> common::CallBuilder for BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {}
6775
6776impl<'a, C> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
6777where
6778 C: common::Connector,
6779{
6780 /// Perform the operation you have build so far.
6781 pub async fn doit(
6782 mut self,
6783 ) -> common::Result<(
6784 common::Response,
6785 GoogleCloudRecommenderV1beta1RecommenderConfig,
6786 )> {
6787 use std::borrow::Cow;
6788 use std::io::{Read, Seek};
6789
6790 use common::{url::Params, ToParts};
6791 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6792
6793 let mut dd = common::DefaultDelegate;
6794 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6795 dlg.begin(common::MethodInfo {
6796 id: "recommender.billingAccounts.locations.recommenders.updateConfig",
6797 http_method: hyper::Method::PATCH,
6798 });
6799
6800 for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
6801 if self._additional_params.contains_key(field) {
6802 dlg.finished(false);
6803 return Err(common::Error::FieldClash(field));
6804 }
6805 }
6806
6807 let mut params = Params::with_capacity(6 + self._additional_params.len());
6808 params.push("name", self._name);
6809 if let Some(value) = self._validate_only.as_ref() {
6810 params.push("validateOnly", value.to_string());
6811 }
6812 if let Some(value) = self._update_mask.as_ref() {
6813 params.push("updateMask", value.to_string());
6814 }
6815
6816 params.extend(self._additional_params.iter());
6817
6818 params.push("alt", "json");
6819 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
6820 if self._scopes.is_empty() {
6821 self._scopes
6822 .insert(Scope::CloudPlatform.as_ref().to_string());
6823 }
6824
6825 #[allow(clippy::single_element_loop)]
6826 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6827 url = params.uri_replacement(url, param_name, find_this, true);
6828 }
6829 {
6830 let to_remove = ["name"];
6831 params.remove_params(&to_remove);
6832 }
6833
6834 let url = params.parse_with_url(&url);
6835
6836 let mut json_mime_type = mime::APPLICATION_JSON;
6837 let mut request_value_reader = {
6838 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6839 common::remove_json_null_values(&mut value);
6840 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6841 serde_json::to_writer(&mut dst, &value).unwrap();
6842 dst
6843 };
6844 let request_size = request_value_reader
6845 .seek(std::io::SeekFrom::End(0))
6846 .unwrap();
6847 request_value_reader
6848 .seek(std::io::SeekFrom::Start(0))
6849 .unwrap();
6850
6851 loop {
6852 let token = match self
6853 .hub
6854 .auth
6855 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6856 .await
6857 {
6858 Ok(token) => token,
6859 Err(e) => match dlg.token(e) {
6860 Ok(token) => token,
6861 Err(e) => {
6862 dlg.finished(false);
6863 return Err(common::Error::MissingToken(e));
6864 }
6865 },
6866 };
6867 request_value_reader
6868 .seek(std::io::SeekFrom::Start(0))
6869 .unwrap();
6870 let mut req_result = {
6871 let client = &self.hub.client;
6872 dlg.pre_request();
6873 let mut req_builder = hyper::Request::builder()
6874 .method(hyper::Method::PATCH)
6875 .uri(url.as_str())
6876 .header(USER_AGENT, self.hub._user_agent.clone());
6877
6878 if let Some(token) = token.as_ref() {
6879 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6880 }
6881
6882 let request = req_builder
6883 .header(CONTENT_TYPE, json_mime_type.to_string())
6884 .header(CONTENT_LENGTH, request_size as u64)
6885 .body(common::to_body(
6886 request_value_reader.get_ref().clone().into(),
6887 ));
6888
6889 client.request(request.unwrap()).await
6890 };
6891
6892 match req_result {
6893 Err(err) => {
6894 if let common::Retry::After(d) = dlg.http_error(&err) {
6895 sleep(d).await;
6896 continue;
6897 }
6898 dlg.finished(false);
6899 return Err(common::Error::HttpError(err));
6900 }
6901 Ok(res) => {
6902 let (mut parts, body) = res.into_parts();
6903 let mut body = common::Body::new(body);
6904 if !parts.status.is_success() {
6905 let bytes = common::to_bytes(body).await.unwrap_or_default();
6906 let error = serde_json::from_str(&common::to_string(&bytes));
6907 let response = common::to_response(parts, bytes.into());
6908
6909 if let common::Retry::After(d) =
6910 dlg.http_failure(&response, error.as_ref().ok())
6911 {
6912 sleep(d).await;
6913 continue;
6914 }
6915
6916 dlg.finished(false);
6917
6918 return Err(match error {
6919 Ok(value) => common::Error::BadRequest(value),
6920 _ => common::Error::Failure(response),
6921 });
6922 }
6923 let response = {
6924 let bytes = common::to_bytes(body).await.unwrap_or_default();
6925 let encoded = common::to_string(&bytes);
6926 match serde_json::from_str(&encoded) {
6927 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6928 Err(error) => {
6929 dlg.response_json_decode_error(&encoded, &error);
6930 return Err(common::Error::JsonDecodeError(
6931 encoded.to_string(),
6932 error,
6933 ));
6934 }
6935 }
6936 };
6937
6938 dlg.finished(true);
6939 return Ok(response);
6940 }
6941 }
6942 }
6943 }
6944
6945 ///
6946 /// Sets the *request* property to the given value.
6947 ///
6948 /// Even though the property as already been set when instantiating this call,
6949 /// we provide this method for API completeness.
6950 pub fn request(
6951 mut self,
6952 new_value: GoogleCloudRecommenderV1beta1RecommenderConfig,
6953 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6954 self._request = new_value;
6955 self
6956 }
6957 /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
6958 ///
6959 /// Sets the *name* path property to the given value.
6960 ///
6961 /// Even though the property as already been set when instantiating this call,
6962 /// we provide this method for API completeness.
6963 pub fn name(
6964 mut self,
6965 new_value: &str,
6966 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6967 self._name = new_value.to_string();
6968 self
6969 }
6970 /// If true, validate the request and preview the change, but do not actually update it.
6971 ///
6972 /// Sets the *validate only* query property to the given value.
6973 pub fn validate_only(
6974 mut self,
6975 new_value: bool,
6976 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6977 self._validate_only = Some(new_value);
6978 self
6979 }
6980 /// The list of fields to be updated.
6981 ///
6982 /// Sets the *update mask* query property to the given value.
6983 pub fn update_mask(
6984 mut self,
6985 new_value: common::FieldMask,
6986 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
6987 self._update_mask = Some(new_value);
6988 self
6989 }
6990 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6991 /// while executing the actual API request.
6992 ///
6993 /// ````text
6994 /// It should be used to handle progress information, and to implement a certain level of resilience.
6995 /// ````
6996 ///
6997 /// Sets the *delegate* property to the given value.
6998 pub fn delegate(
6999 mut self,
7000 new_value: &'a mut dyn common::Delegate,
7001 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
7002 self._delegate = Some(new_value);
7003 self
7004 }
7005
7006 /// Set any additional parameter of the query string used in the request.
7007 /// It should be used to set parameters which are not yet available through their own
7008 /// setters.
7009 ///
7010 /// Please note that this method must not be used to set any of the known parameters
7011 /// which have their own setter method. If done anyway, the request will fail.
7012 ///
7013 /// # Additional Parameters
7014 ///
7015 /// * *$.xgafv* (query-string) - V1 error format.
7016 /// * *access_token* (query-string) - OAuth access token.
7017 /// * *alt* (query-string) - Data format for response.
7018 /// * *callback* (query-string) - JSONP
7019 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7020 /// * *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.
7021 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7022 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7023 /// * *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.
7024 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7025 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7026 pub fn param<T>(
7027 mut self,
7028 name: T,
7029 value: T,
7030 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
7031 where
7032 T: AsRef<str>,
7033 {
7034 self._additional_params
7035 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7036 self
7037 }
7038
7039 /// Identifies the authorization scope for the method you are building.
7040 ///
7041 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7042 /// [`Scope::CloudPlatform`].
7043 ///
7044 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7045 /// tokens for more than one scope.
7046 ///
7047 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7048 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7049 /// sufficient, a read-write scope will do as well.
7050 pub fn add_scope<St>(
7051 mut self,
7052 scope: St,
7053 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
7054 where
7055 St: AsRef<str>,
7056 {
7057 self._scopes.insert(String::from(scope.as_ref()));
7058 self
7059 }
7060 /// Identifies the authorization scope(s) for the method you are building.
7061 ///
7062 /// See [`Self::add_scope()`] for details.
7063 pub fn add_scopes<I, St>(
7064 mut self,
7065 scopes: I,
7066 ) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C>
7067 where
7068 I: IntoIterator<Item = St>,
7069 St: AsRef<str>,
7070 {
7071 self._scopes
7072 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7073 self
7074 }
7075
7076 /// Removes all scopes, and no default scope will be used either.
7077 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7078 /// for details).
7079 pub fn clear_scopes(mut self) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, C> {
7080 self._scopes.clear();
7081 self
7082 }
7083}
7084
7085/// Lists locations with recommendations or insights.
7086///
7087/// A builder for the *locations.list* method supported by a *billingAccount* resource.
7088/// It is not used directly, but through a [`BillingAccountMethods`] instance.
7089///
7090/// # Example
7091///
7092/// Instantiate a resource method builder
7093///
7094/// ```test_harness,no_run
7095/// # extern crate hyper;
7096/// # extern crate hyper_rustls;
7097/// # extern crate google_recommender1_beta1 as recommender1_beta1;
7098/// # async fn dox() {
7099/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7100///
7101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7102/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7103/// # .with_native_roots()
7104/// # .unwrap()
7105/// # .https_only()
7106/// # .enable_http2()
7107/// # .build();
7108///
7109/// # let executor = hyper_util::rt::TokioExecutor::new();
7110/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7111/// # secret,
7112/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7113/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7114/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7115/// # ),
7116/// # ).build().await.unwrap();
7117///
7118/// # let client = hyper_util::client::legacy::Client::builder(
7119/// # hyper_util::rt::TokioExecutor::new()
7120/// # )
7121/// # .build(
7122/// # hyper_rustls::HttpsConnectorBuilder::new()
7123/// # .with_native_roots()
7124/// # .unwrap()
7125/// # .https_or_http()
7126/// # .enable_http2()
7127/// # .build()
7128/// # );
7129/// # let mut hub = Recommender::new(client, auth);
7130/// // You can configure optional parameters by calling the respective setters at will, and
7131/// // execute the final call using `doit()`.
7132/// // Values shown here are possibly random and not representative !
7133/// let result = hub.billing_accounts().locations_list("name")
7134/// .page_token("gubergren")
7135/// .page_size(-16)
7136/// .filter("est")
7137/// .add_extra_location_types("ipsum")
7138/// .doit().await;
7139/// # }
7140/// ```
7141pub struct BillingAccountLocationListCall<'a, C>
7142where
7143 C: 'a,
7144{
7145 hub: &'a Recommender<C>,
7146 _name: String,
7147 _page_token: Option<String>,
7148 _page_size: Option<i32>,
7149 _filter: Option<String>,
7150 _extra_location_types: Vec<String>,
7151 _delegate: Option<&'a mut dyn common::Delegate>,
7152 _additional_params: HashMap<String, String>,
7153 _scopes: BTreeSet<String>,
7154}
7155
7156impl<'a, C> common::CallBuilder for BillingAccountLocationListCall<'a, C> {}
7157
7158impl<'a, C> BillingAccountLocationListCall<'a, C>
7159where
7160 C: common::Connector,
7161{
7162 /// Perform the operation you have build so far.
7163 pub async fn doit(
7164 mut self,
7165 ) -> common::Result<(common::Response, GoogleCloudLocationListLocationsResponse)> {
7166 use std::borrow::Cow;
7167 use std::io::{Read, Seek};
7168
7169 use common::{url::Params, ToParts};
7170 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7171
7172 let mut dd = common::DefaultDelegate;
7173 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7174 dlg.begin(common::MethodInfo {
7175 id: "recommender.billingAccounts.locations.list",
7176 http_method: hyper::Method::GET,
7177 });
7178
7179 for &field in [
7180 "alt",
7181 "name",
7182 "pageToken",
7183 "pageSize",
7184 "filter",
7185 "extraLocationTypes",
7186 ]
7187 .iter()
7188 {
7189 if self._additional_params.contains_key(field) {
7190 dlg.finished(false);
7191 return Err(common::Error::FieldClash(field));
7192 }
7193 }
7194
7195 let mut params = Params::with_capacity(7 + self._additional_params.len());
7196 params.push("name", self._name);
7197 if let Some(value) = self._page_token.as_ref() {
7198 params.push("pageToken", value);
7199 }
7200 if let Some(value) = self._page_size.as_ref() {
7201 params.push("pageSize", value.to_string());
7202 }
7203 if let Some(value) = self._filter.as_ref() {
7204 params.push("filter", value);
7205 }
7206 if !self._extra_location_types.is_empty() {
7207 for f in self._extra_location_types.iter() {
7208 params.push("extraLocationTypes", f);
7209 }
7210 }
7211
7212 params.extend(self._additional_params.iter());
7213
7214 params.push("alt", "json");
7215 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/locations";
7216 if self._scopes.is_empty() {
7217 self._scopes
7218 .insert(Scope::CloudPlatform.as_ref().to_string());
7219 }
7220
7221 #[allow(clippy::single_element_loop)]
7222 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7223 url = params.uri_replacement(url, param_name, find_this, true);
7224 }
7225 {
7226 let to_remove = ["name"];
7227 params.remove_params(&to_remove);
7228 }
7229
7230 let url = params.parse_with_url(&url);
7231
7232 loop {
7233 let token = match self
7234 .hub
7235 .auth
7236 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7237 .await
7238 {
7239 Ok(token) => token,
7240 Err(e) => match dlg.token(e) {
7241 Ok(token) => token,
7242 Err(e) => {
7243 dlg.finished(false);
7244 return Err(common::Error::MissingToken(e));
7245 }
7246 },
7247 };
7248 let mut req_result = {
7249 let client = &self.hub.client;
7250 dlg.pre_request();
7251 let mut req_builder = hyper::Request::builder()
7252 .method(hyper::Method::GET)
7253 .uri(url.as_str())
7254 .header(USER_AGENT, self.hub._user_agent.clone());
7255
7256 if let Some(token) = token.as_ref() {
7257 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7258 }
7259
7260 let request = req_builder
7261 .header(CONTENT_LENGTH, 0_u64)
7262 .body(common::to_body::<String>(None));
7263
7264 client.request(request.unwrap()).await
7265 };
7266
7267 match req_result {
7268 Err(err) => {
7269 if let common::Retry::After(d) = dlg.http_error(&err) {
7270 sleep(d).await;
7271 continue;
7272 }
7273 dlg.finished(false);
7274 return Err(common::Error::HttpError(err));
7275 }
7276 Ok(res) => {
7277 let (mut parts, body) = res.into_parts();
7278 let mut body = common::Body::new(body);
7279 if !parts.status.is_success() {
7280 let bytes = common::to_bytes(body).await.unwrap_or_default();
7281 let error = serde_json::from_str(&common::to_string(&bytes));
7282 let response = common::to_response(parts, bytes.into());
7283
7284 if let common::Retry::After(d) =
7285 dlg.http_failure(&response, error.as_ref().ok())
7286 {
7287 sleep(d).await;
7288 continue;
7289 }
7290
7291 dlg.finished(false);
7292
7293 return Err(match error {
7294 Ok(value) => common::Error::BadRequest(value),
7295 _ => common::Error::Failure(response),
7296 });
7297 }
7298 let response = {
7299 let bytes = common::to_bytes(body).await.unwrap_or_default();
7300 let encoded = common::to_string(&bytes);
7301 match serde_json::from_str(&encoded) {
7302 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7303 Err(error) => {
7304 dlg.response_json_decode_error(&encoded, &error);
7305 return Err(common::Error::JsonDecodeError(
7306 encoded.to_string(),
7307 error,
7308 ));
7309 }
7310 }
7311 };
7312
7313 dlg.finished(true);
7314 return Ok(response);
7315 }
7316 }
7317 }
7318 }
7319
7320 /// The resource that owns the locations collection, if applicable.
7321 ///
7322 /// Sets the *name* path property to the given value.
7323 ///
7324 /// Even though the property as already been set when instantiating this call,
7325 /// we provide this method for API completeness.
7326 pub fn name(mut self, new_value: &str) -> BillingAccountLocationListCall<'a, C> {
7327 self._name = new_value.to_string();
7328 self
7329 }
7330 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
7331 ///
7332 /// Sets the *page token* query property to the given value.
7333 pub fn page_token(mut self, new_value: &str) -> BillingAccountLocationListCall<'a, C> {
7334 self._page_token = Some(new_value.to_string());
7335 self
7336 }
7337 /// The maximum number of results to return. If not set, the service selects a default.
7338 ///
7339 /// Sets the *page size* query property to the given value.
7340 pub fn page_size(mut self, new_value: i32) -> BillingAccountLocationListCall<'a, C> {
7341 self._page_size = Some(new_value);
7342 self
7343 }
7344 /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
7345 ///
7346 /// Sets the *filter* query property to the given value.
7347 pub fn filter(mut self, new_value: &str) -> BillingAccountLocationListCall<'a, C> {
7348 self._filter = Some(new_value.to_string());
7349 self
7350 }
7351 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
7352 ///
7353 /// Append the given value to the *extra location types* query property.
7354 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7355 pub fn add_extra_location_types(
7356 mut self,
7357 new_value: &str,
7358 ) -> BillingAccountLocationListCall<'a, C> {
7359 self._extra_location_types.push(new_value.to_string());
7360 self
7361 }
7362 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7363 /// while executing the actual API request.
7364 ///
7365 /// ````text
7366 /// It should be used to handle progress information, and to implement a certain level of resilience.
7367 /// ````
7368 ///
7369 /// Sets the *delegate* property to the given value.
7370 pub fn delegate(
7371 mut self,
7372 new_value: &'a mut dyn common::Delegate,
7373 ) -> BillingAccountLocationListCall<'a, C> {
7374 self._delegate = Some(new_value);
7375 self
7376 }
7377
7378 /// Set any additional parameter of the query string used in the request.
7379 /// It should be used to set parameters which are not yet available through their own
7380 /// setters.
7381 ///
7382 /// Please note that this method must not be used to set any of the known parameters
7383 /// which have their own setter method. If done anyway, the request will fail.
7384 ///
7385 /// # Additional Parameters
7386 ///
7387 /// * *$.xgafv* (query-string) - V1 error format.
7388 /// * *access_token* (query-string) - OAuth access token.
7389 /// * *alt* (query-string) - Data format for response.
7390 /// * *callback* (query-string) - JSONP
7391 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7392 /// * *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.
7393 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7394 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7395 /// * *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.
7396 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7397 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7398 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountLocationListCall<'a, C>
7399 where
7400 T: AsRef<str>,
7401 {
7402 self._additional_params
7403 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7404 self
7405 }
7406
7407 /// Identifies the authorization scope for the method you are building.
7408 ///
7409 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7410 /// [`Scope::CloudPlatform`].
7411 ///
7412 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7413 /// tokens for more than one scope.
7414 ///
7415 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7416 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7417 /// sufficient, a read-write scope will do as well.
7418 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountLocationListCall<'a, C>
7419 where
7420 St: AsRef<str>,
7421 {
7422 self._scopes.insert(String::from(scope.as_ref()));
7423 self
7424 }
7425 /// Identifies the authorization scope(s) for the method you are building.
7426 ///
7427 /// See [`Self::add_scope()`] for details.
7428 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountLocationListCall<'a, C>
7429 where
7430 I: IntoIterator<Item = St>,
7431 St: AsRef<str>,
7432 {
7433 self._scopes
7434 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7435 self
7436 }
7437
7438 /// Removes all scopes, and no default scope will be used either.
7439 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7440 /// for details).
7441 pub fn clear_scopes(mut self) -> BillingAccountLocationListCall<'a, C> {
7442 self._scopes.clear();
7443 self
7444 }
7445}
7446
7447/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
7448///
7449/// A builder for the *locations.insightTypes.insights.get* method supported by a *folder* resource.
7450/// It is not used directly, but through a [`FolderMethods`] instance.
7451///
7452/// # Example
7453///
7454/// Instantiate a resource method builder
7455///
7456/// ```test_harness,no_run
7457/// # extern crate hyper;
7458/// # extern crate hyper_rustls;
7459/// # extern crate google_recommender1_beta1 as recommender1_beta1;
7460/// # async fn dox() {
7461/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7462///
7463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7464/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7465/// # .with_native_roots()
7466/// # .unwrap()
7467/// # .https_only()
7468/// # .enable_http2()
7469/// # .build();
7470///
7471/// # let executor = hyper_util::rt::TokioExecutor::new();
7472/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7473/// # secret,
7474/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7475/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7476/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7477/// # ),
7478/// # ).build().await.unwrap();
7479///
7480/// # let client = hyper_util::client::legacy::Client::builder(
7481/// # hyper_util::rt::TokioExecutor::new()
7482/// # )
7483/// # .build(
7484/// # hyper_rustls::HttpsConnectorBuilder::new()
7485/// # .with_native_roots()
7486/// # .unwrap()
7487/// # .https_or_http()
7488/// # .enable_http2()
7489/// # .build()
7490/// # );
7491/// # let mut hub = Recommender::new(client, auth);
7492/// // You can configure optional parameters by calling the respective setters at will, and
7493/// // execute the final call using `doit()`.
7494/// // Values shown here are possibly random and not representative !
7495/// let result = hub.folders().locations_insight_types_insights_get("name")
7496/// .doit().await;
7497/// # }
7498/// ```
7499pub struct FolderLocationInsightTypeInsightGetCall<'a, C>
7500where
7501 C: 'a,
7502{
7503 hub: &'a Recommender<C>,
7504 _name: String,
7505 _delegate: Option<&'a mut dyn common::Delegate>,
7506 _additional_params: HashMap<String, String>,
7507 _scopes: BTreeSet<String>,
7508}
7509
7510impl<'a, C> common::CallBuilder for FolderLocationInsightTypeInsightGetCall<'a, C> {}
7511
7512impl<'a, C> FolderLocationInsightTypeInsightGetCall<'a, C>
7513where
7514 C: common::Connector,
7515{
7516 /// Perform the operation you have build so far.
7517 pub async fn doit(
7518 mut self,
7519 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
7520 use std::borrow::Cow;
7521 use std::io::{Read, Seek};
7522
7523 use common::{url::Params, ToParts};
7524 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7525
7526 let mut dd = common::DefaultDelegate;
7527 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7528 dlg.begin(common::MethodInfo {
7529 id: "recommender.folders.locations.insightTypes.insights.get",
7530 http_method: hyper::Method::GET,
7531 });
7532
7533 for &field in ["alt", "name"].iter() {
7534 if self._additional_params.contains_key(field) {
7535 dlg.finished(false);
7536 return Err(common::Error::FieldClash(field));
7537 }
7538 }
7539
7540 let mut params = Params::with_capacity(3 + self._additional_params.len());
7541 params.push("name", self._name);
7542
7543 params.extend(self._additional_params.iter());
7544
7545 params.push("alt", "json");
7546 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7547 if self._scopes.is_empty() {
7548 self._scopes
7549 .insert(Scope::CloudPlatform.as_ref().to_string());
7550 }
7551
7552 #[allow(clippy::single_element_loop)]
7553 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7554 url = params.uri_replacement(url, param_name, find_this, true);
7555 }
7556 {
7557 let to_remove = ["name"];
7558 params.remove_params(&to_remove);
7559 }
7560
7561 let url = params.parse_with_url(&url);
7562
7563 loop {
7564 let token = match self
7565 .hub
7566 .auth
7567 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7568 .await
7569 {
7570 Ok(token) => token,
7571 Err(e) => match dlg.token(e) {
7572 Ok(token) => token,
7573 Err(e) => {
7574 dlg.finished(false);
7575 return Err(common::Error::MissingToken(e));
7576 }
7577 },
7578 };
7579 let mut req_result = {
7580 let client = &self.hub.client;
7581 dlg.pre_request();
7582 let mut req_builder = hyper::Request::builder()
7583 .method(hyper::Method::GET)
7584 .uri(url.as_str())
7585 .header(USER_AGENT, self.hub._user_agent.clone());
7586
7587 if let Some(token) = token.as_ref() {
7588 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7589 }
7590
7591 let request = req_builder
7592 .header(CONTENT_LENGTH, 0_u64)
7593 .body(common::to_body::<String>(None));
7594
7595 client.request(request.unwrap()).await
7596 };
7597
7598 match req_result {
7599 Err(err) => {
7600 if let common::Retry::After(d) = dlg.http_error(&err) {
7601 sleep(d).await;
7602 continue;
7603 }
7604 dlg.finished(false);
7605 return Err(common::Error::HttpError(err));
7606 }
7607 Ok(res) => {
7608 let (mut parts, body) = res.into_parts();
7609 let mut body = common::Body::new(body);
7610 if !parts.status.is_success() {
7611 let bytes = common::to_bytes(body).await.unwrap_or_default();
7612 let error = serde_json::from_str(&common::to_string(&bytes));
7613 let response = common::to_response(parts, bytes.into());
7614
7615 if let common::Retry::After(d) =
7616 dlg.http_failure(&response, error.as_ref().ok())
7617 {
7618 sleep(d).await;
7619 continue;
7620 }
7621
7622 dlg.finished(false);
7623
7624 return Err(match error {
7625 Ok(value) => common::Error::BadRequest(value),
7626 _ => common::Error::Failure(response),
7627 });
7628 }
7629 let response = {
7630 let bytes = common::to_bytes(body).await.unwrap_or_default();
7631 let encoded = common::to_string(&bytes);
7632 match serde_json::from_str(&encoded) {
7633 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7634 Err(error) => {
7635 dlg.response_json_decode_error(&encoded, &error);
7636 return Err(common::Error::JsonDecodeError(
7637 encoded.to_string(),
7638 error,
7639 ));
7640 }
7641 }
7642 };
7643
7644 dlg.finished(true);
7645 return Ok(response);
7646 }
7647 }
7648 }
7649 }
7650
7651 /// Required. Name of the insight.
7652 ///
7653 /// Sets the *name* path property to the given value.
7654 ///
7655 /// Even though the property as already been set when instantiating this call,
7656 /// we provide this method for API completeness.
7657 pub fn name(mut self, new_value: &str) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
7658 self._name = new_value.to_string();
7659 self
7660 }
7661 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7662 /// while executing the actual API request.
7663 ///
7664 /// ````text
7665 /// It should be used to handle progress information, and to implement a certain level of resilience.
7666 /// ````
7667 ///
7668 /// Sets the *delegate* property to the given value.
7669 pub fn delegate(
7670 mut self,
7671 new_value: &'a mut dyn common::Delegate,
7672 ) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
7673 self._delegate = Some(new_value);
7674 self
7675 }
7676
7677 /// Set any additional parameter of the query string used in the request.
7678 /// It should be used to set parameters which are not yet available through their own
7679 /// setters.
7680 ///
7681 /// Please note that this method must not be used to set any of the known parameters
7682 /// which have their own setter method. If done anyway, the request will fail.
7683 ///
7684 /// # Additional Parameters
7685 ///
7686 /// * *$.xgafv* (query-string) - V1 error format.
7687 /// * *access_token* (query-string) - OAuth access token.
7688 /// * *alt* (query-string) - Data format for response.
7689 /// * *callback* (query-string) - JSONP
7690 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7691 /// * *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.
7692 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7693 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7694 /// * *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.
7695 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7696 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7697 pub fn param<T>(mut self, name: T, value: T) -> FolderLocationInsightTypeInsightGetCall<'a, C>
7698 where
7699 T: AsRef<str>,
7700 {
7701 self._additional_params
7702 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7703 self
7704 }
7705
7706 /// Identifies the authorization scope for the method you are building.
7707 ///
7708 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7709 /// [`Scope::CloudPlatform`].
7710 ///
7711 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7712 /// tokens for more than one scope.
7713 ///
7714 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7715 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7716 /// sufficient, a read-write scope will do as well.
7717 pub fn add_scope<St>(mut self, scope: St) -> FolderLocationInsightTypeInsightGetCall<'a, C>
7718 where
7719 St: AsRef<str>,
7720 {
7721 self._scopes.insert(String::from(scope.as_ref()));
7722 self
7723 }
7724 /// Identifies the authorization scope(s) for the method you are building.
7725 ///
7726 /// See [`Self::add_scope()`] for details.
7727 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderLocationInsightTypeInsightGetCall<'a, C>
7728 where
7729 I: IntoIterator<Item = St>,
7730 St: AsRef<str>,
7731 {
7732 self._scopes
7733 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7734 self
7735 }
7736
7737 /// Removes all scopes, and no default scope will be used either.
7738 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7739 /// for details).
7740 pub fn clear_scopes(mut self) -> FolderLocationInsightTypeInsightGetCall<'a, C> {
7741 self._scopes.clear();
7742 self
7743 }
7744}
7745
7746/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
7747///
7748/// A builder for the *locations.insightTypes.insights.list* method supported by a *folder* resource.
7749/// It is not used directly, but through a [`FolderMethods`] instance.
7750///
7751/// # Example
7752///
7753/// Instantiate a resource method builder
7754///
7755/// ```test_harness,no_run
7756/// # extern crate hyper;
7757/// # extern crate hyper_rustls;
7758/// # extern crate google_recommender1_beta1 as recommender1_beta1;
7759/// # async fn dox() {
7760/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7761///
7762/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7763/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7764/// # .with_native_roots()
7765/// # .unwrap()
7766/// # .https_only()
7767/// # .enable_http2()
7768/// # .build();
7769///
7770/// # let executor = hyper_util::rt::TokioExecutor::new();
7771/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7772/// # secret,
7773/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7774/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7775/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7776/// # ),
7777/// # ).build().await.unwrap();
7778///
7779/// # let client = hyper_util::client::legacy::Client::builder(
7780/// # hyper_util::rt::TokioExecutor::new()
7781/// # )
7782/// # .build(
7783/// # hyper_rustls::HttpsConnectorBuilder::new()
7784/// # .with_native_roots()
7785/// # .unwrap()
7786/// # .https_or_http()
7787/// # .enable_http2()
7788/// # .build()
7789/// # );
7790/// # let mut hub = Recommender::new(client, auth);
7791/// // You can configure optional parameters by calling the respective setters at will, and
7792/// // execute the final call using `doit()`.
7793/// // Values shown here are possibly random and not representative !
7794/// let result = hub.folders().locations_insight_types_insights_list("parent")
7795/// .page_token("gubergren")
7796/// .page_size(-17)
7797/// .filter("dolor")
7798/// .doit().await;
7799/// # }
7800/// ```
7801pub struct FolderLocationInsightTypeInsightListCall<'a, C>
7802where
7803 C: 'a,
7804{
7805 hub: &'a Recommender<C>,
7806 _parent: String,
7807 _page_token: Option<String>,
7808 _page_size: Option<i32>,
7809 _filter: Option<String>,
7810 _delegate: Option<&'a mut dyn common::Delegate>,
7811 _additional_params: HashMap<String, String>,
7812 _scopes: BTreeSet<String>,
7813}
7814
7815impl<'a, C> common::CallBuilder for FolderLocationInsightTypeInsightListCall<'a, C> {}
7816
7817impl<'a, C> FolderLocationInsightTypeInsightListCall<'a, C>
7818where
7819 C: common::Connector,
7820{
7821 /// Perform the operation you have build so far.
7822 pub async fn doit(
7823 mut self,
7824 ) -> common::Result<(
7825 common::Response,
7826 GoogleCloudRecommenderV1beta1ListInsightsResponse,
7827 )> {
7828 use std::borrow::Cow;
7829 use std::io::{Read, Seek};
7830
7831 use common::{url::Params, ToParts};
7832 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7833
7834 let mut dd = common::DefaultDelegate;
7835 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7836 dlg.begin(common::MethodInfo {
7837 id: "recommender.folders.locations.insightTypes.insights.list",
7838 http_method: hyper::Method::GET,
7839 });
7840
7841 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
7842 if self._additional_params.contains_key(field) {
7843 dlg.finished(false);
7844 return Err(common::Error::FieldClash(field));
7845 }
7846 }
7847
7848 let mut params = Params::with_capacity(6 + self._additional_params.len());
7849 params.push("parent", self._parent);
7850 if let Some(value) = self._page_token.as_ref() {
7851 params.push("pageToken", value);
7852 }
7853 if let Some(value) = self._page_size.as_ref() {
7854 params.push("pageSize", value.to_string());
7855 }
7856 if let Some(value) = self._filter.as_ref() {
7857 params.push("filter", value);
7858 }
7859
7860 params.extend(self._additional_params.iter());
7861
7862 params.push("alt", "json");
7863 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/insights";
7864 if self._scopes.is_empty() {
7865 self._scopes
7866 .insert(Scope::CloudPlatform.as_ref().to_string());
7867 }
7868
7869 #[allow(clippy::single_element_loop)]
7870 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7871 url = params.uri_replacement(url, param_name, find_this, true);
7872 }
7873 {
7874 let to_remove = ["parent"];
7875 params.remove_params(&to_remove);
7876 }
7877
7878 let url = params.parse_with_url(&url);
7879
7880 loop {
7881 let token = match self
7882 .hub
7883 .auth
7884 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7885 .await
7886 {
7887 Ok(token) => token,
7888 Err(e) => match dlg.token(e) {
7889 Ok(token) => token,
7890 Err(e) => {
7891 dlg.finished(false);
7892 return Err(common::Error::MissingToken(e));
7893 }
7894 },
7895 };
7896 let mut req_result = {
7897 let client = &self.hub.client;
7898 dlg.pre_request();
7899 let mut req_builder = hyper::Request::builder()
7900 .method(hyper::Method::GET)
7901 .uri(url.as_str())
7902 .header(USER_AGENT, self.hub._user_agent.clone());
7903
7904 if let Some(token) = token.as_ref() {
7905 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7906 }
7907
7908 let request = req_builder
7909 .header(CONTENT_LENGTH, 0_u64)
7910 .body(common::to_body::<String>(None));
7911
7912 client.request(request.unwrap()).await
7913 };
7914
7915 match req_result {
7916 Err(err) => {
7917 if let common::Retry::After(d) = dlg.http_error(&err) {
7918 sleep(d).await;
7919 continue;
7920 }
7921 dlg.finished(false);
7922 return Err(common::Error::HttpError(err));
7923 }
7924 Ok(res) => {
7925 let (mut parts, body) = res.into_parts();
7926 let mut body = common::Body::new(body);
7927 if !parts.status.is_success() {
7928 let bytes = common::to_bytes(body).await.unwrap_or_default();
7929 let error = serde_json::from_str(&common::to_string(&bytes));
7930 let response = common::to_response(parts, bytes.into());
7931
7932 if let common::Retry::After(d) =
7933 dlg.http_failure(&response, error.as_ref().ok())
7934 {
7935 sleep(d).await;
7936 continue;
7937 }
7938
7939 dlg.finished(false);
7940
7941 return Err(match error {
7942 Ok(value) => common::Error::BadRequest(value),
7943 _ => common::Error::Failure(response),
7944 });
7945 }
7946 let response = {
7947 let bytes = common::to_bytes(body).await.unwrap_or_default();
7948 let encoded = common::to_string(&bytes);
7949 match serde_json::from_str(&encoded) {
7950 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7951 Err(error) => {
7952 dlg.response_json_decode_error(&encoded, &error);
7953 return Err(common::Error::JsonDecodeError(
7954 encoded.to_string(),
7955 error,
7956 ));
7957 }
7958 }
7959 };
7960
7961 dlg.finished(true);
7962 return Ok(response);
7963 }
7964 }
7965 }
7966 }
7967
7968 /// 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.
7969 ///
7970 /// Sets the *parent* path property to the given value.
7971 ///
7972 /// Even though the property as already been set when instantiating this call,
7973 /// we provide this method for API completeness.
7974 pub fn parent(mut self, new_value: &str) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7975 self._parent = new_value.to_string();
7976 self
7977 }
7978 /// 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.
7979 ///
7980 /// Sets the *page token* query property to the given value.
7981 pub fn page_token(
7982 mut self,
7983 new_value: &str,
7984 ) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7985 self._page_token = Some(new_value.to_string());
7986 self
7987 }
7988 /// 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.
7989 ///
7990 /// Sets the *page size* query property to the given value.
7991 pub fn page_size(mut self, new_value: i32) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7992 self._page_size = Some(new_value);
7993 self
7994 }
7995 /// 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)
7996 ///
7997 /// Sets the *filter* query property to the given value.
7998 pub fn filter(mut self, new_value: &str) -> FolderLocationInsightTypeInsightListCall<'a, C> {
7999 self._filter = Some(new_value.to_string());
8000 self
8001 }
8002 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8003 /// while executing the actual API request.
8004 ///
8005 /// ````text
8006 /// It should be used to handle progress information, and to implement a certain level of resilience.
8007 /// ````
8008 ///
8009 /// Sets the *delegate* property to the given value.
8010 pub fn delegate(
8011 mut self,
8012 new_value: &'a mut dyn common::Delegate,
8013 ) -> FolderLocationInsightTypeInsightListCall<'a, C> {
8014 self._delegate = Some(new_value);
8015 self
8016 }
8017
8018 /// Set any additional parameter of the query string used in the request.
8019 /// It should be used to set parameters which are not yet available through their own
8020 /// setters.
8021 ///
8022 /// Please note that this method must not be used to set any of the known parameters
8023 /// which have their own setter method. If done anyway, the request will fail.
8024 ///
8025 /// # Additional Parameters
8026 ///
8027 /// * *$.xgafv* (query-string) - V1 error format.
8028 /// * *access_token* (query-string) - OAuth access token.
8029 /// * *alt* (query-string) - Data format for response.
8030 /// * *callback* (query-string) - JSONP
8031 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8032 /// * *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.
8033 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8034 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8035 /// * *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.
8036 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8037 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8038 pub fn param<T>(mut self, name: T, value: T) -> FolderLocationInsightTypeInsightListCall<'a, C>
8039 where
8040 T: AsRef<str>,
8041 {
8042 self._additional_params
8043 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8044 self
8045 }
8046
8047 /// Identifies the authorization scope for the method you are building.
8048 ///
8049 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8050 /// [`Scope::CloudPlatform`].
8051 ///
8052 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8053 /// tokens for more than one scope.
8054 ///
8055 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8056 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8057 /// sufficient, a read-write scope will do as well.
8058 pub fn add_scope<St>(mut self, scope: St) -> FolderLocationInsightTypeInsightListCall<'a, C>
8059 where
8060 St: AsRef<str>,
8061 {
8062 self._scopes.insert(String::from(scope.as_ref()));
8063 self
8064 }
8065 /// Identifies the authorization scope(s) for the method you are building.
8066 ///
8067 /// See [`Self::add_scope()`] for details.
8068 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderLocationInsightTypeInsightListCall<'a, C>
8069 where
8070 I: IntoIterator<Item = St>,
8071 St: AsRef<str>,
8072 {
8073 self._scopes
8074 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8075 self
8076 }
8077
8078 /// Removes all scopes, and no default scope will be used either.
8079 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8080 /// for details).
8081 pub fn clear_scopes(mut self) -> FolderLocationInsightTypeInsightListCall<'a, C> {
8082 self._scopes.clear();
8083 self
8084 }
8085}
8086
8087/// 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.
8088///
8089/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *folder* resource.
8090/// It is not used directly, but through a [`FolderMethods`] instance.
8091///
8092/// # Example
8093///
8094/// Instantiate a resource method builder
8095///
8096/// ```test_harness,no_run
8097/// # extern crate hyper;
8098/// # extern crate hyper_rustls;
8099/// # extern crate google_recommender1_beta1 as recommender1_beta1;
8100/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
8101/// # async fn dox() {
8102/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8103///
8104/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8105/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8106/// # .with_native_roots()
8107/// # .unwrap()
8108/// # .https_only()
8109/// # .enable_http2()
8110/// # .build();
8111///
8112/// # let executor = hyper_util::rt::TokioExecutor::new();
8113/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8114/// # secret,
8115/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8116/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8117/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8118/// # ),
8119/// # ).build().await.unwrap();
8120///
8121/// # let client = hyper_util::client::legacy::Client::builder(
8122/// # hyper_util::rt::TokioExecutor::new()
8123/// # )
8124/// # .build(
8125/// # hyper_rustls::HttpsConnectorBuilder::new()
8126/// # .with_native_roots()
8127/// # .unwrap()
8128/// # .https_or_http()
8129/// # .enable_http2()
8130/// # .build()
8131/// # );
8132/// # let mut hub = Recommender::new(client, auth);
8133/// // As the method needs a request, you would usually fill it with the desired information
8134/// // into the respective structure. Some of the parts shown here might not be applicable !
8135/// // Values shown here are possibly random and not representative !
8136/// let mut req = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::default();
8137///
8138/// // You can configure optional parameters by calling the respective setters at will, and
8139/// // execute the final call using `doit()`.
8140/// // Values shown here are possibly random and not representative !
8141/// let result = hub.folders().locations_insight_types_insights_mark_accepted(req, "name")
8142/// .doit().await;
8143/// # }
8144/// ```
8145pub struct FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
8146where
8147 C: 'a,
8148{
8149 hub: &'a Recommender<C>,
8150 _request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
8151 _name: String,
8152 _delegate: Option<&'a mut dyn common::Delegate>,
8153 _additional_params: HashMap<String, String>,
8154 _scopes: BTreeSet<String>,
8155}
8156
8157impl<'a, C> common::CallBuilder for FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {}
8158
8159impl<'a, C> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
8160where
8161 C: common::Connector,
8162{
8163 /// Perform the operation you have build so far.
8164 pub async fn doit(
8165 mut self,
8166 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
8167 use std::borrow::Cow;
8168 use std::io::{Read, Seek};
8169
8170 use common::{url::Params, ToParts};
8171 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8172
8173 let mut dd = common::DefaultDelegate;
8174 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8175 dlg.begin(common::MethodInfo {
8176 id: "recommender.folders.locations.insightTypes.insights.markAccepted",
8177 http_method: hyper::Method::POST,
8178 });
8179
8180 for &field in ["alt", "name"].iter() {
8181 if self._additional_params.contains_key(field) {
8182 dlg.finished(false);
8183 return Err(common::Error::FieldClash(field));
8184 }
8185 }
8186
8187 let mut params = Params::with_capacity(4 + self._additional_params.len());
8188 params.push("name", self._name);
8189
8190 params.extend(self._additional_params.iter());
8191
8192 params.push("alt", "json");
8193 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markAccepted";
8194 if self._scopes.is_empty() {
8195 self._scopes
8196 .insert(Scope::CloudPlatform.as_ref().to_string());
8197 }
8198
8199 #[allow(clippy::single_element_loop)]
8200 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8201 url = params.uri_replacement(url, param_name, find_this, true);
8202 }
8203 {
8204 let to_remove = ["name"];
8205 params.remove_params(&to_remove);
8206 }
8207
8208 let url = params.parse_with_url(&url);
8209
8210 let mut json_mime_type = mime::APPLICATION_JSON;
8211 let mut request_value_reader = {
8212 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8213 common::remove_json_null_values(&mut value);
8214 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8215 serde_json::to_writer(&mut dst, &value).unwrap();
8216 dst
8217 };
8218 let request_size = request_value_reader
8219 .seek(std::io::SeekFrom::End(0))
8220 .unwrap();
8221 request_value_reader
8222 .seek(std::io::SeekFrom::Start(0))
8223 .unwrap();
8224
8225 loop {
8226 let token = match self
8227 .hub
8228 .auth
8229 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8230 .await
8231 {
8232 Ok(token) => token,
8233 Err(e) => match dlg.token(e) {
8234 Ok(token) => token,
8235 Err(e) => {
8236 dlg.finished(false);
8237 return Err(common::Error::MissingToken(e));
8238 }
8239 },
8240 };
8241 request_value_reader
8242 .seek(std::io::SeekFrom::Start(0))
8243 .unwrap();
8244 let mut req_result = {
8245 let client = &self.hub.client;
8246 dlg.pre_request();
8247 let mut req_builder = hyper::Request::builder()
8248 .method(hyper::Method::POST)
8249 .uri(url.as_str())
8250 .header(USER_AGENT, self.hub._user_agent.clone());
8251
8252 if let Some(token) = token.as_ref() {
8253 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8254 }
8255
8256 let request = req_builder
8257 .header(CONTENT_TYPE, json_mime_type.to_string())
8258 .header(CONTENT_LENGTH, request_size as u64)
8259 .body(common::to_body(
8260 request_value_reader.get_ref().clone().into(),
8261 ));
8262
8263 client.request(request.unwrap()).await
8264 };
8265
8266 match req_result {
8267 Err(err) => {
8268 if let common::Retry::After(d) = dlg.http_error(&err) {
8269 sleep(d).await;
8270 continue;
8271 }
8272 dlg.finished(false);
8273 return Err(common::Error::HttpError(err));
8274 }
8275 Ok(res) => {
8276 let (mut parts, body) = res.into_parts();
8277 let mut body = common::Body::new(body);
8278 if !parts.status.is_success() {
8279 let bytes = common::to_bytes(body).await.unwrap_or_default();
8280 let error = serde_json::from_str(&common::to_string(&bytes));
8281 let response = common::to_response(parts, bytes.into());
8282
8283 if let common::Retry::After(d) =
8284 dlg.http_failure(&response, error.as_ref().ok())
8285 {
8286 sleep(d).await;
8287 continue;
8288 }
8289
8290 dlg.finished(false);
8291
8292 return Err(match error {
8293 Ok(value) => common::Error::BadRequest(value),
8294 _ => common::Error::Failure(response),
8295 });
8296 }
8297 let response = {
8298 let bytes = common::to_bytes(body).await.unwrap_or_default();
8299 let encoded = common::to_string(&bytes);
8300 match serde_json::from_str(&encoded) {
8301 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8302 Err(error) => {
8303 dlg.response_json_decode_error(&encoded, &error);
8304 return Err(common::Error::JsonDecodeError(
8305 encoded.to_string(),
8306 error,
8307 ));
8308 }
8309 }
8310 };
8311
8312 dlg.finished(true);
8313 return Ok(response);
8314 }
8315 }
8316 }
8317 }
8318
8319 ///
8320 /// Sets the *request* property to the given value.
8321 ///
8322 /// Even though the property as already been set when instantiating this call,
8323 /// we provide this method for API completeness.
8324 pub fn request(
8325 mut self,
8326 new_value: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
8327 ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
8328 self._request = new_value;
8329 self
8330 }
8331 /// Required. Name of the insight.
8332 ///
8333 /// Sets the *name* path property to the given value.
8334 ///
8335 /// Even though the property as already been set when instantiating this call,
8336 /// we provide this method for API completeness.
8337 pub fn name(
8338 mut self,
8339 new_value: &str,
8340 ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
8341 self._name = new_value.to_string();
8342 self
8343 }
8344 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8345 /// while executing the actual API request.
8346 ///
8347 /// ````text
8348 /// It should be used to handle progress information, and to implement a certain level of resilience.
8349 /// ````
8350 ///
8351 /// Sets the *delegate* property to the given value.
8352 pub fn delegate(
8353 mut self,
8354 new_value: &'a mut dyn common::Delegate,
8355 ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
8356 self._delegate = Some(new_value);
8357 self
8358 }
8359
8360 /// Set any additional parameter of the query string used in the request.
8361 /// It should be used to set parameters which are not yet available through their own
8362 /// setters.
8363 ///
8364 /// Please note that this method must not be used to set any of the known parameters
8365 /// which have their own setter method. If done anyway, the request will fail.
8366 ///
8367 /// # Additional Parameters
8368 ///
8369 /// * *$.xgafv* (query-string) - V1 error format.
8370 /// * *access_token* (query-string) - OAuth access token.
8371 /// * *alt* (query-string) - Data format for response.
8372 /// * *callback* (query-string) - JSONP
8373 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8374 /// * *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.
8375 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8376 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8377 /// * *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.
8378 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8379 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8380 pub fn param<T>(
8381 mut self,
8382 name: T,
8383 value: T,
8384 ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
8385 where
8386 T: AsRef<str>,
8387 {
8388 self._additional_params
8389 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8390 self
8391 }
8392
8393 /// Identifies the authorization scope for the method you are building.
8394 ///
8395 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8396 /// [`Scope::CloudPlatform`].
8397 ///
8398 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8399 /// tokens for more than one scope.
8400 ///
8401 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8402 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8403 /// sufficient, a read-write scope will do as well.
8404 pub fn add_scope<St>(
8405 mut self,
8406 scope: St,
8407 ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
8408 where
8409 St: AsRef<str>,
8410 {
8411 self._scopes.insert(String::from(scope.as_ref()));
8412 self
8413 }
8414 /// Identifies the authorization scope(s) for the method you are building.
8415 ///
8416 /// See [`Self::add_scope()`] for details.
8417 pub fn add_scopes<I, St>(
8418 mut self,
8419 scopes: I,
8420 ) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C>
8421 where
8422 I: IntoIterator<Item = St>,
8423 St: AsRef<str>,
8424 {
8425 self._scopes
8426 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8427 self
8428 }
8429
8430 /// Removes all scopes, and no default scope will be used either.
8431 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8432 /// for details).
8433 pub fn clear_scopes(mut self) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
8434 self._scopes.clear();
8435 self
8436 }
8437}
8438
8439/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
8440///
8441/// A builder for the *locations.recommenders.recommendations.get* method supported by a *folder* resource.
8442/// It is not used directly, but through a [`FolderMethods`] instance.
8443///
8444/// # Example
8445///
8446/// Instantiate a resource method builder
8447///
8448/// ```test_harness,no_run
8449/// # extern crate hyper;
8450/// # extern crate hyper_rustls;
8451/// # extern crate google_recommender1_beta1 as recommender1_beta1;
8452/// # async fn dox() {
8453/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8454///
8455/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8456/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8457/// # .with_native_roots()
8458/// # .unwrap()
8459/// # .https_only()
8460/// # .enable_http2()
8461/// # .build();
8462///
8463/// # let executor = hyper_util::rt::TokioExecutor::new();
8464/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8465/// # secret,
8466/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8467/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8468/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8469/// # ),
8470/// # ).build().await.unwrap();
8471///
8472/// # let client = hyper_util::client::legacy::Client::builder(
8473/// # hyper_util::rt::TokioExecutor::new()
8474/// # )
8475/// # .build(
8476/// # hyper_rustls::HttpsConnectorBuilder::new()
8477/// # .with_native_roots()
8478/// # .unwrap()
8479/// # .https_or_http()
8480/// # .enable_http2()
8481/// # .build()
8482/// # );
8483/// # let mut hub = Recommender::new(client, auth);
8484/// // You can configure optional parameters by calling the respective setters at will, and
8485/// // execute the final call using `doit()`.
8486/// // Values shown here are possibly random and not representative !
8487/// let result = hub.folders().locations_recommenders_recommendations_get("name")
8488/// .doit().await;
8489/// # }
8490/// ```
8491pub struct FolderLocationRecommenderRecommendationGetCall<'a, C>
8492where
8493 C: 'a,
8494{
8495 hub: &'a Recommender<C>,
8496 _name: String,
8497 _delegate: Option<&'a mut dyn common::Delegate>,
8498 _additional_params: HashMap<String, String>,
8499 _scopes: BTreeSet<String>,
8500}
8501
8502impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationGetCall<'a, C> {}
8503
8504impl<'a, C> FolderLocationRecommenderRecommendationGetCall<'a, C>
8505where
8506 C: common::Connector,
8507{
8508 /// Perform the operation you have build so far.
8509 pub async fn doit(
8510 mut self,
8511 ) -> common::Result<(
8512 common::Response,
8513 GoogleCloudRecommenderV1beta1Recommendation,
8514 )> {
8515 use std::borrow::Cow;
8516 use std::io::{Read, Seek};
8517
8518 use common::{url::Params, ToParts};
8519 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8520
8521 let mut dd = common::DefaultDelegate;
8522 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8523 dlg.begin(common::MethodInfo {
8524 id: "recommender.folders.locations.recommenders.recommendations.get",
8525 http_method: hyper::Method::GET,
8526 });
8527
8528 for &field in ["alt", "name"].iter() {
8529 if self._additional_params.contains_key(field) {
8530 dlg.finished(false);
8531 return Err(common::Error::FieldClash(field));
8532 }
8533 }
8534
8535 let mut params = Params::with_capacity(3 + self._additional_params.len());
8536 params.push("name", self._name);
8537
8538 params.extend(self._additional_params.iter());
8539
8540 params.push("alt", "json");
8541 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
8542 if self._scopes.is_empty() {
8543 self._scopes
8544 .insert(Scope::CloudPlatform.as_ref().to_string());
8545 }
8546
8547 #[allow(clippy::single_element_loop)]
8548 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8549 url = params.uri_replacement(url, param_name, find_this, true);
8550 }
8551 {
8552 let to_remove = ["name"];
8553 params.remove_params(&to_remove);
8554 }
8555
8556 let url = params.parse_with_url(&url);
8557
8558 loop {
8559 let token = match self
8560 .hub
8561 .auth
8562 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8563 .await
8564 {
8565 Ok(token) => token,
8566 Err(e) => match dlg.token(e) {
8567 Ok(token) => token,
8568 Err(e) => {
8569 dlg.finished(false);
8570 return Err(common::Error::MissingToken(e));
8571 }
8572 },
8573 };
8574 let mut req_result = {
8575 let client = &self.hub.client;
8576 dlg.pre_request();
8577 let mut req_builder = hyper::Request::builder()
8578 .method(hyper::Method::GET)
8579 .uri(url.as_str())
8580 .header(USER_AGENT, self.hub._user_agent.clone());
8581
8582 if let Some(token) = token.as_ref() {
8583 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8584 }
8585
8586 let request = req_builder
8587 .header(CONTENT_LENGTH, 0_u64)
8588 .body(common::to_body::<String>(None));
8589
8590 client.request(request.unwrap()).await
8591 };
8592
8593 match req_result {
8594 Err(err) => {
8595 if let common::Retry::After(d) = dlg.http_error(&err) {
8596 sleep(d).await;
8597 continue;
8598 }
8599 dlg.finished(false);
8600 return Err(common::Error::HttpError(err));
8601 }
8602 Ok(res) => {
8603 let (mut parts, body) = res.into_parts();
8604 let mut body = common::Body::new(body);
8605 if !parts.status.is_success() {
8606 let bytes = common::to_bytes(body).await.unwrap_or_default();
8607 let error = serde_json::from_str(&common::to_string(&bytes));
8608 let response = common::to_response(parts, bytes.into());
8609
8610 if let common::Retry::After(d) =
8611 dlg.http_failure(&response, error.as_ref().ok())
8612 {
8613 sleep(d).await;
8614 continue;
8615 }
8616
8617 dlg.finished(false);
8618
8619 return Err(match error {
8620 Ok(value) => common::Error::BadRequest(value),
8621 _ => common::Error::Failure(response),
8622 });
8623 }
8624 let response = {
8625 let bytes = common::to_bytes(body).await.unwrap_or_default();
8626 let encoded = common::to_string(&bytes);
8627 match serde_json::from_str(&encoded) {
8628 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8629 Err(error) => {
8630 dlg.response_json_decode_error(&encoded, &error);
8631 return Err(common::Error::JsonDecodeError(
8632 encoded.to_string(),
8633 error,
8634 ));
8635 }
8636 }
8637 };
8638
8639 dlg.finished(true);
8640 return Ok(response);
8641 }
8642 }
8643 }
8644 }
8645
8646 /// Required. Name of the recommendation.
8647 ///
8648 /// Sets the *name* path property to the given value.
8649 ///
8650 /// Even though the property as already been set when instantiating this call,
8651 /// we provide this method for API completeness.
8652 pub fn name(
8653 mut self,
8654 new_value: &str,
8655 ) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
8656 self._name = new_value.to_string();
8657 self
8658 }
8659 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8660 /// while executing the actual API request.
8661 ///
8662 /// ````text
8663 /// It should be used to handle progress information, and to implement a certain level of resilience.
8664 /// ````
8665 ///
8666 /// Sets the *delegate* property to the given value.
8667 pub fn delegate(
8668 mut self,
8669 new_value: &'a mut dyn common::Delegate,
8670 ) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
8671 self._delegate = Some(new_value);
8672 self
8673 }
8674
8675 /// Set any additional parameter of the query string used in the request.
8676 /// It should be used to set parameters which are not yet available through their own
8677 /// setters.
8678 ///
8679 /// Please note that this method must not be used to set any of the known parameters
8680 /// which have their own setter method. If done anyway, the request will fail.
8681 ///
8682 /// # Additional Parameters
8683 ///
8684 /// * *$.xgafv* (query-string) - V1 error format.
8685 /// * *access_token* (query-string) - OAuth access token.
8686 /// * *alt* (query-string) - Data format for response.
8687 /// * *callback* (query-string) - JSONP
8688 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8689 /// * *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.
8690 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8691 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8692 /// * *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.
8693 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8694 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8695 pub fn param<T>(
8696 mut self,
8697 name: T,
8698 value: T,
8699 ) -> FolderLocationRecommenderRecommendationGetCall<'a, C>
8700 where
8701 T: AsRef<str>,
8702 {
8703 self._additional_params
8704 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8705 self
8706 }
8707
8708 /// Identifies the authorization scope for the method you are building.
8709 ///
8710 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8711 /// [`Scope::CloudPlatform`].
8712 ///
8713 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8714 /// tokens for more than one scope.
8715 ///
8716 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8717 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8718 /// sufficient, a read-write scope will do as well.
8719 pub fn add_scope<St>(
8720 mut self,
8721 scope: St,
8722 ) -> FolderLocationRecommenderRecommendationGetCall<'a, C>
8723 where
8724 St: AsRef<str>,
8725 {
8726 self._scopes.insert(String::from(scope.as_ref()));
8727 self
8728 }
8729 /// Identifies the authorization scope(s) for the method you are building.
8730 ///
8731 /// See [`Self::add_scope()`] for details.
8732 pub fn add_scopes<I, St>(
8733 mut self,
8734 scopes: I,
8735 ) -> FolderLocationRecommenderRecommendationGetCall<'a, C>
8736 where
8737 I: IntoIterator<Item = St>,
8738 St: AsRef<str>,
8739 {
8740 self._scopes
8741 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8742 self
8743 }
8744
8745 /// Removes all scopes, and no default scope will be used either.
8746 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8747 /// for details).
8748 pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationGetCall<'a, C> {
8749 self._scopes.clear();
8750 self
8751 }
8752}
8753
8754/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
8755///
8756/// A builder for the *locations.recommenders.recommendations.list* method supported by a *folder* resource.
8757/// It is not used directly, but through a [`FolderMethods`] instance.
8758///
8759/// # Example
8760///
8761/// Instantiate a resource method builder
8762///
8763/// ```test_harness,no_run
8764/// # extern crate hyper;
8765/// # extern crate hyper_rustls;
8766/// # extern crate google_recommender1_beta1 as recommender1_beta1;
8767/// # async fn dox() {
8768/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8769///
8770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8771/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8772/// # .with_native_roots()
8773/// # .unwrap()
8774/// # .https_only()
8775/// # .enable_http2()
8776/// # .build();
8777///
8778/// # let executor = hyper_util::rt::TokioExecutor::new();
8779/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8780/// # secret,
8781/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8782/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8783/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8784/// # ),
8785/// # ).build().await.unwrap();
8786///
8787/// # let client = hyper_util::client::legacy::Client::builder(
8788/// # hyper_util::rt::TokioExecutor::new()
8789/// # )
8790/// # .build(
8791/// # hyper_rustls::HttpsConnectorBuilder::new()
8792/// # .with_native_roots()
8793/// # .unwrap()
8794/// # .https_or_http()
8795/// # .enable_http2()
8796/// # .build()
8797/// # );
8798/// # let mut hub = Recommender::new(client, auth);
8799/// // You can configure optional parameters by calling the respective setters at will, and
8800/// // execute the final call using `doit()`.
8801/// // Values shown here are possibly random and not representative !
8802/// let result = hub.folders().locations_recommenders_recommendations_list("parent")
8803/// .page_token("sed")
8804/// .page_size(-70)
8805/// .filter("sed")
8806/// .doit().await;
8807/// # }
8808/// ```
8809pub struct FolderLocationRecommenderRecommendationListCall<'a, C>
8810where
8811 C: 'a,
8812{
8813 hub: &'a Recommender<C>,
8814 _parent: String,
8815 _page_token: Option<String>,
8816 _page_size: Option<i32>,
8817 _filter: Option<String>,
8818 _delegate: Option<&'a mut dyn common::Delegate>,
8819 _additional_params: HashMap<String, String>,
8820 _scopes: BTreeSet<String>,
8821}
8822
8823impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationListCall<'a, C> {}
8824
8825impl<'a, C> FolderLocationRecommenderRecommendationListCall<'a, C>
8826where
8827 C: common::Connector,
8828{
8829 /// Perform the operation you have build so far.
8830 pub async fn doit(
8831 mut self,
8832 ) -> common::Result<(
8833 common::Response,
8834 GoogleCloudRecommenderV1beta1ListRecommendationsResponse,
8835 )> {
8836 use std::borrow::Cow;
8837 use std::io::{Read, Seek};
8838
8839 use common::{url::Params, ToParts};
8840 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8841
8842 let mut dd = common::DefaultDelegate;
8843 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8844 dlg.begin(common::MethodInfo {
8845 id: "recommender.folders.locations.recommenders.recommendations.list",
8846 http_method: hyper::Method::GET,
8847 });
8848
8849 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
8850 if self._additional_params.contains_key(field) {
8851 dlg.finished(false);
8852 return Err(common::Error::FieldClash(field));
8853 }
8854 }
8855
8856 let mut params = Params::with_capacity(6 + self._additional_params.len());
8857 params.push("parent", self._parent);
8858 if let Some(value) = self._page_token.as_ref() {
8859 params.push("pageToken", value);
8860 }
8861 if let Some(value) = self._page_size.as_ref() {
8862 params.push("pageSize", value.to_string());
8863 }
8864 if let Some(value) = self._filter.as_ref() {
8865 params.push("filter", value);
8866 }
8867
8868 params.extend(self._additional_params.iter());
8869
8870 params.push("alt", "json");
8871 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/recommendations";
8872 if self._scopes.is_empty() {
8873 self._scopes
8874 .insert(Scope::CloudPlatform.as_ref().to_string());
8875 }
8876
8877 #[allow(clippy::single_element_loop)]
8878 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8879 url = params.uri_replacement(url, param_name, find_this, true);
8880 }
8881 {
8882 let to_remove = ["parent"];
8883 params.remove_params(&to_remove);
8884 }
8885
8886 let url = params.parse_with_url(&url);
8887
8888 loop {
8889 let token = match self
8890 .hub
8891 .auth
8892 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8893 .await
8894 {
8895 Ok(token) => token,
8896 Err(e) => match dlg.token(e) {
8897 Ok(token) => token,
8898 Err(e) => {
8899 dlg.finished(false);
8900 return Err(common::Error::MissingToken(e));
8901 }
8902 },
8903 };
8904 let mut req_result = {
8905 let client = &self.hub.client;
8906 dlg.pre_request();
8907 let mut req_builder = hyper::Request::builder()
8908 .method(hyper::Method::GET)
8909 .uri(url.as_str())
8910 .header(USER_AGENT, self.hub._user_agent.clone());
8911
8912 if let Some(token) = token.as_ref() {
8913 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8914 }
8915
8916 let request = req_builder
8917 .header(CONTENT_LENGTH, 0_u64)
8918 .body(common::to_body::<String>(None));
8919
8920 client.request(request.unwrap()).await
8921 };
8922
8923 match req_result {
8924 Err(err) => {
8925 if let common::Retry::After(d) = dlg.http_error(&err) {
8926 sleep(d).await;
8927 continue;
8928 }
8929 dlg.finished(false);
8930 return Err(common::Error::HttpError(err));
8931 }
8932 Ok(res) => {
8933 let (mut parts, body) = res.into_parts();
8934 let mut body = common::Body::new(body);
8935 if !parts.status.is_success() {
8936 let bytes = common::to_bytes(body).await.unwrap_or_default();
8937 let error = serde_json::from_str(&common::to_string(&bytes));
8938 let response = common::to_response(parts, bytes.into());
8939
8940 if let common::Retry::After(d) =
8941 dlg.http_failure(&response, error.as_ref().ok())
8942 {
8943 sleep(d).await;
8944 continue;
8945 }
8946
8947 dlg.finished(false);
8948
8949 return Err(match error {
8950 Ok(value) => common::Error::BadRequest(value),
8951 _ => common::Error::Failure(response),
8952 });
8953 }
8954 let response = {
8955 let bytes = common::to_bytes(body).await.unwrap_or_default();
8956 let encoded = common::to_string(&bytes);
8957 match serde_json::from_str(&encoded) {
8958 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8959 Err(error) => {
8960 dlg.response_json_decode_error(&encoded, &error);
8961 return Err(common::Error::JsonDecodeError(
8962 encoded.to_string(),
8963 error,
8964 ));
8965 }
8966 }
8967 };
8968
8969 dlg.finished(true);
8970 return Ok(response);
8971 }
8972 }
8973 }
8974 }
8975
8976 /// 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.
8977 ///
8978 /// Sets the *parent* path property to the given value.
8979 ///
8980 /// Even though the property as already been set when instantiating this call,
8981 /// we provide this method for API completeness.
8982 pub fn parent(
8983 mut self,
8984 new_value: &str,
8985 ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8986 self._parent = new_value.to_string();
8987 self
8988 }
8989 /// 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.
8990 ///
8991 /// Sets the *page token* query property to the given value.
8992 pub fn page_token(
8993 mut self,
8994 new_value: &str,
8995 ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
8996 self._page_token = Some(new_value.to_string());
8997 self
8998 }
8999 /// 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.
9000 ///
9001 /// Sets the *page size* query property to the given value.
9002 pub fn page_size(
9003 mut self,
9004 new_value: i32,
9005 ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
9006 self._page_size = Some(new_value);
9007 self
9008 }
9009 /// 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)
9010 ///
9011 /// Sets the *filter* query property to the given value.
9012 pub fn filter(
9013 mut self,
9014 new_value: &str,
9015 ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
9016 self._filter = Some(new_value.to_string());
9017 self
9018 }
9019 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9020 /// while executing the actual API request.
9021 ///
9022 /// ````text
9023 /// It should be used to handle progress information, and to implement a certain level of resilience.
9024 /// ````
9025 ///
9026 /// Sets the *delegate* property to the given value.
9027 pub fn delegate(
9028 mut self,
9029 new_value: &'a mut dyn common::Delegate,
9030 ) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
9031 self._delegate = Some(new_value);
9032 self
9033 }
9034
9035 /// Set any additional parameter of the query string used in the request.
9036 /// It should be used to set parameters which are not yet available through their own
9037 /// setters.
9038 ///
9039 /// Please note that this method must not be used to set any of the known parameters
9040 /// which have their own setter method. If done anyway, the request will fail.
9041 ///
9042 /// # Additional Parameters
9043 ///
9044 /// * *$.xgafv* (query-string) - V1 error format.
9045 /// * *access_token* (query-string) - OAuth access token.
9046 /// * *alt* (query-string) - Data format for response.
9047 /// * *callback* (query-string) - JSONP
9048 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9049 /// * *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.
9050 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9051 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9052 /// * *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.
9053 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9054 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9055 pub fn param<T>(
9056 mut self,
9057 name: T,
9058 value: T,
9059 ) -> FolderLocationRecommenderRecommendationListCall<'a, C>
9060 where
9061 T: AsRef<str>,
9062 {
9063 self._additional_params
9064 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9065 self
9066 }
9067
9068 /// Identifies the authorization scope for the method you are building.
9069 ///
9070 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9071 /// [`Scope::CloudPlatform`].
9072 ///
9073 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9074 /// tokens for more than one scope.
9075 ///
9076 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9077 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9078 /// sufficient, a read-write scope will do as well.
9079 pub fn add_scope<St>(
9080 mut self,
9081 scope: St,
9082 ) -> FolderLocationRecommenderRecommendationListCall<'a, C>
9083 where
9084 St: AsRef<str>,
9085 {
9086 self._scopes.insert(String::from(scope.as_ref()));
9087 self
9088 }
9089 /// Identifies the authorization scope(s) for the method you are building.
9090 ///
9091 /// See [`Self::add_scope()`] for details.
9092 pub fn add_scopes<I, St>(
9093 mut self,
9094 scopes: I,
9095 ) -> FolderLocationRecommenderRecommendationListCall<'a, C>
9096 where
9097 I: IntoIterator<Item = St>,
9098 St: AsRef<str>,
9099 {
9100 self._scopes
9101 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9102 self
9103 }
9104
9105 /// Removes all scopes, and no default scope will be used either.
9106 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9107 /// for details).
9108 pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationListCall<'a, C> {
9109 self._scopes.clear();
9110 self
9111 }
9112}
9113
9114/// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
9115///
9116/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *folder* resource.
9117/// It is not used directly, but through a [`FolderMethods`] instance.
9118///
9119/// # Example
9120///
9121/// Instantiate a resource method builder
9122///
9123/// ```test_harness,no_run
9124/// # extern crate hyper;
9125/// # extern crate hyper_rustls;
9126/// # extern crate google_recommender1_beta1 as recommender1_beta1;
9127/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
9128/// # async fn dox() {
9129/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9130///
9131/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9132/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9133/// # .with_native_roots()
9134/// # .unwrap()
9135/// # .https_only()
9136/// # .enable_http2()
9137/// # .build();
9138///
9139/// # let executor = hyper_util::rt::TokioExecutor::new();
9140/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9141/// # secret,
9142/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9143/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9144/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9145/// # ),
9146/// # ).build().await.unwrap();
9147///
9148/// # let client = hyper_util::client::legacy::Client::builder(
9149/// # hyper_util::rt::TokioExecutor::new()
9150/// # )
9151/// # .build(
9152/// # hyper_rustls::HttpsConnectorBuilder::new()
9153/// # .with_native_roots()
9154/// # .unwrap()
9155/// # .https_or_http()
9156/// # .enable_http2()
9157/// # .build()
9158/// # );
9159/// # let mut hub = Recommender::new(client, auth);
9160/// // As the method needs a request, you would usually fill it with the desired information
9161/// // into the respective structure. Some of the parts shown here might not be applicable !
9162/// // Values shown here are possibly random and not representative !
9163/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::default();
9164///
9165/// // You can configure optional parameters by calling the respective setters at will, and
9166/// // execute the final call using `doit()`.
9167/// // Values shown here are possibly random and not representative !
9168/// let result = hub.folders().locations_recommenders_recommendations_mark_claimed(req, "name")
9169/// .doit().await;
9170/// # }
9171/// ```
9172pub struct FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
9173where
9174 C: 'a,
9175{
9176 hub: &'a Recommender<C>,
9177 _request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
9178 _name: String,
9179 _delegate: Option<&'a mut dyn common::Delegate>,
9180 _additional_params: HashMap<String, String>,
9181 _scopes: BTreeSet<String>,
9182}
9183
9184impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {}
9185
9186impl<'a, C> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
9187where
9188 C: common::Connector,
9189{
9190 /// Perform the operation you have build so far.
9191 pub async fn doit(
9192 mut self,
9193 ) -> common::Result<(
9194 common::Response,
9195 GoogleCloudRecommenderV1beta1Recommendation,
9196 )> {
9197 use std::borrow::Cow;
9198 use std::io::{Read, Seek};
9199
9200 use common::{url::Params, ToParts};
9201 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9202
9203 let mut dd = common::DefaultDelegate;
9204 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9205 dlg.begin(common::MethodInfo {
9206 id: "recommender.folders.locations.recommenders.recommendations.markClaimed",
9207 http_method: hyper::Method::POST,
9208 });
9209
9210 for &field in ["alt", "name"].iter() {
9211 if self._additional_params.contains_key(field) {
9212 dlg.finished(false);
9213 return Err(common::Error::FieldClash(field));
9214 }
9215 }
9216
9217 let mut params = Params::with_capacity(4 + self._additional_params.len());
9218 params.push("name", self._name);
9219
9220 params.extend(self._additional_params.iter());
9221
9222 params.push("alt", "json");
9223 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markClaimed";
9224 if self._scopes.is_empty() {
9225 self._scopes
9226 .insert(Scope::CloudPlatform.as_ref().to_string());
9227 }
9228
9229 #[allow(clippy::single_element_loop)]
9230 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9231 url = params.uri_replacement(url, param_name, find_this, true);
9232 }
9233 {
9234 let to_remove = ["name"];
9235 params.remove_params(&to_remove);
9236 }
9237
9238 let url = params.parse_with_url(&url);
9239
9240 let mut json_mime_type = mime::APPLICATION_JSON;
9241 let mut request_value_reader = {
9242 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9243 common::remove_json_null_values(&mut value);
9244 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9245 serde_json::to_writer(&mut dst, &value).unwrap();
9246 dst
9247 };
9248 let request_size = request_value_reader
9249 .seek(std::io::SeekFrom::End(0))
9250 .unwrap();
9251 request_value_reader
9252 .seek(std::io::SeekFrom::Start(0))
9253 .unwrap();
9254
9255 loop {
9256 let token = match self
9257 .hub
9258 .auth
9259 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9260 .await
9261 {
9262 Ok(token) => token,
9263 Err(e) => match dlg.token(e) {
9264 Ok(token) => token,
9265 Err(e) => {
9266 dlg.finished(false);
9267 return Err(common::Error::MissingToken(e));
9268 }
9269 },
9270 };
9271 request_value_reader
9272 .seek(std::io::SeekFrom::Start(0))
9273 .unwrap();
9274 let mut req_result = {
9275 let client = &self.hub.client;
9276 dlg.pre_request();
9277 let mut req_builder = hyper::Request::builder()
9278 .method(hyper::Method::POST)
9279 .uri(url.as_str())
9280 .header(USER_AGENT, self.hub._user_agent.clone());
9281
9282 if let Some(token) = token.as_ref() {
9283 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9284 }
9285
9286 let request = req_builder
9287 .header(CONTENT_TYPE, json_mime_type.to_string())
9288 .header(CONTENT_LENGTH, request_size as u64)
9289 .body(common::to_body(
9290 request_value_reader.get_ref().clone().into(),
9291 ));
9292
9293 client.request(request.unwrap()).await
9294 };
9295
9296 match req_result {
9297 Err(err) => {
9298 if let common::Retry::After(d) = dlg.http_error(&err) {
9299 sleep(d).await;
9300 continue;
9301 }
9302 dlg.finished(false);
9303 return Err(common::Error::HttpError(err));
9304 }
9305 Ok(res) => {
9306 let (mut parts, body) = res.into_parts();
9307 let mut body = common::Body::new(body);
9308 if !parts.status.is_success() {
9309 let bytes = common::to_bytes(body).await.unwrap_or_default();
9310 let error = serde_json::from_str(&common::to_string(&bytes));
9311 let response = common::to_response(parts, bytes.into());
9312
9313 if let common::Retry::After(d) =
9314 dlg.http_failure(&response, error.as_ref().ok())
9315 {
9316 sleep(d).await;
9317 continue;
9318 }
9319
9320 dlg.finished(false);
9321
9322 return Err(match error {
9323 Ok(value) => common::Error::BadRequest(value),
9324 _ => common::Error::Failure(response),
9325 });
9326 }
9327 let response = {
9328 let bytes = common::to_bytes(body).await.unwrap_or_default();
9329 let encoded = common::to_string(&bytes);
9330 match serde_json::from_str(&encoded) {
9331 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9332 Err(error) => {
9333 dlg.response_json_decode_error(&encoded, &error);
9334 return Err(common::Error::JsonDecodeError(
9335 encoded.to_string(),
9336 error,
9337 ));
9338 }
9339 }
9340 };
9341
9342 dlg.finished(true);
9343 return Ok(response);
9344 }
9345 }
9346 }
9347 }
9348
9349 ///
9350 /// Sets the *request* property to the given value.
9351 ///
9352 /// Even though the property as already been set when instantiating this call,
9353 /// we provide this method for API completeness.
9354 pub fn request(
9355 mut self,
9356 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
9357 ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
9358 self._request = new_value;
9359 self
9360 }
9361 /// Required. Name of the recommendation.
9362 ///
9363 /// Sets the *name* path property to the given value.
9364 ///
9365 /// Even though the property as already been set when instantiating this call,
9366 /// we provide this method for API completeness.
9367 pub fn name(
9368 mut self,
9369 new_value: &str,
9370 ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
9371 self._name = new_value.to_string();
9372 self
9373 }
9374 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9375 /// while executing the actual API request.
9376 ///
9377 /// ````text
9378 /// It should be used to handle progress information, and to implement a certain level of resilience.
9379 /// ````
9380 ///
9381 /// Sets the *delegate* property to the given value.
9382 pub fn delegate(
9383 mut self,
9384 new_value: &'a mut dyn common::Delegate,
9385 ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
9386 self._delegate = Some(new_value);
9387 self
9388 }
9389
9390 /// Set any additional parameter of the query string used in the request.
9391 /// It should be used to set parameters which are not yet available through their own
9392 /// setters.
9393 ///
9394 /// Please note that this method must not be used to set any of the known parameters
9395 /// which have their own setter method. If done anyway, the request will fail.
9396 ///
9397 /// # Additional Parameters
9398 ///
9399 /// * *$.xgafv* (query-string) - V1 error format.
9400 /// * *access_token* (query-string) - OAuth access token.
9401 /// * *alt* (query-string) - Data format for response.
9402 /// * *callback* (query-string) - JSONP
9403 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9404 /// * *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.
9405 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9406 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9407 /// * *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.
9408 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9409 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9410 pub fn param<T>(
9411 mut self,
9412 name: T,
9413 value: T,
9414 ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
9415 where
9416 T: AsRef<str>,
9417 {
9418 self._additional_params
9419 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9420 self
9421 }
9422
9423 /// Identifies the authorization scope for the method you are building.
9424 ///
9425 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9426 /// [`Scope::CloudPlatform`].
9427 ///
9428 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9429 /// tokens for more than one scope.
9430 ///
9431 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9432 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9433 /// sufficient, a read-write scope will do as well.
9434 pub fn add_scope<St>(
9435 mut self,
9436 scope: St,
9437 ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
9438 where
9439 St: AsRef<str>,
9440 {
9441 self._scopes.insert(String::from(scope.as_ref()));
9442 self
9443 }
9444 /// Identifies the authorization scope(s) for the method you are building.
9445 ///
9446 /// See [`Self::add_scope()`] for details.
9447 pub fn add_scopes<I, St>(
9448 mut self,
9449 scopes: I,
9450 ) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C>
9451 where
9452 I: IntoIterator<Item = St>,
9453 St: AsRef<str>,
9454 {
9455 self._scopes
9456 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9457 self
9458 }
9459
9460 /// Removes all scopes, and no default scope will be used either.
9461 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9462 /// for details).
9463 pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
9464 self._scopes.clear();
9465 self
9466 }
9467}
9468
9469/// 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.
9470///
9471/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *folder* resource.
9472/// It is not used directly, but through a [`FolderMethods`] instance.
9473///
9474/// # Example
9475///
9476/// Instantiate a resource method builder
9477///
9478/// ```test_harness,no_run
9479/// # extern crate hyper;
9480/// # extern crate hyper_rustls;
9481/// # extern crate google_recommender1_beta1 as recommender1_beta1;
9482/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
9483/// # async fn dox() {
9484/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9485///
9486/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9487/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9488/// # .with_native_roots()
9489/// # .unwrap()
9490/// # .https_only()
9491/// # .enable_http2()
9492/// # .build();
9493///
9494/// # let executor = hyper_util::rt::TokioExecutor::new();
9495/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9496/// # secret,
9497/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9498/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9499/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9500/// # ),
9501/// # ).build().await.unwrap();
9502///
9503/// # let client = hyper_util::client::legacy::Client::builder(
9504/// # hyper_util::rt::TokioExecutor::new()
9505/// # )
9506/// # .build(
9507/// # hyper_rustls::HttpsConnectorBuilder::new()
9508/// # .with_native_roots()
9509/// # .unwrap()
9510/// # .https_or_http()
9511/// # .enable_http2()
9512/// # .build()
9513/// # );
9514/// # let mut hub = Recommender::new(client, auth);
9515/// // As the method needs a request, you would usually fill it with the desired information
9516/// // into the respective structure. Some of the parts shown here might not be applicable !
9517/// // Values shown here are possibly random and not representative !
9518/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::default();
9519///
9520/// // You can configure optional parameters by calling the respective setters at will, and
9521/// // execute the final call using `doit()`.
9522/// // Values shown here are possibly random and not representative !
9523/// let result = hub.folders().locations_recommenders_recommendations_mark_dismissed(req, "name")
9524/// .doit().await;
9525/// # }
9526/// ```
9527pub struct FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9528where
9529 C: 'a,
9530{
9531 hub: &'a Recommender<C>,
9532 _request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
9533 _name: String,
9534 _delegate: Option<&'a mut dyn common::Delegate>,
9535 _additional_params: HashMap<String, String>,
9536 _scopes: BTreeSet<String>,
9537}
9538
9539impl<'a, C> common::CallBuilder
9540 for FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9541{
9542}
9543
9544impl<'a, C> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9545where
9546 C: common::Connector,
9547{
9548 /// Perform the operation you have build so far.
9549 pub async fn doit(
9550 mut self,
9551 ) -> common::Result<(
9552 common::Response,
9553 GoogleCloudRecommenderV1beta1Recommendation,
9554 )> {
9555 use std::borrow::Cow;
9556 use std::io::{Read, Seek};
9557
9558 use common::{url::Params, ToParts};
9559 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9560
9561 let mut dd = common::DefaultDelegate;
9562 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9563 dlg.begin(common::MethodInfo {
9564 id: "recommender.folders.locations.recommenders.recommendations.markDismissed",
9565 http_method: hyper::Method::POST,
9566 });
9567
9568 for &field in ["alt", "name"].iter() {
9569 if self._additional_params.contains_key(field) {
9570 dlg.finished(false);
9571 return Err(common::Error::FieldClash(field));
9572 }
9573 }
9574
9575 let mut params = Params::with_capacity(4 + self._additional_params.len());
9576 params.push("name", self._name);
9577
9578 params.extend(self._additional_params.iter());
9579
9580 params.push("alt", "json");
9581 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markDismissed";
9582 if self._scopes.is_empty() {
9583 self._scopes
9584 .insert(Scope::CloudPlatform.as_ref().to_string());
9585 }
9586
9587 #[allow(clippy::single_element_loop)]
9588 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9589 url = params.uri_replacement(url, param_name, find_this, true);
9590 }
9591 {
9592 let to_remove = ["name"];
9593 params.remove_params(&to_remove);
9594 }
9595
9596 let url = params.parse_with_url(&url);
9597
9598 let mut json_mime_type = mime::APPLICATION_JSON;
9599 let mut request_value_reader = {
9600 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9601 common::remove_json_null_values(&mut value);
9602 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9603 serde_json::to_writer(&mut dst, &value).unwrap();
9604 dst
9605 };
9606 let request_size = request_value_reader
9607 .seek(std::io::SeekFrom::End(0))
9608 .unwrap();
9609 request_value_reader
9610 .seek(std::io::SeekFrom::Start(0))
9611 .unwrap();
9612
9613 loop {
9614 let token = match self
9615 .hub
9616 .auth
9617 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9618 .await
9619 {
9620 Ok(token) => token,
9621 Err(e) => match dlg.token(e) {
9622 Ok(token) => token,
9623 Err(e) => {
9624 dlg.finished(false);
9625 return Err(common::Error::MissingToken(e));
9626 }
9627 },
9628 };
9629 request_value_reader
9630 .seek(std::io::SeekFrom::Start(0))
9631 .unwrap();
9632 let mut req_result = {
9633 let client = &self.hub.client;
9634 dlg.pre_request();
9635 let mut req_builder = hyper::Request::builder()
9636 .method(hyper::Method::POST)
9637 .uri(url.as_str())
9638 .header(USER_AGENT, self.hub._user_agent.clone());
9639
9640 if let Some(token) = token.as_ref() {
9641 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9642 }
9643
9644 let request = req_builder
9645 .header(CONTENT_TYPE, json_mime_type.to_string())
9646 .header(CONTENT_LENGTH, request_size as u64)
9647 .body(common::to_body(
9648 request_value_reader.get_ref().clone().into(),
9649 ));
9650
9651 client.request(request.unwrap()).await
9652 };
9653
9654 match req_result {
9655 Err(err) => {
9656 if let common::Retry::After(d) = dlg.http_error(&err) {
9657 sleep(d).await;
9658 continue;
9659 }
9660 dlg.finished(false);
9661 return Err(common::Error::HttpError(err));
9662 }
9663 Ok(res) => {
9664 let (mut parts, body) = res.into_parts();
9665 let mut body = common::Body::new(body);
9666 if !parts.status.is_success() {
9667 let bytes = common::to_bytes(body).await.unwrap_or_default();
9668 let error = serde_json::from_str(&common::to_string(&bytes));
9669 let response = common::to_response(parts, bytes.into());
9670
9671 if let common::Retry::After(d) =
9672 dlg.http_failure(&response, error.as_ref().ok())
9673 {
9674 sleep(d).await;
9675 continue;
9676 }
9677
9678 dlg.finished(false);
9679
9680 return Err(match error {
9681 Ok(value) => common::Error::BadRequest(value),
9682 _ => common::Error::Failure(response),
9683 });
9684 }
9685 let response = {
9686 let bytes = common::to_bytes(body).await.unwrap_or_default();
9687 let encoded = common::to_string(&bytes);
9688 match serde_json::from_str(&encoded) {
9689 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9690 Err(error) => {
9691 dlg.response_json_decode_error(&encoded, &error);
9692 return Err(common::Error::JsonDecodeError(
9693 encoded.to_string(),
9694 error,
9695 ));
9696 }
9697 }
9698 };
9699
9700 dlg.finished(true);
9701 return Ok(response);
9702 }
9703 }
9704 }
9705 }
9706
9707 ///
9708 /// Sets the *request* property to the given value.
9709 ///
9710 /// Even though the property as already been set when instantiating this call,
9711 /// we provide this method for API completeness.
9712 pub fn request(
9713 mut self,
9714 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
9715 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
9716 self._request = new_value;
9717 self
9718 }
9719 /// Required. Name of the recommendation.
9720 ///
9721 /// Sets the *name* path property to the given value.
9722 ///
9723 /// Even though the property as already been set when instantiating this call,
9724 /// we provide this method for API completeness.
9725 pub fn name(
9726 mut self,
9727 new_value: &str,
9728 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
9729 self._name = new_value.to_string();
9730 self
9731 }
9732 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9733 /// while executing the actual API request.
9734 ///
9735 /// ````text
9736 /// It should be used to handle progress information, and to implement a certain level of resilience.
9737 /// ````
9738 ///
9739 /// Sets the *delegate* property to the given value.
9740 pub fn delegate(
9741 mut self,
9742 new_value: &'a mut dyn common::Delegate,
9743 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
9744 self._delegate = Some(new_value);
9745 self
9746 }
9747
9748 /// Set any additional parameter of the query string used in the request.
9749 /// It should be used to set parameters which are not yet available through their own
9750 /// setters.
9751 ///
9752 /// Please note that this method must not be used to set any of the known parameters
9753 /// which have their own setter method. If done anyway, the request will fail.
9754 ///
9755 /// # Additional Parameters
9756 ///
9757 /// * *$.xgafv* (query-string) - V1 error format.
9758 /// * *access_token* (query-string) - OAuth access token.
9759 /// * *alt* (query-string) - Data format for response.
9760 /// * *callback* (query-string) - JSONP
9761 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9762 /// * *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.
9763 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9764 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9765 /// * *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.
9766 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9767 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9768 pub fn param<T>(
9769 mut self,
9770 name: T,
9771 value: T,
9772 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9773 where
9774 T: AsRef<str>,
9775 {
9776 self._additional_params
9777 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9778 self
9779 }
9780
9781 /// Identifies the authorization scope for the method you are building.
9782 ///
9783 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9784 /// [`Scope::CloudPlatform`].
9785 ///
9786 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9787 /// tokens for more than one scope.
9788 ///
9789 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9790 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9791 /// sufficient, a read-write scope will do as well.
9792 pub fn add_scope<St>(
9793 mut self,
9794 scope: St,
9795 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9796 where
9797 St: AsRef<str>,
9798 {
9799 self._scopes.insert(String::from(scope.as_ref()));
9800 self
9801 }
9802 /// Identifies the authorization scope(s) for the method you are building.
9803 ///
9804 /// See [`Self::add_scope()`] for details.
9805 pub fn add_scopes<I, St>(
9806 mut self,
9807 scopes: I,
9808 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C>
9809 where
9810 I: IntoIterator<Item = St>,
9811 St: AsRef<str>,
9812 {
9813 self._scopes
9814 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9815 self
9816 }
9817
9818 /// Removes all scopes, and no default scope will be used either.
9819 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9820 /// for details).
9821 pub fn clear_scopes(
9822 mut self,
9823 ) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
9824 self._scopes.clear();
9825 self
9826 }
9827}
9828
9829/// 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.
9830///
9831/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *folder* resource.
9832/// It is not used directly, but through a [`FolderMethods`] instance.
9833///
9834/// # Example
9835///
9836/// Instantiate a resource method builder
9837///
9838/// ```test_harness,no_run
9839/// # extern crate hyper;
9840/// # extern crate hyper_rustls;
9841/// # extern crate google_recommender1_beta1 as recommender1_beta1;
9842/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
9843/// # async fn dox() {
9844/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9845///
9846/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9847/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9848/// # .with_native_roots()
9849/// # .unwrap()
9850/// # .https_only()
9851/// # .enable_http2()
9852/// # .build();
9853///
9854/// # let executor = hyper_util::rt::TokioExecutor::new();
9855/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9856/// # secret,
9857/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9858/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9859/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9860/// # ),
9861/// # ).build().await.unwrap();
9862///
9863/// # let client = hyper_util::client::legacy::Client::builder(
9864/// # hyper_util::rt::TokioExecutor::new()
9865/// # )
9866/// # .build(
9867/// # hyper_rustls::HttpsConnectorBuilder::new()
9868/// # .with_native_roots()
9869/// # .unwrap()
9870/// # .https_or_http()
9871/// # .enable_http2()
9872/// # .build()
9873/// # );
9874/// # let mut hub = Recommender::new(client, auth);
9875/// // As the method needs a request, you would usually fill it with the desired information
9876/// // into the respective structure. Some of the parts shown here might not be applicable !
9877/// // Values shown here are possibly random and not representative !
9878/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::default();
9879///
9880/// // You can configure optional parameters by calling the respective setters at will, and
9881/// // execute the final call using `doit()`.
9882/// // Values shown here are possibly random and not representative !
9883/// let result = hub.folders().locations_recommenders_recommendations_mark_failed(req, "name")
9884/// .doit().await;
9885/// # }
9886/// ```
9887pub struct FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
9888where
9889 C: 'a,
9890{
9891 hub: &'a Recommender<C>,
9892 _request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
9893 _name: String,
9894 _delegate: Option<&'a mut dyn common::Delegate>,
9895 _additional_params: HashMap<String, String>,
9896 _scopes: BTreeSet<String>,
9897}
9898
9899impl<'a, C> common::CallBuilder for FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {}
9900
9901impl<'a, C> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
9902where
9903 C: common::Connector,
9904{
9905 /// Perform the operation you have build so far.
9906 pub async fn doit(
9907 mut self,
9908 ) -> common::Result<(
9909 common::Response,
9910 GoogleCloudRecommenderV1beta1Recommendation,
9911 )> {
9912 use std::borrow::Cow;
9913 use std::io::{Read, Seek};
9914
9915 use common::{url::Params, ToParts};
9916 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9917
9918 let mut dd = common::DefaultDelegate;
9919 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9920 dlg.begin(common::MethodInfo {
9921 id: "recommender.folders.locations.recommenders.recommendations.markFailed",
9922 http_method: hyper::Method::POST,
9923 });
9924
9925 for &field in ["alt", "name"].iter() {
9926 if self._additional_params.contains_key(field) {
9927 dlg.finished(false);
9928 return Err(common::Error::FieldClash(field));
9929 }
9930 }
9931
9932 let mut params = Params::with_capacity(4 + self._additional_params.len());
9933 params.push("name", self._name);
9934
9935 params.extend(self._additional_params.iter());
9936
9937 params.push("alt", "json");
9938 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markFailed";
9939 if self._scopes.is_empty() {
9940 self._scopes
9941 .insert(Scope::CloudPlatform.as_ref().to_string());
9942 }
9943
9944 #[allow(clippy::single_element_loop)]
9945 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9946 url = params.uri_replacement(url, param_name, find_this, true);
9947 }
9948 {
9949 let to_remove = ["name"];
9950 params.remove_params(&to_remove);
9951 }
9952
9953 let url = params.parse_with_url(&url);
9954
9955 let mut json_mime_type = mime::APPLICATION_JSON;
9956 let mut request_value_reader = {
9957 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9958 common::remove_json_null_values(&mut value);
9959 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9960 serde_json::to_writer(&mut dst, &value).unwrap();
9961 dst
9962 };
9963 let request_size = request_value_reader
9964 .seek(std::io::SeekFrom::End(0))
9965 .unwrap();
9966 request_value_reader
9967 .seek(std::io::SeekFrom::Start(0))
9968 .unwrap();
9969
9970 loop {
9971 let token = match self
9972 .hub
9973 .auth
9974 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9975 .await
9976 {
9977 Ok(token) => token,
9978 Err(e) => match dlg.token(e) {
9979 Ok(token) => token,
9980 Err(e) => {
9981 dlg.finished(false);
9982 return Err(common::Error::MissingToken(e));
9983 }
9984 },
9985 };
9986 request_value_reader
9987 .seek(std::io::SeekFrom::Start(0))
9988 .unwrap();
9989 let mut req_result = {
9990 let client = &self.hub.client;
9991 dlg.pre_request();
9992 let mut req_builder = hyper::Request::builder()
9993 .method(hyper::Method::POST)
9994 .uri(url.as_str())
9995 .header(USER_AGENT, self.hub._user_agent.clone());
9996
9997 if let Some(token) = token.as_ref() {
9998 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9999 }
10000
10001 let request = req_builder
10002 .header(CONTENT_TYPE, json_mime_type.to_string())
10003 .header(CONTENT_LENGTH, request_size as u64)
10004 .body(common::to_body(
10005 request_value_reader.get_ref().clone().into(),
10006 ));
10007
10008 client.request(request.unwrap()).await
10009 };
10010
10011 match req_result {
10012 Err(err) => {
10013 if let common::Retry::After(d) = dlg.http_error(&err) {
10014 sleep(d).await;
10015 continue;
10016 }
10017 dlg.finished(false);
10018 return Err(common::Error::HttpError(err));
10019 }
10020 Ok(res) => {
10021 let (mut parts, body) = res.into_parts();
10022 let mut body = common::Body::new(body);
10023 if !parts.status.is_success() {
10024 let bytes = common::to_bytes(body).await.unwrap_or_default();
10025 let error = serde_json::from_str(&common::to_string(&bytes));
10026 let response = common::to_response(parts, bytes.into());
10027
10028 if let common::Retry::After(d) =
10029 dlg.http_failure(&response, error.as_ref().ok())
10030 {
10031 sleep(d).await;
10032 continue;
10033 }
10034
10035 dlg.finished(false);
10036
10037 return Err(match error {
10038 Ok(value) => common::Error::BadRequest(value),
10039 _ => common::Error::Failure(response),
10040 });
10041 }
10042 let response = {
10043 let bytes = common::to_bytes(body).await.unwrap_or_default();
10044 let encoded = common::to_string(&bytes);
10045 match serde_json::from_str(&encoded) {
10046 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10047 Err(error) => {
10048 dlg.response_json_decode_error(&encoded, &error);
10049 return Err(common::Error::JsonDecodeError(
10050 encoded.to_string(),
10051 error,
10052 ));
10053 }
10054 }
10055 };
10056
10057 dlg.finished(true);
10058 return Ok(response);
10059 }
10060 }
10061 }
10062 }
10063
10064 ///
10065 /// Sets the *request* property to the given value.
10066 ///
10067 /// Even though the property as already been set when instantiating this call,
10068 /// we provide this method for API completeness.
10069 pub fn request(
10070 mut self,
10071 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
10072 ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
10073 self._request = new_value;
10074 self
10075 }
10076 /// Required. Name of the recommendation.
10077 ///
10078 /// Sets the *name* path property to the given value.
10079 ///
10080 /// Even though the property as already been set when instantiating this call,
10081 /// we provide this method for API completeness.
10082 pub fn name(
10083 mut self,
10084 new_value: &str,
10085 ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
10086 self._name = new_value.to_string();
10087 self
10088 }
10089 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10090 /// while executing the actual API request.
10091 ///
10092 /// ````text
10093 /// It should be used to handle progress information, and to implement a certain level of resilience.
10094 /// ````
10095 ///
10096 /// Sets the *delegate* property to the given value.
10097 pub fn delegate(
10098 mut self,
10099 new_value: &'a mut dyn common::Delegate,
10100 ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
10101 self._delegate = Some(new_value);
10102 self
10103 }
10104
10105 /// Set any additional parameter of the query string used in the request.
10106 /// It should be used to set parameters which are not yet available through their own
10107 /// setters.
10108 ///
10109 /// Please note that this method must not be used to set any of the known parameters
10110 /// which have their own setter method. If done anyway, the request will fail.
10111 ///
10112 /// # Additional Parameters
10113 ///
10114 /// * *$.xgafv* (query-string) - V1 error format.
10115 /// * *access_token* (query-string) - OAuth access token.
10116 /// * *alt* (query-string) - Data format for response.
10117 /// * *callback* (query-string) - JSONP
10118 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10119 /// * *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.
10120 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10121 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10122 /// * *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.
10123 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10124 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10125 pub fn param<T>(
10126 mut self,
10127 name: T,
10128 value: T,
10129 ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
10130 where
10131 T: AsRef<str>,
10132 {
10133 self._additional_params
10134 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10135 self
10136 }
10137
10138 /// Identifies the authorization scope for the method you are building.
10139 ///
10140 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10141 /// [`Scope::CloudPlatform`].
10142 ///
10143 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10144 /// tokens for more than one scope.
10145 ///
10146 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10147 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10148 /// sufficient, a read-write scope will do as well.
10149 pub fn add_scope<St>(
10150 mut self,
10151 scope: St,
10152 ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
10153 where
10154 St: AsRef<str>,
10155 {
10156 self._scopes.insert(String::from(scope.as_ref()));
10157 self
10158 }
10159 /// Identifies the authorization scope(s) for the method you are building.
10160 ///
10161 /// See [`Self::add_scope()`] for details.
10162 pub fn add_scopes<I, St>(
10163 mut self,
10164 scopes: I,
10165 ) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C>
10166 where
10167 I: IntoIterator<Item = St>,
10168 St: AsRef<str>,
10169 {
10170 self._scopes
10171 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10172 self
10173 }
10174
10175 /// Removes all scopes, and no default scope will be used either.
10176 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10177 /// for details).
10178 pub fn clear_scopes(mut self) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, C> {
10179 self._scopes.clear();
10180 self
10181 }
10182}
10183
10184/// 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.
10185///
10186/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *folder* resource.
10187/// It is not used directly, but through a [`FolderMethods`] instance.
10188///
10189/// # Example
10190///
10191/// Instantiate a resource method builder
10192///
10193/// ```test_harness,no_run
10194/// # extern crate hyper;
10195/// # extern crate hyper_rustls;
10196/// # extern crate google_recommender1_beta1 as recommender1_beta1;
10197/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
10198/// # async fn dox() {
10199/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10200///
10201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10202/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10203/// # .with_native_roots()
10204/// # .unwrap()
10205/// # .https_only()
10206/// # .enable_http2()
10207/// # .build();
10208///
10209/// # let executor = hyper_util::rt::TokioExecutor::new();
10210/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10211/// # secret,
10212/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10213/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10214/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10215/// # ),
10216/// # ).build().await.unwrap();
10217///
10218/// # let client = hyper_util::client::legacy::Client::builder(
10219/// # hyper_util::rt::TokioExecutor::new()
10220/// # )
10221/// # .build(
10222/// # hyper_rustls::HttpsConnectorBuilder::new()
10223/// # .with_native_roots()
10224/// # .unwrap()
10225/// # .https_or_http()
10226/// # .enable_http2()
10227/// # .build()
10228/// # );
10229/// # let mut hub = Recommender::new(client, auth);
10230/// // As the method needs a request, you would usually fill it with the desired information
10231/// // into the respective structure. Some of the parts shown here might not be applicable !
10232/// // Values shown here are possibly random and not representative !
10233/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::default();
10234///
10235/// // You can configure optional parameters by calling the respective setters at will, and
10236/// // execute the final call using `doit()`.
10237/// // Values shown here are possibly random and not representative !
10238/// let result = hub.folders().locations_recommenders_recommendations_mark_succeeded(req, "name")
10239/// .doit().await;
10240/// # }
10241/// ```
10242pub struct FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
10243where
10244 C: 'a,
10245{
10246 hub: &'a Recommender<C>,
10247 _request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
10248 _name: String,
10249 _delegate: Option<&'a mut dyn common::Delegate>,
10250 _additional_params: HashMap<String, String>,
10251 _scopes: BTreeSet<String>,
10252}
10253
10254impl<'a, C> common::CallBuilder
10255 for FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
10256{
10257}
10258
10259impl<'a, C> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
10260where
10261 C: common::Connector,
10262{
10263 /// Perform the operation you have build so far.
10264 pub async fn doit(
10265 mut self,
10266 ) -> common::Result<(
10267 common::Response,
10268 GoogleCloudRecommenderV1beta1Recommendation,
10269 )> {
10270 use std::borrow::Cow;
10271 use std::io::{Read, Seek};
10272
10273 use common::{url::Params, ToParts};
10274 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10275
10276 let mut dd = common::DefaultDelegate;
10277 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10278 dlg.begin(common::MethodInfo {
10279 id: "recommender.folders.locations.recommenders.recommendations.markSucceeded",
10280 http_method: hyper::Method::POST,
10281 });
10282
10283 for &field in ["alt", "name"].iter() {
10284 if self._additional_params.contains_key(field) {
10285 dlg.finished(false);
10286 return Err(common::Error::FieldClash(field));
10287 }
10288 }
10289
10290 let mut params = Params::with_capacity(4 + self._additional_params.len());
10291 params.push("name", self._name);
10292
10293 params.extend(self._additional_params.iter());
10294
10295 params.push("alt", "json");
10296 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markSucceeded";
10297 if self._scopes.is_empty() {
10298 self._scopes
10299 .insert(Scope::CloudPlatform.as_ref().to_string());
10300 }
10301
10302 #[allow(clippy::single_element_loop)]
10303 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10304 url = params.uri_replacement(url, param_name, find_this, true);
10305 }
10306 {
10307 let to_remove = ["name"];
10308 params.remove_params(&to_remove);
10309 }
10310
10311 let url = params.parse_with_url(&url);
10312
10313 let mut json_mime_type = mime::APPLICATION_JSON;
10314 let mut request_value_reader = {
10315 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10316 common::remove_json_null_values(&mut value);
10317 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10318 serde_json::to_writer(&mut dst, &value).unwrap();
10319 dst
10320 };
10321 let request_size = request_value_reader
10322 .seek(std::io::SeekFrom::End(0))
10323 .unwrap();
10324 request_value_reader
10325 .seek(std::io::SeekFrom::Start(0))
10326 .unwrap();
10327
10328 loop {
10329 let token = match self
10330 .hub
10331 .auth
10332 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10333 .await
10334 {
10335 Ok(token) => token,
10336 Err(e) => match dlg.token(e) {
10337 Ok(token) => token,
10338 Err(e) => {
10339 dlg.finished(false);
10340 return Err(common::Error::MissingToken(e));
10341 }
10342 },
10343 };
10344 request_value_reader
10345 .seek(std::io::SeekFrom::Start(0))
10346 .unwrap();
10347 let mut req_result = {
10348 let client = &self.hub.client;
10349 dlg.pre_request();
10350 let mut req_builder = hyper::Request::builder()
10351 .method(hyper::Method::POST)
10352 .uri(url.as_str())
10353 .header(USER_AGENT, self.hub._user_agent.clone());
10354
10355 if let Some(token) = token.as_ref() {
10356 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10357 }
10358
10359 let request = req_builder
10360 .header(CONTENT_TYPE, json_mime_type.to_string())
10361 .header(CONTENT_LENGTH, request_size as u64)
10362 .body(common::to_body(
10363 request_value_reader.get_ref().clone().into(),
10364 ));
10365
10366 client.request(request.unwrap()).await
10367 };
10368
10369 match req_result {
10370 Err(err) => {
10371 if let common::Retry::After(d) = dlg.http_error(&err) {
10372 sleep(d).await;
10373 continue;
10374 }
10375 dlg.finished(false);
10376 return Err(common::Error::HttpError(err));
10377 }
10378 Ok(res) => {
10379 let (mut parts, body) = res.into_parts();
10380 let mut body = common::Body::new(body);
10381 if !parts.status.is_success() {
10382 let bytes = common::to_bytes(body).await.unwrap_or_default();
10383 let error = serde_json::from_str(&common::to_string(&bytes));
10384 let response = common::to_response(parts, bytes.into());
10385
10386 if let common::Retry::After(d) =
10387 dlg.http_failure(&response, error.as_ref().ok())
10388 {
10389 sleep(d).await;
10390 continue;
10391 }
10392
10393 dlg.finished(false);
10394
10395 return Err(match error {
10396 Ok(value) => common::Error::BadRequest(value),
10397 _ => common::Error::Failure(response),
10398 });
10399 }
10400 let response = {
10401 let bytes = common::to_bytes(body).await.unwrap_or_default();
10402 let encoded = common::to_string(&bytes);
10403 match serde_json::from_str(&encoded) {
10404 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10405 Err(error) => {
10406 dlg.response_json_decode_error(&encoded, &error);
10407 return Err(common::Error::JsonDecodeError(
10408 encoded.to_string(),
10409 error,
10410 ));
10411 }
10412 }
10413 };
10414
10415 dlg.finished(true);
10416 return Ok(response);
10417 }
10418 }
10419 }
10420 }
10421
10422 ///
10423 /// Sets the *request* property to the given value.
10424 ///
10425 /// Even though the property as already been set when instantiating this call,
10426 /// we provide this method for API completeness.
10427 pub fn request(
10428 mut self,
10429 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
10430 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
10431 self._request = new_value;
10432 self
10433 }
10434 /// Required. Name of the recommendation.
10435 ///
10436 /// Sets the *name* path property to the given value.
10437 ///
10438 /// Even though the property as already been set when instantiating this call,
10439 /// we provide this method for API completeness.
10440 pub fn name(
10441 mut self,
10442 new_value: &str,
10443 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
10444 self._name = new_value.to_string();
10445 self
10446 }
10447 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10448 /// while executing the actual API request.
10449 ///
10450 /// ````text
10451 /// It should be used to handle progress information, and to implement a certain level of resilience.
10452 /// ````
10453 ///
10454 /// Sets the *delegate* property to the given value.
10455 pub fn delegate(
10456 mut self,
10457 new_value: &'a mut dyn common::Delegate,
10458 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
10459 self._delegate = Some(new_value);
10460 self
10461 }
10462
10463 /// Set any additional parameter of the query string used in the request.
10464 /// It should be used to set parameters which are not yet available through their own
10465 /// setters.
10466 ///
10467 /// Please note that this method must not be used to set any of the known parameters
10468 /// which have their own setter method. If done anyway, the request will fail.
10469 ///
10470 /// # Additional Parameters
10471 ///
10472 /// * *$.xgafv* (query-string) - V1 error format.
10473 /// * *access_token* (query-string) - OAuth access token.
10474 /// * *alt* (query-string) - Data format for response.
10475 /// * *callback* (query-string) - JSONP
10476 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10477 /// * *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.
10478 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10479 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10480 /// * *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.
10481 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10482 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10483 pub fn param<T>(
10484 mut self,
10485 name: T,
10486 value: T,
10487 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
10488 where
10489 T: AsRef<str>,
10490 {
10491 self._additional_params
10492 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10493 self
10494 }
10495
10496 /// Identifies the authorization scope for the method you are building.
10497 ///
10498 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10499 /// [`Scope::CloudPlatform`].
10500 ///
10501 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10502 /// tokens for more than one scope.
10503 ///
10504 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10505 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10506 /// sufficient, a read-write scope will do as well.
10507 pub fn add_scope<St>(
10508 mut self,
10509 scope: St,
10510 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
10511 where
10512 St: AsRef<str>,
10513 {
10514 self._scopes.insert(String::from(scope.as_ref()));
10515 self
10516 }
10517 /// Identifies the authorization scope(s) for the method you are building.
10518 ///
10519 /// See [`Self::add_scope()`] for details.
10520 pub fn add_scopes<I, St>(
10521 mut self,
10522 scopes: I,
10523 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C>
10524 where
10525 I: IntoIterator<Item = St>,
10526 St: AsRef<str>,
10527 {
10528 self._scopes
10529 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10530 self
10531 }
10532
10533 /// Removes all scopes, and no default scope will be used either.
10534 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10535 /// for details).
10536 pub fn clear_scopes(
10537 mut self,
10538 ) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
10539 self._scopes.clear();
10540 self
10541 }
10542}
10543
10544/// Lists locations with recommendations or insights.
10545///
10546/// A builder for the *locations.list* method supported by a *folder* resource.
10547/// It is not used directly, but through a [`FolderMethods`] instance.
10548///
10549/// # Example
10550///
10551/// Instantiate a resource method builder
10552///
10553/// ```test_harness,no_run
10554/// # extern crate hyper;
10555/// # extern crate hyper_rustls;
10556/// # extern crate google_recommender1_beta1 as recommender1_beta1;
10557/// # async fn dox() {
10558/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10559///
10560/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10561/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10562/// # .with_native_roots()
10563/// # .unwrap()
10564/// # .https_only()
10565/// # .enable_http2()
10566/// # .build();
10567///
10568/// # let executor = hyper_util::rt::TokioExecutor::new();
10569/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10570/// # secret,
10571/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10572/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10573/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10574/// # ),
10575/// # ).build().await.unwrap();
10576///
10577/// # let client = hyper_util::client::legacy::Client::builder(
10578/// # hyper_util::rt::TokioExecutor::new()
10579/// # )
10580/// # .build(
10581/// # hyper_rustls::HttpsConnectorBuilder::new()
10582/// # .with_native_roots()
10583/// # .unwrap()
10584/// # .https_or_http()
10585/// # .enable_http2()
10586/// # .build()
10587/// # );
10588/// # let mut hub = Recommender::new(client, auth);
10589/// // You can configure optional parameters by calling the respective setters at will, and
10590/// // execute the final call using `doit()`.
10591/// // Values shown here are possibly random and not representative !
10592/// let result = hub.folders().locations_list("name")
10593/// .page_token("et")
10594/// .page_size(-68)
10595/// .filter("vero")
10596/// .add_extra_location_types("erat")
10597/// .doit().await;
10598/// # }
10599/// ```
10600pub struct FolderLocationListCall<'a, C>
10601where
10602 C: 'a,
10603{
10604 hub: &'a Recommender<C>,
10605 _name: String,
10606 _page_token: Option<String>,
10607 _page_size: Option<i32>,
10608 _filter: Option<String>,
10609 _extra_location_types: Vec<String>,
10610 _delegate: Option<&'a mut dyn common::Delegate>,
10611 _additional_params: HashMap<String, String>,
10612 _scopes: BTreeSet<String>,
10613}
10614
10615impl<'a, C> common::CallBuilder for FolderLocationListCall<'a, C> {}
10616
10617impl<'a, C> FolderLocationListCall<'a, C>
10618where
10619 C: common::Connector,
10620{
10621 /// Perform the operation you have build so far.
10622 pub async fn doit(
10623 mut self,
10624 ) -> common::Result<(common::Response, GoogleCloudLocationListLocationsResponse)> {
10625 use std::borrow::Cow;
10626 use std::io::{Read, Seek};
10627
10628 use common::{url::Params, ToParts};
10629 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10630
10631 let mut dd = common::DefaultDelegate;
10632 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10633 dlg.begin(common::MethodInfo {
10634 id: "recommender.folders.locations.list",
10635 http_method: hyper::Method::GET,
10636 });
10637
10638 for &field in [
10639 "alt",
10640 "name",
10641 "pageToken",
10642 "pageSize",
10643 "filter",
10644 "extraLocationTypes",
10645 ]
10646 .iter()
10647 {
10648 if self._additional_params.contains_key(field) {
10649 dlg.finished(false);
10650 return Err(common::Error::FieldClash(field));
10651 }
10652 }
10653
10654 let mut params = Params::with_capacity(7 + self._additional_params.len());
10655 params.push("name", self._name);
10656 if let Some(value) = self._page_token.as_ref() {
10657 params.push("pageToken", value);
10658 }
10659 if let Some(value) = self._page_size.as_ref() {
10660 params.push("pageSize", value.to_string());
10661 }
10662 if let Some(value) = self._filter.as_ref() {
10663 params.push("filter", value);
10664 }
10665 if !self._extra_location_types.is_empty() {
10666 for f in self._extra_location_types.iter() {
10667 params.push("extraLocationTypes", f);
10668 }
10669 }
10670
10671 params.extend(self._additional_params.iter());
10672
10673 params.push("alt", "json");
10674 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/locations";
10675 if self._scopes.is_empty() {
10676 self._scopes
10677 .insert(Scope::CloudPlatform.as_ref().to_string());
10678 }
10679
10680 #[allow(clippy::single_element_loop)]
10681 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10682 url = params.uri_replacement(url, param_name, find_this, true);
10683 }
10684 {
10685 let to_remove = ["name"];
10686 params.remove_params(&to_remove);
10687 }
10688
10689 let url = params.parse_with_url(&url);
10690
10691 loop {
10692 let token = match self
10693 .hub
10694 .auth
10695 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10696 .await
10697 {
10698 Ok(token) => token,
10699 Err(e) => match dlg.token(e) {
10700 Ok(token) => token,
10701 Err(e) => {
10702 dlg.finished(false);
10703 return Err(common::Error::MissingToken(e));
10704 }
10705 },
10706 };
10707 let mut req_result = {
10708 let client = &self.hub.client;
10709 dlg.pre_request();
10710 let mut req_builder = hyper::Request::builder()
10711 .method(hyper::Method::GET)
10712 .uri(url.as_str())
10713 .header(USER_AGENT, self.hub._user_agent.clone());
10714
10715 if let Some(token) = token.as_ref() {
10716 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10717 }
10718
10719 let request = req_builder
10720 .header(CONTENT_LENGTH, 0_u64)
10721 .body(common::to_body::<String>(None));
10722
10723 client.request(request.unwrap()).await
10724 };
10725
10726 match req_result {
10727 Err(err) => {
10728 if let common::Retry::After(d) = dlg.http_error(&err) {
10729 sleep(d).await;
10730 continue;
10731 }
10732 dlg.finished(false);
10733 return Err(common::Error::HttpError(err));
10734 }
10735 Ok(res) => {
10736 let (mut parts, body) = res.into_parts();
10737 let mut body = common::Body::new(body);
10738 if !parts.status.is_success() {
10739 let bytes = common::to_bytes(body).await.unwrap_or_default();
10740 let error = serde_json::from_str(&common::to_string(&bytes));
10741 let response = common::to_response(parts, bytes.into());
10742
10743 if let common::Retry::After(d) =
10744 dlg.http_failure(&response, error.as_ref().ok())
10745 {
10746 sleep(d).await;
10747 continue;
10748 }
10749
10750 dlg.finished(false);
10751
10752 return Err(match error {
10753 Ok(value) => common::Error::BadRequest(value),
10754 _ => common::Error::Failure(response),
10755 });
10756 }
10757 let response = {
10758 let bytes = common::to_bytes(body).await.unwrap_or_default();
10759 let encoded = common::to_string(&bytes);
10760 match serde_json::from_str(&encoded) {
10761 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10762 Err(error) => {
10763 dlg.response_json_decode_error(&encoded, &error);
10764 return Err(common::Error::JsonDecodeError(
10765 encoded.to_string(),
10766 error,
10767 ));
10768 }
10769 }
10770 };
10771
10772 dlg.finished(true);
10773 return Ok(response);
10774 }
10775 }
10776 }
10777 }
10778
10779 /// The resource that owns the locations collection, if applicable.
10780 ///
10781 /// Sets the *name* path property to the given value.
10782 ///
10783 /// Even though the property as already been set when instantiating this call,
10784 /// we provide this method for API completeness.
10785 pub fn name(mut self, new_value: &str) -> FolderLocationListCall<'a, C> {
10786 self._name = new_value.to_string();
10787 self
10788 }
10789 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
10790 ///
10791 /// Sets the *page token* query property to the given value.
10792 pub fn page_token(mut self, new_value: &str) -> FolderLocationListCall<'a, C> {
10793 self._page_token = Some(new_value.to_string());
10794 self
10795 }
10796 /// The maximum number of results to return. If not set, the service selects a default.
10797 ///
10798 /// Sets the *page size* query property to the given value.
10799 pub fn page_size(mut self, new_value: i32) -> FolderLocationListCall<'a, C> {
10800 self._page_size = Some(new_value);
10801 self
10802 }
10803 /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
10804 ///
10805 /// Sets the *filter* query property to the given value.
10806 pub fn filter(mut self, new_value: &str) -> FolderLocationListCall<'a, C> {
10807 self._filter = Some(new_value.to_string());
10808 self
10809 }
10810 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
10811 ///
10812 /// Append the given value to the *extra location types* query property.
10813 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10814 pub fn add_extra_location_types(mut self, new_value: &str) -> FolderLocationListCall<'a, C> {
10815 self._extra_location_types.push(new_value.to_string());
10816 self
10817 }
10818 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10819 /// while executing the actual API request.
10820 ///
10821 /// ````text
10822 /// It should be used to handle progress information, and to implement a certain level of resilience.
10823 /// ````
10824 ///
10825 /// Sets the *delegate* property to the given value.
10826 pub fn delegate(
10827 mut self,
10828 new_value: &'a mut dyn common::Delegate,
10829 ) -> FolderLocationListCall<'a, C> {
10830 self._delegate = Some(new_value);
10831 self
10832 }
10833
10834 /// Set any additional parameter of the query string used in the request.
10835 /// It should be used to set parameters which are not yet available through their own
10836 /// setters.
10837 ///
10838 /// Please note that this method must not be used to set any of the known parameters
10839 /// which have their own setter method. If done anyway, the request will fail.
10840 ///
10841 /// # Additional Parameters
10842 ///
10843 /// * *$.xgafv* (query-string) - V1 error format.
10844 /// * *access_token* (query-string) - OAuth access token.
10845 /// * *alt* (query-string) - Data format for response.
10846 /// * *callback* (query-string) - JSONP
10847 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10848 /// * *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.
10849 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10850 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10851 /// * *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.
10852 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10853 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10854 pub fn param<T>(mut self, name: T, value: T) -> FolderLocationListCall<'a, C>
10855 where
10856 T: AsRef<str>,
10857 {
10858 self._additional_params
10859 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10860 self
10861 }
10862
10863 /// Identifies the authorization scope for the method you are building.
10864 ///
10865 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10866 /// [`Scope::CloudPlatform`].
10867 ///
10868 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10869 /// tokens for more than one scope.
10870 ///
10871 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10872 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10873 /// sufficient, a read-write scope will do as well.
10874 pub fn add_scope<St>(mut self, scope: St) -> FolderLocationListCall<'a, C>
10875 where
10876 St: AsRef<str>,
10877 {
10878 self._scopes.insert(String::from(scope.as_ref()));
10879 self
10880 }
10881 /// Identifies the authorization scope(s) for the method you are building.
10882 ///
10883 /// See [`Self::add_scope()`] for details.
10884 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderLocationListCall<'a, C>
10885 where
10886 I: IntoIterator<Item = St>,
10887 St: AsRef<str>,
10888 {
10889 self._scopes
10890 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10891 self
10892 }
10893
10894 /// Removes all scopes, and no default scope will be used either.
10895 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10896 /// for details).
10897 pub fn clear_scopes(mut self) -> FolderLocationListCall<'a, C> {
10898 self._scopes.clear();
10899 self
10900 }
10901}
10902
10903/// Lists available InsightTypes. No IAM permissions are required.
10904///
10905/// A builder for the *list* method supported by a *insightType* resource.
10906/// It is not used directly, but through a [`InsightTypeMethods`] instance.
10907///
10908/// # Example
10909///
10910/// Instantiate a resource method builder
10911///
10912/// ```test_harness,no_run
10913/// # extern crate hyper;
10914/// # extern crate hyper_rustls;
10915/// # extern crate google_recommender1_beta1 as recommender1_beta1;
10916/// # async fn dox() {
10917/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10918///
10919/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10920/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10921/// # .with_native_roots()
10922/// # .unwrap()
10923/// # .https_only()
10924/// # .enable_http2()
10925/// # .build();
10926///
10927/// # let executor = hyper_util::rt::TokioExecutor::new();
10928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10929/// # secret,
10930/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10931/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10932/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10933/// # ),
10934/// # ).build().await.unwrap();
10935///
10936/// # let client = hyper_util::client::legacy::Client::builder(
10937/// # hyper_util::rt::TokioExecutor::new()
10938/// # )
10939/// # .build(
10940/// # hyper_rustls::HttpsConnectorBuilder::new()
10941/// # .with_native_roots()
10942/// # .unwrap()
10943/// # .https_or_http()
10944/// # .enable_http2()
10945/// # .build()
10946/// # );
10947/// # let mut hub = Recommender::new(client, auth);
10948/// // You can configure optional parameters by calling the respective setters at will, and
10949/// // execute the final call using `doit()`.
10950/// // Values shown here are possibly random and not representative !
10951/// let result = hub.insight_types().list()
10952/// .page_token("sed")
10953/// .page_size(-20)
10954/// .doit().await;
10955/// # }
10956/// ```
10957pub struct InsightTypeListCall<'a, C>
10958where
10959 C: 'a,
10960{
10961 hub: &'a Recommender<C>,
10962 _page_token: Option<String>,
10963 _page_size: Option<i32>,
10964 _delegate: Option<&'a mut dyn common::Delegate>,
10965 _additional_params: HashMap<String, String>,
10966 _scopes: BTreeSet<String>,
10967}
10968
10969impl<'a, C> common::CallBuilder for InsightTypeListCall<'a, C> {}
10970
10971impl<'a, C> InsightTypeListCall<'a, C>
10972where
10973 C: common::Connector,
10974{
10975 /// Perform the operation you have build so far.
10976 pub async fn doit(
10977 mut self,
10978 ) -> common::Result<(
10979 common::Response,
10980 GoogleCloudRecommenderV1beta1ListInsightTypesResponse,
10981 )> {
10982 use std::borrow::Cow;
10983 use std::io::{Read, Seek};
10984
10985 use common::{url::Params, ToParts};
10986 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10987
10988 let mut dd = common::DefaultDelegate;
10989 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10990 dlg.begin(common::MethodInfo {
10991 id: "recommender.insightTypes.list",
10992 http_method: hyper::Method::GET,
10993 });
10994
10995 for &field in ["alt", "pageToken", "pageSize"].iter() {
10996 if self._additional_params.contains_key(field) {
10997 dlg.finished(false);
10998 return Err(common::Error::FieldClash(field));
10999 }
11000 }
11001
11002 let mut params = Params::with_capacity(4 + self._additional_params.len());
11003 if let Some(value) = self._page_token.as_ref() {
11004 params.push("pageToken", value);
11005 }
11006 if let Some(value) = self._page_size.as_ref() {
11007 params.push("pageSize", value.to_string());
11008 }
11009
11010 params.extend(self._additional_params.iter());
11011
11012 params.push("alt", "json");
11013 let mut url = self.hub._base_url.clone() + "v1beta1/insightTypes";
11014 if self._scopes.is_empty() {
11015 self._scopes
11016 .insert(Scope::CloudPlatform.as_ref().to_string());
11017 }
11018
11019 let url = params.parse_with_url(&url);
11020
11021 loop {
11022 let token = match self
11023 .hub
11024 .auth
11025 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11026 .await
11027 {
11028 Ok(token) => token,
11029 Err(e) => match dlg.token(e) {
11030 Ok(token) => token,
11031 Err(e) => {
11032 dlg.finished(false);
11033 return Err(common::Error::MissingToken(e));
11034 }
11035 },
11036 };
11037 let mut req_result = {
11038 let client = &self.hub.client;
11039 dlg.pre_request();
11040 let mut req_builder = hyper::Request::builder()
11041 .method(hyper::Method::GET)
11042 .uri(url.as_str())
11043 .header(USER_AGENT, self.hub._user_agent.clone());
11044
11045 if let Some(token) = token.as_ref() {
11046 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11047 }
11048
11049 let request = req_builder
11050 .header(CONTENT_LENGTH, 0_u64)
11051 .body(common::to_body::<String>(None));
11052
11053 client.request(request.unwrap()).await
11054 };
11055
11056 match req_result {
11057 Err(err) => {
11058 if let common::Retry::After(d) = dlg.http_error(&err) {
11059 sleep(d).await;
11060 continue;
11061 }
11062 dlg.finished(false);
11063 return Err(common::Error::HttpError(err));
11064 }
11065 Ok(res) => {
11066 let (mut parts, body) = res.into_parts();
11067 let mut body = common::Body::new(body);
11068 if !parts.status.is_success() {
11069 let bytes = common::to_bytes(body).await.unwrap_or_default();
11070 let error = serde_json::from_str(&common::to_string(&bytes));
11071 let response = common::to_response(parts, bytes.into());
11072
11073 if let common::Retry::After(d) =
11074 dlg.http_failure(&response, error.as_ref().ok())
11075 {
11076 sleep(d).await;
11077 continue;
11078 }
11079
11080 dlg.finished(false);
11081
11082 return Err(match error {
11083 Ok(value) => common::Error::BadRequest(value),
11084 _ => common::Error::Failure(response),
11085 });
11086 }
11087 let response = {
11088 let bytes = common::to_bytes(body).await.unwrap_or_default();
11089 let encoded = common::to_string(&bytes);
11090 match serde_json::from_str(&encoded) {
11091 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11092 Err(error) => {
11093 dlg.response_json_decode_error(&encoded, &error);
11094 return Err(common::Error::JsonDecodeError(
11095 encoded.to_string(),
11096 error,
11097 ));
11098 }
11099 }
11100 };
11101
11102 dlg.finished(true);
11103 return Ok(response);
11104 }
11105 }
11106 }
11107 }
11108
11109 /// Optional. A page token, received from a previous `ListRecommenders` call. Provide this to retrieve the subsequent page.
11110 ///
11111 /// Sets the *page token* query property to the given value.
11112 pub fn page_token(mut self, new_value: &str) -> InsightTypeListCall<'a, C> {
11113 self._page_token = Some(new_value.to_string());
11114 self
11115 }
11116 /// Optional. The number of InsightTypes to return per page. The service may return fewer than this value.
11117 ///
11118 /// Sets the *page size* query property to the given value.
11119 pub fn page_size(mut self, new_value: i32) -> InsightTypeListCall<'a, C> {
11120 self._page_size = Some(new_value);
11121 self
11122 }
11123 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11124 /// while executing the actual API request.
11125 ///
11126 /// ````text
11127 /// It should be used to handle progress information, and to implement a certain level of resilience.
11128 /// ````
11129 ///
11130 /// Sets the *delegate* property to the given value.
11131 pub fn delegate(
11132 mut self,
11133 new_value: &'a mut dyn common::Delegate,
11134 ) -> InsightTypeListCall<'a, C> {
11135 self._delegate = Some(new_value);
11136 self
11137 }
11138
11139 /// Set any additional parameter of the query string used in the request.
11140 /// It should be used to set parameters which are not yet available through their own
11141 /// setters.
11142 ///
11143 /// Please note that this method must not be used to set any of the known parameters
11144 /// which have their own setter method. If done anyway, the request will fail.
11145 ///
11146 /// # Additional Parameters
11147 ///
11148 /// * *$.xgafv* (query-string) - V1 error format.
11149 /// * *access_token* (query-string) - OAuth access token.
11150 /// * *alt* (query-string) - Data format for response.
11151 /// * *callback* (query-string) - JSONP
11152 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11153 /// * *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.
11154 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11155 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11156 /// * *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.
11157 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11158 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11159 pub fn param<T>(mut self, name: T, value: T) -> InsightTypeListCall<'a, C>
11160 where
11161 T: AsRef<str>,
11162 {
11163 self._additional_params
11164 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11165 self
11166 }
11167
11168 /// Identifies the authorization scope for the method you are building.
11169 ///
11170 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11171 /// [`Scope::CloudPlatform`].
11172 ///
11173 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11174 /// tokens for more than one scope.
11175 ///
11176 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11177 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11178 /// sufficient, a read-write scope will do as well.
11179 pub fn add_scope<St>(mut self, scope: St) -> InsightTypeListCall<'a, C>
11180 where
11181 St: AsRef<str>,
11182 {
11183 self._scopes.insert(String::from(scope.as_ref()));
11184 self
11185 }
11186 /// Identifies the authorization scope(s) for the method you are building.
11187 ///
11188 /// See [`Self::add_scope()`] for details.
11189 pub fn add_scopes<I, St>(mut self, scopes: I) -> InsightTypeListCall<'a, C>
11190 where
11191 I: IntoIterator<Item = St>,
11192 St: AsRef<str>,
11193 {
11194 self._scopes
11195 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11196 self
11197 }
11198
11199 /// Removes all scopes, and no default scope will be used either.
11200 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11201 /// for details).
11202 pub fn clear_scopes(mut self) -> InsightTypeListCall<'a, C> {
11203 self._scopes.clear();
11204 self
11205 }
11206}
11207
11208/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
11209///
11210/// A builder for the *locations.insightTypes.insights.get* method supported by a *organization* resource.
11211/// It is not used directly, but through a [`OrganizationMethods`] instance.
11212///
11213/// # Example
11214///
11215/// Instantiate a resource method builder
11216///
11217/// ```test_harness,no_run
11218/// # extern crate hyper;
11219/// # extern crate hyper_rustls;
11220/// # extern crate google_recommender1_beta1 as recommender1_beta1;
11221/// # async fn dox() {
11222/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11223///
11224/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11225/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11226/// # .with_native_roots()
11227/// # .unwrap()
11228/// # .https_only()
11229/// # .enable_http2()
11230/// # .build();
11231///
11232/// # let executor = hyper_util::rt::TokioExecutor::new();
11233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11234/// # secret,
11235/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11236/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11237/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11238/// # ),
11239/// # ).build().await.unwrap();
11240///
11241/// # let client = hyper_util::client::legacy::Client::builder(
11242/// # hyper_util::rt::TokioExecutor::new()
11243/// # )
11244/// # .build(
11245/// # hyper_rustls::HttpsConnectorBuilder::new()
11246/// # .with_native_roots()
11247/// # .unwrap()
11248/// # .https_or_http()
11249/// # .enable_http2()
11250/// # .build()
11251/// # );
11252/// # let mut hub = Recommender::new(client, auth);
11253/// // You can configure optional parameters by calling the respective setters at will, and
11254/// // execute the final call using `doit()`.
11255/// // Values shown here are possibly random and not representative !
11256/// let result = hub.organizations().locations_insight_types_insights_get("name")
11257/// .doit().await;
11258/// # }
11259/// ```
11260pub struct OrganizationLocationInsightTypeInsightGetCall<'a, C>
11261where
11262 C: 'a,
11263{
11264 hub: &'a Recommender<C>,
11265 _name: String,
11266 _delegate: Option<&'a mut dyn common::Delegate>,
11267 _additional_params: HashMap<String, String>,
11268 _scopes: BTreeSet<String>,
11269}
11270
11271impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeInsightGetCall<'a, C> {}
11272
11273impl<'a, C> OrganizationLocationInsightTypeInsightGetCall<'a, C>
11274where
11275 C: common::Connector,
11276{
11277 /// Perform the operation you have build so far.
11278 pub async fn doit(
11279 mut self,
11280 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
11281 use std::borrow::Cow;
11282 use std::io::{Read, Seek};
11283
11284 use common::{url::Params, ToParts};
11285 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11286
11287 let mut dd = common::DefaultDelegate;
11288 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11289 dlg.begin(common::MethodInfo {
11290 id: "recommender.organizations.locations.insightTypes.insights.get",
11291 http_method: hyper::Method::GET,
11292 });
11293
11294 for &field in ["alt", "name"].iter() {
11295 if self._additional_params.contains_key(field) {
11296 dlg.finished(false);
11297 return Err(common::Error::FieldClash(field));
11298 }
11299 }
11300
11301 let mut params = Params::with_capacity(3 + self._additional_params.len());
11302 params.push("name", self._name);
11303
11304 params.extend(self._additional_params.iter());
11305
11306 params.push("alt", "json");
11307 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
11308 if self._scopes.is_empty() {
11309 self._scopes
11310 .insert(Scope::CloudPlatform.as_ref().to_string());
11311 }
11312
11313 #[allow(clippy::single_element_loop)]
11314 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11315 url = params.uri_replacement(url, param_name, find_this, true);
11316 }
11317 {
11318 let to_remove = ["name"];
11319 params.remove_params(&to_remove);
11320 }
11321
11322 let url = params.parse_with_url(&url);
11323
11324 loop {
11325 let token = match self
11326 .hub
11327 .auth
11328 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11329 .await
11330 {
11331 Ok(token) => token,
11332 Err(e) => match dlg.token(e) {
11333 Ok(token) => token,
11334 Err(e) => {
11335 dlg.finished(false);
11336 return Err(common::Error::MissingToken(e));
11337 }
11338 },
11339 };
11340 let mut req_result = {
11341 let client = &self.hub.client;
11342 dlg.pre_request();
11343 let mut req_builder = hyper::Request::builder()
11344 .method(hyper::Method::GET)
11345 .uri(url.as_str())
11346 .header(USER_AGENT, self.hub._user_agent.clone());
11347
11348 if let Some(token) = token.as_ref() {
11349 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11350 }
11351
11352 let request = req_builder
11353 .header(CONTENT_LENGTH, 0_u64)
11354 .body(common::to_body::<String>(None));
11355
11356 client.request(request.unwrap()).await
11357 };
11358
11359 match req_result {
11360 Err(err) => {
11361 if let common::Retry::After(d) = dlg.http_error(&err) {
11362 sleep(d).await;
11363 continue;
11364 }
11365 dlg.finished(false);
11366 return Err(common::Error::HttpError(err));
11367 }
11368 Ok(res) => {
11369 let (mut parts, body) = res.into_parts();
11370 let mut body = common::Body::new(body);
11371 if !parts.status.is_success() {
11372 let bytes = common::to_bytes(body).await.unwrap_or_default();
11373 let error = serde_json::from_str(&common::to_string(&bytes));
11374 let response = common::to_response(parts, bytes.into());
11375
11376 if let common::Retry::After(d) =
11377 dlg.http_failure(&response, error.as_ref().ok())
11378 {
11379 sleep(d).await;
11380 continue;
11381 }
11382
11383 dlg.finished(false);
11384
11385 return Err(match error {
11386 Ok(value) => common::Error::BadRequest(value),
11387 _ => common::Error::Failure(response),
11388 });
11389 }
11390 let response = {
11391 let bytes = common::to_bytes(body).await.unwrap_or_default();
11392 let encoded = common::to_string(&bytes);
11393 match serde_json::from_str(&encoded) {
11394 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11395 Err(error) => {
11396 dlg.response_json_decode_error(&encoded, &error);
11397 return Err(common::Error::JsonDecodeError(
11398 encoded.to_string(),
11399 error,
11400 ));
11401 }
11402 }
11403 };
11404
11405 dlg.finished(true);
11406 return Ok(response);
11407 }
11408 }
11409 }
11410 }
11411
11412 /// Required. Name of the insight.
11413 ///
11414 /// Sets the *name* path property to the given value.
11415 ///
11416 /// Even though the property as already been set when instantiating this call,
11417 /// we provide this method for API completeness.
11418 pub fn name(mut self, new_value: &str) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
11419 self._name = new_value.to_string();
11420 self
11421 }
11422 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11423 /// while executing the actual API request.
11424 ///
11425 /// ````text
11426 /// It should be used to handle progress information, and to implement a certain level of resilience.
11427 /// ````
11428 ///
11429 /// Sets the *delegate* property to the given value.
11430 pub fn delegate(
11431 mut self,
11432 new_value: &'a mut dyn common::Delegate,
11433 ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
11434 self._delegate = Some(new_value);
11435 self
11436 }
11437
11438 /// Set any additional parameter of the query string used in the request.
11439 /// It should be used to set parameters which are not yet available through their own
11440 /// setters.
11441 ///
11442 /// Please note that this method must not be used to set any of the known parameters
11443 /// which have their own setter method. If done anyway, the request will fail.
11444 ///
11445 /// # Additional Parameters
11446 ///
11447 /// * *$.xgafv* (query-string) - V1 error format.
11448 /// * *access_token* (query-string) - OAuth access token.
11449 /// * *alt* (query-string) - Data format for response.
11450 /// * *callback* (query-string) - JSONP
11451 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11452 /// * *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.
11453 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11454 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11455 /// * *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.
11456 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11457 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11458 pub fn param<T>(
11459 mut self,
11460 name: T,
11461 value: T,
11462 ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C>
11463 where
11464 T: AsRef<str>,
11465 {
11466 self._additional_params
11467 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11468 self
11469 }
11470
11471 /// Identifies the authorization scope for the method you are building.
11472 ///
11473 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11474 /// [`Scope::CloudPlatform`].
11475 ///
11476 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11477 /// tokens for more than one scope.
11478 ///
11479 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11480 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11481 /// sufficient, a read-write scope will do as well.
11482 pub fn add_scope<St>(
11483 mut self,
11484 scope: St,
11485 ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C>
11486 where
11487 St: AsRef<str>,
11488 {
11489 self._scopes.insert(String::from(scope.as_ref()));
11490 self
11491 }
11492 /// Identifies the authorization scope(s) for the method you are building.
11493 ///
11494 /// See [`Self::add_scope()`] for details.
11495 pub fn add_scopes<I, St>(
11496 mut self,
11497 scopes: I,
11498 ) -> OrganizationLocationInsightTypeInsightGetCall<'a, C>
11499 where
11500 I: IntoIterator<Item = St>,
11501 St: AsRef<str>,
11502 {
11503 self._scopes
11504 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11505 self
11506 }
11507
11508 /// Removes all scopes, and no default scope will be used either.
11509 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11510 /// for details).
11511 pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeInsightGetCall<'a, C> {
11512 self._scopes.clear();
11513 self
11514 }
11515}
11516
11517/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
11518///
11519/// A builder for the *locations.insightTypes.insights.list* method supported by a *organization* resource.
11520/// It is not used directly, but through a [`OrganizationMethods`] instance.
11521///
11522/// # Example
11523///
11524/// Instantiate a resource method builder
11525///
11526/// ```test_harness,no_run
11527/// # extern crate hyper;
11528/// # extern crate hyper_rustls;
11529/// # extern crate google_recommender1_beta1 as recommender1_beta1;
11530/// # async fn dox() {
11531/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11532///
11533/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11534/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11535/// # .with_native_roots()
11536/// # .unwrap()
11537/// # .https_only()
11538/// # .enable_http2()
11539/// # .build();
11540///
11541/// # let executor = hyper_util::rt::TokioExecutor::new();
11542/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11543/// # secret,
11544/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11545/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11546/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11547/// # ),
11548/// # ).build().await.unwrap();
11549///
11550/// # let client = hyper_util::client::legacy::Client::builder(
11551/// # hyper_util::rt::TokioExecutor::new()
11552/// # )
11553/// # .build(
11554/// # hyper_rustls::HttpsConnectorBuilder::new()
11555/// # .with_native_roots()
11556/// # .unwrap()
11557/// # .https_or_http()
11558/// # .enable_http2()
11559/// # .build()
11560/// # );
11561/// # let mut hub = Recommender::new(client, auth);
11562/// // You can configure optional parameters by calling the respective setters at will, and
11563/// // execute the final call using `doit()`.
11564/// // Values shown here are possibly random and not representative !
11565/// let result = hub.organizations().locations_insight_types_insights_list("parent")
11566/// .page_token("voluptua.")
11567/// .page_size(-2)
11568/// .filter("consetetur")
11569/// .doit().await;
11570/// # }
11571/// ```
11572pub struct OrganizationLocationInsightTypeInsightListCall<'a, C>
11573where
11574 C: 'a,
11575{
11576 hub: &'a Recommender<C>,
11577 _parent: String,
11578 _page_token: Option<String>,
11579 _page_size: Option<i32>,
11580 _filter: Option<String>,
11581 _delegate: Option<&'a mut dyn common::Delegate>,
11582 _additional_params: HashMap<String, String>,
11583 _scopes: BTreeSet<String>,
11584}
11585
11586impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeInsightListCall<'a, C> {}
11587
11588impl<'a, C> OrganizationLocationInsightTypeInsightListCall<'a, C>
11589where
11590 C: common::Connector,
11591{
11592 /// Perform the operation you have build so far.
11593 pub async fn doit(
11594 mut self,
11595 ) -> common::Result<(
11596 common::Response,
11597 GoogleCloudRecommenderV1beta1ListInsightsResponse,
11598 )> {
11599 use std::borrow::Cow;
11600 use std::io::{Read, Seek};
11601
11602 use common::{url::Params, ToParts};
11603 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11604
11605 let mut dd = common::DefaultDelegate;
11606 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11607 dlg.begin(common::MethodInfo {
11608 id: "recommender.organizations.locations.insightTypes.insights.list",
11609 http_method: hyper::Method::GET,
11610 });
11611
11612 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
11613 if self._additional_params.contains_key(field) {
11614 dlg.finished(false);
11615 return Err(common::Error::FieldClash(field));
11616 }
11617 }
11618
11619 let mut params = Params::with_capacity(6 + self._additional_params.len());
11620 params.push("parent", self._parent);
11621 if let Some(value) = self._page_token.as_ref() {
11622 params.push("pageToken", value);
11623 }
11624 if let Some(value) = self._page_size.as_ref() {
11625 params.push("pageSize", value.to_string());
11626 }
11627 if let Some(value) = self._filter.as_ref() {
11628 params.push("filter", value);
11629 }
11630
11631 params.extend(self._additional_params.iter());
11632
11633 params.push("alt", "json");
11634 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/insights";
11635 if self._scopes.is_empty() {
11636 self._scopes
11637 .insert(Scope::CloudPlatform.as_ref().to_string());
11638 }
11639
11640 #[allow(clippy::single_element_loop)]
11641 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11642 url = params.uri_replacement(url, param_name, find_this, true);
11643 }
11644 {
11645 let to_remove = ["parent"];
11646 params.remove_params(&to_remove);
11647 }
11648
11649 let url = params.parse_with_url(&url);
11650
11651 loop {
11652 let token = match self
11653 .hub
11654 .auth
11655 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11656 .await
11657 {
11658 Ok(token) => token,
11659 Err(e) => match dlg.token(e) {
11660 Ok(token) => token,
11661 Err(e) => {
11662 dlg.finished(false);
11663 return Err(common::Error::MissingToken(e));
11664 }
11665 },
11666 };
11667 let mut req_result = {
11668 let client = &self.hub.client;
11669 dlg.pre_request();
11670 let mut req_builder = hyper::Request::builder()
11671 .method(hyper::Method::GET)
11672 .uri(url.as_str())
11673 .header(USER_AGENT, self.hub._user_agent.clone());
11674
11675 if let Some(token) = token.as_ref() {
11676 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11677 }
11678
11679 let request = req_builder
11680 .header(CONTENT_LENGTH, 0_u64)
11681 .body(common::to_body::<String>(None));
11682
11683 client.request(request.unwrap()).await
11684 };
11685
11686 match req_result {
11687 Err(err) => {
11688 if let common::Retry::After(d) = dlg.http_error(&err) {
11689 sleep(d).await;
11690 continue;
11691 }
11692 dlg.finished(false);
11693 return Err(common::Error::HttpError(err));
11694 }
11695 Ok(res) => {
11696 let (mut parts, body) = res.into_parts();
11697 let mut body = common::Body::new(body);
11698 if !parts.status.is_success() {
11699 let bytes = common::to_bytes(body).await.unwrap_or_default();
11700 let error = serde_json::from_str(&common::to_string(&bytes));
11701 let response = common::to_response(parts, bytes.into());
11702
11703 if let common::Retry::After(d) =
11704 dlg.http_failure(&response, error.as_ref().ok())
11705 {
11706 sleep(d).await;
11707 continue;
11708 }
11709
11710 dlg.finished(false);
11711
11712 return Err(match error {
11713 Ok(value) => common::Error::BadRequest(value),
11714 _ => common::Error::Failure(response),
11715 });
11716 }
11717 let response = {
11718 let bytes = common::to_bytes(body).await.unwrap_or_default();
11719 let encoded = common::to_string(&bytes);
11720 match serde_json::from_str(&encoded) {
11721 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11722 Err(error) => {
11723 dlg.response_json_decode_error(&encoded, &error);
11724 return Err(common::Error::JsonDecodeError(
11725 encoded.to_string(),
11726 error,
11727 ));
11728 }
11729 }
11730 };
11731
11732 dlg.finished(true);
11733 return Ok(response);
11734 }
11735 }
11736 }
11737 }
11738
11739 /// 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.
11740 ///
11741 /// Sets the *parent* path property to the given value.
11742 ///
11743 /// Even though the property as already been set when instantiating this call,
11744 /// we provide this method for API completeness.
11745 pub fn parent(
11746 mut self,
11747 new_value: &str,
11748 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
11749 self._parent = new_value.to_string();
11750 self
11751 }
11752 /// 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.
11753 ///
11754 /// Sets the *page token* query property to the given value.
11755 pub fn page_token(
11756 mut self,
11757 new_value: &str,
11758 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
11759 self._page_token = Some(new_value.to_string());
11760 self
11761 }
11762 /// 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.
11763 ///
11764 /// Sets the *page size* query property to the given value.
11765 pub fn page_size(
11766 mut self,
11767 new_value: i32,
11768 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
11769 self._page_size = Some(new_value);
11770 self
11771 }
11772 /// 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)
11773 ///
11774 /// Sets the *filter* query property to the given value.
11775 pub fn filter(
11776 mut self,
11777 new_value: &str,
11778 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
11779 self._filter = Some(new_value.to_string());
11780 self
11781 }
11782 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11783 /// while executing the actual API request.
11784 ///
11785 /// ````text
11786 /// It should be used to handle progress information, and to implement a certain level of resilience.
11787 /// ````
11788 ///
11789 /// Sets the *delegate* property to the given value.
11790 pub fn delegate(
11791 mut self,
11792 new_value: &'a mut dyn common::Delegate,
11793 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
11794 self._delegate = Some(new_value);
11795 self
11796 }
11797
11798 /// Set any additional parameter of the query string used in the request.
11799 /// It should be used to set parameters which are not yet available through their own
11800 /// setters.
11801 ///
11802 /// Please note that this method must not be used to set any of the known parameters
11803 /// which have their own setter method. If done anyway, the request will fail.
11804 ///
11805 /// # Additional Parameters
11806 ///
11807 /// * *$.xgafv* (query-string) - V1 error format.
11808 /// * *access_token* (query-string) - OAuth access token.
11809 /// * *alt* (query-string) - Data format for response.
11810 /// * *callback* (query-string) - JSONP
11811 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11812 /// * *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.
11813 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11814 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11815 /// * *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.
11816 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11817 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11818 pub fn param<T>(
11819 mut self,
11820 name: T,
11821 value: T,
11822 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C>
11823 where
11824 T: AsRef<str>,
11825 {
11826 self._additional_params
11827 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11828 self
11829 }
11830
11831 /// Identifies the authorization scope for the method you are building.
11832 ///
11833 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11834 /// [`Scope::CloudPlatform`].
11835 ///
11836 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11837 /// tokens for more than one scope.
11838 ///
11839 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11840 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11841 /// sufficient, a read-write scope will do as well.
11842 pub fn add_scope<St>(
11843 mut self,
11844 scope: St,
11845 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C>
11846 where
11847 St: AsRef<str>,
11848 {
11849 self._scopes.insert(String::from(scope.as_ref()));
11850 self
11851 }
11852 /// Identifies the authorization scope(s) for the method you are building.
11853 ///
11854 /// See [`Self::add_scope()`] for details.
11855 pub fn add_scopes<I, St>(
11856 mut self,
11857 scopes: I,
11858 ) -> OrganizationLocationInsightTypeInsightListCall<'a, C>
11859 where
11860 I: IntoIterator<Item = St>,
11861 St: AsRef<str>,
11862 {
11863 self._scopes
11864 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11865 self
11866 }
11867
11868 /// Removes all scopes, and no default scope will be used either.
11869 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11870 /// for details).
11871 pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeInsightListCall<'a, C> {
11872 self._scopes.clear();
11873 self
11874 }
11875}
11876
11877/// 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.
11878///
11879/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *organization* resource.
11880/// It is not used directly, but through a [`OrganizationMethods`] instance.
11881///
11882/// # Example
11883///
11884/// Instantiate a resource method builder
11885///
11886/// ```test_harness,no_run
11887/// # extern crate hyper;
11888/// # extern crate hyper_rustls;
11889/// # extern crate google_recommender1_beta1 as recommender1_beta1;
11890/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
11891/// # async fn dox() {
11892/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11893///
11894/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11895/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11896/// # .with_native_roots()
11897/// # .unwrap()
11898/// # .https_only()
11899/// # .enable_http2()
11900/// # .build();
11901///
11902/// # let executor = hyper_util::rt::TokioExecutor::new();
11903/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11904/// # secret,
11905/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11906/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11907/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11908/// # ),
11909/// # ).build().await.unwrap();
11910///
11911/// # let client = hyper_util::client::legacy::Client::builder(
11912/// # hyper_util::rt::TokioExecutor::new()
11913/// # )
11914/// # .build(
11915/// # hyper_rustls::HttpsConnectorBuilder::new()
11916/// # .with_native_roots()
11917/// # .unwrap()
11918/// # .https_or_http()
11919/// # .enable_http2()
11920/// # .build()
11921/// # );
11922/// # let mut hub = Recommender::new(client, auth);
11923/// // As the method needs a request, you would usually fill it with the desired information
11924/// // into the respective structure. Some of the parts shown here might not be applicable !
11925/// // Values shown here are possibly random and not representative !
11926/// let mut req = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::default();
11927///
11928/// // You can configure optional parameters by calling the respective setters at will, and
11929/// // execute the final call using `doit()`.
11930/// // Values shown here are possibly random and not representative !
11931/// let result = hub.organizations().locations_insight_types_insights_mark_accepted(req, "name")
11932/// .doit().await;
11933/// # }
11934/// ```
11935pub struct OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
11936where
11937 C: 'a,
11938{
11939 hub: &'a Recommender<C>,
11940 _request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
11941 _name: String,
11942 _delegate: Option<&'a mut dyn common::Delegate>,
11943 _additional_params: HashMap<String, String>,
11944 _scopes: BTreeSet<String>,
11945}
11946
11947impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {}
11948
11949impl<'a, C> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
11950where
11951 C: common::Connector,
11952{
11953 /// Perform the operation you have build so far.
11954 pub async fn doit(
11955 mut self,
11956 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
11957 use std::borrow::Cow;
11958 use std::io::{Read, Seek};
11959
11960 use common::{url::Params, ToParts};
11961 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11962
11963 let mut dd = common::DefaultDelegate;
11964 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11965 dlg.begin(common::MethodInfo {
11966 id: "recommender.organizations.locations.insightTypes.insights.markAccepted",
11967 http_method: hyper::Method::POST,
11968 });
11969
11970 for &field in ["alt", "name"].iter() {
11971 if self._additional_params.contains_key(field) {
11972 dlg.finished(false);
11973 return Err(common::Error::FieldClash(field));
11974 }
11975 }
11976
11977 let mut params = Params::with_capacity(4 + self._additional_params.len());
11978 params.push("name", self._name);
11979
11980 params.extend(self._additional_params.iter());
11981
11982 params.push("alt", "json");
11983 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markAccepted";
11984 if self._scopes.is_empty() {
11985 self._scopes
11986 .insert(Scope::CloudPlatform.as_ref().to_string());
11987 }
11988
11989 #[allow(clippy::single_element_loop)]
11990 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11991 url = params.uri_replacement(url, param_name, find_this, true);
11992 }
11993 {
11994 let to_remove = ["name"];
11995 params.remove_params(&to_remove);
11996 }
11997
11998 let url = params.parse_with_url(&url);
11999
12000 let mut json_mime_type = mime::APPLICATION_JSON;
12001 let mut request_value_reader = {
12002 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12003 common::remove_json_null_values(&mut value);
12004 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12005 serde_json::to_writer(&mut dst, &value).unwrap();
12006 dst
12007 };
12008 let request_size = request_value_reader
12009 .seek(std::io::SeekFrom::End(0))
12010 .unwrap();
12011 request_value_reader
12012 .seek(std::io::SeekFrom::Start(0))
12013 .unwrap();
12014
12015 loop {
12016 let token = match self
12017 .hub
12018 .auth
12019 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12020 .await
12021 {
12022 Ok(token) => token,
12023 Err(e) => match dlg.token(e) {
12024 Ok(token) => token,
12025 Err(e) => {
12026 dlg.finished(false);
12027 return Err(common::Error::MissingToken(e));
12028 }
12029 },
12030 };
12031 request_value_reader
12032 .seek(std::io::SeekFrom::Start(0))
12033 .unwrap();
12034 let mut req_result = {
12035 let client = &self.hub.client;
12036 dlg.pre_request();
12037 let mut req_builder = hyper::Request::builder()
12038 .method(hyper::Method::POST)
12039 .uri(url.as_str())
12040 .header(USER_AGENT, self.hub._user_agent.clone());
12041
12042 if let Some(token) = token.as_ref() {
12043 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12044 }
12045
12046 let request = req_builder
12047 .header(CONTENT_TYPE, json_mime_type.to_string())
12048 .header(CONTENT_LENGTH, request_size as u64)
12049 .body(common::to_body(
12050 request_value_reader.get_ref().clone().into(),
12051 ));
12052
12053 client.request(request.unwrap()).await
12054 };
12055
12056 match req_result {
12057 Err(err) => {
12058 if let common::Retry::After(d) = dlg.http_error(&err) {
12059 sleep(d).await;
12060 continue;
12061 }
12062 dlg.finished(false);
12063 return Err(common::Error::HttpError(err));
12064 }
12065 Ok(res) => {
12066 let (mut parts, body) = res.into_parts();
12067 let mut body = common::Body::new(body);
12068 if !parts.status.is_success() {
12069 let bytes = common::to_bytes(body).await.unwrap_or_default();
12070 let error = serde_json::from_str(&common::to_string(&bytes));
12071 let response = common::to_response(parts, bytes.into());
12072
12073 if let common::Retry::After(d) =
12074 dlg.http_failure(&response, error.as_ref().ok())
12075 {
12076 sleep(d).await;
12077 continue;
12078 }
12079
12080 dlg.finished(false);
12081
12082 return Err(match error {
12083 Ok(value) => common::Error::BadRequest(value),
12084 _ => common::Error::Failure(response),
12085 });
12086 }
12087 let response = {
12088 let bytes = common::to_bytes(body).await.unwrap_or_default();
12089 let encoded = common::to_string(&bytes);
12090 match serde_json::from_str(&encoded) {
12091 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12092 Err(error) => {
12093 dlg.response_json_decode_error(&encoded, &error);
12094 return Err(common::Error::JsonDecodeError(
12095 encoded.to_string(),
12096 error,
12097 ));
12098 }
12099 }
12100 };
12101
12102 dlg.finished(true);
12103 return Ok(response);
12104 }
12105 }
12106 }
12107 }
12108
12109 ///
12110 /// Sets the *request* property to the given value.
12111 ///
12112 /// Even though the property as already been set when instantiating this call,
12113 /// we provide this method for API completeness.
12114 pub fn request(
12115 mut self,
12116 new_value: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
12117 ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
12118 self._request = new_value;
12119 self
12120 }
12121 /// Required. Name of the insight.
12122 ///
12123 /// Sets the *name* path property to the given value.
12124 ///
12125 /// Even though the property as already been set when instantiating this call,
12126 /// we provide this method for API completeness.
12127 pub fn name(
12128 mut self,
12129 new_value: &str,
12130 ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
12131 self._name = new_value.to_string();
12132 self
12133 }
12134 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12135 /// while executing the actual API request.
12136 ///
12137 /// ````text
12138 /// It should be used to handle progress information, and to implement a certain level of resilience.
12139 /// ````
12140 ///
12141 /// Sets the *delegate* property to the given value.
12142 pub fn delegate(
12143 mut self,
12144 new_value: &'a mut dyn common::Delegate,
12145 ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
12146 self._delegate = Some(new_value);
12147 self
12148 }
12149
12150 /// Set any additional parameter of the query string used in the request.
12151 /// It should be used to set parameters which are not yet available through their own
12152 /// setters.
12153 ///
12154 /// Please note that this method must not be used to set any of the known parameters
12155 /// which have their own setter method. If done anyway, the request will fail.
12156 ///
12157 /// # Additional Parameters
12158 ///
12159 /// * *$.xgafv* (query-string) - V1 error format.
12160 /// * *access_token* (query-string) - OAuth access token.
12161 /// * *alt* (query-string) - Data format for response.
12162 /// * *callback* (query-string) - JSONP
12163 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12164 /// * *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.
12165 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12166 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12167 /// * *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.
12168 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12169 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12170 pub fn param<T>(
12171 mut self,
12172 name: T,
12173 value: T,
12174 ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
12175 where
12176 T: AsRef<str>,
12177 {
12178 self._additional_params
12179 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12180 self
12181 }
12182
12183 /// Identifies the authorization scope for the method you are building.
12184 ///
12185 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12186 /// [`Scope::CloudPlatform`].
12187 ///
12188 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12189 /// tokens for more than one scope.
12190 ///
12191 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12192 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12193 /// sufficient, a read-write scope will do as well.
12194 pub fn add_scope<St>(
12195 mut self,
12196 scope: St,
12197 ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
12198 where
12199 St: AsRef<str>,
12200 {
12201 self._scopes.insert(String::from(scope.as_ref()));
12202 self
12203 }
12204 /// Identifies the authorization scope(s) for the method you are building.
12205 ///
12206 /// See [`Self::add_scope()`] for details.
12207 pub fn add_scopes<I, St>(
12208 mut self,
12209 scopes: I,
12210 ) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C>
12211 where
12212 I: IntoIterator<Item = St>,
12213 St: AsRef<str>,
12214 {
12215 self._scopes
12216 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12217 self
12218 }
12219
12220 /// Removes all scopes, and no default scope will be used either.
12221 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12222 /// for details).
12223 pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
12224 self._scopes.clear();
12225 self
12226 }
12227}
12228
12229/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
12230///
12231/// A builder for the *locations.insightTypes.getConfig* method supported by a *organization* resource.
12232/// It is not used directly, but through a [`OrganizationMethods`] instance.
12233///
12234/// # Example
12235///
12236/// Instantiate a resource method builder
12237///
12238/// ```test_harness,no_run
12239/// # extern crate hyper;
12240/// # extern crate hyper_rustls;
12241/// # extern crate google_recommender1_beta1 as recommender1_beta1;
12242/// # async fn dox() {
12243/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12244///
12245/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12246/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12247/// # .with_native_roots()
12248/// # .unwrap()
12249/// # .https_only()
12250/// # .enable_http2()
12251/// # .build();
12252///
12253/// # let executor = hyper_util::rt::TokioExecutor::new();
12254/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12255/// # secret,
12256/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12257/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12258/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12259/// # ),
12260/// # ).build().await.unwrap();
12261///
12262/// # let client = hyper_util::client::legacy::Client::builder(
12263/// # hyper_util::rt::TokioExecutor::new()
12264/// # )
12265/// # .build(
12266/// # hyper_rustls::HttpsConnectorBuilder::new()
12267/// # .with_native_roots()
12268/// # .unwrap()
12269/// # .https_or_http()
12270/// # .enable_http2()
12271/// # .build()
12272/// # );
12273/// # let mut hub = Recommender::new(client, auth);
12274/// // You can configure optional parameters by calling the respective setters at will, and
12275/// // execute the final call using `doit()`.
12276/// // Values shown here are possibly random and not representative !
12277/// let result = hub.organizations().locations_insight_types_get_config("name")
12278/// .doit().await;
12279/// # }
12280/// ```
12281pub struct OrganizationLocationInsightTypeGetConfigCall<'a, C>
12282where
12283 C: 'a,
12284{
12285 hub: &'a Recommender<C>,
12286 _name: String,
12287 _delegate: Option<&'a mut dyn common::Delegate>,
12288 _additional_params: HashMap<String, String>,
12289 _scopes: BTreeSet<String>,
12290}
12291
12292impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeGetConfigCall<'a, C> {}
12293
12294impl<'a, C> OrganizationLocationInsightTypeGetConfigCall<'a, C>
12295where
12296 C: common::Connector,
12297{
12298 /// Perform the operation you have build so far.
12299 pub async fn doit(
12300 mut self,
12301 ) -> common::Result<(
12302 common::Response,
12303 GoogleCloudRecommenderV1beta1InsightTypeConfig,
12304 )> {
12305 use std::borrow::Cow;
12306 use std::io::{Read, Seek};
12307
12308 use common::{url::Params, ToParts};
12309 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12310
12311 let mut dd = common::DefaultDelegate;
12312 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12313 dlg.begin(common::MethodInfo {
12314 id: "recommender.organizations.locations.insightTypes.getConfig",
12315 http_method: hyper::Method::GET,
12316 });
12317
12318 for &field in ["alt", "name"].iter() {
12319 if self._additional_params.contains_key(field) {
12320 dlg.finished(false);
12321 return Err(common::Error::FieldClash(field));
12322 }
12323 }
12324
12325 let mut params = Params::with_capacity(3 + self._additional_params.len());
12326 params.push("name", self._name);
12327
12328 params.extend(self._additional_params.iter());
12329
12330 params.push("alt", "json");
12331 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
12332 if self._scopes.is_empty() {
12333 self._scopes
12334 .insert(Scope::CloudPlatform.as_ref().to_string());
12335 }
12336
12337 #[allow(clippy::single_element_loop)]
12338 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12339 url = params.uri_replacement(url, param_name, find_this, true);
12340 }
12341 {
12342 let to_remove = ["name"];
12343 params.remove_params(&to_remove);
12344 }
12345
12346 let url = params.parse_with_url(&url);
12347
12348 loop {
12349 let token = match self
12350 .hub
12351 .auth
12352 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12353 .await
12354 {
12355 Ok(token) => token,
12356 Err(e) => match dlg.token(e) {
12357 Ok(token) => token,
12358 Err(e) => {
12359 dlg.finished(false);
12360 return Err(common::Error::MissingToken(e));
12361 }
12362 },
12363 };
12364 let mut req_result = {
12365 let client = &self.hub.client;
12366 dlg.pre_request();
12367 let mut req_builder = hyper::Request::builder()
12368 .method(hyper::Method::GET)
12369 .uri(url.as_str())
12370 .header(USER_AGENT, self.hub._user_agent.clone());
12371
12372 if let Some(token) = token.as_ref() {
12373 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12374 }
12375
12376 let request = req_builder
12377 .header(CONTENT_LENGTH, 0_u64)
12378 .body(common::to_body::<String>(None));
12379
12380 client.request(request.unwrap()).await
12381 };
12382
12383 match req_result {
12384 Err(err) => {
12385 if let common::Retry::After(d) = dlg.http_error(&err) {
12386 sleep(d).await;
12387 continue;
12388 }
12389 dlg.finished(false);
12390 return Err(common::Error::HttpError(err));
12391 }
12392 Ok(res) => {
12393 let (mut parts, body) = res.into_parts();
12394 let mut body = common::Body::new(body);
12395 if !parts.status.is_success() {
12396 let bytes = common::to_bytes(body).await.unwrap_or_default();
12397 let error = serde_json::from_str(&common::to_string(&bytes));
12398 let response = common::to_response(parts, bytes.into());
12399
12400 if let common::Retry::After(d) =
12401 dlg.http_failure(&response, error.as_ref().ok())
12402 {
12403 sleep(d).await;
12404 continue;
12405 }
12406
12407 dlg.finished(false);
12408
12409 return Err(match error {
12410 Ok(value) => common::Error::BadRequest(value),
12411 _ => common::Error::Failure(response),
12412 });
12413 }
12414 let response = {
12415 let bytes = common::to_bytes(body).await.unwrap_or_default();
12416 let encoded = common::to_string(&bytes);
12417 match serde_json::from_str(&encoded) {
12418 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12419 Err(error) => {
12420 dlg.response_json_decode_error(&encoded, &error);
12421 return Err(common::Error::JsonDecodeError(
12422 encoded.to_string(),
12423 error,
12424 ));
12425 }
12426 }
12427 };
12428
12429 dlg.finished(true);
12430 return Ok(response);
12431 }
12432 }
12433 }
12434 }
12435
12436 /// 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`
12437 ///
12438 /// Sets the *name* path property to the given value.
12439 ///
12440 /// Even though the property as already been set when instantiating this call,
12441 /// we provide this method for API completeness.
12442 pub fn name(mut self, new_value: &str) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
12443 self._name = new_value.to_string();
12444 self
12445 }
12446 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12447 /// while executing the actual API request.
12448 ///
12449 /// ````text
12450 /// It should be used to handle progress information, and to implement a certain level of resilience.
12451 /// ````
12452 ///
12453 /// Sets the *delegate* property to the given value.
12454 pub fn delegate(
12455 mut self,
12456 new_value: &'a mut dyn common::Delegate,
12457 ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
12458 self._delegate = Some(new_value);
12459 self
12460 }
12461
12462 /// Set any additional parameter of the query string used in the request.
12463 /// It should be used to set parameters which are not yet available through their own
12464 /// setters.
12465 ///
12466 /// Please note that this method must not be used to set any of the known parameters
12467 /// which have their own setter method. If done anyway, the request will fail.
12468 ///
12469 /// # Additional Parameters
12470 ///
12471 /// * *$.xgafv* (query-string) - V1 error format.
12472 /// * *access_token* (query-string) - OAuth access token.
12473 /// * *alt* (query-string) - Data format for response.
12474 /// * *callback* (query-string) - JSONP
12475 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12476 /// * *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.
12477 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12478 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12479 /// * *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.
12480 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12481 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12482 pub fn param<T>(
12483 mut self,
12484 name: T,
12485 value: T,
12486 ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C>
12487 where
12488 T: AsRef<str>,
12489 {
12490 self._additional_params
12491 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12492 self
12493 }
12494
12495 /// Identifies the authorization scope for the method you are building.
12496 ///
12497 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12498 /// [`Scope::CloudPlatform`].
12499 ///
12500 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12501 /// tokens for more than one scope.
12502 ///
12503 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12504 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12505 /// sufficient, a read-write scope will do as well.
12506 pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationInsightTypeGetConfigCall<'a, C>
12507 where
12508 St: AsRef<str>,
12509 {
12510 self._scopes.insert(String::from(scope.as_ref()));
12511 self
12512 }
12513 /// Identifies the authorization scope(s) for the method you are building.
12514 ///
12515 /// See [`Self::add_scope()`] for details.
12516 pub fn add_scopes<I, St>(
12517 mut self,
12518 scopes: I,
12519 ) -> OrganizationLocationInsightTypeGetConfigCall<'a, C>
12520 where
12521 I: IntoIterator<Item = St>,
12522 St: AsRef<str>,
12523 {
12524 self._scopes
12525 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12526 self
12527 }
12528
12529 /// Removes all scopes, and no default scope will be used either.
12530 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12531 /// for details).
12532 pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeGetConfigCall<'a, C> {
12533 self._scopes.clear();
12534 self
12535 }
12536}
12537
12538/// Updates an InsightTypeConfig change. This will create a new revision of the config.
12539///
12540/// A builder for the *locations.insightTypes.updateConfig* method supported by a *organization* resource.
12541/// It is not used directly, but through a [`OrganizationMethods`] instance.
12542///
12543/// # Example
12544///
12545/// Instantiate a resource method builder
12546///
12547/// ```test_harness,no_run
12548/// # extern crate hyper;
12549/// # extern crate hyper_rustls;
12550/// # extern crate google_recommender1_beta1 as recommender1_beta1;
12551/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1InsightTypeConfig;
12552/// # async fn dox() {
12553/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12554///
12555/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12556/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12557/// # .with_native_roots()
12558/// # .unwrap()
12559/// # .https_only()
12560/// # .enable_http2()
12561/// # .build();
12562///
12563/// # let executor = hyper_util::rt::TokioExecutor::new();
12564/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12565/// # secret,
12566/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12567/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12568/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12569/// # ),
12570/// # ).build().await.unwrap();
12571///
12572/// # let client = hyper_util::client::legacy::Client::builder(
12573/// # hyper_util::rt::TokioExecutor::new()
12574/// # )
12575/// # .build(
12576/// # hyper_rustls::HttpsConnectorBuilder::new()
12577/// # .with_native_roots()
12578/// # .unwrap()
12579/// # .https_or_http()
12580/// # .enable_http2()
12581/// # .build()
12582/// # );
12583/// # let mut hub = Recommender::new(client, auth);
12584/// // As the method needs a request, you would usually fill it with the desired information
12585/// // into the respective structure. Some of the parts shown here might not be applicable !
12586/// // Values shown here are possibly random and not representative !
12587/// let mut req = GoogleCloudRecommenderV1beta1InsightTypeConfig::default();
12588///
12589/// // You can configure optional parameters by calling the respective setters at will, and
12590/// // execute the final call using `doit()`.
12591/// // Values shown here are possibly random and not representative !
12592/// let result = hub.organizations().locations_insight_types_update_config(req, "name")
12593/// .validate_only(false)
12594/// .update_mask(FieldMask::new::<&str>(&[]))
12595/// .doit().await;
12596/// # }
12597/// ```
12598pub struct OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
12599where
12600 C: 'a,
12601{
12602 hub: &'a Recommender<C>,
12603 _request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
12604 _name: String,
12605 _validate_only: Option<bool>,
12606 _update_mask: Option<common::FieldMask>,
12607 _delegate: Option<&'a mut dyn common::Delegate>,
12608 _additional_params: HashMap<String, String>,
12609 _scopes: BTreeSet<String>,
12610}
12611
12612impl<'a, C> common::CallBuilder for OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {}
12613
12614impl<'a, C> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
12615where
12616 C: common::Connector,
12617{
12618 /// Perform the operation you have build so far.
12619 pub async fn doit(
12620 mut self,
12621 ) -> common::Result<(
12622 common::Response,
12623 GoogleCloudRecommenderV1beta1InsightTypeConfig,
12624 )> {
12625 use std::borrow::Cow;
12626 use std::io::{Read, Seek};
12627
12628 use common::{url::Params, ToParts};
12629 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12630
12631 let mut dd = common::DefaultDelegate;
12632 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12633 dlg.begin(common::MethodInfo {
12634 id: "recommender.organizations.locations.insightTypes.updateConfig",
12635 http_method: hyper::Method::PATCH,
12636 });
12637
12638 for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
12639 if self._additional_params.contains_key(field) {
12640 dlg.finished(false);
12641 return Err(common::Error::FieldClash(field));
12642 }
12643 }
12644
12645 let mut params = Params::with_capacity(6 + self._additional_params.len());
12646 params.push("name", self._name);
12647 if let Some(value) = self._validate_only.as_ref() {
12648 params.push("validateOnly", value.to_string());
12649 }
12650 if let Some(value) = self._update_mask.as_ref() {
12651 params.push("updateMask", value.to_string());
12652 }
12653
12654 params.extend(self._additional_params.iter());
12655
12656 params.push("alt", "json");
12657 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
12658 if self._scopes.is_empty() {
12659 self._scopes
12660 .insert(Scope::CloudPlatform.as_ref().to_string());
12661 }
12662
12663 #[allow(clippy::single_element_loop)]
12664 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12665 url = params.uri_replacement(url, param_name, find_this, true);
12666 }
12667 {
12668 let to_remove = ["name"];
12669 params.remove_params(&to_remove);
12670 }
12671
12672 let url = params.parse_with_url(&url);
12673
12674 let mut json_mime_type = mime::APPLICATION_JSON;
12675 let mut request_value_reader = {
12676 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12677 common::remove_json_null_values(&mut value);
12678 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12679 serde_json::to_writer(&mut dst, &value).unwrap();
12680 dst
12681 };
12682 let request_size = request_value_reader
12683 .seek(std::io::SeekFrom::End(0))
12684 .unwrap();
12685 request_value_reader
12686 .seek(std::io::SeekFrom::Start(0))
12687 .unwrap();
12688
12689 loop {
12690 let token = match self
12691 .hub
12692 .auth
12693 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12694 .await
12695 {
12696 Ok(token) => token,
12697 Err(e) => match dlg.token(e) {
12698 Ok(token) => token,
12699 Err(e) => {
12700 dlg.finished(false);
12701 return Err(common::Error::MissingToken(e));
12702 }
12703 },
12704 };
12705 request_value_reader
12706 .seek(std::io::SeekFrom::Start(0))
12707 .unwrap();
12708 let mut req_result = {
12709 let client = &self.hub.client;
12710 dlg.pre_request();
12711 let mut req_builder = hyper::Request::builder()
12712 .method(hyper::Method::PATCH)
12713 .uri(url.as_str())
12714 .header(USER_AGENT, self.hub._user_agent.clone());
12715
12716 if let Some(token) = token.as_ref() {
12717 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12718 }
12719
12720 let request = req_builder
12721 .header(CONTENT_TYPE, json_mime_type.to_string())
12722 .header(CONTENT_LENGTH, request_size as u64)
12723 .body(common::to_body(
12724 request_value_reader.get_ref().clone().into(),
12725 ));
12726
12727 client.request(request.unwrap()).await
12728 };
12729
12730 match req_result {
12731 Err(err) => {
12732 if let common::Retry::After(d) = dlg.http_error(&err) {
12733 sleep(d).await;
12734 continue;
12735 }
12736 dlg.finished(false);
12737 return Err(common::Error::HttpError(err));
12738 }
12739 Ok(res) => {
12740 let (mut parts, body) = res.into_parts();
12741 let mut body = common::Body::new(body);
12742 if !parts.status.is_success() {
12743 let bytes = common::to_bytes(body).await.unwrap_or_default();
12744 let error = serde_json::from_str(&common::to_string(&bytes));
12745 let response = common::to_response(parts, bytes.into());
12746
12747 if let common::Retry::After(d) =
12748 dlg.http_failure(&response, error.as_ref().ok())
12749 {
12750 sleep(d).await;
12751 continue;
12752 }
12753
12754 dlg.finished(false);
12755
12756 return Err(match error {
12757 Ok(value) => common::Error::BadRequest(value),
12758 _ => common::Error::Failure(response),
12759 });
12760 }
12761 let response = {
12762 let bytes = common::to_bytes(body).await.unwrap_or_default();
12763 let encoded = common::to_string(&bytes);
12764 match serde_json::from_str(&encoded) {
12765 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12766 Err(error) => {
12767 dlg.response_json_decode_error(&encoded, &error);
12768 return Err(common::Error::JsonDecodeError(
12769 encoded.to_string(),
12770 error,
12771 ));
12772 }
12773 }
12774 };
12775
12776 dlg.finished(true);
12777 return Ok(response);
12778 }
12779 }
12780 }
12781 }
12782
12783 ///
12784 /// Sets the *request* property to the given value.
12785 ///
12786 /// Even though the property as already been set when instantiating this call,
12787 /// we provide this method for API completeness.
12788 pub fn request(
12789 mut self,
12790 new_value: GoogleCloudRecommenderV1beta1InsightTypeConfig,
12791 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
12792 self._request = new_value;
12793 self
12794 }
12795 /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
12796 ///
12797 /// Sets the *name* path property to the given value.
12798 ///
12799 /// Even though the property as already been set when instantiating this call,
12800 /// we provide this method for API completeness.
12801 pub fn name(
12802 mut self,
12803 new_value: &str,
12804 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
12805 self._name = new_value.to_string();
12806 self
12807 }
12808 /// If true, validate the request and preview the change, but do not actually update it.
12809 ///
12810 /// Sets the *validate only* query property to the given value.
12811 pub fn validate_only(
12812 mut self,
12813 new_value: bool,
12814 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
12815 self._validate_only = Some(new_value);
12816 self
12817 }
12818 /// The list of fields to be updated.
12819 ///
12820 /// Sets the *update mask* query property to the given value.
12821 pub fn update_mask(
12822 mut self,
12823 new_value: common::FieldMask,
12824 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
12825 self._update_mask = Some(new_value);
12826 self
12827 }
12828 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12829 /// while executing the actual API request.
12830 ///
12831 /// ````text
12832 /// It should be used to handle progress information, and to implement a certain level of resilience.
12833 /// ````
12834 ///
12835 /// Sets the *delegate* property to the given value.
12836 pub fn delegate(
12837 mut self,
12838 new_value: &'a mut dyn common::Delegate,
12839 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
12840 self._delegate = Some(new_value);
12841 self
12842 }
12843
12844 /// Set any additional parameter of the query string used in the request.
12845 /// It should be used to set parameters which are not yet available through their own
12846 /// setters.
12847 ///
12848 /// Please note that this method must not be used to set any of the known parameters
12849 /// which have their own setter method. If done anyway, the request will fail.
12850 ///
12851 /// # Additional Parameters
12852 ///
12853 /// * *$.xgafv* (query-string) - V1 error format.
12854 /// * *access_token* (query-string) - OAuth access token.
12855 /// * *alt* (query-string) - Data format for response.
12856 /// * *callback* (query-string) - JSONP
12857 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12858 /// * *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.
12859 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12860 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12861 /// * *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.
12862 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12863 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12864 pub fn param<T>(
12865 mut self,
12866 name: T,
12867 value: T,
12868 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
12869 where
12870 T: AsRef<str>,
12871 {
12872 self._additional_params
12873 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12874 self
12875 }
12876
12877 /// Identifies the authorization scope for the method you are building.
12878 ///
12879 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12880 /// [`Scope::CloudPlatform`].
12881 ///
12882 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12883 /// tokens for more than one scope.
12884 ///
12885 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12886 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12887 /// sufficient, a read-write scope will do as well.
12888 pub fn add_scope<St>(
12889 mut self,
12890 scope: St,
12891 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
12892 where
12893 St: AsRef<str>,
12894 {
12895 self._scopes.insert(String::from(scope.as_ref()));
12896 self
12897 }
12898 /// Identifies the authorization scope(s) for the method you are building.
12899 ///
12900 /// See [`Self::add_scope()`] for details.
12901 pub fn add_scopes<I, St>(
12902 mut self,
12903 scopes: I,
12904 ) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C>
12905 where
12906 I: IntoIterator<Item = St>,
12907 St: AsRef<str>,
12908 {
12909 self._scopes
12910 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12911 self
12912 }
12913
12914 /// Removes all scopes, and no default scope will be used either.
12915 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12916 /// for details).
12917 pub fn clear_scopes(mut self) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, C> {
12918 self._scopes.clear();
12919 self
12920 }
12921}
12922
12923/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
12924///
12925/// A builder for the *locations.recommenders.recommendations.get* method supported by a *organization* resource.
12926/// It is not used directly, but through a [`OrganizationMethods`] instance.
12927///
12928/// # Example
12929///
12930/// Instantiate a resource method builder
12931///
12932/// ```test_harness,no_run
12933/// # extern crate hyper;
12934/// # extern crate hyper_rustls;
12935/// # extern crate google_recommender1_beta1 as recommender1_beta1;
12936/// # async fn dox() {
12937/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12938///
12939/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12940/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12941/// # .with_native_roots()
12942/// # .unwrap()
12943/// # .https_only()
12944/// # .enable_http2()
12945/// # .build();
12946///
12947/// # let executor = hyper_util::rt::TokioExecutor::new();
12948/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12949/// # secret,
12950/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12951/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12952/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12953/// # ),
12954/// # ).build().await.unwrap();
12955///
12956/// # let client = hyper_util::client::legacy::Client::builder(
12957/// # hyper_util::rt::TokioExecutor::new()
12958/// # )
12959/// # .build(
12960/// # hyper_rustls::HttpsConnectorBuilder::new()
12961/// # .with_native_roots()
12962/// # .unwrap()
12963/// # .https_or_http()
12964/// # .enable_http2()
12965/// # .build()
12966/// # );
12967/// # let mut hub = Recommender::new(client, auth);
12968/// // You can configure optional parameters by calling the respective setters at will, and
12969/// // execute the final call using `doit()`.
12970/// // Values shown here are possibly random and not representative !
12971/// let result = hub.organizations().locations_recommenders_recommendations_get("name")
12972/// .doit().await;
12973/// # }
12974/// ```
12975pub struct OrganizationLocationRecommenderRecommendationGetCall<'a, C>
12976where
12977 C: 'a,
12978{
12979 hub: &'a Recommender<C>,
12980 _name: String,
12981 _delegate: Option<&'a mut dyn common::Delegate>,
12982 _additional_params: HashMap<String, String>,
12983 _scopes: BTreeSet<String>,
12984}
12985
12986impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderRecommendationGetCall<'a, C> {}
12987
12988impl<'a, C> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
12989where
12990 C: common::Connector,
12991{
12992 /// Perform the operation you have build so far.
12993 pub async fn doit(
12994 mut self,
12995 ) -> common::Result<(
12996 common::Response,
12997 GoogleCloudRecommenderV1beta1Recommendation,
12998 )> {
12999 use std::borrow::Cow;
13000 use std::io::{Read, Seek};
13001
13002 use common::{url::Params, ToParts};
13003 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13004
13005 let mut dd = common::DefaultDelegate;
13006 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13007 dlg.begin(common::MethodInfo {
13008 id: "recommender.organizations.locations.recommenders.recommendations.get",
13009 http_method: hyper::Method::GET,
13010 });
13011
13012 for &field in ["alt", "name"].iter() {
13013 if self._additional_params.contains_key(field) {
13014 dlg.finished(false);
13015 return Err(common::Error::FieldClash(field));
13016 }
13017 }
13018
13019 let mut params = Params::with_capacity(3 + self._additional_params.len());
13020 params.push("name", self._name);
13021
13022 params.extend(self._additional_params.iter());
13023
13024 params.push("alt", "json");
13025 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
13026 if self._scopes.is_empty() {
13027 self._scopes
13028 .insert(Scope::CloudPlatform.as_ref().to_string());
13029 }
13030
13031 #[allow(clippy::single_element_loop)]
13032 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13033 url = params.uri_replacement(url, param_name, find_this, true);
13034 }
13035 {
13036 let to_remove = ["name"];
13037 params.remove_params(&to_remove);
13038 }
13039
13040 let url = params.parse_with_url(&url);
13041
13042 loop {
13043 let token = match self
13044 .hub
13045 .auth
13046 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13047 .await
13048 {
13049 Ok(token) => token,
13050 Err(e) => match dlg.token(e) {
13051 Ok(token) => token,
13052 Err(e) => {
13053 dlg.finished(false);
13054 return Err(common::Error::MissingToken(e));
13055 }
13056 },
13057 };
13058 let mut req_result = {
13059 let client = &self.hub.client;
13060 dlg.pre_request();
13061 let mut req_builder = hyper::Request::builder()
13062 .method(hyper::Method::GET)
13063 .uri(url.as_str())
13064 .header(USER_AGENT, self.hub._user_agent.clone());
13065
13066 if let Some(token) = token.as_ref() {
13067 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13068 }
13069
13070 let request = req_builder
13071 .header(CONTENT_LENGTH, 0_u64)
13072 .body(common::to_body::<String>(None));
13073
13074 client.request(request.unwrap()).await
13075 };
13076
13077 match req_result {
13078 Err(err) => {
13079 if let common::Retry::After(d) = dlg.http_error(&err) {
13080 sleep(d).await;
13081 continue;
13082 }
13083 dlg.finished(false);
13084 return Err(common::Error::HttpError(err));
13085 }
13086 Ok(res) => {
13087 let (mut parts, body) = res.into_parts();
13088 let mut body = common::Body::new(body);
13089 if !parts.status.is_success() {
13090 let bytes = common::to_bytes(body).await.unwrap_or_default();
13091 let error = serde_json::from_str(&common::to_string(&bytes));
13092 let response = common::to_response(parts, bytes.into());
13093
13094 if let common::Retry::After(d) =
13095 dlg.http_failure(&response, error.as_ref().ok())
13096 {
13097 sleep(d).await;
13098 continue;
13099 }
13100
13101 dlg.finished(false);
13102
13103 return Err(match error {
13104 Ok(value) => common::Error::BadRequest(value),
13105 _ => common::Error::Failure(response),
13106 });
13107 }
13108 let response = {
13109 let bytes = common::to_bytes(body).await.unwrap_or_default();
13110 let encoded = common::to_string(&bytes);
13111 match serde_json::from_str(&encoded) {
13112 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13113 Err(error) => {
13114 dlg.response_json_decode_error(&encoded, &error);
13115 return Err(common::Error::JsonDecodeError(
13116 encoded.to_string(),
13117 error,
13118 ));
13119 }
13120 }
13121 };
13122
13123 dlg.finished(true);
13124 return Ok(response);
13125 }
13126 }
13127 }
13128 }
13129
13130 /// Required. Name of the recommendation.
13131 ///
13132 /// Sets the *name* path property to the given value.
13133 ///
13134 /// Even though the property as already been set when instantiating this call,
13135 /// we provide this method for API completeness.
13136 pub fn name(
13137 mut self,
13138 new_value: &str,
13139 ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
13140 self._name = new_value.to_string();
13141 self
13142 }
13143 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13144 /// while executing the actual API request.
13145 ///
13146 /// ````text
13147 /// It should be used to handle progress information, and to implement a certain level of resilience.
13148 /// ````
13149 ///
13150 /// Sets the *delegate* property to the given value.
13151 pub fn delegate(
13152 mut self,
13153 new_value: &'a mut dyn common::Delegate,
13154 ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
13155 self._delegate = Some(new_value);
13156 self
13157 }
13158
13159 /// Set any additional parameter of the query string used in the request.
13160 /// It should be used to set parameters which are not yet available through their own
13161 /// setters.
13162 ///
13163 /// Please note that this method must not be used to set any of the known parameters
13164 /// which have their own setter method. If done anyway, the request will fail.
13165 ///
13166 /// # Additional Parameters
13167 ///
13168 /// * *$.xgafv* (query-string) - V1 error format.
13169 /// * *access_token* (query-string) - OAuth access token.
13170 /// * *alt* (query-string) - Data format for response.
13171 /// * *callback* (query-string) - JSONP
13172 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13173 /// * *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.
13174 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13175 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13176 /// * *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.
13177 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13178 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13179 pub fn param<T>(
13180 mut self,
13181 name: T,
13182 value: T,
13183 ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
13184 where
13185 T: AsRef<str>,
13186 {
13187 self._additional_params
13188 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13189 self
13190 }
13191
13192 /// Identifies the authorization scope for the method you are building.
13193 ///
13194 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13195 /// [`Scope::CloudPlatform`].
13196 ///
13197 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13198 /// tokens for more than one scope.
13199 ///
13200 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13201 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13202 /// sufficient, a read-write scope will do as well.
13203 pub fn add_scope<St>(
13204 mut self,
13205 scope: St,
13206 ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
13207 where
13208 St: AsRef<str>,
13209 {
13210 self._scopes.insert(String::from(scope.as_ref()));
13211 self
13212 }
13213 /// Identifies the authorization scope(s) for the method you are building.
13214 ///
13215 /// See [`Self::add_scope()`] for details.
13216 pub fn add_scopes<I, St>(
13217 mut self,
13218 scopes: I,
13219 ) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C>
13220 where
13221 I: IntoIterator<Item = St>,
13222 St: AsRef<str>,
13223 {
13224 self._scopes
13225 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13226 self
13227 }
13228
13229 /// Removes all scopes, and no default scope will be used either.
13230 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13231 /// for details).
13232 pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderRecommendationGetCall<'a, C> {
13233 self._scopes.clear();
13234 self
13235 }
13236}
13237
13238/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
13239///
13240/// A builder for the *locations.recommenders.recommendations.list* method supported by a *organization* resource.
13241/// It is not used directly, but through a [`OrganizationMethods`] instance.
13242///
13243/// # Example
13244///
13245/// Instantiate a resource method builder
13246///
13247/// ```test_harness,no_run
13248/// # extern crate hyper;
13249/// # extern crate hyper_rustls;
13250/// # extern crate google_recommender1_beta1 as recommender1_beta1;
13251/// # async fn dox() {
13252/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13253///
13254/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13255/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13256/// # .with_native_roots()
13257/// # .unwrap()
13258/// # .https_only()
13259/// # .enable_http2()
13260/// # .build();
13261///
13262/// # let executor = hyper_util::rt::TokioExecutor::new();
13263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13264/// # secret,
13265/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13266/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13267/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13268/// # ),
13269/// # ).build().await.unwrap();
13270///
13271/// # let client = hyper_util::client::legacy::Client::builder(
13272/// # hyper_util::rt::TokioExecutor::new()
13273/// # )
13274/// # .build(
13275/// # hyper_rustls::HttpsConnectorBuilder::new()
13276/// # .with_native_roots()
13277/// # .unwrap()
13278/// # .https_or_http()
13279/// # .enable_http2()
13280/// # .build()
13281/// # );
13282/// # let mut hub = Recommender::new(client, auth);
13283/// // You can configure optional parameters by calling the respective setters at will, and
13284/// // execute the final call using `doit()`.
13285/// // Values shown here are possibly random and not representative !
13286/// let result = hub.organizations().locations_recommenders_recommendations_list("parent")
13287/// .page_token("duo")
13288/// .page_size(-76)
13289/// .filter("vero")
13290/// .doit().await;
13291/// # }
13292/// ```
13293pub struct OrganizationLocationRecommenderRecommendationListCall<'a, C>
13294where
13295 C: 'a,
13296{
13297 hub: &'a Recommender<C>,
13298 _parent: String,
13299 _page_token: Option<String>,
13300 _page_size: Option<i32>,
13301 _filter: Option<String>,
13302 _delegate: Option<&'a mut dyn common::Delegate>,
13303 _additional_params: HashMap<String, String>,
13304 _scopes: BTreeSet<String>,
13305}
13306
13307impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderRecommendationListCall<'a, C> {}
13308
13309impl<'a, C> OrganizationLocationRecommenderRecommendationListCall<'a, C>
13310where
13311 C: common::Connector,
13312{
13313 /// Perform the operation you have build so far.
13314 pub async fn doit(
13315 mut self,
13316 ) -> common::Result<(
13317 common::Response,
13318 GoogleCloudRecommenderV1beta1ListRecommendationsResponse,
13319 )> {
13320 use std::borrow::Cow;
13321 use std::io::{Read, Seek};
13322
13323 use common::{url::Params, ToParts};
13324 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13325
13326 let mut dd = common::DefaultDelegate;
13327 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13328 dlg.begin(common::MethodInfo {
13329 id: "recommender.organizations.locations.recommenders.recommendations.list",
13330 http_method: hyper::Method::GET,
13331 });
13332
13333 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
13334 if self._additional_params.contains_key(field) {
13335 dlg.finished(false);
13336 return Err(common::Error::FieldClash(field));
13337 }
13338 }
13339
13340 let mut params = Params::with_capacity(6 + self._additional_params.len());
13341 params.push("parent", self._parent);
13342 if let Some(value) = self._page_token.as_ref() {
13343 params.push("pageToken", value);
13344 }
13345 if let Some(value) = self._page_size.as_ref() {
13346 params.push("pageSize", value.to_string());
13347 }
13348 if let Some(value) = self._filter.as_ref() {
13349 params.push("filter", value);
13350 }
13351
13352 params.extend(self._additional_params.iter());
13353
13354 params.push("alt", "json");
13355 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/recommendations";
13356 if self._scopes.is_empty() {
13357 self._scopes
13358 .insert(Scope::CloudPlatform.as_ref().to_string());
13359 }
13360
13361 #[allow(clippy::single_element_loop)]
13362 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13363 url = params.uri_replacement(url, param_name, find_this, true);
13364 }
13365 {
13366 let to_remove = ["parent"];
13367 params.remove_params(&to_remove);
13368 }
13369
13370 let url = params.parse_with_url(&url);
13371
13372 loop {
13373 let token = match self
13374 .hub
13375 .auth
13376 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13377 .await
13378 {
13379 Ok(token) => token,
13380 Err(e) => match dlg.token(e) {
13381 Ok(token) => token,
13382 Err(e) => {
13383 dlg.finished(false);
13384 return Err(common::Error::MissingToken(e));
13385 }
13386 },
13387 };
13388 let mut req_result = {
13389 let client = &self.hub.client;
13390 dlg.pre_request();
13391 let mut req_builder = hyper::Request::builder()
13392 .method(hyper::Method::GET)
13393 .uri(url.as_str())
13394 .header(USER_AGENT, self.hub._user_agent.clone());
13395
13396 if let Some(token) = token.as_ref() {
13397 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13398 }
13399
13400 let request = req_builder
13401 .header(CONTENT_LENGTH, 0_u64)
13402 .body(common::to_body::<String>(None));
13403
13404 client.request(request.unwrap()).await
13405 };
13406
13407 match req_result {
13408 Err(err) => {
13409 if let common::Retry::After(d) = dlg.http_error(&err) {
13410 sleep(d).await;
13411 continue;
13412 }
13413 dlg.finished(false);
13414 return Err(common::Error::HttpError(err));
13415 }
13416 Ok(res) => {
13417 let (mut parts, body) = res.into_parts();
13418 let mut body = common::Body::new(body);
13419 if !parts.status.is_success() {
13420 let bytes = common::to_bytes(body).await.unwrap_or_default();
13421 let error = serde_json::from_str(&common::to_string(&bytes));
13422 let response = common::to_response(parts, bytes.into());
13423
13424 if let common::Retry::After(d) =
13425 dlg.http_failure(&response, error.as_ref().ok())
13426 {
13427 sleep(d).await;
13428 continue;
13429 }
13430
13431 dlg.finished(false);
13432
13433 return Err(match error {
13434 Ok(value) => common::Error::BadRequest(value),
13435 _ => common::Error::Failure(response),
13436 });
13437 }
13438 let response = {
13439 let bytes = common::to_bytes(body).await.unwrap_or_default();
13440 let encoded = common::to_string(&bytes);
13441 match serde_json::from_str(&encoded) {
13442 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13443 Err(error) => {
13444 dlg.response_json_decode_error(&encoded, &error);
13445 return Err(common::Error::JsonDecodeError(
13446 encoded.to_string(),
13447 error,
13448 ));
13449 }
13450 }
13451 };
13452
13453 dlg.finished(true);
13454 return Ok(response);
13455 }
13456 }
13457 }
13458 }
13459
13460 /// 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.
13461 ///
13462 /// Sets the *parent* path property to the given value.
13463 ///
13464 /// Even though the property as already been set when instantiating this call,
13465 /// we provide this method for API completeness.
13466 pub fn parent(
13467 mut self,
13468 new_value: &str,
13469 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
13470 self._parent = new_value.to_string();
13471 self
13472 }
13473 /// 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.
13474 ///
13475 /// Sets the *page token* query property to the given value.
13476 pub fn page_token(
13477 mut self,
13478 new_value: &str,
13479 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
13480 self._page_token = Some(new_value.to_string());
13481 self
13482 }
13483 /// 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.
13484 ///
13485 /// Sets the *page size* query property to the given value.
13486 pub fn page_size(
13487 mut self,
13488 new_value: i32,
13489 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
13490 self._page_size = Some(new_value);
13491 self
13492 }
13493 /// 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)
13494 ///
13495 /// Sets the *filter* query property to the given value.
13496 pub fn filter(
13497 mut self,
13498 new_value: &str,
13499 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
13500 self._filter = Some(new_value.to_string());
13501 self
13502 }
13503 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13504 /// while executing the actual API request.
13505 ///
13506 /// ````text
13507 /// It should be used to handle progress information, and to implement a certain level of resilience.
13508 /// ````
13509 ///
13510 /// Sets the *delegate* property to the given value.
13511 pub fn delegate(
13512 mut self,
13513 new_value: &'a mut dyn common::Delegate,
13514 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
13515 self._delegate = Some(new_value);
13516 self
13517 }
13518
13519 /// Set any additional parameter of the query string used in the request.
13520 /// It should be used to set parameters which are not yet available through their own
13521 /// setters.
13522 ///
13523 /// Please note that this method must not be used to set any of the known parameters
13524 /// which have their own setter method. If done anyway, the request will fail.
13525 ///
13526 /// # Additional Parameters
13527 ///
13528 /// * *$.xgafv* (query-string) - V1 error format.
13529 /// * *access_token* (query-string) - OAuth access token.
13530 /// * *alt* (query-string) - Data format for response.
13531 /// * *callback* (query-string) - JSONP
13532 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13533 /// * *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.
13534 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13535 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13536 /// * *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.
13537 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13538 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13539 pub fn param<T>(
13540 mut self,
13541 name: T,
13542 value: T,
13543 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C>
13544 where
13545 T: AsRef<str>,
13546 {
13547 self._additional_params
13548 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13549 self
13550 }
13551
13552 /// Identifies the authorization scope for the method you are building.
13553 ///
13554 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13555 /// [`Scope::CloudPlatform`].
13556 ///
13557 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13558 /// tokens for more than one scope.
13559 ///
13560 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13561 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13562 /// sufficient, a read-write scope will do as well.
13563 pub fn add_scope<St>(
13564 mut self,
13565 scope: St,
13566 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C>
13567 where
13568 St: AsRef<str>,
13569 {
13570 self._scopes.insert(String::from(scope.as_ref()));
13571 self
13572 }
13573 /// Identifies the authorization scope(s) for the method you are building.
13574 ///
13575 /// See [`Self::add_scope()`] for details.
13576 pub fn add_scopes<I, St>(
13577 mut self,
13578 scopes: I,
13579 ) -> OrganizationLocationRecommenderRecommendationListCall<'a, C>
13580 where
13581 I: IntoIterator<Item = St>,
13582 St: AsRef<str>,
13583 {
13584 self._scopes
13585 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13586 self
13587 }
13588
13589 /// Removes all scopes, and no default scope will be used either.
13590 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13591 /// for details).
13592 pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderRecommendationListCall<'a, C> {
13593 self._scopes.clear();
13594 self
13595 }
13596}
13597
13598/// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
13599///
13600/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *organization* resource.
13601/// It is not used directly, but through a [`OrganizationMethods`] instance.
13602///
13603/// # Example
13604///
13605/// Instantiate a resource method builder
13606///
13607/// ```test_harness,no_run
13608/// # extern crate hyper;
13609/// # extern crate hyper_rustls;
13610/// # extern crate google_recommender1_beta1 as recommender1_beta1;
13611/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
13612/// # async fn dox() {
13613/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13614///
13615/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13616/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13617/// # .with_native_roots()
13618/// # .unwrap()
13619/// # .https_only()
13620/// # .enable_http2()
13621/// # .build();
13622///
13623/// # let executor = hyper_util::rt::TokioExecutor::new();
13624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13625/// # secret,
13626/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13627/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13628/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13629/// # ),
13630/// # ).build().await.unwrap();
13631///
13632/// # let client = hyper_util::client::legacy::Client::builder(
13633/// # hyper_util::rt::TokioExecutor::new()
13634/// # )
13635/// # .build(
13636/// # hyper_rustls::HttpsConnectorBuilder::new()
13637/// # .with_native_roots()
13638/// # .unwrap()
13639/// # .https_or_http()
13640/// # .enable_http2()
13641/// # .build()
13642/// # );
13643/// # let mut hub = Recommender::new(client, auth);
13644/// // As the method needs a request, you would usually fill it with the desired information
13645/// // into the respective structure. Some of the parts shown here might not be applicable !
13646/// // Values shown here are possibly random and not representative !
13647/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::default();
13648///
13649/// // You can configure optional parameters by calling the respective setters at will, and
13650/// // execute the final call using `doit()`.
13651/// // Values shown here are possibly random and not representative !
13652/// let result = hub.organizations().locations_recommenders_recommendations_mark_claimed(req, "name")
13653/// .doit().await;
13654/// # }
13655/// ```
13656pub struct OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
13657where
13658 C: 'a,
13659{
13660 hub: &'a Recommender<C>,
13661 _request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
13662 _name: String,
13663 _delegate: Option<&'a mut dyn common::Delegate>,
13664 _additional_params: HashMap<String, String>,
13665 _scopes: BTreeSet<String>,
13666}
13667
13668impl<'a, C> common::CallBuilder
13669 for OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
13670{
13671}
13672
13673impl<'a, C> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
13674where
13675 C: common::Connector,
13676{
13677 /// Perform the operation you have build so far.
13678 pub async fn doit(
13679 mut self,
13680 ) -> common::Result<(
13681 common::Response,
13682 GoogleCloudRecommenderV1beta1Recommendation,
13683 )> {
13684 use std::borrow::Cow;
13685 use std::io::{Read, Seek};
13686
13687 use common::{url::Params, ToParts};
13688 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13689
13690 let mut dd = common::DefaultDelegate;
13691 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13692 dlg.begin(common::MethodInfo {
13693 id: "recommender.organizations.locations.recommenders.recommendations.markClaimed",
13694 http_method: hyper::Method::POST,
13695 });
13696
13697 for &field in ["alt", "name"].iter() {
13698 if self._additional_params.contains_key(field) {
13699 dlg.finished(false);
13700 return Err(common::Error::FieldClash(field));
13701 }
13702 }
13703
13704 let mut params = Params::with_capacity(4 + self._additional_params.len());
13705 params.push("name", self._name);
13706
13707 params.extend(self._additional_params.iter());
13708
13709 params.push("alt", "json");
13710 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markClaimed";
13711 if self._scopes.is_empty() {
13712 self._scopes
13713 .insert(Scope::CloudPlatform.as_ref().to_string());
13714 }
13715
13716 #[allow(clippy::single_element_loop)]
13717 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13718 url = params.uri_replacement(url, param_name, find_this, true);
13719 }
13720 {
13721 let to_remove = ["name"];
13722 params.remove_params(&to_remove);
13723 }
13724
13725 let url = params.parse_with_url(&url);
13726
13727 let mut json_mime_type = mime::APPLICATION_JSON;
13728 let mut request_value_reader = {
13729 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13730 common::remove_json_null_values(&mut value);
13731 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13732 serde_json::to_writer(&mut dst, &value).unwrap();
13733 dst
13734 };
13735 let request_size = request_value_reader
13736 .seek(std::io::SeekFrom::End(0))
13737 .unwrap();
13738 request_value_reader
13739 .seek(std::io::SeekFrom::Start(0))
13740 .unwrap();
13741
13742 loop {
13743 let token = match self
13744 .hub
13745 .auth
13746 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13747 .await
13748 {
13749 Ok(token) => token,
13750 Err(e) => match dlg.token(e) {
13751 Ok(token) => token,
13752 Err(e) => {
13753 dlg.finished(false);
13754 return Err(common::Error::MissingToken(e));
13755 }
13756 },
13757 };
13758 request_value_reader
13759 .seek(std::io::SeekFrom::Start(0))
13760 .unwrap();
13761 let mut req_result = {
13762 let client = &self.hub.client;
13763 dlg.pre_request();
13764 let mut req_builder = hyper::Request::builder()
13765 .method(hyper::Method::POST)
13766 .uri(url.as_str())
13767 .header(USER_AGENT, self.hub._user_agent.clone());
13768
13769 if let Some(token) = token.as_ref() {
13770 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13771 }
13772
13773 let request = req_builder
13774 .header(CONTENT_TYPE, json_mime_type.to_string())
13775 .header(CONTENT_LENGTH, request_size as u64)
13776 .body(common::to_body(
13777 request_value_reader.get_ref().clone().into(),
13778 ));
13779
13780 client.request(request.unwrap()).await
13781 };
13782
13783 match req_result {
13784 Err(err) => {
13785 if let common::Retry::After(d) = dlg.http_error(&err) {
13786 sleep(d).await;
13787 continue;
13788 }
13789 dlg.finished(false);
13790 return Err(common::Error::HttpError(err));
13791 }
13792 Ok(res) => {
13793 let (mut parts, body) = res.into_parts();
13794 let mut body = common::Body::new(body);
13795 if !parts.status.is_success() {
13796 let bytes = common::to_bytes(body).await.unwrap_or_default();
13797 let error = serde_json::from_str(&common::to_string(&bytes));
13798 let response = common::to_response(parts, bytes.into());
13799
13800 if let common::Retry::After(d) =
13801 dlg.http_failure(&response, error.as_ref().ok())
13802 {
13803 sleep(d).await;
13804 continue;
13805 }
13806
13807 dlg.finished(false);
13808
13809 return Err(match error {
13810 Ok(value) => common::Error::BadRequest(value),
13811 _ => common::Error::Failure(response),
13812 });
13813 }
13814 let response = {
13815 let bytes = common::to_bytes(body).await.unwrap_or_default();
13816 let encoded = common::to_string(&bytes);
13817 match serde_json::from_str(&encoded) {
13818 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13819 Err(error) => {
13820 dlg.response_json_decode_error(&encoded, &error);
13821 return Err(common::Error::JsonDecodeError(
13822 encoded.to_string(),
13823 error,
13824 ));
13825 }
13826 }
13827 };
13828
13829 dlg.finished(true);
13830 return Ok(response);
13831 }
13832 }
13833 }
13834 }
13835
13836 ///
13837 /// Sets the *request* property to the given value.
13838 ///
13839 /// Even though the property as already been set when instantiating this call,
13840 /// we provide this method for API completeness.
13841 pub fn request(
13842 mut self,
13843 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
13844 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
13845 self._request = new_value;
13846 self
13847 }
13848 /// Required. Name of the recommendation.
13849 ///
13850 /// Sets the *name* path property to the given value.
13851 ///
13852 /// Even though the property as already been set when instantiating this call,
13853 /// we provide this method for API completeness.
13854 pub fn name(
13855 mut self,
13856 new_value: &str,
13857 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
13858 self._name = new_value.to_string();
13859 self
13860 }
13861 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13862 /// while executing the actual API request.
13863 ///
13864 /// ````text
13865 /// It should be used to handle progress information, and to implement a certain level of resilience.
13866 /// ````
13867 ///
13868 /// Sets the *delegate* property to the given value.
13869 pub fn delegate(
13870 mut self,
13871 new_value: &'a mut dyn common::Delegate,
13872 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
13873 self._delegate = Some(new_value);
13874 self
13875 }
13876
13877 /// Set any additional parameter of the query string used in the request.
13878 /// It should be used to set parameters which are not yet available through their own
13879 /// setters.
13880 ///
13881 /// Please note that this method must not be used to set any of the known parameters
13882 /// which have their own setter method. If done anyway, the request will fail.
13883 ///
13884 /// # Additional Parameters
13885 ///
13886 /// * *$.xgafv* (query-string) - V1 error format.
13887 /// * *access_token* (query-string) - OAuth access token.
13888 /// * *alt* (query-string) - Data format for response.
13889 /// * *callback* (query-string) - JSONP
13890 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13891 /// * *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.
13892 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13893 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13894 /// * *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.
13895 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13896 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13897 pub fn param<T>(
13898 mut self,
13899 name: T,
13900 value: T,
13901 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
13902 where
13903 T: AsRef<str>,
13904 {
13905 self._additional_params
13906 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13907 self
13908 }
13909
13910 /// Identifies the authorization scope for the method you are building.
13911 ///
13912 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13913 /// [`Scope::CloudPlatform`].
13914 ///
13915 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13916 /// tokens for more than one scope.
13917 ///
13918 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13919 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13920 /// sufficient, a read-write scope will do as well.
13921 pub fn add_scope<St>(
13922 mut self,
13923 scope: St,
13924 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
13925 where
13926 St: AsRef<str>,
13927 {
13928 self._scopes.insert(String::from(scope.as_ref()));
13929 self
13930 }
13931 /// Identifies the authorization scope(s) for the method you are building.
13932 ///
13933 /// See [`Self::add_scope()`] for details.
13934 pub fn add_scopes<I, St>(
13935 mut self,
13936 scopes: I,
13937 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C>
13938 where
13939 I: IntoIterator<Item = St>,
13940 St: AsRef<str>,
13941 {
13942 self._scopes
13943 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13944 self
13945 }
13946
13947 /// Removes all scopes, and no default scope will be used either.
13948 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13949 /// for details).
13950 pub fn clear_scopes(
13951 mut self,
13952 ) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
13953 self._scopes.clear();
13954 self
13955 }
13956}
13957
13958/// 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.
13959///
13960/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *organization* resource.
13961/// It is not used directly, but through a [`OrganizationMethods`] instance.
13962///
13963/// # Example
13964///
13965/// Instantiate a resource method builder
13966///
13967/// ```test_harness,no_run
13968/// # extern crate hyper;
13969/// # extern crate hyper_rustls;
13970/// # extern crate google_recommender1_beta1 as recommender1_beta1;
13971/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
13972/// # async fn dox() {
13973/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13974///
13975/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13976/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13977/// # .with_native_roots()
13978/// # .unwrap()
13979/// # .https_only()
13980/// # .enable_http2()
13981/// # .build();
13982///
13983/// # let executor = hyper_util::rt::TokioExecutor::new();
13984/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13985/// # secret,
13986/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13987/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13988/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13989/// # ),
13990/// # ).build().await.unwrap();
13991///
13992/// # let client = hyper_util::client::legacy::Client::builder(
13993/// # hyper_util::rt::TokioExecutor::new()
13994/// # )
13995/// # .build(
13996/// # hyper_rustls::HttpsConnectorBuilder::new()
13997/// # .with_native_roots()
13998/// # .unwrap()
13999/// # .https_or_http()
14000/// # .enable_http2()
14001/// # .build()
14002/// # );
14003/// # let mut hub = Recommender::new(client, auth);
14004/// // As the method needs a request, you would usually fill it with the desired information
14005/// // into the respective structure. Some of the parts shown here might not be applicable !
14006/// // Values shown here are possibly random and not representative !
14007/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::default();
14008///
14009/// // You can configure optional parameters by calling the respective setters at will, and
14010/// // execute the final call using `doit()`.
14011/// // Values shown here are possibly random and not representative !
14012/// let result = hub.organizations().locations_recommenders_recommendations_mark_dismissed(req, "name")
14013/// .doit().await;
14014/// # }
14015/// ```
14016pub struct OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
14017where
14018 C: 'a,
14019{
14020 hub: &'a Recommender<C>,
14021 _request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
14022 _name: String,
14023 _delegate: Option<&'a mut dyn common::Delegate>,
14024 _additional_params: HashMap<String, String>,
14025 _scopes: BTreeSet<String>,
14026}
14027
14028impl<'a, C> common::CallBuilder
14029 for OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
14030{
14031}
14032
14033impl<'a, C> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
14034where
14035 C: common::Connector,
14036{
14037 /// Perform the operation you have build so far.
14038 pub async fn doit(
14039 mut self,
14040 ) -> common::Result<(
14041 common::Response,
14042 GoogleCloudRecommenderV1beta1Recommendation,
14043 )> {
14044 use std::borrow::Cow;
14045 use std::io::{Read, Seek};
14046
14047 use common::{url::Params, ToParts};
14048 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14049
14050 let mut dd = common::DefaultDelegate;
14051 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14052 dlg.begin(common::MethodInfo {
14053 id: "recommender.organizations.locations.recommenders.recommendations.markDismissed",
14054 http_method: hyper::Method::POST,
14055 });
14056
14057 for &field in ["alt", "name"].iter() {
14058 if self._additional_params.contains_key(field) {
14059 dlg.finished(false);
14060 return Err(common::Error::FieldClash(field));
14061 }
14062 }
14063
14064 let mut params = Params::with_capacity(4 + self._additional_params.len());
14065 params.push("name", self._name);
14066
14067 params.extend(self._additional_params.iter());
14068
14069 params.push("alt", "json");
14070 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markDismissed";
14071 if self._scopes.is_empty() {
14072 self._scopes
14073 .insert(Scope::CloudPlatform.as_ref().to_string());
14074 }
14075
14076 #[allow(clippy::single_element_loop)]
14077 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14078 url = params.uri_replacement(url, param_name, find_this, true);
14079 }
14080 {
14081 let to_remove = ["name"];
14082 params.remove_params(&to_remove);
14083 }
14084
14085 let url = params.parse_with_url(&url);
14086
14087 let mut json_mime_type = mime::APPLICATION_JSON;
14088 let mut request_value_reader = {
14089 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14090 common::remove_json_null_values(&mut value);
14091 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14092 serde_json::to_writer(&mut dst, &value).unwrap();
14093 dst
14094 };
14095 let request_size = request_value_reader
14096 .seek(std::io::SeekFrom::End(0))
14097 .unwrap();
14098 request_value_reader
14099 .seek(std::io::SeekFrom::Start(0))
14100 .unwrap();
14101
14102 loop {
14103 let token = match self
14104 .hub
14105 .auth
14106 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14107 .await
14108 {
14109 Ok(token) => token,
14110 Err(e) => match dlg.token(e) {
14111 Ok(token) => token,
14112 Err(e) => {
14113 dlg.finished(false);
14114 return Err(common::Error::MissingToken(e));
14115 }
14116 },
14117 };
14118 request_value_reader
14119 .seek(std::io::SeekFrom::Start(0))
14120 .unwrap();
14121 let mut req_result = {
14122 let client = &self.hub.client;
14123 dlg.pre_request();
14124 let mut req_builder = hyper::Request::builder()
14125 .method(hyper::Method::POST)
14126 .uri(url.as_str())
14127 .header(USER_AGENT, self.hub._user_agent.clone());
14128
14129 if let Some(token) = token.as_ref() {
14130 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14131 }
14132
14133 let request = req_builder
14134 .header(CONTENT_TYPE, json_mime_type.to_string())
14135 .header(CONTENT_LENGTH, request_size as u64)
14136 .body(common::to_body(
14137 request_value_reader.get_ref().clone().into(),
14138 ));
14139
14140 client.request(request.unwrap()).await
14141 };
14142
14143 match req_result {
14144 Err(err) => {
14145 if let common::Retry::After(d) = dlg.http_error(&err) {
14146 sleep(d).await;
14147 continue;
14148 }
14149 dlg.finished(false);
14150 return Err(common::Error::HttpError(err));
14151 }
14152 Ok(res) => {
14153 let (mut parts, body) = res.into_parts();
14154 let mut body = common::Body::new(body);
14155 if !parts.status.is_success() {
14156 let bytes = common::to_bytes(body).await.unwrap_or_default();
14157 let error = serde_json::from_str(&common::to_string(&bytes));
14158 let response = common::to_response(parts, bytes.into());
14159
14160 if let common::Retry::After(d) =
14161 dlg.http_failure(&response, error.as_ref().ok())
14162 {
14163 sleep(d).await;
14164 continue;
14165 }
14166
14167 dlg.finished(false);
14168
14169 return Err(match error {
14170 Ok(value) => common::Error::BadRequest(value),
14171 _ => common::Error::Failure(response),
14172 });
14173 }
14174 let response = {
14175 let bytes = common::to_bytes(body).await.unwrap_or_default();
14176 let encoded = common::to_string(&bytes);
14177 match serde_json::from_str(&encoded) {
14178 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14179 Err(error) => {
14180 dlg.response_json_decode_error(&encoded, &error);
14181 return Err(common::Error::JsonDecodeError(
14182 encoded.to_string(),
14183 error,
14184 ));
14185 }
14186 }
14187 };
14188
14189 dlg.finished(true);
14190 return Ok(response);
14191 }
14192 }
14193 }
14194 }
14195
14196 ///
14197 /// Sets the *request* property to the given value.
14198 ///
14199 /// Even though the property as already been set when instantiating this call,
14200 /// we provide this method for API completeness.
14201 pub fn request(
14202 mut self,
14203 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
14204 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
14205 self._request = new_value;
14206 self
14207 }
14208 /// Required. Name of the recommendation.
14209 ///
14210 /// Sets the *name* path property to the given value.
14211 ///
14212 /// Even though the property as already been set when instantiating this call,
14213 /// we provide this method for API completeness.
14214 pub fn name(
14215 mut self,
14216 new_value: &str,
14217 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
14218 self._name = new_value.to_string();
14219 self
14220 }
14221 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14222 /// while executing the actual API request.
14223 ///
14224 /// ````text
14225 /// It should be used to handle progress information, and to implement a certain level of resilience.
14226 /// ````
14227 ///
14228 /// Sets the *delegate* property to the given value.
14229 pub fn delegate(
14230 mut self,
14231 new_value: &'a mut dyn common::Delegate,
14232 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
14233 self._delegate = Some(new_value);
14234 self
14235 }
14236
14237 /// Set any additional parameter of the query string used in the request.
14238 /// It should be used to set parameters which are not yet available through their own
14239 /// setters.
14240 ///
14241 /// Please note that this method must not be used to set any of the known parameters
14242 /// which have their own setter method. If done anyway, the request will fail.
14243 ///
14244 /// # Additional Parameters
14245 ///
14246 /// * *$.xgafv* (query-string) - V1 error format.
14247 /// * *access_token* (query-string) - OAuth access token.
14248 /// * *alt* (query-string) - Data format for response.
14249 /// * *callback* (query-string) - JSONP
14250 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14251 /// * *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.
14252 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14253 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14254 /// * *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.
14255 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14256 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14257 pub fn param<T>(
14258 mut self,
14259 name: T,
14260 value: T,
14261 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
14262 where
14263 T: AsRef<str>,
14264 {
14265 self._additional_params
14266 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14267 self
14268 }
14269
14270 /// Identifies the authorization scope for the method you are building.
14271 ///
14272 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14273 /// [`Scope::CloudPlatform`].
14274 ///
14275 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14276 /// tokens for more than one scope.
14277 ///
14278 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14279 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14280 /// sufficient, a read-write scope will do as well.
14281 pub fn add_scope<St>(
14282 mut self,
14283 scope: St,
14284 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
14285 where
14286 St: AsRef<str>,
14287 {
14288 self._scopes.insert(String::from(scope.as_ref()));
14289 self
14290 }
14291 /// Identifies the authorization scope(s) for the method you are building.
14292 ///
14293 /// See [`Self::add_scope()`] for details.
14294 pub fn add_scopes<I, St>(
14295 mut self,
14296 scopes: I,
14297 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C>
14298 where
14299 I: IntoIterator<Item = St>,
14300 St: AsRef<str>,
14301 {
14302 self._scopes
14303 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14304 self
14305 }
14306
14307 /// Removes all scopes, and no default scope will be used either.
14308 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14309 /// for details).
14310 pub fn clear_scopes(
14311 mut self,
14312 ) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
14313 self._scopes.clear();
14314 self
14315 }
14316}
14317
14318/// 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.
14319///
14320/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *organization* resource.
14321/// It is not used directly, but through a [`OrganizationMethods`] instance.
14322///
14323/// # Example
14324///
14325/// Instantiate a resource method builder
14326///
14327/// ```test_harness,no_run
14328/// # extern crate hyper;
14329/// # extern crate hyper_rustls;
14330/// # extern crate google_recommender1_beta1 as recommender1_beta1;
14331/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
14332/// # async fn dox() {
14333/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14334///
14335/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14336/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14337/// # .with_native_roots()
14338/// # .unwrap()
14339/// # .https_only()
14340/// # .enable_http2()
14341/// # .build();
14342///
14343/// # let executor = hyper_util::rt::TokioExecutor::new();
14344/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14345/// # secret,
14346/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14347/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14348/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14349/// # ),
14350/// # ).build().await.unwrap();
14351///
14352/// # let client = hyper_util::client::legacy::Client::builder(
14353/// # hyper_util::rt::TokioExecutor::new()
14354/// # )
14355/// # .build(
14356/// # hyper_rustls::HttpsConnectorBuilder::new()
14357/// # .with_native_roots()
14358/// # .unwrap()
14359/// # .https_or_http()
14360/// # .enable_http2()
14361/// # .build()
14362/// # );
14363/// # let mut hub = Recommender::new(client, auth);
14364/// // As the method needs a request, you would usually fill it with the desired information
14365/// // into the respective structure. Some of the parts shown here might not be applicable !
14366/// // Values shown here are possibly random and not representative !
14367/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::default();
14368///
14369/// // You can configure optional parameters by calling the respective setters at will, and
14370/// // execute the final call using `doit()`.
14371/// // Values shown here are possibly random and not representative !
14372/// let result = hub.organizations().locations_recommenders_recommendations_mark_failed(req, "name")
14373/// .doit().await;
14374/// # }
14375/// ```
14376pub struct OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
14377where
14378 C: 'a,
14379{
14380 hub: &'a Recommender<C>,
14381 _request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
14382 _name: String,
14383 _delegate: Option<&'a mut dyn common::Delegate>,
14384 _additional_params: HashMap<String, String>,
14385 _scopes: BTreeSet<String>,
14386}
14387
14388impl<'a, C> common::CallBuilder
14389 for OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
14390{
14391}
14392
14393impl<'a, C> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
14394where
14395 C: common::Connector,
14396{
14397 /// Perform the operation you have build so far.
14398 pub async fn doit(
14399 mut self,
14400 ) -> common::Result<(
14401 common::Response,
14402 GoogleCloudRecommenderV1beta1Recommendation,
14403 )> {
14404 use std::borrow::Cow;
14405 use std::io::{Read, Seek};
14406
14407 use common::{url::Params, ToParts};
14408 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14409
14410 let mut dd = common::DefaultDelegate;
14411 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14412 dlg.begin(common::MethodInfo {
14413 id: "recommender.organizations.locations.recommenders.recommendations.markFailed",
14414 http_method: hyper::Method::POST,
14415 });
14416
14417 for &field in ["alt", "name"].iter() {
14418 if self._additional_params.contains_key(field) {
14419 dlg.finished(false);
14420 return Err(common::Error::FieldClash(field));
14421 }
14422 }
14423
14424 let mut params = Params::with_capacity(4 + self._additional_params.len());
14425 params.push("name", self._name);
14426
14427 params.extend(self._additional_params.iter());
14428
14429 params.push("alt", "json");
14430 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markFailed";
14431 if self._scopes.is_empty() {
14432 self._scopes
14433 .insert(Scope::CloudPlatform.as_ref().to_string());
14434 }
14435
14436 #[allow(clippy::single_element_loop)]
14437 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14438 url = params.uri_replacement(url, param_name, find_this, true);
14439 }
14440 {
14441 let to_remove = ["name"];
14442 params.remove_params(&to_remove);
14443 }
14444
14445 let url = params.parse_with_url(&url);
14446
14447 let mut json_mime_type = mime::APPLICATION_JSON;
14448 let mut request_value_reader = {
14449 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14450 common::remove_json_null_values(&mut value);
14451 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14452 serde_json::to_writer(&mut dst, &value).unwrap();
14453 dst
14454 };
14455 let request_size = request_value_reader
14456 .seek(std::io::SeekFrom::End(0))
14457 .unwrap();
14458 request_value_reader
14459 .seek(std::io::SeekFrom::Start(0))
14460 .unwrap();
14461
14462 loop {
14463 let token = match self
14464 .hub
14465 .auth
14466 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14467 .await
14468 {
14469 Ok(token) => token,
14470 Err(e) => match dlg.token(e) {
14471 Ok(token) => token,
14472 Err(e) => {
14473 dlg.finished(false);
14474 return Err(common::Error::MissingToken(e));
14475 }
14476 },
14477 };
14478 request_value_reader
14479 .seek(std::io::SeekFrom::Start(0))
14480 .unwrap();
14481 let mut req_result = {
14482 let client = &self.hub.client;
14483 dlg.pre_request();
14484 let mut req_builder = hyper::Request::builder()
14485 .method(hyper::Method::POST)
14486 .uri(url.as_str())
14487 .header(USER_AGENT, self.hub._user_agent.clone());
14488
14489 if let Some(token) = token.as_ref() {
14490 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14491 }
14492
14493 let request = req_builder
14494 .header(CONTENT_TYPE, json_mime_type.to_string())
14495 .header(CONTENT_LENGTH, request_size as u64)
14496 .body(common::to_body(
14497 request_value_reader.get_ref().clone().into(),
14498 ));
14499
14500 client.request(request.unwrap()).await
14501 };
14502
14503 match req_result {
14504 Err(err) => {
14505 if let common::Retry::After(d) = dlg.http_error(&err) {
14506 sleep(d).await;
14507 continue;
14508 }
14509 dlg.finished(false);
14510 return Err(common::Error::HttpError(err));
14511 }
14512 Ok(res) => {
14513 let (mut parts, body) = res.into_parts();
14514 let mut body = common::Body::new(body);
14515 if !parts.status.is_success() {
14516 let bytes = common::to_bytes(body).await.unwrap_or_default();
14517 let error = serde_json::from_str(&common::to_string(&bytes));
14518 let response = common::to_response(parts, bytes.into());
14519
14520 if let common::Retry::After(d) =
14521 dlg.http_failure(&response, error.as_ref().ok())
14522 {
14523 sleep(d).await;
14524 continue;
14525 }
14526
14527 dlg.finished(false);
14528
14529 return Err(match error {
14530 Ok(value) => common::Error::BadRequest(value),
14531 _ => common::Error::Failure(response),
14532 });
14533 }
14534 let response = {
14535 let bytes = common::to_bytes(body).await.unwrap_or_default();
14536 let encoded = common::to_string(&bytes);
14537 match serde_json::from_str(&encoded) {
14538 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14539 Err(error) => {
14540 dlg.response_json_decode_error(&encoded, &error);
14541 return Err(common::Error::JsonDecodeError(
14542 encoded.to_string(),
14543 error,
14544 ));
14545 }
14546 }
14547 };
14548
14549 dlg.finished(true);
14550 return Ok(response);
14551 }
14552 }
14553 }
14554 }
14555
14556 ///
14557 /// Sets the *request* property to the given value.
14558 ///
14559 /// Even though the property as already been set when instantiating this call,
14560 /// we provide this method for API completeness.
14561 pub fn request(
14562 mut self,
14563 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
14564 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
14565 self._request = new_value;
14566 self
14567 }
14568 /// Required. Name of the recommendation.
14569 ///
14570 /// Sets the *name* path property to the given value.
14571 ///
14572 /// Even though the property as already been set when instantiating this call,
14573 /// we provide this method for API completeness.
14574 pub fn name(
14575 mut self,
14576 new_value: &str,
14577 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
14578 self._name = new_value.to_string();
14579 self
14580 }
14581 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14582 /// while executing the actual API request.
14583 ///
14584 /// ````text
14585 /// It should be used to handle progress information, and to implement a certain level of resilience.
14586 /// ````
14587 ///
14588 /// Sets the *delegate* property to the given value.
14589 pub fn delegate(
14590 mut self,
14591 new_value: &'a mut dyn common::Delegate,
14592 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
14593 self._delegate = Some(new_value);
14594 self
14595 }
14596
14597 /// Set any additional parameter of the query string used in the request.
14598 /// It should be used to set parameters which are not yet available through their own
14599 /// setters.
14600 ///
14601 /// Please note that this method must not be used to set any of the known parameters
14602 /// which have their own setter method. If done anyway, the request will fail.
14603 ///
14604 /// # Additional Parameters
14605 ///
14606 /// * *$.xgafv* (query-string) - V1 error format.
14607 /// * *access_token* (query-string) - OAuth access token.
14608 /// * *alt* (query-string) - Data format for response.
14609 /// * *callback* (query-string) - JSONP
14610 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14611 /// * *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.
14612 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14613 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14614 /// * *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.
14615 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14616 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14617 pub fn param<T>(
14618 mut self,
14619 name: T,
14620 value: T,
14621 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
14622 where
14623 T: AsRef<str>,
14624 {
14625 self._additional_params
14626 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14627 self
14628 }
14629
14630 /// Identifies the authorization scope for the method you are building.
14631 ///
14632 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14633 /// [`Scope::CloudPlatform`].
14634 ///
14635 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14636 /// tokens for more than one scope.
14637 ///
14638 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14639 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14640 /// sufficient, a read-write scope will do as well.
14641 pub fn add_scope<St>(
14642 mut self,
14643 scope: St,
14644 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
14645 where
14646 St: AsRef<str>,
14647 {
14648 self._scopes.insert(String::from(scope.as_ref()));
14649 self
14650 }
14651 /// Identifies the authorization scope(s) for the method you are building.
14652 ///
14653 /// See [`Self::add_scope()`] for details.
14654 pub fn add_scopes<I, St>(
14655 mut self,
14656 scopes: I,
14657 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C>
14658 where
14659 I: IntoIterator<Item = St>,
14660 St: AsRef<str>,
14661 {
14662 self._scopes
14663 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14664 self
14665 }
14666
14667 /// Removes all scopes, and no default scope will be used either.
14668 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14669 /// for details).
14670 pub fn clear_scopes(
14671 mut self,
14672 ) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, C> {
14673 self._scopes.clear();
14674 self
14675 }
14676}
14677
14678/// 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.
14679///
14680/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *organization* resource.
14681/// It is not used directly, but through a [`OrganizationMethods`] instance.
14682///
14683/// # Example
14684///
14685/// Instantiate a resource method builder
14686///
14687/// ```test_harness,no_run
14688/// # extern crate hyper;
14689/// # extern crate hyper_rustls;
14690/// # extern crate google_recommender1_beta1 as recommender1_beta1;
14691/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
14692/// # async fn dox() {
14693/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14694///
14695/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14696/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14697/// # .with_native_roots()
14698/// # .unwrap()
14699/// # .https_only()
14700/// # .enable_http2()
14701/// # .build();
14702///
14703/// # let executor = hyper_util::rt::TokioExecutor::new();
14704/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14705/// # secret,
14706/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14707/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14708/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14709/// # ),
14710/// # ).build().await.unwrap();
14711///
14712/// # let client = hyper_util::client::legacy::Client::builder(
14713/// # hyper_util::rt::TokioExecutor::new()
14714/// # )
14715/// # .build(
14716/// # hyper_rustls::HttpsConnectorBuilder::new()
14717/// # .with_native_roots()
14718/// # .unwrap()
14719/// # .https_or_http()
14720/// # .enable_http2()
14721/// # .build()
14722/// # );
14723/// # let mut hub = Recommender::new(client, auth);
14724/// // As the method needs a request, you would usually fill it with the desired information
14725/// // into the respective structure. Some of the parts shown here might not be applicable !
14726/// // Values shown here are possibly random and not representative !
14727/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::default();
14728///
14729/// // You can configure optional parameters by calling the respective setters at will, and
14730/// // execute the final call using `doit()`.
14731/// // Values shown here are possibly random and not representative !
14732/// let result = hub.organizations().locations_recommenders_recommendations_mark_succeeded(req, "name")
14733/// .doit().await;
14734/// # }
14735/// ```
14736pub struct OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
14737where
14738 C: 'a,
14739{
14740 hub: &'a Recommender<C>,
14741 _request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
14742 _name: String,
14743 _delegate: Option<&'a mut dyn common::Delegate>,
14744 _additional_params: HashMap<String, String>,
14745 _scopes: BTreeSet<String>,
14746}
14747
14748impl<'a, C> common::CallBuilder
14749 for OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
14750{
14751}
14752
14753impl<'a, C> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
14754where
14755 C: common::Connector,
14756{
14757 /// Perform the operation you have build so far.
14758 pub async fn doit(
14759 mut self,
14760 ) -> common::Result<(
14761 common::Response,
14762 GoogleCloudRecommenderV1beta1Recommendation,
14763 )> {
14764 use std::borrow::Cow;
14765 use std::io::{Read, Seek};
14766
14767 use common::{url::Params, ToParts};
14768 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14769
14770 let mut dd = common::DefaultDelegate;
14771 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14772 dlg.begin(common::MethodInfo {
14773 id: "recommender.organizations.locations.recommenders.recommendations.markSucceeded",
14774 http_method: hyper::Method::POST,
14775 });
14776
14777 for &field in ["alt", "name"].iter() {
14778 if self._additional_params.contains_key(field) {
14779 dlg.finished(false);
14780 return Err(common::Error::FieldClash(field));
14781 }
14782 }
14783
14784 let mut params = Params::with_capacity(4 + self._additional_params.len());
14785 params.push("name", self._name);
14786
14787 params.extend(self._additional_params.iter());
14788
14789 params.push("alt", "json");
14790 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markSucceeded";
14791 if self._scopes.is_empty() {
14792 self._scopes
14793 .insert(Scope::CloudPlatform.as_ref().to_string());
14794 }
14795
14796 #[allow(clippy::single_element_loop)]
14797 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14798 url = params.uri_replacement(url, param_name, find_this, true);
14799 }
14800 {
14801 let to_remove = ["name"];
14802 params.remove_params(&to_remove);
14803 }
14804
14805 let url = params.parse_with_url(&url);
14806
14807 let mut json_mime_type = mime::APPLICATION_JSON;
14808 let mut request_value_reader = {
14809 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14810 common::remove_json_null_values(&mut value);
14811 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14812 serde_json::to_writer(&mut dst, &value).unwrap();
14813 dst
14814 };
14815 let request_size = request_value_reader
14816 .seek(std::io::SeekFrom::End(0))
14817 .unwrap();
14818 request_value_reader
14819 .seek(std::io::SeekFrom::Start(0))
14820 .unwrap();
14821
14822 loop {
14823 let token = match self
14824 .hub
14825 .auth
14826 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14827 .await
14828 {
14829 Ok(token) => token,
14830 Err(e) => match dlg.token(e) {
14831 Ok(token) => token,
14832 Err(e) => {
14833 dlg.finished(false);
14834 return Err(common::Error::MissingToken(e));
14835 }
14836 },
14837 };
14838 request_value_reader
14839 .seek(std::io::SeekFrom::Start(0))
14840 .unwrap();
14841 let mut req_result = {
14842 let client = &self.hub.client;
14843 dlg.pre_request();
14844 let mut req_builder = hyper::Request::builder()
14845 .method(hyper::Method::POST)
14846 .uri(url.as_str())
14847 .header(USER_AGENT, self.hub._user_agent.clone());
14848
14849 if let Some(token) = token.as_ref() {
14850 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14851 }
14852
14853 let request = req_builder
14854 .header(CONTENT_TYPE, json_mime_type.to_string())
14855 .header(CONTENT_LENGTH, request_size as u64)
14856 .body(common::to_body(
14857 request_value_reader.get_ref().clone().into(),
14858 ));
14859
14860 client.request(request.unwrap()).await
14861 };
14862
14863 match req_result {
14864 Err(err) => {
14865 if let common::Retry::After(d) = dlg.http_error(&err) {
14866 sleep(d).await;
14867 continue;
14868 }
14869 dlg.finished(false);
14870 return Err(common::Error::HttpError(err));
14871 }
14872 Ok(res) => {
14873 let (mut parts, body) = res.into_parts();
14874 let mut body = common::Body::new(body);
14875 if !parts.status.is_success() {
14876 let bytes = common::to_bytes(body).await.unwrap_or_default();
14877 let error = serde_json::from_str(&common::to_string(&bytes));
14878 let response = common::to_response(parts, bytes.into());
14879
14880 if let common::Retry::After(d) =
14881 dlg.http_failure(&response, error.as_ref().ok())
14882 {
14883 sleep(d).await;
14884 continue;
14885 }
14886
14887 dlg.finished(false);
14888
14889 return Err(match error {
14890 Ok(value) => common::Error::BadRequest(value),
14891 _ => common::Error::Failure(response),
14892 });
14893 }
14894 let response = {
14895 let bytes = common::to_bytes(body).await.unwrap_or_default();
14896 let encoded = common::to_string(&bytes);
14897 match serde_json::from_str(&encoded) {
14898 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14899 Err(error) => {
14900 dlg.response_json_decode_error(&encoded, &error);
14901 return Err(common::Error::JsonDecodeError(
14902 encoded.to_string(),
14903 error,
14904 ));
14905 }
14906 }
14907 };
14908
14909 dlg.finished(true);
14910 return Ok(response);
14911 }
14912 }
14913 }
14914 }
14915
14916 ///
14917 /// Sets the *request* property to the given value.
14918 ///
14919 /// Even though the property as already been set when instantiating this call,
14920 /// we provide this method for API completeness.
14921 pub fn request(
14922 mut self,
14923 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
14924 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
14925 self._request = new_value;
14926 self
14927 }
14928 /// Required. Name of the recommendation.
14929 ///
14930 /// Sets the *name* path property to the given value.
14931 ///
14932 /// Even though the property as already been set when instantiating this call,
14933 /// we provide this method for API completeness.
14934 pub fn name(
14935 mut self,
14936 new_value: &str,
14937 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
14938 self._name = new_value.to_string();
14939 self
14940 }
14941 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14942 /// while executing the actual API request.
14943 ///
14944 /// ````text
14945 /// It should be used to handle progress information, and to implement a certain level of resilience.
14946 /// ````
14947 ///
14948 /// Sets the *delegate* property to the given value.
14949 pub fn delegate(
14950 mut self,
14951 new_value: &'a mut dyn common::Delegate,
14952 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
14953 self._delegate = Some(new_value);
14954 self
14955 }
14956
14957 /// Set any additional parameter of the query string used in the request.
14958 /// It should be used to set parameters which are not yet available through their own
14959 /// setters.
14960 ///
14961 /// Please note that this method must not be used to set any of the known parameters
14962 /// which have their own setter method. If done anyway, the request will fail.
14963 ///
14964 /// # Additional Parameters
14965 ///
14966 /// * *$.xgafv* (query-string) - V1 error format.
14967 /// * *access_token* (query-string) - OAuth access token.
14968 /// * *alt* (query-string) - Data format for response.
14969 /// * *callback* (query-string) - JSONP
14970 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14971 /// * *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.
14972 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14973 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14974 /// * *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.
14975 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14976 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14977 pub fn param<T>(
14978 mut self,
14979 name: T,
14980 value: T,
14981 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
14982 where
14983 T: AsRef<str>,
14984 {
14985 self._additional_params
14986 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14987 self
14988 }
14989
14990 /// Identifies the authorization scope for the method you are building.
14991 ///
14992 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14993 /// [`Scope::CloudPlatform`].
14994 ///
14995 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14996 /// tokens for more than one scope.
14997 ///
14998 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14999 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15000 /// sufficient, a read-write scope will do as well.
15001 pub fn add_scope<St>(
15002 mut self,
15003 scope: St,
15004 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
15005 where
15006 St: AsRef<str>,
15007 {
15008 self._scopes.insert(String::from(scope.as_ref()));
15009 self
15010 }
15011 /// Identifies the authorization scope(s) for the method you are building.
15012 ///
15013 /// See [`Self::add_scope()`] for details.
15014 pub fn add_scopes<I, St>(
15015 mut self,
15016 scopes: I,
15017 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C>
15018 where
15019 I: IntoIterator<Item = St>,
15020 St: AsRef<str>,
15021 {
15022 self._scopes
15023 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15024 self
15025 }
15026
15027 /// Removes all scopes, and no default scope will be used either.
15028 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15029 /// for details).
15030 pub fn clear_scopes(
15031 mut self,
15032 ) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
15033 self._scopes.clear();
15034 self
15035 }
15036}
15037
15038/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
15039///
15040/// A builder for the *locations.recommenders.getConfig* method supported by a *organization* resource.
15041/// It is not used directly, but through a [`OrganizationMethods`] instance.
15042///
15043/// # Example
15044///
15045/// Instantiate a resource method builder
15046///
15047/// ```test_harness,no_run
15048/// # extern crate hyper;
15049/// # extern crate hyper_rustls;
15050/// # extern crate google_recommender1_beta1 as recommender1_beta1;
15051/// # async fn dox() {
15052/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15053///
15054/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15055/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15056/// # .with_native_roots()
15057/// # .unwrap()
15058/// # .https_only()
15059/// # .enable_http2()
15060/// # .build();
15061///
15062/// # let executor = hyper_util::rt::TokioExecutor::new();
15063/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15064/// # secret,
15065/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15066/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15067/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15068/// # ),
15069/// # ).build().await.unwrap();
15070///
15071/// # let client = hyper_util::client::legacy::Client::builder(
15072/// # hyper_util::rt::TokioExecutor::new()
15073/// # )
15074/// # .build(
15075/// # hyper_rustls::HttpsConnectorBuilder::new()
15076/// # .with_native_roots()
15077/// # .unwrap()
15078/// # .https_or_http()
15079/// # .enable_http2()
15080/// # .build()
15081/// # );
15082/// # let mut hub = Recommender::new(client, auth);
15083/// // You can configure optional parameters by calling the respective setters at will, and
15084/// // execute the final call using `doit()`.
15085/// // Values shown here are possibly random and not representative !
15086/// let result = hub.organizations().locations_recommenders_get_config("name")
15087/// .doit().await;
15088/// # }
15089/// ```
15090pub struct OrganizationLocationRecommenderGetConfigCall<'a, C>
15091where
15092 C: 'a,
15093{
15094 hub: &'a Recommender<C>,
15095 _name: String,
15096 _delegate: Option<&'a mut dyn common::Delegate>,
15097 _additional_params: HashMap<String, String>,
15098 _scopes: BTreeSet<String>,
15099}
15100
15101impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderGetConfigCall<'a, C> {}
15102
15103impl<'a, C> OrganizationLocationRecommenderGetConfigCall<'a, C>
15104where
15105 C: common::Connector,
15106{
15107 /// Perform the operation you have build so far.
15108 pub async fn doit(
15109 mut self,
15110 ) -> common::Result<(
15111 common::Response,
15112 GoogleCloudRecommenderV1beta1RecommenderConfig,
15113 )> {
15114 use std::borrow::Cow;
15115 use std::io::{Read, Seek};
15116
15117 use common::{url::Params, ToParts};
15118 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15119
15120 let mut dd = common::DefaultDelegate;
15121 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15122 dlg.begin(common::MethodInfo {
15123 id: "recommender.organizations.locations.recommenders.getConfig",
15124 http_method: hyper::Method::GET,
15125 });
15126
15127 for &field in ["alt", "name"].iter() {
15128 if self._additional_params.contains_key(field) {
15129 dlg.finished(false);
15130 return Err(common::Error::FieldClash(field));
15131 }
15132 }
15133
15134 let mut params = Params::with_capacity(3 + self._additional_params.len());
15135 params.push("name", self._name);
15136
15137 params.extend(self._additional_params.iter());
15138
15139 params.push("alt", "json");
15140 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
15141 if self._scopes.is_empty() {
15142 self._scopes
15143 .insert(Scope::CloudPlatform.as_ref().to_string());
15144 }
15145
15146 #[allow(clippy::single_element_loop)]
15147 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15148 url = params.uri_replacement(url, param_name, find_this, true);
15149 }
15150 {
15151 let to_remove = ["name"];
15152 params.remove_params(&to_remove);
15153 }
15154
15155 let url = params.parse_with_url(&url);
15156
15157 loop {
15158 let token = match self
15159 .hub
15160 .auth
15161 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15162 .await
15163 {
15164 Ok(token) => token,
15165 Err(e) => match dlg.token(e) {
15166 Ok(token) => token,
15167 Err(e) => {
15168 dlg.finished(false);
15169 return Err(common::Error::MissingToken(e));
15170 }
15171 },
15172 };
15173 let mut req_result = {
15174 let client = &self.hub.client;
15175 dlg.pre_request();
15176 let mut req_builder = hyper::Request::builder()
15177 .method(hyper::Method::GET)
15178 .uri(url.as_str())
15179 .header(USER_AGENT, self.hub._user_agent.clone());
15180
15181 if let Some(token) = token.as_ref() {
15182 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15183 }
15184
15185 let request = req_builder
15186 .header(CONTENT_LENGTH, 0_u64)
15187 .body(common::to_body::<String>(None));
15188
15189 client.request(request.unwrap()).await
15190 };
15191
15192 match req_result {
15193 Err(err) => {
15194 if let common::Retry::After(d) = dlg.http_error(&err) {
15195 sleep(d).await;
15196 continue;
15197 }
15198 dlg.finished(false);
15199 return Err(common::Error::HttpError(err));
15200 }
15201 Ok(res) => {
15202 let (mut parts, body) = res.into_parts();
15203 let mut body = common::Body::new(body);
15204 if !parts.status.is_success() {
15205 let bytes = common::to_bytes(body).await.unwrap_or_default();
15206 let error = serde_json::from_str(&common::to_string(&bytes));
15207 let response = common::to_response(parts, bytes.into());
15208
15209 if let common::Retry::After(d) =
15210 dlg.http_failure(&response, error.as_ref().ok())
15211 {
15212 sleep(d).await;
15213 continue;
15214 }
15215
15216 dlg.finished(false);
15217
15218 return Err(match error {
15219 Ok(value) => common::Error::BadRequest(value),
15220 _ => common::Error::Failure(response),
15221 });
15222 }
15223 let response = {
15224 let bytes = common::to_bytes(body).await.unwrap_or_default();
15225 let encoded = common::to_string(&bytes);
15226 match serde_json::from_str(&encoded) {
15227 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15228 Err(error) => {
15229 dlg.response_json_decode_error(&encoded, &error);
15230 return Err(common::Error::JsonDecodeError(
15231 encoded.to_string(),
15232 error,
15233 ));
15234 }
15235 }
15236 };
15237
15238 dlg.finished(true);
15239 return Ok(response);
15240 }
15241 }
15242 }
15243 }
15244
15245 /// 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`
15246 ///
15247 /// Sets the *name* path property to the given value.
15248 ///
15249 /// Even though the property as already been set when instantiating this call,
15250 /// we provide this method for API completeness.
15251 pub fn name(mut self, new_value: &str) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
15252 self._name = new_value.to_string();
15253 self
15254 }
15255 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15256 /// while executing the actual API request.
15257 ///
15258 /// ````text
15259 /// It should be used to handle progress information, and to implement a certain level of resilience.
15260 /// ````
15261 ///
15262 /// Sets the *delegate* property to the given value.
15263 pub fn delegate(
15264 mut self,
15265 new_value: &'a mut dyn common::Delegate,
15266 ) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
15267 self._delegate = Some(new_value);
15268 self
15269 }
15270
15271 /// Set any additional parameter of the query string used in the request.
15272 /// It should be used to set parameters which are not yet available through their own
15273 /// setters.
15274 ///
15275 /// Please note that this method must not be used to set any of the known parameters
15276 /// which have their own setter method. If done anyway, the request will fail.
15277 ///
15278 /// # Additional Parameters
15279 ///
15280 /// * *$.xgafv* (query-string) - V1 error format.
15281 /// * *access_token* (query-string) - OAuth access token.
15282 /// * *alt* (query-string) - Data format for response.
15283 /// * *callback* (query-string) - JSONP
15284 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15285 /// * *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.
15286 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15287 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15288 /// * *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.
15289 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15290 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15291 pub fn param<T>(
15292 mut self,
15293 name: T,
15294 value: T,
15295 ) -> OrganizationLocationRecommenderGetConfigCall<'a, C>
15296 where
15297 T: AsRef<str>,
15298 {
15299 self._additional_params
15300 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15301 self
15302 }
15303
15304 /// Identifies the authorization scope for the method you are building.
15305 ///
15306 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15307 /// [`Scope::CloudPlatform`].
15308 ///
15309 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15310 /// tokens for more than one scope.
15311 ///
15312 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15313 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15314 /// sufficient, a read-write scope will do as well.
15315 pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationRecommenderGetConfigCall<'a, C>
15316 where
15317 St: AsRef<str>,
15318 {
15319 self._scopes.insert(String::from(scope.as_ref()));
15320 self
15321 }
15322 /// Identifies the authorization scope(s) for the method you are building.
15323 ///
15324 /// See [`Self::add_scope()`] for details.
15325 pub fn add_scopes<I, St>(
15326 mut self,
15327 scopes: I,
15328 ) -> OrganizationLocationRecommenderGetConfigCall<'a, C>
15329 where
15330 I: IntoIterator<Item = St>,
15331 St: AsRef<str>,
15332 {
15333 self._scopes
15334 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15335 self
15336 }
15337
15338 /// Removes all scopes, and no default scope will be used either.
15339 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15340 /// for details).
15341 pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderGetConfigCall<'a, C> {
15342 self._scopes.clear();
15343 self
15344 }
15345}
15346
15347/// Updates a Recommender Config. This will create a new revision of the config.
15348///
15349/// A builder for the *locations.recommenders.updateConfig* method supported by a *organization* resource.
15350/// It is not used directly, but through a [`OrganizationMethods`] instance.
15351///
15352/// # Example
15353///
15354/// Instantiate a resource method builder
15355///
15356/// ```test_harness,no_run
15357/// # extern crate hyper;
15358/// # extern crate hyper_rustls;
15359/// # extern crate google_recommender1_beta1 as recommender1_beta1;
15360/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1RecommenderConfig;
15361/// # async fn dox() {
15362/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15363///
15364/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15365/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15366/// # .with_native_roots()
15367/// # .unwrap()
15368/// # .https_only()
15369/// # .enable_http2()
15370/// # .build();
15371///
15372/// # let executor = hyper_util::rt::TokioExecutor::new();
15373/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15374/// # secret,
15375/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15376/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15377/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15378/// # ),
15379/// # ).build().await.unwrap();
15380///
15381/// # let client = hyper_util::client::legacy::Client::builder(
15382/// # hyper_util::rt::TokioExecutor::new()
15383/// # )
15384/// # .build(
15385/// # hyper_rustls::HttpsConnectorBuilder::new()
15386/// # .with_native_roots()
15387/// # .unwrap()
15388/// # .https_or_http()
15389/// # .enable_http2()
15390/// # .build()
15391/// # );
15392/// # let mut hub = Recommender::new(client, auth);
15393/// // As the method needs a request, you would usually fill it with the desired information
15394/// // into the respective structure. Some of the parts shown here might not be applicable !
15395/// // Values shown here are possibly random and not representative !
15396/// let mut req = GoogleCloudRecommenderV1beta1RecommenderConfig::default();
15397///
15398/// // You can configure optional parameters by calling the respective setters at will, and
15399/// // execute the final call using `doit()`.
15400/// // Values shown here are possibly random and not representative !
15401/// let result = hub.organizations().locations_recommenders_update_config(req, "name")
15402/// .validate_only(true)
15403/// .update_mask(FieldMask::new::<&str>(&[]))
15404/// .doit().await;
15405/// # }
15406/// ```
15407pub struct OrganizationLocationRecommenderUpdateConfigCall<'a, C>
15408where
15409 C: 'a,
15410{
15411 hub: &'a Recommender<C>,
15412 _request: GoogleCloudRecommenderV1beta1RecommenderConfig,
15413 _name: String,
15414 _validate_only: Option<bool>,
15415 _update_mask: Option<common::FieldMask>,
15416 _delegate: Option<&'a mut dyn common::Delegate>,
15417 _additional_params: HashMap<String, String>,
15418 _scopes: BTreeSet<String>,
15419}
15420
15421impl<'a, C> common::CallBuilder for OrganizationLocationRecommenderUpdateConfigCall<'a, C> {}
15422
15423impl<'a, C> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
15424where
15425 C: common::Connector,
15426{
15427 /// Perform the operation you have build so far.
15428 pub async fn doit(
15429 mut self,
15430 ) -> common::Result<(
15431 common::Response,
15432 GoogleCloudRecommenderV1beta1RecommenderConfig,
15433 )> {
15434 use std::borrow::Cow;
15435 use std::io::{Read, Seek};
15436
15437 use common::{url::Params, ToParts};
15438 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15439
15440 let mut dd = common::DefaultDelegate;
15441 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15442 dlg.begin(common::MethodInfo {
15443 id: "recommender.organizations.locations.recommenders.updateConfig",
15444 http_method: hyper::Method::PATCH,
15445 });
15446
15447 for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
15448 if self._additional_params.contains_key(field) {
15449 dlg.finished(false);
15450 return Err(common::Error::FieldClash(field));
15451 }
15452 }
15453
15454 let mut params = Params::with_capacity(6 + self._additional_params.len());
15455 params.push("name", self._name);
15456 if let Some(value) = self._validate_only.as_ref() {
15457 params.push("validateOnly", value.to_string());
15458 }
15459 if let Some(value) = self._update_mask.as_ref() {
15460 params.push("updateMask", value.to_string());
15461 }
15462
15463 params.extend(self._additional_params.iter());
15464
15465 params.push("alt", "json");
15466 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
15467 if self._scopes.is_empty() {
15468 self._scopes
15469 .insert(Scope::CloudPlatform.as_ref().to_string());
15470 }
15471
15472 #[allow(clippy::single_element_loop)]
15473 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15474 url = params.uri_replacement(url, param_name, find_this, true);
15475 }
15476 {
15477 let to_remove = ["name"];
15478 params.remove_params(&to_remove);
15479 }
15480
15481 let url = params.parse_with_url(&url);
15482
15483 let mut json_mime_type = mime::APPLICATION_JSON;
15484 let mut request_value_reader = {
15485 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15486 common::remove_json_null_values(&mut value);
15487 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15488 serde_json::to_writer(&mut dst, &value).unwrap();
15489 dst
15490 };
15491 let request_size = request_value_reader
15492 .seek(std::io::SeekFrom::End(0))
15493 .unwrap();
15494 request_value_reader
15495 .seek(std::io::SeekFrom::Start(0))
15496 .unwrap();
15497
15498 loop {
15499 let token = match self
15500 .hub
15501 .auth
15502 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15503 .await
15504 {
15505 Ok(token) => token,
15506 Err(e) => match dlg.token(e) {
15507 Ok(token) => token,
15508 Err(e) => {
15509 dlg.finished(false);
15510 return Err(common::Error::MissingToken(e));
15511 }
15512 },
15513 };
15514 request_value_reader
15515 .seek(std::io::SeekFrom::Start(0))
15516 .unwrap();
15517 let mut req_result = {
15518 let client = &self.hub.client;
15519 dlg.pre_request();
15520 let mut req_builder = hyper::Request::builder()
15521 .method(hyper::Method::PATCH)
15522 .uri(url.as_str())
15523 .header(USER_AGENT, self.hub._user_agent.clone());
15524
15525 if let Some(token) = token.as_ref() {
15526 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15527 }
15528
15529 let request = req_builder
15530 .header(CONTENT_TYPE, json_mime_type.to_string())
15531 .header(CONTENT_LENGTH, request_size as u64)
15532 .body(common::to_body(
15533 request_value_reader.get_ref().clone().into(),
15534 ));
15535
15536 client.request(request.unwrap()).await
15537 };
15538
15539 match req_result {
15540 Err(err) => {
15541 if let common::Retry::After(d) = dlg.http_error(&err) {
15542 sleep(d).await;
15543 continue;
15544 }
15545 dlg.finished(false);
15546 return Err(common::Error::HttpError(err));
15547 }
15548 Ok(res) => {
15549 let (mut parts, body) = res.into_parts();
15550 let mut body = common::Body::new(body);
15551 if !parts.status.is_success() {
15552 let bytes = common::to_bytes(body).await.unwrap_or_default();
15553 let error = serde_json::from_str(&common::to_string(&bytes));
15554 let response = common::to_response(parts, bytes.into());
15555
15556 if let common::Retry::After(d) =
15557 dlg.http_failure(&response, error.as_ref().ok())
15558 {
15559 sleep(d).await;
15560 continue;
15561 }
15562
15563 dlg.finished(false);
15564
15565 return Err(match error {
15566 Ok(value) => common::Error::BadRequest(value),
15567 _ => common::Error::Failure(response),
15568 });
15569 }
15570 let response = {
15571 let bytes = common::to_bytes(body).await.unwrap_or_default();
15572 let encoded = common::to_string(&bytes);
15573 match serde_json::from_str(&encoded) {
15574 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15575 Err(error) => {
15576 dlg.response_json_decode_error(&encoded, &error);
15577 return Err(common::Error::JsonDecodeError(
15578 encoded.to_string(),
15579 error,
15580 ));
15581 }
15582 }
15583 };
15584
15585 dlg.finished(true);
15586 return Ok(response);
15587 }
15588 }
15589 }
15590 }
15591
15592 ///
15593 /// Sets the *request* property to the given value.
15594 ///
15595 /// Even though the property as already been set when instantiating this call,
15596 /// we provide this method for API completeness.
15597 pub fn request(
15598 mut self,
15599 new_value: GoogleCloudRecommenderV1beta1RecommenderConfig,
15600 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
15601 self._request = new_value;
15602 self
15603 }
15604 /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
15605 ///
15606 /// Sets the *name* path property to the given value.
15607 ///
15608 /// Even though the property as already been set when instantiating this call,
15609 /// we provide this method for API completeness.
15610 pub fn name(
15611 mut self,
15612 new_value: &str,
15613 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
15614 self._name = new_value.to_string();
15615 self
15616 }
15617 /// If true, validate the request and preview the change, but do not actually update it.
15618 ///
15619 /// Sets the *validate only* query property to the given value.
15620 pub fn validate_only(
15621 mut self,
15622 new_value: bool,
15623 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
15624 self._validate_only = Some(new_value);
15625 self
15626 }
15627 /// The list of fields to be updated.
15628 ///
15629 /// Sets the *update mask* query property to the given value.
15630 pub fn update_mask(
15631 mut self,
15632 new_value: common::FieldMask,
15633 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
15634 self._update_mask = Some(new_value);
15635 self
15636 }
15637 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15638 /// while executing the actual API request.
15639 ///
15640 /// ````text
15641 /// It should be used to handle progress information, and to implement a certain level of resilience.
15642 /// ````
15643 ///
15644 /// Sets the *delegate* property to the given value.
15645 pub fn delegate(
15646 mut self,
15647 new_value: &'a mut dyn common::Delegate,
15648 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
15649 self._delegate = Some(new_value);
15650 self
15651 }
15652
15653 /// Set any additional parameter of the query string used in the request.
15654 /// It should be used to set parameters which are not yet available through their own
15655 /// setters.
15656 ///
15657 /// Please note that this method must not be used to set any of the known parameters
15658 /// which have their own setter method. If done anyway, the request will fail.
15659 ///
15660 /// # Additional Parameters
15661 ///
15662 /// * *$.xgafv* (query-string) - V1 error format.
15663 /// * *access_token* (query-string) - OAuth access token.
15664 /// * *alt* (query-string) - Data format for response.
15665 /// * *callback* (query-string) - JSONP
15666 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15667 /// * *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.
15668 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15669 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15670 /// * *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.
15671 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15672 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15673 pub fn param<T>(
15674 mut self,
15675 name: T,
15676 value: T,
15677 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
15678 where
15679 T: AsRef<str>,
15680 {
15681 self._additional_params
15682 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15683 self
15684 }
15685
15686 /// Identifies the authorization scope for the method you are building.
15687 ///
15688 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15689 /// [`Scope::CloudPlatform`].
15690 ///
15691 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15692 /// tokens for more than one scope.
15693 ///
15694 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15695 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15696 /// sufficient, a read-write scope will do as well.
15697 pub fn add_scope<St>(
15698 mut self,
15699 scope: St,
15700 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
15701 where
15702 St: AsRef<str>,
15703 {
15704 self._scopes.insert(String::from(scope.as_ref()));
15705 self
15706 }
15707 /// Identifies the authorization scope(s) for the method you are building.
15708 ///
15709 /// See [`Self::add_scope()`] for details.
15710 pub fn add_scopes<I, St>(
15711 mut self,
15712 scopes: I,
15713 ) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C>
15714 where
15715 I: IntoIterator<Item = St>,
15716 St: AsRef<str>,
15717 {
15718 self._scopes
15719 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15720 self
15721 }
15722
15723 /// Removes all scopes, and no default scope will be used either.
15724 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15725 /// for details).
15726 pub fn clear_scopes(mut self) -> OrganizationLocationRecommenderUpdateConfigCall<'a, C> {
15727 self._scopes.clear();
15728 self
15729 }
15730}
15731
15732/// Lists locations with recommendations or insights.
15733///
15734/// A builder for the *locations.list* method supported by a *organization* resource.
15735/// It is not used directly, but through a [`OrganizationMethods`] instance.
15736///
15737/// # Example
15738///
15739/// Instantiate a resource method builder
15740///
15741/// ```test_harness,no_run
15742/// # extern crate hyper;
15743/// # extern crate hyper_rustls;
15744/// # extern crate google_recommender1_beta1 as recommender1_beta1;
15745/// # async fn dox() {
15746/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15747///
15748/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15749/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15750/// # .with_native_roots()
15751/// # .unwrap()
15752/// # .https_only()
15753/// # .enable_http2()
15754/// # .build();
15755///
15756/// # let executor = hyper_util::rt::TokioExecutor::new();
15757/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15758/// # secret,
15759/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15760/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15761/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15762/// # ),
15763/// # ).build().await.unwrap();
15764///
15765/// # let client = hyper_util::client::legacy::Client::builder(
15766/// # hyper_util::rt::TokioExecutor::new()
15767/// # )
15768/// # .build(
15769/// # hyper_rustls::HttpsConnectorBuilder::new()
15770/// # .with_native_roots()
15771/// # .unwrap()
15772/// # .https_or_http()
15773/// # .enable_http2()
15774/// # .build()
15775/// # );
15776/// # let mut hub = Recommender::new(client, auth);
15777/// // You can configure optional parameters by calling the respective setters at will, and
15778/// // execute the final call using `doit()`.
15779/// // Values shown here are possibly random and not representative !
15780/// let result = hub.organizations().locations_list("name")
15781/// .page_token("accusam")
15782/// .page_size(-59)
15783/// .filter("consetetur")
15784/// .add_extra_location_types("voluptua.")
15785/// .doit().await;
15786/// # }
15787/// ```
15788pub struct OrganizationLocationListCall<'a, C>
15789where
15790 C: 'a,
15791{
15792 hub: &'a Recommender<C>,
15793 _name: String,
15794 _page_token: Option<String>,
15795 _page_size: Option<i32>,
15796 _filter: Option<String>,
15797 _extra_location_types: Vec<String>,
15798 _delegate: Option<&'a mut dyn common::Delegate>,
15799 _additional_params: HashMap<String, String>,
15800 _scopes: BTreeSet<String>,
15801}
15802
15803impl<'a, C> common::CallBuilder for OrganizationLocationListCall<'a, C> {}
15804
15805impl<'a, C> OrganizationLocationListCall<'a, C>
15806where
15807 C: common::Connector,
15808{
15809 /// Perform the operation you have build so far.
15810 pub async fn doit(
15811 mut self,
15812 ) -> common::Result<(common::Response, GoogleCloudLocationListLocationsResponse)> {
15813 use std::borrow::Cow;
15814 use std::io::{Read, Seek};
15815
15816 use common::{url::Params, ToParts};
15817 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15818
15819 let mut dd = common::DefaultDelegate;
15820 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15821 dlg.begin(common::MethodInfo {
15822 id: "recommender.organizations.locations.list",
15823 http_method: hyper::Method::GET,
15824 });
15825
15826 for &field in [
15827 "alt",
15828 "name",
15829 "pageToken",
15830 "pageSize",
15831 "filter",
15832 "extraLocationTypes",
15833 ]
15834 .iter()
15835 {
15836 if self._additional_params.contains_key(field) {
15837 dlg.finished(false);
15838 return Err(common::Error::FieldClash(field));
15839 }
15840 }
15841
15842 let mut params = Params::with_capacity(7 + self._additional_params.len());
15843 params.push("name", self._name);
15844 if let Some(value) = self._page_token.as_ref() {
15845 params.push("pageToken", value);
15846 }
15847 if let Some(value) = self._page_size.as_ref() {
15848 params.push("pageSize", value.to_string());
15849 }
15850 if let Some(value) = self._filter.as_ref() {
15851 params.push("filter", value);
15852 }
15853 if !self._extra_location_types.is_empty() {
15854 for f in self._extra_location_types.iter() {
15855 params.push("extraLocationTypes", f);
15856 }
15857 }
15858
15859 params.extend(self._additional_params.iter());
15860
15861 params.push("alt", "json");
15862 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/locations";
15863 if self._scopes.is_empty() {
15864 self._scopes
15865 .insert(Scope::CloudPlatform.as_ref().to_string());
15866 }
15867
15868 #[allow(clippy::single_element_loop)]
15869 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15870 url = params.uri_replacement(url, param_name, find_this, true);
15871 }
15872 {
15873 let to_remove = ["name"];
15874 params.remove_params(&to_remove);
15875 }
15876
15877 let url = params.parse_with_url(&url);
15878
15879 loop {
15880 let token = match self
15881 .hub
15882 .auth
15883 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15884 .await
15885 {
15886 Ok(token) => token,
15887 Err(e) => match dlg.token(e) {
15888 Ok(token) => token,
15889 Err(e) => {
15890 dlg.finished(false);
15891 return Err(common::Error::MissingToken(e));
15892 }
15893 },
15894 };
15895 let mut req_result = {
15896 let client = &self.hub.client;
15897 dlg.pre_request();
15898 let mut req_builder = hyper::Request::builder()
15899 .method(hyper::Method::GET)
15900 .uri(url.as_str())
15901 .header(USER_AGENT, self.hub._user_agent.clone());
15902
15903 if let Some(token) = token.as_ref() {
15904 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15905 }
15906
15907 let request = req_builder
15908 .header(CONTENT_LENGTH, 0_u64)
15909 .body(common::to_body::<String>(None));
15910
15911 client.request(request.unwrap()).await
15912 };
15913
15914 match req_result {
15915 Err(err) => {
15916 if let common::Retry::After(d) = dlg.http_error(&err) {
15917 sleep(d).await;
15918 continue;
15919 }
15920 dlg.finished(false);
15921 return Err(common::Error::HttpError(err));
15922 }
15923 Ok(res) => {
15924 let (mut parts, body) = res.into_parts();
15925 let mut body = common::Body::new(body);
15926 if !parts.status.is_success() {
15927 let bytes = common::to_bytes(body).await.unwrap_or_default();
15928 let error = serde_json::from_str(&common::to_string(&bytes));
15929 let response = common::to_response(parts, bytes.into());
15930
15931 if let common::Retry::After(d) =
15932 dlg.http_failure(&response, error.as_ref().ok())
15933 {
15934 sleep(d).await;
15935 continue;
15936 }
15937
15938 dlg.finished(false);
15939
15940 return Err(match error {
15941 Ok(value) => common::Error::BadRequest(value),
15942 _ => common::Error::Failure(response),
15943 });
15944 }
15945 let response = {
15946 let bytes = common::to_bytes(body).await.unwrap_or_default();
15947 let encoded = common::to_string(&bytes);
15948 match serde_json::from_str(&encoded) {
15949 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15950 Err(error) => {
15951 dlg.response_json_decode_error(&encoded, &error);
15952 return Err(common::Error::JsonDecodeError(
15953 encoded.to_string(),
15954 error,
15955 ));
15956 }
15957 }
15958 };
15959
15960 dlg.finished(true);
15961 return Ok(response);
15962 }
15963 }
15964 }
15965 }
15966
15967 /// The resource that owns the locations collection, if applicable.
15968 ///
15969 /// Sets the *name* path property to the given value.
15970 ///
15971 /// Even though the property as already been set when instantiating this call,
15972 /// we provide this method for API completeness.
15973 pub fn name(mut self, new_value: &str) -> OrganizationLocationListCall<'a, C> {
15974 self._name = new_value.to_string();
15975 self
15976 }
15977 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
15978 ///
15979 /// Sets the *page token* query property to the given value.
15980 pub fn page_token(mut self, new_value: &str) -> OrganizationLocationListCall<'a, C> {
15981 self._page_token = Some(new_value.to_string());
15982 self
15983 }
15984 /// The maximum number of results to return. If not set, the service selects a default.
15985 ///
15986 /// Sets the *page size* query property to the given value.
15987 pub fn page_size(mut self, new_value: i32) -> OrganizationLocationListCall<'a, C> {
15988 self._page_size = Some(new_value);
15989 self
15990 }
15991 /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
15992 ///
15993 /// Sets the *filter* query property to the given value.
15994 pub fn filter(mut self, new_value: &str) -> OrganizationLocationListCall<'a, C> {
15995 self._filter = Some(new_value.to_string());
15996 self
15997 }
15998 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
15999 ///
16000 /// Append the given value to the *extra location types* query property.
16001 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
16002 pub fn add_extra_location_types(
16003 mut self,
16004 new_value: &str,
16005 ) -> OrganizationLocationListCall<'a, C> {
16006 self._extra_location_types.push(new_value.to_string());
16007 self
16008 }
16009 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16010 /// while executing the actual API request.
16011 ///
16012 /// ````text
16013 /// It should be used to handle progress information, and to implement a certain level of resilience.
16014 /// ````
16015 ///
16016 /// Sets the *delegate* property to the given value.
16017 pub fn delegate(
16018 mut self,
16019 new_value: &'a mut dyn common::Delegate,
16020 ) -> OrganizationLocationListCall<'a, C> {
16021 self._delegate = Some(new_value);
16022 self
16023 }
16024
16025 /// Set any additional parameter of the query string used in the request.
16026 /// It should be used to set parameters which are not yet available through their own
16027 /// setters.
16028 ///
16029 /// Please note that this method must not be used to set any of the known parameters
16030 /// which have their own setter method. If done anyway, the request will fail.
16031 ///
16032 /// # Additional Parameters
16033 ///
16034 /// * *$.xgafv* (query-string) - V1 error format.
16035 /// * *access_token* (query-string) - OAuth access token.
16036 /// * *alt* (query-string) - Data format for response.
16037 /// * *callback* (query-string) - JSONP
16038 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16039 /// * *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.
16040 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16041 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16042 /// * *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.
16043 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16044 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16045 pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationListCall<'a, C>
16046 where
16047 T: AsRef<str>,
16048 {
16049 self._additional_params
16050 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16051 self
16052 }
16053
16054 /// Identifies the authorization scope for the method you are building.
16055 ///
16056 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16057 /// [`Scope::CloudPlatform`].
16058 ///
16059 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16060 /// tokens for more than one scope.
16061 ///
16062 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16063 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16064 /// sufficient, a read-write scope will do as well.
16065 pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationListCall<'a, C>
16066 where
16067 St: AsRef<str>,
16068 {
16069 self._scopes.insert(String::from(scope.as_ref()));
16070 self
16071 }
16072 /// Identifies the authorization scope(s) for the method you are building.
16073 ///
16074 /// See [`Self::add_scope()`] for details.
16075 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationListCall<'a, C>
16076 where
16077 I: IntoIterator<Item = St>,
16078 St: AsRef<str>,
16079 {
16080 self._scopes
16081 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16082 self
16083 }
16084
16085 /// Removes all scopes, and no default scope will be used either.
16086 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16087 /// for details).
16088 pub fn clear_scopes(mut self) -> OrganizationLocationListCall<'a, C> {
16089 self._scopes.clear();
16090 self
16091 }
16092}
16093
16094/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
16095///
16096/// A builder for the *locations.insightTypes.insights.get* method supported by a *project* resource.
16097/// It is not used directly, but through a [`ProjectMethods`] instance.
16098///
16099/// # Example
16100///
16101/// Instantiate a resource method builder
16102///
16103/// ```test_harness,no_run
16104/// # extern crate hyper;
16105/// # extern crate hyper_rustls;
16106/// # extern crate google_recommender1_beta1 as recommender1_beta1;
16107/// # async fn dox() {
16108/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16109///
16110/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16111/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16112/// # .with_native_roots()
16113/// # .unwrap()
16114/// # .https_only()
16115/// # .enable_http2()
16116/// # .build();
16117///
16118/// # let executor = hyper_util::rt::TokioExecutor::new();
16119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16120/// # secret,
16121/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16122/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16123/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16124/// # ),
16125/// # ).build().await.unwrap();
16126///
16127/// # let client = hyper_util::client::legacy::Client::builder(
16128/// # hyper_util::rt::TokioExecutor::new()
16129/// # )
16130/// # .build(
16131/// # hyper_rustls::HttpsConnectorBuilder::new()
16132/// # .with_native_roots()
16133/// # .unwrap()
16134/// # .https_or_http()
16135/// # .enable_http2()
16136/// # .build()
16137/// # );
16138/// # let mut hub = Recommender::new(client, auth);
16139/// // You can configure optional parameters by calling the respective setters at will, and
16140/// // execute the final call using `doit()`.
16141/// // Values shown here are possibly random and not representative !
16142/// let result = hub.projects().locations_insight_types_insights_get("name")
16143/// .doit().await;
16144/// # }
16145/// ```
16146pub struct ProjectLocationInsightTypeInsightGetCall<'a, C>
16147where
16148 C: 'a,
16149{
16150 hub: &'a Recommender<C>,
16151 _name: String,
16152 _delegate: Option<&'a mut dyn common::Delegate>,
16153 _additional_params: HashMap<String, String>,
16154 _scopes: BTreeSet<String>,
16155}
16156
16157impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeInsightGetCall<'a, C> {}
16158
16159impl<'a, C> ProjectLocationInsightTypeInsightGetCall<'a, C>
16160where
16161 C: common::Connector,
16162{
16163 /// Perform the operation you have build so far.
16164 pub async fn doit(
16165 mut self,
16166 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
16167 use std::borrow::Cow;
16168 use std::io::{Read, Seek};
16169
16170 use common::{url::Params, ToParts};
16171 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16172
16173 let mut dd = common::DefaultDelegate;
16174 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16175 dlg.begin(common::MethodInfo {
16176 id: "recommender.projects.locations.insightTypes.insights.get",
16177 http_method: hyper::Method::GET,
16178 });
16179
16180 for &field in ["alt", "name"].iter() {
16181 if self._additional_params.contains_key(field) {
16182 dlg.finished(false);
16183 return Err(common::Error::FieldClash(field));
16184 }
16185 }
16186
16187 let mut params = Params::with_capacity(3 + self._additional_params.len());
16188 params.push("name", self._name);
16189
16190 params.extend(self._additional_params.iter());
16191
16192 params.push("alt", "json");
16193 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
16194 if self._scopes.is_empty() {
16195 self._scopes
16196 .insert(Scope::CloudPlatform.as_ref().to_string());
16197 }
16198
16199 #[allow(clippy::single_element_loop)]
16200 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16201 url = params.uri_replacement(url, param_name, find_this, true);
16202 }
16203 {
16204 let to_remove = ["name"];
16205 params.remove_params(&to_remove);
16206 }
16207
16208 let url = params.parse_with_url(&url);
16209
16210 loop {
16211 let token = match self
16212 .hub
16213 .auth
16214 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16215 .await
16216 {
16217 Ok(token) => token,
16218 Err(e) => match dlg.token(e) {
16219 Ok(token) => token,
16220 Err(e) => {
16221 dlg.finished(false);
16222 return Err(common::Error::MissingToken(e));
16223 }
16224 },
16225 };
16226 let mut req_result = {
16227 let client = &self.hub.client;
16228 dlg.pre_request();
16229 let mut req_builder = hyper::Request::builder()
16230 .method(hyper::Method::GET)
16231 .uri(url.as_str())
16232 .header(USER_AGENT, self.hub._user_agent.clone());
16233
16234 if let Some(token) = token.as_ref() {
16235 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16236 }
16237
16238 let request = req_builder
16239 .header(CONTENT_LENGTH, 0_u64)
16240 .body(common::to_body::<String>(None));
16241
16242 client.request(request.unwrap()).await
16243 };
16244
16245 match req_result {
16246 Err(err) => {
16247 if let common::Retry::After(d) = dlg.http_error(&err) {
16248 sleep(d).await;
16249 continue;
16250 }
16251 dlg.finished(false);
16252 return Err(common::Error::HttpError(err));
16253 }
16254 Ok(res) => {
16255 let (mut parts, body) = res.into_parts();
16256 let mut body = common::Body::new(body);
16257 if !parts.status.is_success() {
16258 let bytes = common::to_bytes(body).await.unwrap_or_default();
16259 let error = serde_json::from_str(&common::to_string(&bytes));
16260 let response = common::to_response(parts, bytes.into());
16261
16262 if let common::Retry::After(d) =
16263 dlg.http_failure(&response, error.as_ref().ok())
16264 {
16265 sleep(d).await;
16266 continue;
16267 }
16268
16269 dlg.finished(false);
16270
16271 return Err(match error {
16272 Ok(value) => common::Error::BadRequest(value),
16273 _ => common::Error::Failure(response),
16274 });
16275 }
16276 let response = {
16277 let bytes = common::to_bytes(body).await.unwrap_or_default();
16278 let encoded = common::to_string(&bytes);
16279 match serde_json::from_str(&encoded) {
16280 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16281 Err(error) => {
16282 dlg.response_json_decode_error(&encoded, &error);
16283 return Err(common::Error::JsonDecodeError(
16284 encoded.to_string(),
16285 error,
16286 ));
16287 }
16288 }
16289 };
16290
16291 dlg.finished(true);
16292 return Ok(response);
16293 }
16294 }
16295 }
16296 }
16297
16298 /// Required. Name of the insight.
16299 ///
16300 /// Sets the *name* path property to the given value.
16301 ///
16302 /// Even though the property as already been set when instantiating this call,
16303 /// we provide this method for API completeness.
16304 pub fn name(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
16305 self._name = new_value.to_string();
16306 self
16307 }
16308 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16309 /// while executing the actual API request.
16310 ///
16311 /// ````text
16312 /// It should be used to handle progress information, and to implement a certain level of resilience.
16313 /// ````
16314 ///
16315 /// Sets the *delegate* property to the given value.
16316 pub fn delegate(
16317 mut self,
16318 new_value: &'a mut dyn common::Delegate,
16319 ) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
16320 self._delegate = Some(new_value);
16321 self
16322 }
16323
16324 /// Set any additional parameter of the query string used in the request.
16325 /// It should be used to set parameters which are not yet available through their own
16326 /// setters.
16327 ///
16328 /// Please note that this method must not be used to set any of the known parameters
16329 /// which have their own setter method. If done anyway, the request will fail.
16330 ///
16331 /// # Additional Parameters
16332 ///
16333 /// * *$.xgafv* (query-string) - V1 error format.
16334 /// * *access_token* (query-string) - OAuth access token.
16335 /// * *alt* (query-string) - Data format for response.
16336 /// * *callback* (query-string) - JSONP
16337 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16338 /// * *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.
16339 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16340 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16341 /// * *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.
16342 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16343 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16344 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeInsightGetCall<'a, C>
16345 where
16346 T: AsRef<str>,
16347 {
16348 self._additional_params
16349 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16350 self
16351 }
16352
16353 /// Identifies the authorization scope for the method you are building.
16354 ///
16355 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16356 /// [`Scope::CloudPlatform`].
16357 ///
16358 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16359 /// tokens for more than one scope.
16360 ///
16361 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16362 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16363 /// sufficient, a read-write scope will do as well.
16364 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeInsightGetCall<'a, C>
16365 where
16366 St: AsRef<str>,
16367 {
16368 self._scopes.insert(String::from(scope.as_ref()));
16369 self
16370 }
16371 /// Identifies the authorization scope(s) for the method you are building.
16372 ///
16373 /// See [`Self::add_scope()`] for details.
16374 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeInsightGetCall<'a, C>
16375 where
16376 I: IntoIterator<Item = St>,
16377 St: AsRef<str>,
16378 {
16379 self._scopes
16380 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16381 self
16382 }
16383
16384 /// Removes all scopes, and no default scope will be used either.
16385 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16386 /// for details).
16387 pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeInsightGetCall<'a, C> {
16388 self._scopes.clear();
16389 self
16390 }
16391}
16392
16393/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
16394///
16395/// A builder for the *locations.insightTypes.insights.list* method supported by a *project* resource.
16396/// It is not used directly, but through a [`ProjectMethods`] instance.
16397///
16398/// # Example
16399///
16400/// Instantiate a resource method builder
16401///
16402/// ```test_harness,no_run
16403/// # extern crate hyper;
16404/// # extern crate hyper_rustls;
16405/// # extern crate google_recommender1_beta1 as recommender1_beta1;
16406/// # async fn dox() {
16407/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16408///
16409/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16410/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16411/// # .with_native_roots()
16412/// # .unwrap()
16413/// # .https_only()
16414/// # .enable_http2()
16415/// # .build();
16416///
16417/// # let executor = hyper_util::rt::TokioExecutor::new();
16418/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16419/// # secret,
16420/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16421/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16422/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16423/// # ),
16424/// # ).build().await.unwrap();
16425///
16426/// # let client = hyper_util::client::legacy::Client::builder(
16427/// # hyper_util::rt::TokioExecutor::new()
16428/// # )
16429/// # .build(
16430/// # hyper_rustls::HttpsConnectorBuilder::new()
16431/// # .with_native_roots()
16432/// # .unwrap()
16433/// # .https_or_http()
16434/// # .enable_http2()
16435/// # .build()
16436/// # );
16437/// # let mut hub = Recommender::new(client, auth);
16438/// // You can configure optional parameters by calling the respective setters at will, and
16439/// // execute the final call using `doit()`.
16440/// // Values shown here are possibly random and not representative !
16441/// let result = hub.projects().locations_insight_types_insights_list("parent")
16442/// .page_token("consetetur")
16443/// .page_size(-2)
16444/// .filter("sed")
16445/// .doit().await;
16446/// # }
16447/// ```
16448pub struct ProjectLocationInsightTypeInsightListCall<'a, C>
16449where
16450 C: 'a,
16451{
16452 hub: &'a Recommender<C>,
16453 _parent: String,
16454 _page_token: Option<String>,
16455 _page_size: Option<i32>,
16456 _filter: Option<String>,
16457 _delegate: Option<&'a mut dyn common::Delegate>,
16458 _additional_params: HashMap<String, String>,
16459 _scopes: BTreeSet<String>,
16460}
16461
16462impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeInsightListCall<'a, C> {}
16463
16464impl<'a, C> ProjectLocationInsightTypeInsightListCall<'a, C>
16465where
16466 C: common::Connector,
16467{
16468 /// Perform the operation you have build so far.
16469 pub async fn doit(
16470 mut self,
16471 ) -> common::Result<(
16472 common::Response,
16473 GoogleCloudRecommenderV1beta1ListInsightsResponse,
16474 )> {
16475 use std::borrow::Cow;
16476 use std::io::{Read, Seek};
16477
16478 use common::{url::Params, ToParts};
16479 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16480
16481 let mut dd = common::DefaultDelegate;
16482 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16483 dlg.begin(common::MethodInfo {
16484 id: "recommender.projects.locations.insightTypes.insights.list",
16485 http_method: hyper::Method::GET,
16486 });
16487
16488 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
16489 if self._additional_params.contains_key(field) {
16490 dlg.finished(false);
16491 return Err(common::Error::FieldClash(field));
16492 }
16493 }
16494
16495 let mut params = Params::with_capacity(6 + self._additional_params.len());
16496 params.push("parent", self._parent);
16497 if let Some(value) = self._page_token.as_ref() {
16498 params.push("pageToken", value);
16499 }
16500 if let Some(value) = self._page_size.as_ref() {
16501 params.push("pageSize", value.to_string());
16502 }
16503 if let Some(value) = self._filter.as_ref() {
16504 params.push("filter", value);
16505 }
16506
16507 params.extend(self._additional_params.iter());
16508
16509 params.push("alt", "json");
16510 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/insights";
16511 if self._scopes.is_empty() {
16512 self._scopes
16513 .insert(Scope::CloudPlatform.as_ref().to_string());
16514 }
16515
16516 #[allow(clippy::single_element_loop)]
16517 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16518 url = params.uri_replacement(url, param_name, find_this, true);
16519 }
16520 {
16521 let to_remove = ["parent"];
16522 params.remove_params(&to_remove);
16523 }
16524
16525 let url = params.parse_with_url(&url);
16526
16527 loop {
16528 let token = match self
16529 .hub
16530 .auth
16531 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16532 .await
16533 {
16534 Ok(token) => token,
16535 Err(e) => match dlg.token(e) {
16536 Ok(token) => token,
16537 Err(e) => {
16538 dlg.finished(false);
16539 return Err(common::Error::MissingToken(e));
16540 }
16541 },
16542 };
16543 let mut req_result = {
16544 let client = &self.hub.client;
16545 dlg.pre_request();
16546 let mut req_builder = hyper::Request::builder()
16547 .method(hyper::Method::GET)
16548 .uri(url.as_str())
16549 .header(USER_AGENT, self.hub._user_agent.clone());
16550
16551 if let Some(token) = token.as_ref() {
16552 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16553 }
16554
16555 let request = req_builder
16556 .header(CONTENT_LENGTH, 0_u64)
16557 .body(common::to_body::<String>(None));
16558
16559 client.request(request.unwrap()).await
16560 };
16561
16562 match req_result {
16563 Err(err) => {
16564 if let common::Retry::After(d) = dlg.http_error(&err) {
16565 sleep(d).await;
16566 continue;
16567 }
16568 dlg.finished(false);
16569 return Err(common::Error::HttpError(err));
16570 }
16571 Ok(res) => {
16572 let (mut parts, body) = res.into_parts();
16573 let mut body = common::Body::new(body);
16574 if !parts.status.is_success() {
16575 let bytes = common::to_bytes(body).await.unwrap_or_default();
16576 let error = serde_json::from_str(&common::to_string(&bytes));
16577 let response = common::to_response(parts, bytes.into());
16578
16579 if let common::Retry::After(d) =
16580 dlg.http_failure(&response, error.as_ref().ok())
16581 {
16582 sleep(d).await;
16583 continue;
16584 }
16585
16586 dlg.finished(false);
16587
16588 return Err(match error {
16589 Ok(value) => common::Error::BadRequest(value),
16590 _ => common::Error::Failure(response),
16591 });
16592 }
16593 let response = {
16594 let bytes = common::to_bytes(body).await.unwrap_or_default();
16595 let encoded = common::to_string(&bytes);
16596 match serde_json::from_str(&encoded) {
16597 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16598 Err(error) => {
16599 dlg.response_json_decode_error(&encoded, &error);
16600 return Err(common::Error::JsonDecodeError(
16601 encoded.to_string(),
16602 error,
16603 ));
16604 }
16605 }
16606 };
16607
16608 dlg.finished(true);
16609 return Ok(response);
16610 }
16611 }
16612 }
16613 }
16614
16615 /// 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.
16616 ///
16617 /// Sets the *parent* path property to the given value.
16618 ///
16619 /// Even though the property as already been set when instantiating this call,
16620 /// we provide this method for API completeness.
16621 pub fn parent(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
16622 self._parent = new_value.to_string();
16623 self
16624 }
16625 /// 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.
16626 ///
16627 /// Sets the *page token* query property to the given value.
16628 pub fn page_token(
16629 mut self,
16630 new_value: &str,
16631 ) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
16632 self._page_token = Some(new_value.to_string());
16633 self
16634 }
16635 /// 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.
16636 ///
16637 /// Sets the *page size* query property to the given value.
16638 pub fn page_size(mut self, new_value: i32) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
16639 self._page_size = Some(new_value);
16640 self
16641 }
16642 /// 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)
16643 ///
16644 /// Sets the *filter* query property to the given value.
16645 pub fn filter(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
16646 self._filter = Some(new_value.to_string());
16647 self
16648 }
16649 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16650 /// while executing the actual API request.
16651 ///
16652 /// ````text
16653 /// It should be used to handle progress information, and to implement a certain level of resilience.
16654 /// ````
16655 ///
16656 /// Sets the *delegate* property to the given value.
16657 pub fn delegate(
16658 mut self,
16659 new_value: &'a mut dyn common::Delegate,
16660 ) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
16661 self._delegate = Some(new_value);
16662 self
16663 }
16664
16665 /// Set any additional parameter of the query string used in the request.
16666 /// It should be used to set parameters which are not yet available through their own
16667 /// setters.
16668 ///
16669 /// Please note that this method must not be used to set any of the known parameters
16670 /// which have their own setter method. If done anyway, the request will fail.
16671 ///
16672 /// # Additional Parameters
16673 ///
16674 /// * *$.xgafv* (query-string) - V1 error format.
16675 /// * *access_token* (query-string) - OAuth access token.
16676 /// * *alt* (query-string) - Data format for response.
16677 /// * *callback* (query-string) - JSONP
16678 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16679 /// * *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.
16680 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16681 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16682 /// * *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.
16683 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16684 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16685 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeInsightListCall<'a, C>
16686 where
16687 T: AsRef<str>,
16688 {
16689 self._additional_params
16690 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16691 self
16692 }
16693
16694 /// Identifies the authorization scope for the method you are building.
16695 ///
16696 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16697 /// [`Scope::CloudPlatform`].
16698 ///
16699 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16700 /// tokens for more than one scope.
16701 ///
16702 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16703 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16704 /// sufficient, a read-write scope will do as well.
16705 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeInsightListCall<'a, C>
16706 where
16707 St: AsRef<str>,
16708 {
16709 self._scopes.insert(String::from(scope.as_ref()));
16710 self
16711 }
16712 /// Identifies the authorization scope(s) for the method you are building.
16713 ///
16714 /// See [`Self::add_scope()`] for details.
16715 pub fn add_scopes<I, St>(
16716 mut self,
16717 scopes: I,
16718 ) -> ProjectLocationInsightTypeInsightListCall<'a, C>
16719 where
16720 I: IntoIterator<Item = St>,
16721 St: AsRef<str>,
16722 {
16723 self._scopes
16724 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16725 self
16726 }
16727
16728 /// Removes all scopes, and no default scope will be used either.
16729 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16730 /// for details).
16731 pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeInsightListCall<'a, C> {
16732 self._scopes.clear();
16733 self
16734 }
16735}
16736
16737/// 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.
16738///
16739/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *project* resource.
16740/// It is not used directly, but through a [`ProjectMethods`] instance.
16741///
16742/// # Example
16743///
16744/// Instantiate a resource method builder
16745///
16746/// ```test_harness,no_run
16747/// # extern crate hyper;
16748/// # extern crate hyper_rustls;
16749/// # extern crate google_recommender1_beta1 as recommender1_beta1;
16750/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
16751/// # async fn dox() {
16752/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16753///
16754/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16755/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16756/// # .with_native_roots()
16757/// # .unwrap()
16758/// # .https_only()
16759/// # .enable_http2()
16760/// # .build();
16761///
16762/// # let executor = hyper_util::rt::TokioExecutor::new();
16763/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16764/// # secret,
16765/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16766/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16767/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16768/// # ),
16769/// # ).build().await.unwrap();
16770///
16771/// # let client = hyper_util::client::legacy::Client::builder(
16772/// # hyper_util::rt::TokioExecutor::new()
16773/// # )
16774/// # .build(
16775/// # hyper_rustls::HttpsConnectorBuilder::new()
16776/// # .with_native_roots()
16777/// # .unwrap()
16778/// # .https_or_http()
16779/// # .enable_http2()
16780/// # .build()
16781/// # );
16782/// # let mut hub = Recommender::new(client, auth);
16783/// // As the method needs a request, you would usually fill it with the desired information
16784/// // into the respective structure. Some of the parts shown here might not be applicable !
16785/// // Values shown here are possibly random and not representative !
16786/// let mut req = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::default();
16787///
16788/// // You can configure optional parameters by calling the respective setters at will, and
16789/// // execute the final call using `doit()`.
16790/// // Values shown here are possibly random and not representative !
16791/// let result = hub.projects().locations_insight_types_insights_mark_accepted(req, "name")
16792/// .doit().await;
16793/// # }
16794/// ```
16795pub struct ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
16796where
16797 C: 'a,
16798{
16799 hub: &'a Recommender<C>,
16800 _request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
16801 _name: String,
16802 _delegate: Option<&'a mut dyn common::Delegate>,
16803 _additional_params: HashMap<String, String>,
16804 _scopes: BTreeSet<String>,
16805}
16806
16807impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {}
16808
16809impl<'a, C> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
16810where
16811 C: common::Connector,
16812{
16813 /// Perform the operation you have build so far.
16814 pub async fn doit(
16815 mut self,
16816 ) -> common::Result<(common::Response, GoogleCloudRecommenderV1beta1Insight)> {
16817 use std::borrow::Cow;
16818 use std::io::{Read, Seek};
16819
16820 use common::{url::Params, ToParts};
16821 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16822
16823 let mut dd = common::DefaultDelegate;
16824 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16825 dlg.begin(common::MethodInfo {
16826 id: "recommender.projects.locations.insightTypes.insights.markAccepted",
16827 http_method: hyper::Method::POST,
16828 });
16829
16830 for &field in ["alt", "name"].iter() {
16831 if self._additional_params.contains_key(field) {
16832 dlg.finished(false);
16833 return Err(common::Error::FieldClash(field));
16834 }
16835 }
16836
16837 let mut params = Params::with_capacity(4 + self._additional_params.len());
16838 params.push("name", self._name);
16839
16840 params.extend(self._additional_params.iter());
16841
16842 params.push("alt", "json");
16843 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markAccepted";
16844 if self._scopes.is_empty() {
16845 self._scopes
16846 .insert(Scope::CloudPlatform.as_ref().to_string());
16847 }
16848
16849 #[allow(clippy::single_element_loop)]
16850 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16851 url = params.uri_replacement(url, param_name, find_this, true);
16852 }
16853 {
16854 let to_remove = ["name"];
16855 params.remove_params(&to_remove);
16856 }
16857
16858 let url = params.parse_with_url(&url);
16859
16860 let mut json_mime_type = mime::APPLICATION_JSON;
16861 let mut request_value_reader = {
16862 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16863 common::remove_json_null_values(&mut value);
16864 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16865 serde_json::to_writer(&mut dst, &value).unwrap();
16866 dst
16867 };
16868 let request_size = request_value_reader
16869 .seek(std::io::SeekFrom::End(0))
16870 .unwrap();
16871 request_value_reader
16872 .seek(std::io::SeekFrom::Start(0))
16873 .unwrap();
16874
16875 loop {
16876 let token = match self
16877 .hub
16878 .auth
16879 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16880 .await
16881 {
16882 Ok(token) => token,
16883 Err(e) => match dlg.token(e) {
16884 Ok(token) => token,
16885 Err(e) => {
16886 dlg.finished(false);
16887 return Err(common::Error::MissingToken(e));
16888 }
16889 },
16890 };
16891 request_value_reader
16892 .seek(std::io::SeekFrom::Start(0))
16893 .unwrap();
16894 let mut req_result = {
16895 let client = &self.hub.client;
16896 dlg.pre_request();
16897 let mut req_builder = hyper::Request::builder()
16898 .method(hyper::Method::POST)
16899 .uri(url.as_str())
16900 .header(USER_AGENT, self.hub._user_agent.clone());
16901
16902 if let Some(token) = token.as_ref() {
16903 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16904 }
16905
16906 let request = req_builder
16907 .header(CONTENT_TYPE, json_mime_type.to_string())
16908 .header(CONTENT_LENGTH, request_size as u64)
16909 .body(common::to_body(
16910 request_value_reader.get_ref().clone().into(),
16911 ));
16912
16913 client.request(request.unwrap()).await
16914 };
16915
16916 match req_result {
16917 Err(err) => {
16918 if let common::Retry::After(d) = dlg.http_error(&err) {
16919 sleep(d).await;
16920 continue;
16921 }
16922 dlg.finished(false);
16923 return Err(common::Error::HttpError(err));
16924 }
16925 Ok(res) => {
16926 let (mut parts, body) = res.into_parts();
16927 let mut body = common::Body::new(body);
16928 if !parts.status.is_success() {
16929 let bytes = common::to_bytes(body).await.unwrap_or_default();
16930 let error = serde_json::from_str(&common::to_string(&bytes));
16931 let response = common::to_response(parts, bytes.into());
16932
16933 if let common::Retry::After(d) =
16934 dlg.http_failure(&response, error.as_ref().ok())
16935 {
16936 sleep(d).await;
16937 continue;
16938 }
16939
16940 dlg.finished(false);
16941
16942 return Err(match error {
16943 Ok(value) => common::Error::BadRequest(value),
16944 _ => common::Error::Failure(response),
16945 });
16946 }
16947 let response = {
16948 let bytes = common::to_bytes(body).await.unwrap_or_default();
16949 let encoded = common::to_string(&bytes);
16950 match serde_json::from_str(&encoded) {
16951 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16952 Err(error) => {
16953 dlg.response_json_decode_error(&encoded, &error);
16954 return Err(common::Error::JsonDecodeError(
16955 encoded.to_string(),
16956 error,
16957 ));
16958 }
16959 }
16960 };
16961
16962 dlg.finished(true);
16963 return Ok(response);
16964 }
16965 }
16966 }
16967 }
16968
16969 ///
16970 /// Sets the *request* property to the given value.
16971 ///
16972 /// Even though the property as already been set when instantiating this call,
16973 /// we provide this method for API completeness.
16974 pub fn request(
16975 mut self,
16976 new_value: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
16977 ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
16978 self._request = new_value;
16979 self
16980 }
16981 /// Required. Name of the insight.
16982 ///
16983 /// Sets the *name* path property to the given value.
16984 ///
16985 /// Even though the property as already been set when instantiating this call,
16986 /// we provide this method for API completeness.
16987 pub fn name(
16988 mut self,
16989 new_value: &str,
16990 ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
16991 self._name = new_value.to_string();
16992 self
16993 }
16994 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16995 /// while executing the actual API request.
16996 ///
16997 /// ````text
16998 /// It should be used to handle progress information, and to implement a certain level of resilience.
16999 /// ````
17000 ///
17001 /// Sets the *delegate* property to the given value.
17002 pub fn delegate(
17003 mut self,
17004 new_value: &'a mut dyn common::Delegate,
17005 ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
17006 self._delegate = Some(new_value);
17007 self
17008 }
17009
17010 /// Set any additional parameter of the query string used in the request.
17011 /// It should be used to set parameters which are not yet available through their own
17012 /// setters.
17013 ///
17014 /// Please note that this method must not be used to set any of the known parameters
17015 /// which have their own setter method. If done anyway, the request will fail.
17016 ///
17017 /// # Additional Parameters
17018 ///
17019 /// * *$.xgafv* (query-string) - V1 error format.
17020 /// * *access_token* (query-string) - OAuth access token.
17021 /// * *alt* (query-string) - Data format for response.
17022 /// * *callback* (query-string) - JSONP
17023 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17024 /// * *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.
17025 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17026 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17027 /// * *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.
17028 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17029 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17030 pub fn param<T>(
17031 mut self,
17032 name: T,
17033 value: T,
17034 ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
17035 where
17036 T: AsRef<str>,
17037 {
17038 self._additional_params
17039 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17040 self
17041 }
17042
17043 /// Identifies the authorization scope for the method you are building.
17044 ///
17045 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17046 /// [`Scope::CloudPlatform`].
17047 ///
17048 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17049 /// tokens for more than one scope.
17050 ///
17051 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17052 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17053 /// sufficient, a read-write scope will do as well.
17054 pub fn add_scope<St>(
17055 mut self,
17056 scope: St,
17057 ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
17058 where
17059 St: AsRef<str>,
17060 {
17061 self._scopes.insert(String::from(scope.as_ref()));
17062 self
17063 }
17064 /// Identifies the authorization scope(s) for the method you are building.
17065 ///
17066 /// See [`Self::add_scope()`] for details.
17067 pub fn add_scopes<I, St>(
17068 mut self,
17069 scopes: I,
17070 ) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C>
17071 where
17072 I: IntoIterator<Item = St>,
17073 St: AsRef<str>,
17074 {
17075 self._scopes
17076 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17077 self
17078 }
17079
17080 /// Removes all scopes, and no default scope will be used either.
17081 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17082 /// for details).
17083 pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, C> {
17084 self._scopes.clear();
17085 self
17086 }
17087}
17088
17089/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
17090///
17091/// A builder for the *locations.insightTypes.getConfig* method supported by a *project* resource.
17092/// It is not used directly, but through a [`ProjectMethods`] instance.
17093///
17094/// # Example
17095///
17096/// Instantiate a resource method builder
17097///
17098/// ```test_harness,no_run
17099/// # extern crate hyper;
17100/// # extern crate hyper_rustls;
17101/// # extern crate google_recommender1_beta1 as recommender1_beta1;
17102/// # async fn dox() {
17103/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17104///
17105/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17106/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17107/// # .with_native_roots()
17108/// # .unwrap()
17109/// # .https_only()
17110/// # .enable_http2()
17111/// # .build();
17112///
17113/// # let executor = hyper_util::rt::TokioExecutor::new();
17114/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17115/// # secret,
17116/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17117/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17118/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17119/// # ),
17120/// # ).build().await.unwrap();
17121///
17122/// # let client = hyper_util::client::legacy::Client::builder(
17123/// # hyper_util::rt::TokioExecutor::new()
17124/// # )
17125/// # .build(
17126/// # hyper_rustls::HttpsConnectorBuilder::new()
17127/// # .with_native_roots()
17128/// # .unwrap()
17129/// # .https_or_http()
17130/// # .enable_http2()
17131/// # .build()
17132/// # );
17133/// # let mut hub = Recommender::new(client, auth);
17134/// // You can configure optional parameters by calling the respective setters at will, and
17135/// // execute the final call using `doit()`.
17136/// // Values shown here are possibly random and not representative !
17137/// let result = hub.projects().locations_insight_types_get_config("name")
17138/// .doit().await;
17139/// # }
17140/// ```
17141pub struct ProjectLocationInsightTypeGetConfigCall<'a, C>
17142where
17143 C: 'a,
17144{
17145 hub: &'a Recommender<C>,
17146 _name: String,
17147 _delegate: Option<&'a mut dyn common::Delegate>,
17148 _additional_params: HashMap<String, String>,
17149 _scopes: BTreeSet<String>,
17150}
17151
17152impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeGetConfigCall<'a, C> {}
17153
17154impl<'a, C> ProjectLocationInsightTypeGetConfigCall<'a, C>
17155where
17156 C: common::Connector,
17157{
17158 /// Perform the operation you have build so far.
17159 pub async fn doit(
17160 mut self,
17161 ) -> common::Result<(
17162 common::Response,
17163 GoogleCloudRecommenderV1beta1InsightTypeConfig,
17164 )> {
17165 use std::borrow::Cow;
17166 use std::io::{Read, Seek};
17167
17168 use common::{url::Params, ToParts};
17169 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17170
17171 let mut dd = common::DefaultDelegate;
17172 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17173 dlg.begin(common::MethodInfo {
17174 id: "recommender.projects.locations.insightTypes.getConfig",
17175 http_method: hyper::Method::GET,
17176 });
17177
17178 for &field in ["alt", "name"].iter() {
17179 if self._additional_params.contains_key(field) {
17180 dlg.finished(false);
17181 return Err(common::Error::FieldClash(field));
17182 }
17183 }
17184
17185 let mut params = Params::with_capacity(3 + self._additional_params.len());
17186 params.push("name", self._name);
17187
17188 params.extend(self._additional_params.iter());
17189
17190 params.push("alt", "json");
17191 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
17192 if self._scopes.is_empty() {
17193 self._scopes
17194 .insert(Scope::CloudPlatform.as_ref().to_string());
17195 }
17196
17197 #[allow(clippy::single_element_loop)]
17198 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17199 url = params.uri_replacement(url, param_name, find_this, true);
17200 }
17201 {
17202 let to_remove = ["name"];
17203 params.remove_params(&to_remove);
17204 }
17205
17206 let url = params.parse_with_url(&url);
17207
17208 loop {
17209 let token = match self
17210 .hub
17211 .auth
17212 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17213 .await
17214 {
17215 Ok(token) => token,
17216 Err(e) => match dlg.token(e) {
17217 Ok(token) => token,
17218 Err(e) => {
17219 dlg.finished(false);
17220 return Err(common::Error::MissingToken(e));
17221 }
17222 },
17223 };
17224 let mut req_result = {
17225 let client = &self.hub.client;
17226 dlg.pre_request();
17227 let mut req_builder = hyper::Request::builder()
17228 .method(hyper::Method::GET)
17229 .uri(url.as_str())
17230 .header(USER_AGENT, self.hub._user_agent.clone());
17231
17232 if let Some(token) = token.as_ref() {
17233 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17234 }
17235
17236 let request = req_builder
17237 .header(CONTENT_LENGTH, 0_u64)
17238 .body(common::to_body::<String>(None));
17239
17240 client.request(request.unwrap()).await
17241 };
17242
17243 match req_result {
17244 Err(err) => {
17245 if let common::Retry::After(d) = dlg.http_error(&err) {
17246 sleep(d).await;
17247 continue;
17248 }
17249 dlg.finished(false);
17250 return Err(common::Error::HttpError(err));
17251 }
17252 Ok(res) => {
17253 let (mut parts, body) = res.into_parts();
17254 let mut body = common::Body::new(body);
17255 if !parts.status.is_success() {
17256 let bytes = common::to_bytes(body).await.unwrap_or_default();
17257 let error = serde_json::from_str(&common::to_string(&bytes));
17258 let response = common::to_response(parts, bytes.into());
17259
17260 if let common::Retry::After(d) =
17261 dlg.http_failure(&response, error.as_ref().ok())
17262 {
17263 sleep(d).await;
17264 continue;
17265 }
17266
17267 dlg.finished(false);
17268
17269 return Err(match error {
17270 Ok(value) => common::Error::BadRequest(value),
17271 _ => common::Error::Failure(response),
17272 });
17273 }
17274 let response = {
17275 let bytes = common::to_bytes(body).await.unwrap_or_default();
17276 let encoded = common::to_string(&bytes);
17277 match serde_json::from_str(&encoded) {
17278 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17279 Err(error) => {
17280 dlg.response_json_decode_error(&encoded, &error);
17281 return Err(common::Error::JsonDecodeError(
17282 encoded.to_string(),
17283 error,
17284 ));
17285 }
17286 }
17287 };
17288
17289 dlg.finished(true);
17290 return Ok(response);
17291 }
17292 }
17293 }
17294 }
17295
17296 /// 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`
17297 ///
17298 /// Sets the *name* path property to the given value.
17299 ///
17300 /// Even though the property as already been set when instantiating this call,
17301 /// we provide this method for API completeness.
17302 pub fn name(mut self, new_value: &str) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
17303 self._name = new_value.to_string();
17304 self
17305 }
17306 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17307 /// while executing the actual API request.
17308 ///
17309 /// ````text
17310 /// It should be used to handle progress information, and to implement a certain level of resilience.
17311 /// ````
17312 ///
17313 /// Sets the *delegate* property to the given value.
17314 pub fn delegate(
17315 mut self,
17316 new_value: &'a mut dyn common::Delegate,
17317 ) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
17318 self._delegate = Some(new_value);
17319 self
17320 }
17321
17322 /// Set any additional parameter of the query string used in the request.
17323 /// It should be used to set parameters which are not yet available through their own
17324 /// setters.
17325 ///
17326 /// Please note that this method must not be used to set any of the known parameters
17327 /// which have their own setter method. If done anyway, the request will fail.
17328 ///
17329 /// # Additional Parameters
17330 ///
17331 /// * *$.xgafv* (query-string) - V1 error format.
17332 /// * *access_token* (query-string) - OAuth access token.
17333 /// * *alt* (query-string) - Data format for response.
17334 /// * *callback* (query-string) - JSONP
17335 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17336 /// * *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.
17337 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17338 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17339 /// * *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.
17340 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17341 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17342 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeGetConfigCall<'a, C>
17343 where
17344 T: AsRef<str>,
17345 {
17346 self._additional_params
17347 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17348 self
17349 }
17350
17351 /// Identifies the authorization scope for the method you are building.
17352 ///
17353 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17354 /// [`Scope::CloudPlatform`].
17355 ///
17356 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17357 /// tokens for more than one scope.
17358 ///
17359 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17360 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17361 /// sufficient, a read-write scope will do as well.
17362 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeGetConfigCall<'a, C>
17363 where
17364 St: AsRef<str>,
17365 {
17366 self._scopes.insert(String::from(scope.as_ref()));
17367 self
17368 }
17369 /// Identifies the authorization scope(s) for the method you are building.
17370 ///
17371 /// See [`Self::add_scope()`] for details.
17372 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeGetConfigCall<'a, C>
17373 where
17374 I: IntoIterator<Item = St>,
17375 St: AsRef<str>,
17376 {
17377 self._scopes
17378 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17379 self
17380 }
17381
17382 /// Removes all scopes, and no default scope will be used either.
17383 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17384 /// for details).
17385 pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeGetConfigCall<'a, C> {
17386 self._scopes.clear();
17387 self
17388 }
17389}
17390
17391/// Updates an InsightTypeConfig change. This will create a new revision of the config.
17392///
17393/// A builder for the *locations.insightTypes.updateConfig* method supported by a *project* resource.
17394/// It is not used directly, but through a [`ProjectMethods`] instance.
17395///
17396/// # Example
17397///
17398/// Instantiate a resource method builder
17399///
17400/// ```test_harness,no_run
17401/// # extern crate hyper;
17402/// # extern crate hyper_rustls;
17403/// # extern crate google_recommender1_beta1 as recommender1_beta1;
17404/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1InsightTypeConfig;
17405/// # async fn dox() {
17406/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17407///
17408/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17409/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17410/// # .with_native_roots()
17411/// # .unwrap()
17412/// # .https_only()
17413/// # .enable_http2()
17414/// # .build();
17415///
17416/// # let executor = hyper_util::rt::TokioExecutor::new();
17417/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17418/// # secret,
17419/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17420/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17421/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17422/// # ),
17423/// # ).build().await.unwrap();
17424///
17425/// # let client = hyper_util::client::legacy::Client::builder(
17426/// # hyper_util::rt::TokioExecutor::new()
17427/// # )
17428/// # .build(
17429/// # hyper_rustls::HttpsConnectorBuilder::new()
17430/// # .with_native_roots()
17431/// # .unwrap()
17432/// # .https_or_http()
17433/// # .enable_http2()
17434/// # .build()
17435/// # );
17436/// # let mut hub = Recommender::new(client, auth);
17437/// // As the method needs a request, you would usually fill it with the desired information
17438/// // into the respective structure. Some of the parts shown here might not be applicable !
17439/// // Values shown here are possibly random and not representative !
17440/// let mut req = GoogleCloudRecommenderV1beta1InsightTypeConfig::default();
17441///
17442/// // You can configure optional parameters by calling the respective setters at will, and
17443/// // execute the final call using `doit()`.
17444/// // Values shown here are possibly random and not representative !
17445/// let result = hub.projects().locations_insight_types_update_config(req, "name")
17446/// .validate_only(false)
17447/// .update_mask(FieldMask::new::<&str>(&[]))
17448/// .doit().await;
17449/// # }
17450/// ```
17451pub struct ProjectLocationInsightTypeUpdateConfigCall<'a, C>
17452where
17453 C: 'a,
17454{
17455 hub: &'a Recommender<C>,
17456 _request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
17457 _name: String,
17458 _validate_only: Option<bool>,
17459 _update_mask: Option<common::FieldMask>,
17460 _delegate: Option<&'a mut dyn common::Delegate>,
17461 _additional_params: HashMap<String, String>,
17462 _scopes: BTreeSet<String>,
17463}
17464
17465impl<'a, C> common::CallBuilder for ProjectLocationInsightTypeUpdateConfigCall<'a, C> {}
17466
17467impl<'a, C> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
17468where
17469 C: common::Connector,
17470{
17471 /// Perform the operation you have build so far.
17472 pub async fn doit(
17473 mut self,
17474 ) -> common::Result<(
17475 common::Response,
17476 GoogleCloudRecommenderV1beta1InsightTypeConfig,
17477 )> {
17478 use std::borrow::Cow;
17479 use std::io::{Read, Seek};
17480
17481 use common::{url::Params, ToParts};
17482 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17483
17484 let mut dd = common::DefaultDelegate;
17485 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17486 dlg.begin(common::MethodInfo {
17487 id: "recommender.projects.locations.insightTypes.updateConfig",
17488 http_method: hyper::Method::PATCH,
17489 });
17490
17491 for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
17492 if self._additional_params.contains_key(field) {
17493 dlg.finished(false);
17494 return Err(common::Error::FieldClash(field));
17495 }
17496 }
17497
17498 let mut params = Params::with_capacity(6 + self._additional_params.len());
17499 params.push("name", self._name);
17500 if let Some(value) = self._validate_only.as_ref() {
17501 params.push("validateOnly", value.to_string());
17502 }
17503 if let Some(value) = self._update_mask.as_ref() {
17504 params.push("updateMask", value.to_string());
17505 }
17506
17507 params.extend(self._additional_params.iter());
17508
17509 params.push("alt", "json");
17510 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
17511 if self._scopes.is_empty() {
17512 self._scopes
17513 .insert(Scope::CloudPlatform.as_ref().to_string());
17514 }
17515
17516 #[allow(clippy::single_element_loop)]
17517 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17518 url = params.uri_replacement(url, param_name, find_this, true);
17519 }
17520 {
17521 let to_remove = ["name"];
17522 params.remove_params(&to_remove);
17523 }
17524
17525 let url = params.parse_with_url(&url);
17526
17527 let mut json_mime_type = mime::APPLICATION_JSON;
17528 let mut request_value_reader = {
17529 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17530 common::remove_json_null_values(&mut value);
17531 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17532 serde_json::to_writer(&mut dst, &value).unwrap();
17533 dst
17534 };
17535 let request_size = request_value_reader
17536 .seek(std::io::SeekFrom::End(0))
17537 .unwrap();
17538 request_value_reader
17539 .seek(std::io::SeekFrom::Start(0))
17540 .unwrap();
17541
17542 loop {
17543 let token = match self
17544 .hub
17545 .auth
17546 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17547 .await
17548 {
17549 Ok(token) => token,
17550 Err(e) => match dlg.token(e) {
17551 Ok(token) => token,
17552 Err(e) => {
17553 dlg.finished(false);
17554 return Err(common::Error::MissingToken(e));
17555 }
17556 },
17557 };
17558 request_value_reader
17559 .seek(std::io::SeekFrom::Start(0))
17560 .unwrap();
17561 let mut req_result = {
17562 let client = &self.hub.client;
17563 dlg.pre_request();
17564 let mut req_builder = hyper::Request::builder()
17565 .method(hyper::Method::PATCH)
17566 .uri(url.as_str())
17567 .header(USER_AGENT, self.hub._user_agent.clone());
17568
17569 if let Some(token) = token.as_ref() {
17570 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17571 }
17572
17573 let request = req_builder
17574 .header(CONTENT_TYPE, json_mime_type.to_string())
17575 .header(CONTENT_LENGTH, request_size as u64)
17576 .body(common::to_body(
17577 request_value_reader.get_ref().clone().into(),
17578 ));
17579
17580 client.request(request.unwrap()).await
17581 };
17582
17583 match req_result {
17584 Err(err) => {
17585 if let common::Retry::After(d) = dlg.http_error(&err) {
17586 sleep(d).await;
17587 continue;
17588 }
17589 dlg.finished(false);
17590 return Err(common::Error::HttpError(err));
17591 }
17592 Ok(res) => {
17593 let (mut parts, body) = res.into_parts();
17594 let mut body = common::Body::new(body);
17595 if !parts.status.is_success() {
17596 let bytes = common::to_bytes(body).await.unwrap_or_default();
17597 let error = serde_json::from_str(&common::to_string(&bytes));
17598 let response = common::to_response(parts, bytes.into());
17599
17600 if let common::Retry::After(d) =
17601 dlg.http_failure(&response, error.as_ref().ok())
17602 {
17603 sleep(d).await;
17604 continue;
17605 }
17606
17607 dlg.finished(false);
17608
17609 return Err(match error {
17610 Ok(value) => common::Error::BadRequest(value),
17611 _ => common::Error::Failure(response),
17612 });
17613 }
17614 let response = {
17615 let bytes = common::to_bytes(body).await.unwrap_or_default();
17616 let encoded = common::to_string(&bytes);
17617 match serde_json::from_str(&encoded) {
17618 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17619 Err(error) => {
17620 dlg.response_json_decode_error(&encoded, &error);
17621 return Err(common::Error::JsonDecodeError(
17622 encoded.to_string(),
17623 error,
17624 ));
17625 }
17626 }
17627 };
17628
17629 dlg.finished(true);
17630 return Ok(response);
17631 }
17632 }
17633 }
17634 }
17635
17636 ///
17637 /// Sets the *request* property to the given value.
17638 ///
17639 /// Even though the property as already been set when instantiating this call,
17640 /// we provide this method for API completeness.
17641 pub fn request(
17642 mut self,
17643 new_value: GoogleCloudRecommenderV1beta1InsightTypeConfig,
17644 ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
17645 self._request = new_value;
17646 self
17647 }
17648 /// Identifier. Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
17649 ///
17650 /// Sets the *name* path property to the given value.
17651 ///
17652 /// Even though the property as already been set when instantiating this call,
17653 /// we provide this method for API completeness.
17654 pub fn name(mut self, new_value: &str) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
17655 self._name = new_value.to_string();
17656 self
17657 }
17658 /// If true, validate the request and preview the change, but do not actually update it.
17659 ///
17660 /// Sets the *validate only* query property to the given value.
17661 pub fn validate_only(
17662 mut self,
17663 new_value: bool,
17664 ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
17665 self._validate_only = Some(new_value);
17666 self
17667 }
17668 /// The list of fields to be updated.
17669 ///
17670 /// Sets the *update mask* query property to the given value.
17671 pub fn update_mask(
17672 mut self,
17673 new_value: common::FieldMask,
17674 ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
17675 self._update_mask = Some(new_value);
17676 self
17677 }
17678 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17679 /// while executing the actual API request.
17680 ///
17681 /// ````text
17682 /// It should be used to handle progress information, and to implement a certain level of resilience.
17683 /// ````
17684 ///
17685 /// Sets the *delegate* property to the given value.
17686 pub fn delegate(
17687 mut self,
17688 new_value: &'a mut dyn common::Delegate,
17689 ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
17690 self._delegate = Some(new_value);
17691 self
17692 }
17693
17694 /// Set any additional parameter of the query string used in the request.
17695 /// It should be used to set parameters which are not yet available through their own
17696 /// setters.
17697 ///
17698 /// Please note that this method must not be used to set any of the known parameters
17699 /// which have their own setter method. If done anyway, the request will fail.
17700 ///
17701 /// # Additional Parameters
17702 ///
17703 /// * *$.xgafv* (query-string) - V1 error format.
17704 /// * *access_token* (query-string) - OAuth access token.
17705 /// * *alt* (query-string) - Data format for response.
17706 /// * *callback* (query-string) - JSONP
17707 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17708 /// * *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.
17709 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17710 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17711 /// * *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.
17712 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17713 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17714 pub fn param<T>(
17715 mut self,
17716 name: T,
17717 value: T,
17718 ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
17719 where
17720 T: AsRef<str>,
17721 {
17722 self._additional_params
17723 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17724 self
17725 }
17726
17727 /// Identifies the authorization scope for the method you are building.
17728 ///
17729 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17730 /// [`Scope::CloudPlatform`].
17731 ///
17732 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17733 /// tokens for more than one scope.
17734 ///
17735 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17736 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17737 /// sufficient, a read-write scope will do as well.
17738 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
17739 where
17740 St: AsRef<str>,
17741 {
17742 self._scopes.insert(String::from(scope.as_ref()));
17743 self
17744 }
17745 /// Identifies the authorization scope(s) for the method you are building.
17746 ///
17747 /// See [`Self::add_scope()`] for details.
17748 pub fn add_scopes<I, St>(
17749 mut self,
17750 scopes: I,
17751 ) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C>
17752 where
17753 I: IntoIterator<Item = St>,
17754 St: AsRef<str>,
17755 {
17756 self._scopes
17757 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17758 self
17759 }
17760
17761 /// Removes all scopes, and no default scope will be used either.
17762 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17763 /// for details).
17764 pub fn clear_scopes(mut self) -> ProjectLocationInsightTypeUpdateConfigCall<'a, C> {
17765 self._scopes.clear();
17766 self
17767 }
17768}
17769
17770/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
17771///
17772/// A builder for the *locations.recommenders.recommendations.get* method supported by a *project* resource.
17773/// It is not used directly, but through a [`ProjectMethods`] instance.
17774///
17775/// # Example
17776///
17777/// Instantiate a resource method builder
17778///
17779/// ```test_harness,no_run
17780/// # extern crate hyper;
17781/// # extern crate hyper_rustls;
17782/// # extern crate google_recommender1_beta1 as recommender1_beta1;
17783/// # async fn dox() {
17784/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17785///
17786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17787/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17788/// # .with_native_roots()
17789/// # .unwrap()
17790/// # .https_only()
17791/// # .enable_http2()
17792/// # .build();
17793///
17794/// # let executor = hyper_util::rt::TokioExecutor::new();
17795/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17796/// # secret,
17797/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17798/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17799/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17800/// # ),
17801/// # ).build().await.unwrap();
17802///
17803/// # let client = hyper_util::client::legacy::Client::builder(
17804/// # hyper_util::rt::TokioExecutor::new()
17805/// # )
17806/// # .build(
17807/// # hyper_rustls::HttpsConnectorBuilder::new()
17808/// # .with_native_roots()
17809/// # .unwrap()
17810/// # .https_or_http()
17811/// # .enable_http2()
17812/// # .build()
17813/// # );
17814/// # let mut hub = Recommender::new(client, auth);
17815/// // You can configure optional parameters by calling the respective setters at will, and
17816/// // execute the final call using `doit()`.
17817/// // Values shown here are possibly random and not representative !
17818/// let result = hub.projects().locations_recommenders_recommendations_get("name")
17819/// .doit().await;
17820/// # }
17821/// ```
17822pub struct ProjectLocationRecommenderRecommendationGetCall<'a, C>
17823where
17824 C: 'a,
17825{
17826 hub: &'a Recommender<C>,
17827 _name: String,
17828 _delegate: Option<&'a mut dyn common::Delegate>,
17829 _additional_params: HashMap<String, String>,
17830 _scopes: BTreeSet<String>,
17831}
17832
17833impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationGetCall<'a, C> {}
17834
17835impl<'a, C> ProjectLocationRecommenderRecommendationGetCall<'a, C>
17836where
17837 C: common::Connector,
17838{
17839 /// Perform the operation you have build so far.
17840 pub async fn doit(
17841 mut self,
17842 ) -> common::Result<(
17843 common::Response,
17844 GoogleCloudRecommenderV1beta1Recommendation,
17845 )> {
17846 use std::borrow::Cow;
17847 use std::io::{Read, Seek};
17848
17849 use common::{url::Params, ToParts};
17850 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17851
17852 let mut dd = common::DefaultDelegate;
17853 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17854 dlg.begin(common::MethodInfo {
17855 id: "recommender.projects.locations.recommenders.recommendations.get",
17856 http_method: hyper::Method::GET,
17857 });
17858
17859 for &field in ["alt", "name"].iter() {
17860 if self._additional_params.contains_key(field) {
17861 dlg.finished(false);
17862 return Err(common::Error::FieldClash(field));
17863 }
17864 }
17865
17866 let mut params = Params::with_capacity(3 + self._additional_params.len());
17867 params.push("name", self._name);
17868
17869 params.extend(self._additional_params.iter());
17870
17871 params.push("alt", "json");
17872 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
17873 if self._scopes.is_empty() {
17874 self._scopes
17875 .insert(Scope::CloudPlatform.as_ref().to_string());
17876 }
17877
17878 #[allow(clippy::single_element_loop)]
17879 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17880 url = params.uri_replacement(url, param_name, find_this, true);
17881 }
17882 {
17883 let to_remove = ["name"];
17884 params.remove_params(&to_remove);
17885 }
17886
17887 let url = params.parse_with_url(&url);
17888
17889 loop {
17890 let token = match self
17891 .hub
17892 .auth
17893 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17894 .await
17895 {
17896 Ok(token) => token,
17897 Err(e) => match dlg.token(e) {
17898 Ok(token) => token,
17899 Err(e) => {
17900 dlg.finished(false);
17901 return Err(common::Error::MissingToken(e));
17902 }
17903 },
17904 };
17905 let mut req_result = {
17906 let client = &self.hub.client;
17907 dlg.pre_request();
17908 let mut req_builder = hyper::Request::builder()
17909 .method(hyper::Method::GET)
17910 .uri(url.as_str())
17911 .header(USER_AGENT, self.hub._user_agent.clone());
17912
17913 if let Some(token) = token.as_ref() {
17914 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17915 }
17916
17917 let request = req_builder
17918 .header(CONTENT_LENGTH, 0_u64)
17919 .body(common::to_body::<String>(None));
17920
17921 client.request(request.unwrap()).await
17922 };
17923
17924 match req_result {
17925 Err(err) => {
17926 if let common::Retry::After(d) = dlg.http_error(&err) {
17927 sleep(d).await;
17928 continue;
17929 }
17930 dlg.finished(false);
17931 return Err(common::Error::HttpError(err));
17932 }
17933 Ok(res) => {
17934 let (mut parts, body) = res.into_parts();
17935 let mut body = common::Body::new(body);
17936 if !parts.status.is_success() {
17937 let bytes = common::to_bytes(body).await.unwrap_or_default();
17938 let error = serde_json::from_str(&common::to_string(&bytes));
17939 let response = common::to_response(parts, bytes.into());
17940
17941 if let common::Retry::After(d) =
17942 dlg.http_failure(&response, error.as_ref().ok())
17943 {
17944 sleep(d).await;
17945 continue;
17946 }
17947
17948 dlg.finished(false);
17949
17950 return Err(match error {
17951 Ok(value) => common::Error::BadRequest(value),
17952 _ => common::Error::Failure(response),
17953 });
17954 }
17955 let response = {
17956 let bytes = common::to_bytes(body).await.unwrap_or_default();
17957 let encoded = common::to_string(&bytes);
17958 match serde_json::from_str(&encoded) {
17959 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17960 Err(error) => {
17961 dlg.response_json_decode_error(&encoded, &error);
17962 return Err(common::Error::JsonDecodeError(
17963 encoded.to_string(),
17964 error,
17965 ));
17966 }
17967 }
17968 };
17969
17970 dlg.finished(true);
17971 return Ok(response);
17972 }
17973 }
17974 }
17975 }
17976
17977 /// Required. Name of the recommendation.
17978 ///
17979 /// Sets the *name* path property to the given value.
17980 ///
17981 /// Even though the property as already been set when instantiating this call,
17982 /// we provide this method for API completeness.
17983 pub fn name(
17984 mut self,
17985 new_value: &str,
17986 ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
17987 self._name = new_value.to_string();
17988 self
17989 }
17990 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17991 /// while executing the actual API request.
17992 ///
17993 /// ````text
17994 /// It should be used to handle progress information, and to implement a certain level of resilience.
17995 /// ````
17996 ///
17997 /// Sets the *delegate* property to the given value.
17998 pub fn delegate(
17999 mut self,
18000 new_value: &'a mut dyn common::Delegate,
18001 ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
18002 self._delegate = Some(new_value);
18003 self
18004 }
18005
18006 /// Set any additional parameter of the query string used in the request.
18007 /// It should be used to set parameters which are not yet available through their own
18008 /// setters.
18009 ///
18010 /// Please note that this method must not be used to set any of the known parameters
18011 /// which have their own setter method. If done anyway, the request will fail.
18012 ///
18013 /// # Additional Parameters
18014 ///
18015 /// * *$.xgafv* (query-string) - V1 error format.
18016 /// * *access_token* (query-string) - OAuth access token.
18017 /// * *alt* (query-string) - Data format for response.
18018 /// * *callback* (query-string) - JSONP
18019 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18020 /// * *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.
18021 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18022 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18023 /// * *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.
18024 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18025 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18026 pub fn param<T>(
18027 mut self,
18028 name: T,
18029 value: T,
18030 ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C>
18031 where
18032 T: AsRef<str>,
18033 {
18034 self._additional_params
18035 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18036 self
18037 }
18038
18039 /// Identifies the authorization scope for the method you are building.
18040 ///
18041 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18042 /// [`Scope::CloudPlatform`].
18043 ///
18044 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18045 /// tokens for more than one scope.
18046 ///
18047 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18048 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18049 /// sufficient, a read-write scope will do as well.
18050 pub fn add_scope<St>(
18051 mut self,
18052 scope: St,
18053 ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C>
18054 where
18055 St: AsRef<str>,
18056 {
18057 self._scopes.insert(String::from(scope.as_ref()));
18058 self
18059 }
18060 /// Identifies the authorization scope(s) for the method you are building.
18061 ///
18062 /// See [`Self::add_scope()`] for details.
18063 pub fn add_scopes<I, St>(
18064 mut self,
18065 scopes: I,
18066 ) -> ProjectLocationRecommenderRecommendationGetCall<'a, C>
18067 where
18068 I: IntoIterator<Item = St>,
18069 St: AsRef<str>,
18070 {
18071 self._scopes
18072 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18073 self
18074 }
18075
18076 /// Removes all scopes, and no default scope will be used either.
18077 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18078 /// for details).
18079 pub fn clear_scopes(mut self) -> ProjectLocationRecommenderRecommendationGetCall<'a, C> {
18080 self._scopes.clear();
18081 self
18082 }
18083}
18084
18085/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
18086///
18087/// A builder for the *locations.recommenders.recommendations.list* method supported by a *project* resource.
18088/// It is not used directly, but through a [`ProjectMethods`] instance.
18089///
18090/// # Example
18091///
18092/// Instantiate a resource method builder
18093///
18094/// ```test_harness,no_run
18095/// # extern crate hyper;
18096/// # extern crate hyper_rustls;
18097/// # extern crate google_recommender1_beta1 as recommender1_beta1;
18098/// # async fn dox() {
18099/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18100///
18101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18102/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18103/// # .with_native_roots()
18104/// # .unwrap()
18105/// # .https_only()
18106/// # .enable_http2()
18107/// # .build();
18108///
18109/// # let executor = hyper_util::rt::TokioExecutor::new();
18110/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18111/// # secret,
18112/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18113/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18114/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18115/// # ),
18116/// # ).build().await.unwrap();
18117///
18118/// # let client = hyper_util::client::legacy::Client::builder(
18119/// # hyper_util::rt::TokioExecutor::new()
18120/// # )
18121/// # .build(
18122/// # hyper_rustls::HttpsConnectorBuilder::new()
18123/// # .with_native_roots()
18124/// # .unwrap()
18125/// # .https_or_http()
18126/// # .enable_http2()
18127/// # .build()
18128/// # );
18129/// # let mut hub = Recommender::new(client, auth);
18130/// // You can configure optional parameters by calling the respective setters at will, and
18131/// // execute the final call using `doit()`.
18132/// // Values shown here are possibly random and not representative !
18133/// let result = hub.projects().locations_recommenders_recommendations_list("parent")
18134/// .page_token("dolore")
18135/// .page_size(-34)
18136/// .filter("dolore")
18137/// .doit().await;
18138/// # }
18139/// ```
18140pub struct ProjectLocationRecommenderRecommendationListCall<'a, C>
18141where
18142 C: 'a,
18143{
18144 hub: &'a Recommender<C>,
18145 _parent: String,
18146 _page_token: Option<String>,
18147 _page_size: Option<i32>,
18148 _filter: Option<String>,
18149 _delegate: Option<&'a mut dyn common::Delegate>,
18150 _additional_params: HashMap<String, String>,
18151 _scopes: BTreeSet<String>,
18152}
18153
18154impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationListCall<'a, C> {}
18155
18156impl<'a, C> ProjectLocationRecommenderRecommendationListCall<'a, C>
18157where
18158 C: common::Connector,
18159{
18160 /// Perform the operation you have build so far.
18161 pub async fn doit(
18162 mut self,
18163 ) -> common::Result<(
18164 common::Response,
18165 GoogleCloudRecommenderV1beta1ListRecommendationsResponse,
18166 )> {
18167 use std::borrow::Cow;
18168 use std::io::{Read, Seek};
18169
18170 use common::{url::Params, ToParts};
18171 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18172
18173 let mut dd = common::DefaultDelegate;
18174 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18175 dlg.begin(common::MethodInfo {
18176 id: "recommender.projects.locations.recommenders.recommendations.list",
18177 http_method: hyper::Method::GET,
18178 });
18179
18180 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
18181 if self._additional_params.contains_key(field) {
18182 dlg.finished(false);
18183 return Err(common::Error::FieldClash(field));
18184 }
18185 }
18186
18187 let mut params = Params::with_capacity(6 + self._additional_params.len());
18188 params.push("parent", self._parent);
18189 if let Some(value) = self._page_token.as_ref() {
18190 params.push("pageToken", value);
18191 }
18192 if let Some(value) = self._page_size.as_ref() {
18193 params.push("pageSize", value.to_string());
18194 }
18195 if let Some(value) = self._filter.as_ref() {
18196 params.push("filter", value);
18197 }
18198
18199 params.extend(self._additional_params.iter());
18200
18201 params.push("alt", "json");
18202 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/recommendations";
18203 if self._scopes.is_empty() {
18204 self._scopes
18205 .insert(Scope::CloudPlatform.as_ref().to_string());
18206 }
18207
18208 #[allow(clippy::single_element_loop)]
18209 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18210 url = params.uri_replacement(url, param_name, find_this, true);
18211 }
18212 {
18213 let to_remove = ["parent"];
18214 params.remove_params(&to_remove);
18215 }
18216
18217 let url = params.parse_with_url(&url);
18218
18219 loop {
18220 let token = match self
18221 .hub
18222 .auth
18223 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18224 .await
18225 {
18226 Ok(token) => token,
18227 Err(e) => match dlg.token(e) {
18228 Ok(token) => token,
18229 Err(e) => {
18230 dlg.finished(false);
18231 return Err(common::Error::MissingToken(e));
18232 }
18233 },
18234 };
18235 let mut req_result = {
18236 let client = &self.hub.client;
18237 dlg.pre_request();
18238 let mut req_builder = hyper::Request::builder()
18239 .method(hyper::Method::GET)
18240 .uri(url.as_str())
18241 .header(USER_AGENT, self.hub._user_agent.clone());
18242
18243 if let Some(token) = token.as_ref() {
18244 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18245 }
18246
18247 let request = req_builder
18248 .header(CONTENT_LENGTH, 0_u64)
18249 .body(common::to_body::<String>(None));
18250
18251 client.request(request.unwrap()).await
18252 };
18253
18254 match req_result {
18255 Err(err) => {
18256 if let common::Retry::After(d) = dlg.http_error(&err) {
18257 sleep(d).await;
18258 continue;
18259 }
18260 dlg.finished(false);
18261 return Err(common::Error::HttpError(err));
18262 }
18263 Ok(res) => {
18264 let (mut parts, body) = res.into_parts();
18265 let mut body = common::Body::new(body);
18266 if !parts.status.is_success() {
18267 let bytes = common::to_bytes(body).await.unwrap_or_default();
18268 let error = serde_json::from_str(&common::to_string(&bytes));
18269 let response = common::to_response(parts, bytes.into());
18270
18271 if let common::Retry::After(d) =
18272 dlg.http_failure(&response, error.as_ref().ok())
18273 {
18274 sleep(d).await;
18275 continue;
18276 }
18277
18278 dlg.finished(false);
18279
18280 return Err(match error {
18281 Ok(value) => common::Error::BadRequest(value),
18282 _ => common::Error::Failure(response),
18283 });
18284 }
18285 let response = {
18286 let bytes = common::to_bytes(body).await.unwrap_or_default();
18287 let encoded = common::to_string(&bytes);
18288 match serde_json::from_str(&encoded) {
18289 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18290 Err(error) => {
18291 dlg.response_json_decode_error(&encoded, &error);
18292 return Err(common::Error::JsonDecodeError(
18293 encoded.to_string(),
18294 error,
18295 ));
18296 }
18297 }
18298 };
18299
18300 dlg.finished(true);
18301 return Ok(response);
18302 }
18303 }
18304 }
18305 }
18306
18307 /// 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.
18308 ///
18309 /// Sets the *parent* path property to the given value.
18310 ///
18311 /// Even though the property as already been set when instantiating this call,
18312 /// we provide this method for API completeness.
18313 pub fn parent(
18314 mut self,
18315 new_value: &str,
18316 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
18317 self._parent = new_value.to_string();
18318 self
18319 }
18320 /// 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.
18321 ///
18322 /// Sets the *page token* query property to the given value.
18323 pub fn page_token(
18324 mut self,
18325 new_value: &str,
18326 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
18327 self._page_token = Some(new_value.to_string());
18328 self
18329 }
18330 /// 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.
18331 ///
18332 /// Sets the *page size* query property to the given value.
18333 pub fn page_size(
18334 mut self,
18335 new_value: i32,
18336 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
18337 self._page_size = Some(new_value);
18338 self
18339 }
18340 /// 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)
18341 ///
18342 /// Sets the *filter* query property to the given value.
18343 pub fn filter(
18344 mut self,
18345 new_value: &str,
18346 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
18347 self._filter = Some(new_value.to_string());
18348 self
18349 }
18350 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18351 /// while executing the actual API request.
18352 ///
18353 /// ````text
18354 /// It should be used to handle progress information, and to implement a certain level of resilience.
18355 /// ````
18356 ///
18357 /// Sets the *delegate* property to the given value.
18358 pub fn delegate(
18359 mut self,
18360 new_value: &'a mut dyn common::Delegate,
18361 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
18362 self._delegate = Some(new_value);
18363 self
18364 }
18365
18366 /// Set any additional parameter of the query string used in the request.
18367 /// It should be used to set parameters which are not yet available through their own
18368 /// setters.
18369 ///
18370 /// Please note that this method must not be used to set any of the known parameters
18371 /// which have their own setter method. If done anyway, the request will fail.
18372 ///
18373 /// # Additional Parameters
18374 ///
18375 /// * *$.xgafv* (query-string) - V1 error format.
18376 /// * *access_token* (query-string) - OAuth access token.
18377 /// * *alt* (query-string) - Data format for response.
18378 /// * *callback* (query-string) - JSONP
18379 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18380 /// * *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.
18381 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18382 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18383 /// * *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.
18384 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18385 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18386 pub fn param<T>(
18387 mut self,
18388 name: T,
18389 value: T,
18390 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C>
18391 where
18392 T: AsRef<str>,
18393 {
18394 self._additional_params
18395 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18396 self
18397 }
18398
18399 /// Identifies the authorization scope for the method you are building.
18400 ///
18401 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18402 /// [`Scope::CloudPlatform`].
18403 ///
18404 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18405 /// tokens for more than one scope.
18406 ///
18407 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18408 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18409 /// sufficient, a read-write scope will do as well.
18410 pub fn add_scope<St>(
18411 mut self,
18412 scope: St,
18413 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C>
18414 where
18415 St: AsRef<str>,
18416 {
18417 self._scopes.insert(String::from(scope.as_ref()));
18418 self
18419 }
18420 /// Identifies the authorization scope(s) for the method you are building.
18421 ///
18422 /// See [`Self::add_scope()`] for details.
18423 pub fn add_scopes<I, St>(
18424 mut self,
18425 scopes: I,
18426 ) -> ProjectLocationRecommenderRecommendationListCall<'a, C>
18427 where
18428 I: IntoIterator<Item = St>,
18429 St: AsRef<str>,
18430 {
18431 self._scopes
18432 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18433 self
18434 }
18435
18436 /// Removes all scopes, and no default scope will be used either.
18437 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18438 /// for details).
18439 pub fn clear_scopes(mut self) -> ProjectLocationRecommenderRecommendationListCall<'a, C> {
18440 self._scopes.clear();
18441 self
18442 }
18443}
18444
18445/// 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 or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
18446///
18447/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *project* resource.
18448/// It is not used directly, but through a [`ProjectMethods`] instance.
18449///
18450/// # Example
18451///
18452/// Instantiate a resource method builder
18453///
18454/// ```test_harness,no_run
18455/// # extern crate hyper;
18456/// # extern crate hyper_rustls;
18457/// # extern crate google_recommender1_beta1 as recommender1_beta1;
18458/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
18459/// # async fn dox() {
18460/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18461///
18462/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18463/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18464/// # .with_native_roots()
18465/// # .unwrap()
18466/// # .https_only()
18467/// # .enable_http2()
18468/// # .build();
18469///
18470/// # let executor = hyper_util::rt::TokioExecutor::new();
18471/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18472/// # secret,
18473/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18474/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18475/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18476/// # ),
18477/// # ).build().await.unwrap();
18478///
18479/// # let client = hyper_util::client::legacy::Client::builder(
18480/// # hyper_util::rt::TokioExecutor::new()
18481/// # )
18482/// # .build(
18483/// # hyper_rustls::HttpsConnectorBuilder::new()
18484/// # .with_native_roots()
18485/// # .unwrap()
18486/// # .https_or_http()
18487/// # .enable_http2()
18488/// # .build()
18489/// # );
18490/// # let mut hub = Recommender::new(client, auth);
18491/// // As the method needs a request, you would usually fill it with the desired information
18492/// // into the respective structure. Some of the parts shown here might not be applicable !
18493/// // Values shown here are possibly random and not representative !
18494/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::default();
18495///
18496/// // You can configure optional parameters by calling the respective setters at will, and
18497/// // execute the final call using `doit()`.
18498/// // Values shown here are possibly random and not representative !
18499/// let result = hub.projects().locations_recommenders_recommendations_mark_claimed(req, "name")
18500/// .doit().await;
18501/// # }
18502/// ```
18503pub struct ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
18504where
18505 C: 'a,
18506{
18507 hub: &'a Recommender<C>,
18508 _request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
18509 _name: String,
18510 _delegate: Option<&'a mut dyn common::Delegate>,
18511 _additional_params: HashMap<String, String>,
18512 _scopes: BTreeSet<String>,
18513}
18514
18515impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {}
18516
18517impl<'a, C> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
18518where
18519 C: common::Connector,
18520{
18521 /// Perform the operation you have build so far.
18522 pub async fn doit(
18523 mut self,
18524 ) -> common::Result<(
18525 common::Response,
18526 GoogleCloudRecommenderV1beta1Recommendation,
18527 )> {
18528 use std::borrow::Cow;
18529 use std::io::{Read, Seek};
18530
18531 use common::{url::Params, ToParts};
18532 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18533
18534 let mut dd = common::DefaultDelegate;
18535 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18536 dlg.begin(common::MethodInfo {
18537 id: "recommender.projects.locations.recommenders.recommendations.markClaimed",
18538 http_method: hyper::Method::POST,
18539 });
18540
18541 for &field in ["alt", "name"].iter() {
18542 if self._additional_params.contains_key(field) {
18543 dlg.finished(false);
18544 return Err(common::Error::FieldClash(field));
18545 }
18546 }
18547
18548 let mut params = Params::with_capacity(4 + self._additional_params.len());
18549 params.push("name", self._name);
18550
18551 params.extend(self._additional_params.iter());
18552
18553 params.push("alt", "json");
18554 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markClaimed";
18555 if self._scopes.is_empty() {
18556 self._scopes
18557 .insert(Scope::CloudPlatform.as_ref().to_string());
18558 }
18559
18560 #[allow(clippy::single_element_loop)]
18561 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18562 url = params.uri_replacement(url, param_name, find_this, true);
18563 }
18564 {
18565 let to_remove = ["name"];
18566 params.remove_params(&to_remove);
18567 }
18568
18569 let url = params.parse_with_url(&url);
18570
18571 let mut json_mime_type = mime::APPLICATION_JSON;
18572 let mut request_value_reader = {
18573 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18574 common::remove_json_null_values(&mut value);
18575 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18576 serde_json::to_writer(&mut dst, &value).unwrap();
18577 dst
18578 };
18579 let request_size = request_value_reader
18580 .seek(std::io::SeekFrom::End(0))
18581 .unwrap();
18582 request_value_reader
18583 .seek(std::io::SeekFrom::Start(0))
18584 .unwrap();
18585
18586 loop {
18587 let token = match self
18588 .hub
18589 .auth
18590 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18591 .await
18592 {
18593 Ok(token) => token,
18594 Err(e) => match dlg.token(e) {
18595 Ok(token) => token,
18596 Err(e) => {
18597 dlg.finished(false);
18598 return Err(common::Error::MissingToken(e));
18599 }
18600 },
18601 };
18602 request_value_reader
18603 .seek(std::io::SeekFrom::Start(0))
18604 .unwrap();
18605 let mut req_result = {
18606 let client = &self.hub.client;
18607 dlg.pre_request();
18608 let mut req_builder = hyper::Request::builder()
18609 .method(hyper::Method::POST)
18610 .uri(url.as_str())
18611 .header(USER_AGENT, self.hub._user_agent.clone());
18612
18613 if let Some(token) = token.as_ref() {
18614 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18615 }
18616
18617 let request = req_builder
18618 .header(CONTENT_TYPE, json_mime_type.to_string())
18619 .header(CONTENT_LENGTH, request_size as u64)
18620 .body(common::to_body(
18621 request_value_reader.get_ref().clone().into(),
18622 ));
18623
18624 client.request(request.unwrap()).await
18625 };
18626
18627 match req_result {
18628 Err(err) => {
18629 if let common::Retry::After(d) = dlg.http_error(&err) {
18630 sleep(d).await;
18631 continue;
18632 }
18633 dlg.finished(false);
18634 return Err(common::Error::HttpError(err));
18635 }
18636 Ok(res) => {
18637 let (mut parts, body) = res.into_parts();
18638 let mut body = common::Body::new(body);
18639 if !parts.status.is_success() {
18640 let bytes = common::to_bytes(body).await.unwrap_or_default();
18641 let error = serde_json::from_str(&common::to_string(&bytes));
18642 let response = common::to_response(parts, bytes.into());
18643
18644 if let common::Retry::After(d) =
18645 dlg.http_failure(&response, error.as_ref().ok())
18646 {
18647 sleep(d).await;
18648 continue;
18649 }
18650
18651 dlg.finished(false);
18652
18653 return Err(match error {
18654 Ok(value) => common::Error::BadRequest(value),
18655 _ => common::Error::Failure(response),
18656 });
18657 }
18658 let response = {
18659 let bytes = common::to_bytes(body).await.unwrap_or_default();
18660 let encoded = common::to_string(&bytes);
18661 match serde_json::from_str(&encoded) {
18662 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18663 Err(error) => {
18664 dlg.response_json_decode_error(&encoded, &error);
18665 return Err(common::Error::JsonDecodeError(
18666 encoded.to_string(),
18667 error,
18668 ));
18669 }
18670 }
18671 };
18672
18673 dlg.finished(true);
18674 return Ok(response);
18675 }
18676 }
18677 }
18678 }
18679
18680 ///
18681 /// Sets the *request* property to the given value.
18682 ///
18683 /// Even though the property as already been set when instantiating this call,
18684 /// we provide this method for API completeness.
18685 pub fn request(
18686 mut self,
18687 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
18688 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
18689 self._request = new_value;
18690 self
18691 }
18692 /// Required. Name of the recommendation.
18693 ///
18694 /// Sets the *name* path property to the given value.
18695 ///
18696 /// Even though the property as already been set when instantiating this call,
18697 /// we provide this method for API completeness.
18698 pub fn name(
18699 mut self,
18700 new_value: &str,
18701 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
18702 self._name = new_value.to_string();
18703 self
18704 }
18705 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18706 /// while executing the actual API request.
18707 ///
18708 /// ````text
18709 /// It should be used to handle progress information, and to implement a certain level of resilience.
18710 /// ````
18711 ///
18712 /// Sets the *delegate* property to the given value.
18713 pub fn delegate(
18714 mut self,
18715 new_value: &'a mut dyn common::Delegate,
18716 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
18717 self._delegate = Some(new_value);
18718 self
18719 }
18720
18721 /// Set any additional parameter of the query string used in the request.
18722 /// It should be used to set parameters which are not yet available through their own
18723 /// setters.
18724 ///
18725 /// Please note that this method must not be used to set any of the known parameters
18726 /// which have their own setter method. If done anyway, the request will fail.
18727 ///
18728 /// # Additional Parameters
18729 ///
18730 /// * *$.xgafv* (query-string) - V1 error format.
18731 /// * *access_token* (query-string) - OAuth access token.
18732 /// * *alt* (query-string) - Data format for response.
18733 /// * *callback* (query-string) - JSONP
18734 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18735 /// * *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.
18736 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18737 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18738 /// * *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.
18739 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18740 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18741 pub fn param<T>(
18742 mut self,
18743 name: T,
18744 value: T,
18745 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
18746 where
18747 T: AsRef<str>,
18748 {
18749 self._additional_params
18750 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18751 self
18752 }
18753
18754 /// Identifies the authorization scope for the method you are building.
18755 ///
18756 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18757 /// [`Scope::CloudPlatform`].
18758 ///
18759 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18760 /// tokens for more than one scope.
18761 ///
18762 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18763 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18764 /// sufficient, a read-write scope will do as well.
18765 pub fn add_scope<St>(
18766 mut self,
18767 scope: St,
18768 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
18769 where
18770 St: AsRef<str>,
18771 {
18772 self._scopes.insert(String::from(scope.as_ref()));
18773 self
18774 }
18775 /// Identifies the authorization scope(s) for the method you are building.
18776 ///
18777 /// See [`Self::add_scope()`] for details.
18778 pub fn add_scopes<I, St>(
18779 mut self,
18780 scopes: I,
18781 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C>
18782 where
18783 I: IntoIterator<Item = St>,
18784 St: AsRef<str>,
18785 {
18786 self._scopes
18787 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18788 self
18789 }
18790
18791 /// Removes all scopes, and no default scope will be used either.
18792 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18793 /// for details).
18794 pub fn clear_scopes(
18795 mut self,
18796 ) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, C> {
18797 self._scopes.clear();
18798 self
18799 }
18800}
18801
18802/// 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.
18803///
18804/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *project* resource.
18805/// It is not used directly, but through a [`ProjectMethods`] instance.
18806///
18807/// # Example
18808///
18809/// Instantiate a resource method builder
18810///
18811/// ```test_harness,no_run
18812/// # extern crate hyper;
18813/// # extern crate hyper_rustls;
18814/// # extern crate google_recommender1_beta1 as recommender1_beta1;
18815/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
18816/// # async fn dox() {
18817/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18818///
18819/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18820/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18821/// # .with_native_roots()
18822/// # .unwrap()
18823/// # .https_only()
18824/// # .enable_http2()
18825/// # .build();
18826///
18827/// # let executor = hyper_util::rt::TokioExecutor::new();
18828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18829/// # secret,
18830/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18831/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18832/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18833/// # ),
18834/// # ).build().await.unwrap();
18835///
18836/// # let client = hyper_util::client::legacy::Client::builder(
18837/// # hyper_util::rt::TokioExecutor::new()
18838/// # )
18839/// # .build(
18840/// # hyper_rustls::HttpsConnectorBuilder::new()
18841/// # .with_native_roots()
18842/// # .unwrap()
18843/// # .https_or_http()
18844/// # .enable_http2()
18845/// # .build()
18846/// # );
18847/// # let mut hub = Recommender::new(client, auth);
18848/// // As the method needs a request, you would usually fill it with the desired information
18849/// // into the respective structure. Some of the parts shown here might not be applicable !
18850/// // Values shown here are possibly random and not representative !
18851/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::default();
18852///
18853/// // You can configure optional parameters by calling the respective setters at will, and
18854/// // execute the final call using `doit()`.
18855/// // Values shown here are possibly random and not representative !
18856/// let result = hub.projects().locations_recommenders_recommendations_mark_dismissed(req, "name")
18857/// .doit().await;
18858/// # }
18859/// ```
18860pub struct ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
18861where
18862 C: 'a,
18863{
18864 hub: &'a Recommender<C>,
18865 _request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
18866 _name: String,
18867 _delegate: Option<&'a mut dyn common::Delegate>,
18868 _additional_params: HashMap<String, String>,
18869 _scopes: BTreeSet<String>,
18870}
18871
18872impl<'a, C> common::CallBuilder
18873 for ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
18874{
18875}
18876
18877impl<'a, C> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
18878where
18879 C: common::Connector,
18880{
18881 /// Perform the operation you have build so far.
18882 pub async fn doit(
18883 mut self,
18884 ) -> common::Result<(
18885 common::Response,
18886 GoogleCloudRecommenderV1beta1Recommendation,
18887 )> {
18888 use std::borrow::Cow;
18889 use std::io::{Read, Seek};
18890
18891 use common::{url::Params, ToParts};
18892 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18893
18894 let mut dd = common::DefaultDelegate;
18895 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18896 dlg.begin(common::MethodInfo {
18897 id: "recommender.projects.locations.recommenders.recommendations.markDismissed",
18898 http_method: hyper::Method::POST,
18899 });
18900
18901 for &field in ["alt", "name"].iter() {
18902 if self._additional_params.contains_key(field) {
18903 dlg.finished(false);
18904 return Err(common::Error::FieldClash(field));
18905 }
18906 }
18907
18908 let mut params = Params::with_capacity(4 + self._additional_params.len());
18909 params.push("name", self._name);
18910
18911 params.extend(self._additional_params.iter());
18912
18913 params.push("alt", "json");
18914 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markDismissed";
18915 if self._scopes.is_empty() {
18916 self._scopes
18917 .insert(Scope::CloudPlatform.as_ref().to_string());
18918 }
18919
18920 #[allow(clippy::single_element_loop)]
18921 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18922 url = params.uri_replacement(url, param_name, find_this, true);
18923 }
18924 {
18925 let to_remove = ["name"];
18926 params.remove_params(&to_remove);
18927 }
18928
18929 let url = params.parse_with_url(&url);
18930
18931 let mut json_mime_type = mime::APPLICATION_JSON;
18932 let mut request_value_reader = {
18933 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18934 common::remove_json_null_values(&mut value);
18935 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18936 serde_json::to_writer(&mut dst, &value).unwrap();
18937 dst
18938 };
18939 let request_size = request_value_reader
18940 .seek(std::io::SeekFrom::End(0))
18941 .unwrap();
18942 request_value_reader
18943 .seek(std::io::SeekFrom::Start(0))
18944 .unwrap();
18945
18946 loop {
18947 let token = match self
18948 .hub
18949 .auth
18950 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18951 .await
18952 {
18953 Ok(token) => token,
18954 Err(e) => match dlg.token(e) {
18955 Ok(token) => token,
18956 Err(e) => {
18957 dlg.finished(false);
18958 return Err(common::Error::MissingToken(e));
18959 }
18960 },
18961 };
18962 request_value_reader
18963 .seek(std::io::SeekFrom::Start(0))
18964 .unwrap();
18965 let mut req_result = {
18966 let client = &self.hub.client;
18967 dlg.pre_request();
18968 let mut req_builder = hyper::Request::builder()
18969 .method(hyper::Method::POST)
18970 .uri(url.as_str())
18971 .header(USER_AGENT, self.hub._user_agent.clone());
18972
18973 if let Some(token) = token.as_ref() {
18974 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18975 }
18976
18977 let request = req_builder
18978 .header(CONTENT_TYPE, json_mime_type.to_string())
18979 .header(CONTENT_LENGTH, request_size as u64)
18980 .body(common::to_body(
18981 request_value_reader.get_ref().clone().into(),
18982 ));
18983
18984 client.request(request.unwrap()).await
18985 };
18986
18987 match req_result {
18988 Err(err) => {
18989 if let common::Retry::After(d) = dlg.http_error(&err) {
18990 sleep(d).await;
18991 continue;
18992 }
18993 dlg.finished(false);
18994 return Err(common::Error::HttpError(err));
18995 }
18996 Ok(res) => {
18997 let (mut parts, body) = res.into_parts();
18998 let mut body = common::Body::new(body);
18999 if !parts.status.is_success() {
19000 let bytes = common::to_bytes(body).await.unwrap_or_default();
19001 let error = serde_json::from_str(&common::to_string(&bytes));
19002 let response = common::to_response(parts, bytes.into());
19003
19004 if let common::Retry::After(d) =
19005 dlg.http_failure(&response, error.as_ref().ok())
19006 {
19007 sleep(d).await;
19008 continue;
19009 }
19010
19011 dlg.finished(false);
19012
19013 return Err(match error {
19014 Ok(value) => common::Error::BadRequest(value),
19015 _ => common::Error::Failure(response),
19016 });
19017 }
19018 let response = {
19019 let bytes = common::to_bytes(body).await.unwrap_or_default();
19020 let encoded = common::to_string(&bytes);
19021 match serde_json::from_str(&encoded) {
19022 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19023 Err(error) => {
19024 dlg.response_json_decode_error(&encoded, &error);
19025 return Err(common::Error::JsonDecodeError(
19026 encoded.to_string(),
19027 error,
19028 ));
19029 }
19030 }
19031 };
19032
19033 dlg.finished(true);
19034 return Ok(response);
19035 }
19036 }
19037 }
19038 }
19039
19040 ///
19041 /// Sets the *request* property to the given value.
19042 ///
19043 /// Even though the property as already been set when instantiating this call,
19044 /// we provide this method for API completeness.
19045 pub fn request(
19046 mut self,
19047 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
19048 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
19049 self._request = new_value;
19050 self
19051 }
19052 /// Required. Name of the recommendation.
19053 ///
19054 /// Sets the *name* path property to the given value.
19055 ///
19056 /// Even though the property as already been set when instantiating this call,
19057 /// we provide this method for API completeness.
19058 pub fn name(
19059 mut self,
19060 new_value: &str,
19061 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
19062 self._name = new_value.to_string();
19063 self
19064 }
19065 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19066 /// while executing the actual API request.
19067 ///
19068 /// ````text
19069 /// It should be used to handle progress information, and to implement a certain level of resilience.
19070 /// ````
19071 ///
19072 /// Sets the *delegate* property to the given value.
19073 pub fn delegate(
19074 mut self,
19075 new_value: &'a mut dyn common::Delegate,
19076 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
19077 self._delegate = Some(new_value);
19078 self
19079 }
19080
19081 /// Set any additional parameter of the query string used in the request.
19082 /// It should be used to set parameters which are not yet available through their own
19083 /// setters.
19084 ///
19085 /// Please note that this method must not be used to set any of the known parameters
19086 /// which have their own setter method. If done anyway, the request will fail.
19087 ///
19088 /// # Additional Parameters
19089 ///
19090 /// * *$.xgafv* (query-string) - V1 error format.
19091 /// * *access_token* (query-string) - OAuth access token.
19092 /// * *alt* (query-string) - Data format for response.
19093 /// * *callback* (query-string) - JSONP
19094 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19095 /// * *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.
19096 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19097 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19098 /// * *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.
19099 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19100 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19101 pub fn param<T>(
19102 mut self,
19103 name: T,
19104 value: T,
19105 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
19106 where
19107 T: AsRef<str>,
19108 {
19109 self._additional_params
19110 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19111 self
19112 }
19113
19114 /// Identifies the authorization scope for the method you are building.
19115 ///
19116 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19117 /// [`Scope::CloudPlatform`].
19118 ///
19119 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19120 /// tokens for more than one scope.
19121 ///
19122 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19123 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19124 /// sufficient, a read-write scope will do as well.
19125 pub fn add_scope<St>(
19126 mut self,
19127 scope: St,
19128 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
19129 where
19130 St: AsRef<str>,
19131 {
19132 self._scopes.insert(String::from(scope.as_ref()));
19133 self
19134 }
19135 /// Identifies the authorization scope(s) for the method you are building.
19136 ///
19137 /// See [`Self::add_scope()`] for details.
19138 pub fn add_scopes<I, St>(
19139 mut self,
19140 scopes: I,
19141 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C>
19142 where
19143 I: IntoIterator<Item = St>,
19144 St: AsRef<str>,
19145 {
19146 self._scopes
19147 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19148 self
19149 }
19150
19151 /// Removes all scopes, and no default scope will be used either.
19152 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19153 /// for details).
19154 pub fn clear_scopes(
19155 mut self,
19156 ) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, C> {
19157 self._scopes.clear();
19158 self
19159 }
19160}
19161
19162/// 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.
19163///
19164/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *project* resource.
19165/// It is not used directly, but through a [`ProjectMethods`] instance.
19166///
19167/// # Example
19168///
19169/// Instantiate a resource method builder
19170///
19171/// ```test_harness,no_run
19172/// # extern crate hyper;
19173/// # extern crate hyper_rustls;
19174/// # extern crate google_recommender1_beta1 as recommender1_beta1;
19175/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
19176/// # async fn dox() {
19177/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19178///
19179/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19180/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19181/// # .with_native_roots()
19182/// # .unwrap()
19183/// # .https_only()
19184/// # .enable_http2()
19185/// # .build();
19186///
19187/// # let executor = hyper_util::rt::TokioExecutor::new();
19188/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19189/// # secret,
19190/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19191/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19192/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19193/// # ),
19194/// # ).build().await.unwrap();
19195///
19196/// # let client = hyper_util::client::legacy::Client::builder(
19197/// # hyper_util::rt::TokioExecutor::new()
19198/// # )
19199/// # .build(
19200/// # hyper_rustls::HttpsConnectorBuilder::new()
19201/// # .with_native_roots()
19202/// # .unwrap()
19203/// # .https_or_http()
19204/// # .enable_http2()
19205/// # .build()
19206/// # );
19207/// # let mut hub = Recommender::new(client, auth);
19208/// // As the method needs a request, you would usually fill it with the desired information
19209/// // into the respective structure. Some of the parts shown here might not be applicable !
19210/// // Values shown here are possibly random and not representative !
19211/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::default();
19212///
19213/// // You can configure optional parameters by calling the respective setters at will, and
19214/// // execute the final call using `doit()`.
19215/// // Values shown here are possibly random and not representative !
19216/// let result = hub.projects().locations_recommenders_recommendations_mark_failed(req, "name")
19217/// .doit().await;
19218/// # }
19219/// ```
19220pub struct ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
19221where
19222 C: 'a,
19223{
19224 hub: &'a Recommender<C>,
19225 _request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
19226 _name: String,
19227 _delegate: Option<&'a mut dyn common::Delegate>,
19228 _additional_params: HashMap<String, String>,
19229 _scopes: BTreeSet<String>,
19230}
19231
19232impl<'a, C> common::CallBuilder for ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {}
19233
19234impl<'a, C> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
19235where
19236 C: common::Connector,
19237{
19238 /// Perform the operation you have build so far.
19239 pub async fn doit(
19240 mut self,
19241 ) -> common::Result<(
19242 common::Response,
19243 GoogleCloudRecommenderV1beta1Recommendation,
19244 )> {
19245 use std::borrow::Cow;
19246 use std::io::{Read, Seek};
19247
19248 use common::{url::Params, ToParts};
19249 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19250
19251 let mut dd = common::DefaultDelegate;
19252 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19253 dlg.begin(common::MethodInfo {
19254 id: "recommender.projects.locations.recommenders.recommendations.markFailed",
19255 http_method: hyper::Method::POST,
19256 });
19257
19258 for &field in ["alt", "name"].iter() {
19259 if self._additional_params.contains_key(field) {
19260 dlg.finished(false);
19261 return Err(common::Error::FieldClash(field));
19262 }
19263 }
19264
19265 let mut params = Params::with_capacity(4 + self._additional_params.len());
19266 params.push("name", self._name);
19267
19268 params.extend(self._additional_params.iter());
19269
19270 params.push("alt", "json");
19271 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markFailed";
19272 if self._scopes.is_empty() {
19273 self._scopes
19274 .insert(Scope::CloudPlatform.as_ref().to_string());
19275 }
19276
19277 #[allow(clippy::single_element_loop)]
19278 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19279 url = params.uri_replacement(url, param_name, find_this, true);
19280 }
19281 {
19282 let to_remove = ["name"];
19283 params.remove_params(&to_remove);
19284 }
19285
19286 let url = params.parse_with_url(&url);
19287
19288 let mut json_mime_type = mime::APPLICATION_JSON;
19289 let mut request_value_reader = {
19290 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19291 common::remove_json_null_values(&mut value);
19292 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19293 serde_json::to_writer(&mut dst, &value).unwrap();
19294 dst
19295 };
19296 let request_size = request_value_reader
19297 .seek(std::io::SeekFrom::End(0))
19298 .unwrap();
19299 request_value_reader
19300 .seek(std::io::SeekFrom::Start(0))
19301 .unwrap();
19302
19303 loop {
19304 let token = match self
19305 .hub
19306 .auth
19307 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19308 .await
19309 {
19310 Ok(token) => token,
19311 Err(e) => match dlg.token(e) {
19312 Ok(token) => token,
19313 Err(e) => {
19314 dlg.finished(false);
19315 return Err(common::Error::MissingToken(e));
19316 }
19317 },
19318 };
19319 request_value_reader
19320 .seek(std::io::SeekFrom::Start(0))
19321 .unwrap();
19322 let mut req_result = {
19323 let client = &self.hub.client;
19324 dlg.pre_request();
19325 let mut req_builder = hyper::Request::builder()
19326 .method(hyper::Method::POST)
19327 .uri(url.as_str())
19328 .header(USER_AGENT, self.hub._user_agent.clone());
19329
19330 if let Some(token) = token.as_ref() {
19331 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19332 }
19333
19334 let request = req_builder
19335 .header(CONTENT_TYPE, json_mime_type.to_string())
19336 .header(CONTENT_LENGTH, request_size as u64)
19337 .body(common::to_body(
19338 request_value_reader.get_ref().clone().into(),
19339 ));
19340
19341 client.request(request.unwrap()).await
19342 };
19343
19344 match req_result {
19345 Err(err) => {
19346 if let common::Retry::After(d) = dlg.http_error(&err) {
19347 sleep(d).await;
19348 continue;
19349 }
19350 dlg.finished(false);
19351 return Err(common::Error::HttpError(err));
19352 }
19353 Ok(res) => {
19354 let (mut parts, body) = res.into_parts();
19355 let mut body = common::Body::new(body);
19356 if !parts.status.is_success() {
19357 let bytes = common::to_bytes(body).await.unwrap_or_default();
19358 let error = serde_json::from_str(&common::to_string(&bytes));
19359 let response = common::to_response(parts, bytes.into());
19360
19361 if let common::Retry::After(d) =
19362 dlg.http_failure(&response, error.as_ref().ok())
19363 {
19364 sleep(d).await;
19365 continue;
19366 }
19367
19368 dlg.finished(false);
19369
19370 return Err(match error {
19371 Ok(value) => common::Error::BadRequest(value),
19372 _ => common::Error::Failure(response),
19373 });
19374 }
19375 let response = {
19376 let bytes = common::to_bytes(body).await.unwrap_or_default();
19377 let encoded = common::to_string(&bytes);
19378 match serde_json::from_str(&encoded) {
19379 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19380 Err(error) => {
19381 dlg.response_json_decode_error(&encoded, &error);
19382 return Err(common::Error::JsonDecodeError(
19383 encoded.to_string(),
19384 error,
19385 ));
19386 }
19387 }
19388 };
19389
19390 dlg.finished(true);
19391 return Ok(response);
19392 }
19393 }
19394 }
19395 }
19396
19397 ///
19398 /// Sets the *request* property to the given value.
19399 ///
19400 /// Even though the property as already been set when instantiating this call,
19401 /// we provide this method for API completeness.
19402 pub fn request(
19403 mut self,
19404 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
19405 ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
19406 self._request = new_value;
19407 self
19408 }
19409 /// Required. Name of the recommendation.
19410 ///
19411 /// Sets the *name* path property to the given value.
19412 ///
19413 /// Even though the property as already been set when instantiating this call,
19414 /// we provide this method for API completeness.
19415 pub fn name(
19416 mut self,
19417 new_value: &str,
19418 ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
19419 self._name = new_value.to_string();
19420 self
19421 }
19422 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19423 /// while executing the actual API request.
19424 ///
19425 /// ````text
19426 /// It should be used to handle progress information, and to implement a certain level of resilience.
19427 /// ````
19428 ///
19429 /// Sets the *delegate* property to the given value.
19430 pub fn delegate(
19431 mut self,
19432 new_value: &'a mut dyn common::Delegate,
19433 ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
19434 self._delegate = Some(new_value);
19435 self
19436 }
19437
19438 /// Set any additional parameter of the query string used in the request.
19439 /// It should be used to set parameters which are not yet available through their own
19440 /// setters.
19441 ///
19442 /// Please note that this method must not be used to set any of the known parameters
19443 /// which have their own setter method. If done anyway, the request will fail.
19444 ///
19445 /// # Additional Parameters
19446 ///
19447 /// * *$.xgafv* (query-string) - V1 error format.
19448 /// * *access_token* (query-string) - OAuth access token.
19449 /// * *alt* (query-string) - Data format for response.
19450 /// * *callback* (query-string) - JSONP
19451 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19452 /// * *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.
19453 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19454 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19455 /// * *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.
19456 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19457 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19458 pub fn param<T>(
19459 mut self,
19460 name: T,
19461 value: T,
19462 ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
19463 where
19464 T: AsRef<str>,
19465 {
19466 self._additional_params
19467 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19468 self
19469 }
19470
19471 /// Identifies the authorization scope for the method you are building.
19472 ///
19473 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19474 /// [`Scope::CloudPlatform`].
19475 ///
19476 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19477 /// tokens for more than one scope.
19478 ///
19479 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19480 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19481 /// sufficient, a read-write scope will do as well.
19482 pub fn add_scope<St>(
19483 mut self,
19484 scope: St,
19485 ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
19486 where
19487 St: AsRef<str>,
19488 {
19489 self._scopes.insert(String::from(scope.as_ref()));
19490 self
19491 }
19492 /// Identifies the authorization scope(s) for the method you are building.
19493 ///
19494 /// See [`Self::add_scope()`] for details.
19495 pub fn add_scopes<I, St>(
19496 mut self,
19497 scopes: I,
19498 ) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C>
19499 where
19500 I: IntoIterator<Item = St>,
19501 St: AsRef<str>,
19502 {
19503 self._scopes
19504 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19505 self
19506 }
19507
19508 /// Removes all scopes, and no default scope will be used either.
19509 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19510 /// for details).
19511 pub fn clear_scopes(mut self) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, C> {
19512 self._scopes.clear();
19513 self
19514 }
19515}
19516
19517/// 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.
19518///
19519/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *project* resource.
19520/// It is not used directly, but through a [`ProjectMethods`] instance.
19521///
19522/// # Example
19523///
19524/// Instantiate a resource method builder
19525///
19526/// ```test_harness,no_run
19527/// # extern crate hyper;
19528/// # extern crate hyper_rustls;
19529/// # extern crate google_recommender1_beta1 as recommender1_beta1;
19530/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
19531/// # async fn dox() {
19532/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19533///
19534/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19535/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19536/// # .with_native_roots()
19537/// # .unwrap()
19538/// # .https_only()
19539/// # .enable_http2()
19540/// # .build();
19541///
19542/// # let executor = hyper_util::rt::TokioExecutor::new();
19543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19544/// # secret,
19545/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19546/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19547/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19548/// # ),
19549/// # ).build().await.unwrap();
19550///
19551/// # let client = hyper_util::client::legacy::Client::builder(
19552/// # hyper_util::rt::TokioExecutor::new()
19553/// # )
19554/// # .build(
19555/// # hyper_rustls::HttpsConnectorBuilder::new()
19556/// # .with_native_roots()
19557/// # .unwrap()
19558/// # .https_or_http()
19559/// # .enable_http2()
19560/// # .build()
19561/// # );
19562/// # let mut hub = Recommender::new(client, auth);
19563/// // As the method needs a request, you would usually fill it with the desired information
19564/// // into the respective structure. Some of the parts shown here might not be applicable !
19565/// // Values shown here are possibly random and not representative !
19566/// let mut req = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::default();
19567///
19568/// // You can configure optional parameters by calling the respective setters at will, and
19569/// // execute the final call using `doit()`.
19570/// // Values shown here are possibly random and not representative !
19571/// let result = hub.projects().locations_recommenders_recommendations_mark_succeeded(req, "name")
19572/// .doit().await;
19573/// # }
19574/// ```
19575pub struct ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
19576where
19577 C: 'a,
19578{
19579 hub: &'a Recommender<C>,
19580 _request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
19581 _name: String,
19582 _delegate: Option<&'a mut dyn common::Delegate>,
19583 _additional_params: HashMap<String, String>,
19584 _scopes: BTreeSet<String>,
19585}
19586
19587impl<'a, C> common::CallBuilder
19588 for ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
19589{
19590}
19591
19592impl<'a, C> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
19593where
19594 C: common::Connector,
19595{
19596 /// Perform the operation you have build so far.
19597 pub async fn doit(
19598 mut self,
19599 ) -> common::Result<(
19600 common::Response,
19601 GoogleCloudRecommenderV1beta1Recommendation,
19602 )> {
19603 use std::borrow::Cow;
19604 use std::io::{Read, Seek};
19605
19606 use common::{url::Params, ToParts};
19607 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19608
19609 let mut dd = common::DefaultDelegate;
19610 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19611 dlg.begin(common::MethodInfo {
19612 id: "recommender.projects.locations.recommenders.recommendations.markSucceeded",
19613 http_method: hyper::Method::POST,
19614 });
19615
19616 for &field in ["alt", "name"].iter() {
19617 if self._additional_params.contains_key(field) {
19618 dlg.finished(false);
19619 return Err(common::Error::FieldClash(field));
19620 }
19621 }
19622
19623 let mut params = Params::with_capacity(4 + self._additional_params.len());
19624 params.push("name", self._name);
19625
19626 params.extend(self._additional_params.iter());
19627
19628 params.push("alt", "json");
19629 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:markSucceeded";
19630 if self._scopes.is_empty() {
19631 self._scopes
19632 .insert(Scope::CloudPlatform.as_ref().to_string());
19633 }
19634
19635 #[allow(clippy::single_element_loop)]
19636 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19637 url = params.uri_replacement(url, param_name, find_this, true);
19638 }
19639 {
19640 let to_remove = ["name"];
19641 params.remove_params(&to_remove);
19642 }
19643
19644 let url = params.parse_with_url(&url);
19645
19646 let mut json_mime_type = mime::APPLICATION_JSON;
19647 let mut request_value_reader = {
19648 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19649 common::remove_json_null_values(&mut value);
19650 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19651 serde_json::to_writer(&mut dst, &value).unwrap();
19652 dst
19653 };
19654 let request_size = request_value_reader
19655 .seek(std::io::SeekFrom::End(0))
19656 .unwrap();
19657 request_value_reader
19658 .seek(std::io::SeekFrom::Start(0))
19659 .unwrap();
19660
19661 loop {
19662 let token = match self
19663 .hub
19664 .auth
19665 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19666 .await
19667 {
19668 Ok(token) => token,
19669 Err(e) => match dlg.token(e) {
19670 Ok(token) => token,
19671 Err(e) => {
19672 dlg.finished(false);
19673 return Err(common::Error::MissingToken(e));
19674 }
19675 },
19676 };
19677 request_value_reader
19678 .seek(std::io::SeekFrom::Start(0))
19679 .unwrap();
19680 let mut req_result = {
19681 let client = &self.hub.client;
19682 dlg.pre_request();
19683 let mut req_builder = hyper::Request::builder()
19684 .method(hyper::Method::POST)
19685 .uri(url.as_str())
19686 .header(USER_AGENT, self.hub._user_agent.clone());
19687
19688 if let Some(token) = token.as_ref() {
19689 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19690 }
19691
19692 let request = req_builder
19693 .header(CONTENT_TYPE, json_mime_type.to_string())
19694 .header(CONTENT_LENGTH, request_size as u64)
19695 .body(common::to_body(
19696 request_value_reader.get_ref().clone().into(),
19697 ));
19698
19699 client.request(request.unwrap()).await
19700 };
19701
19702 match req_result {
19703 Err(err) => {
19704 if let common::Retry::After(d) = dlg.http_error(&err) {
19705 sleep(d).await;
19706 continue;
19707 }
19708 dlg.finished(false);
19709 return Err(common::Error::HttpError(err));
19710 }
19711 Ok(res) => {
19712 let (mut parts, body) = res.into_parts();
19713 let mut body = common::Body::new(body);
19714 if !parts.status.is_success() {
19715 let bytes = common::to_bytes(body).await.unwrap_or_default();
19716 let error = serde_json::from_str(&common::to_string(&bytes));
19717 let response = common::to_response(parts, bytes.into());
19718
19719 if let common::Retry::After(d) =
19720 dlg.http_failure(&response, error.as_ref().ok())
19721 {
19722 sleep(d).await;
19723 continue;
19724 }
19725
19726 dlg.finished(false);
19727
19728 return Err(match error {
19729 Ok(value) => common::Error::BadRequest(value),
19730 _ => common::Error::Failure(response),
19731 });
19732 }
19733 let response = {
19734 let bytes = common::to_bytes(body).await.unwrap_or_default();
19735 let encoded = common::to_string(&bytes);
19736 match serde_json::from_str(&encoded) {
19737 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19738 Err(error) => {
19739 dlg.response_json_decode_error(&encoded, &error);
19740 return Err(common::Error::JsonDecodeError(
19741 encoded.to_string(),
19742 error,
19743 ));
19744 }
19745 }
19746 };
19747
19748 dlg.finished(true);
19749 return Ok(response);
19750 }
19751 }
19752 }
19753 }
19754
19755 ///
19756 /// Sets the *request* property to the given value.
19757 ///
19758 /// Even though the property as already been set when instantiating this call,
19759 /// we provide this method for API completeness.
19760 pub fn request(
19761 mut self,
19762 new_value: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
19763 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
19764 self._request = new_value;
19765 self
19766 }
19767 /// Required. Name of the recommendation.
19768 ///
19769 /// Sets the *name* path property to the given value.
19770 ///
19771 /// Even though the property as already been set when instantiating this call,
19772 /// we provide this method for API completeness.
19773 pub fn name(
19774 mut self,
19775 new_value: &str,
19776 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
19777 self._name = new_value.to_string();
19778 self
19779 }
19780 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19781 /// while executing the actual API request.
19782 ///
19783 /// ````text
19784 /// It should be used to handle progress information, and to implement a certain level of resilience.
19785 /// ````
19786 ///
19787 /// Sets the *delegate* property to the given value.
19788 pub fn delegate(
19789 mut self,
19790 new_value: &'a mut dyn common::Delegate,
19791 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
19792 self._delegate = Some(new_value);
19793 self
19794 }
19795
19796 /// Set any additional parameter of the query string used in the request.
19797 /// It should be used to set parameters which are not yet available through their own
19798 /// setters.
19799 ///
19800 /// Please note that this method must not be used to set any of the known parameters
19801 /// which have their own setter method. If done anyway, the request will fail.
19802 ///
19803 /// # Additional Parameters
19804 ///
19805 /// * *$.xgafv* (query-string) - V1 error format.
19806 /// * *access_token* (query-string) - OAuth access token.
19807 /// * *alt* (query-string) - Data format for response.
19808 /// * *callback* (query-string) - JSONP
19809 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19810 /// * *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.
19811 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19812 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19813 /// * *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.
19814 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19815 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19816 pub fn param<T>(
19817 mut self,
19818 name: T,
19819 value: T,
19820 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
19821 where
19822 T: AsRef<str>,
19823 {
19824 self._additional_params
19825 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19826 self
19827 }
19828
19829 /// Identifies the authorization scope for the method you are building.
19830 ///
19831 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19832 /// [`Scope::CloudPlatform`].
19833 ///
19834 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19835 /// tokens for more than one scope.
19836 ///
19837 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19838 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19839 /// sufficient, a read-write scope will do as well.
19840 pub fn add_scope<St>(
19841 mut self,
19842 scope: St,
19843 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
19844 where
19845 St: AsRef<str>,
19846 {
19847 self._scopes.insert(String::from(scope.as_ref()));
19848 self
19849 }
19850 /// Identifies the authorization scope(s) for the method you are building.
19851 ///
19852 /// See [`Self::add_scope()`] for details.
19853 pub fn add_scopes<I, St>(
19854 mut self,
19855 scopes: I,
19856 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C>
19857 where
19858 I: IntoIterator<Item = St>,
19859 St: AsRef<str>,
19860 {
19861 self._scopes
19862 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19863 self
19864 }
19865
19866 /// Removes all scopes, and no default scope will be used either.
19867 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19868 /// for details).
19869 pub fn clear_scopes(
19870 mut self,
19871 ) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, C> {
19872 self._scopes.clear();
19873 self
19874 }
19875}
19876
19877/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
19878///
19879/// A builder for the *locations.recommenders.getConfig* method supported by a *project* resource.
19880/// It is not used directly, but through a [`ProjectMethods`] instance.
19881///
19882/// # Example
19883///
19884/// Instantiate a resource method builder
19885///
19886/// ```test_harness,no_run
19887/// # extern crate hyper;
19888/// # extern crate hyper_rustls;
19889/// # extern crate google_recommender1_beta1 as recommender1_beta1;
19890/// # async fn dox() {
19891/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19892///
19893/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19894/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19895/// # .with_native_roots()
19896/// # .unwrap()
19897/// # .https_only()
19898/// # .enable_http2()
19899/// # .build();
19900///
19901/// # let executor = hyper_util::rt::TokioExecutor::new();
19902/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19903/// # secret,
19904/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19905/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19906/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19907/// # ),
19908/// # ).build().await.unwrap();
19909///
19910/// # let client = hyper_util::client::legacy::Client::builder(
19911/// # hyper_util::rt::TokioExecutor::new()
19912/// # )
19913/// # .build(
19914/// # hyper_rustls::HttpsConnectorBuilder::new()
19915/// # .with_native_roots()
19916/// # .unwrap()
19917/// # .https_or_http()
19918/// # .enable_http2()
19919/// # .build()
19920/// # );
19921/// # let mut hub = Recommender::new(client, auth);
19922/// // You can configure optional parameters by calling the respective setters at will, and
19923/// // execute the final call using `doit()`.
19924/// // Values shown here are possibly random and not representative !
19925/// let result = hub.projects().locations_recommenders_get_config("name")
19926/// .doit().await;
19927/// # }
19928/// ```
19929pub struct ProjectLocationRecommenderGetConfigCall<'a, C>
19930where
19931 C: 'a,
19932{
19933 hub: &'a Recommender<C>,
19934 _name: String,
19935 _delegate: Option<&'a mut dyn common::Delegate>,
19936 _additional_params: HashMap<String, String>,
19937 _scopes: BTreeSet<String>,
19938}
19939
19940impl<'a, C> common::CallBuilder for ProjectLocationRecommenderGetConfigCall<'a, C> {}
19941
19942impl<'a, C> ProjectLocationRecommenderGetConfigCall<'a, C>
19943where
19944 C: common::Connector,
19945{
19946 /// Perform the operation you have build so far.
19947 pub async fn doit(
19948 mut self,
19949 ) -> common::Result<(
19950 common::Response,
19951 GoogleCloudRecommenderV1beta1RecommenderConfig,
19952 )> {
19953 use std::borrow::Cow;
19954 use std::io::{Read, Seek};
19955
19956 use common::{url::Params, ToParts};
19957 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19958
19959 let mut dd = common::DefaultDelegate;
19960 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19961 dlg.begin(common::MethodInfo {
19962 id: "recommender.projects.locations.recommenders.getConfig",
19963 http_method: hyper::Method::GET,
19964 });
19965
19966 for &field in ["alt", "name"].iter() {
19967 if self._additional_params.contains_key(field) {
19968 dlg.finished(false);
19969 return Err(common::Error::FieldClash(field));
19970 }
19971 }
19972
19973 let mut params = Params::with_capacity(3 + self._additional_params.len());
19974 params.push("name", self._name);
19975
19976 params.extend(self._additional_params.iter());
19977
19978 params.push("alt", "json");
19979 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
19980 if self._scopes.is_empty() {
19981 self._scopes
19982 .insert(Scope::CloudPlatform.as_ref().to_string());
19983 }
19984
19985 #[allow(clippy::single_element_loop)]
19986 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19987 url = params.uri_replacement(url, param_name, find_this, true);
19988 }
19989 {
19990 let to_remove = ["name"];
19991 params.remove_params(&to_remove);
19992 }
19993
19994 let url = params.parse_with_url(&url);
19995
19996 loop {
19997 let token = match self
19998 .hub
19999 .auth
20000 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20001 .await
20002 {
20003 Ok(token) => token,
20004 Err(e) => match dlg.token(e) {
20005 Ok(token) => token,
20006 Err(e) => {
20007 dlg.finished(false);
20008 return Err(common::Error::MissingToken(e));
20009 }
20010 },
20011 };
20012 let mut req_result = {
20013 let client = &self.hub.client;
20014 dlg.pre_request();
20015 let mut req_builder = hyper::Request::builder()
20016 .method(hyper::Method::GET)
20017 .uri(url.as_str())
20018 .header(USER_AGENT, self.hub._user_agent.clone());
20019
20020 if let Some(token) = token.as_ref() {
20021 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20022 }
20023
20024 let request = req_builder
20025 .header(CONTENT_LENGTH, 0_u64)
20026 .body(common::to_body::<String>(None));
20027
20028 client.request(request.unwrap()).await
20029 };
20030
20031 match req_result {
20032 Err(err) => {
20033 if let common::Retry::After(d) = dlg.http_error(&err) {
20034 sleep(d).await;
20035 continue;
20036 }
20037 dlg.finished(false);
20038 return Err(common::Error::HttpError(err));
20039 }
20040 Ok(res) => {
20041 let (mut parts, body) = res.into_parts();
20042 let mut body = common::Body::new(body);
20043 if !parts.status.is_success() {
20044 let bytes = common::to_bytes(body).await.unwrap_or_default();
20045 let error = serde_json::from_str(&common::to_string(&bytes));
20046 let response = common::to_response(parts, bytes.into());
20047
20048 if let common::Retry::After(d) =
20049 dlg.http_failure(&response, error.as_ref().ok())
20050 {
20051 sleep(d).await;
20052 continue;
20053 }
20054
20055 dlg.finished(false);
20056
20057 return Err(match error {
20058 Ok(value) => common::Error::BadRequest(value),
20059 _ => common::Error::Failure(response),
20060 });
20061 }
20062 let response = {
20063 let bytes = common::to_bytes(body).await.unwrap_or_default();
20064 let encoded = common::to_string(&bytes);
20065 match serde_json::from_str(&encoded) {
20066 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20067 Err(error) => {
20068 dlg.response_json_decode_error(&encoded, &error);
20069 return Err(common::Error::JsonDecodeError(
20070 encoded.to_string(),
20071 error,
20072 ));
20073 }
20074 }
20075 };
20076
20077 dlg.finished(true);
20078 return Ok(response);
20079 }
20080 }
20081 }
20082 }
20083
20084 /// 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`
20085 ///
20086 /// Sets the *name* path property to the given value.
20087 ///
20088 /// Even though the property as already been set when instantiating this call,
20089 /// we provide this method for API completeness.
20090 pub fn name(mut self, new_value: &str) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
20091 self._name = new_value.to_string();
20092 self
20093 }
20094 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20095 /// while executing the actual API request.
20096 ///
20097 /// ````text
20098 /// It should be used to handle progress information, and to implement a certain level of resilience.
20099 /// ````
20100 ///
20101 /// Sets the *delegate* property to the given value.
20102 pub fn delegate(
20103 mut self,
20104 new_value: &'a mut dyn common::Delegate,
20105 ) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
20106 self._delegate = Some(new_value);
20107 self
20108 }
20109
20110 /// Set any additional parameter of the query string used in the request.
20111 /// It should be used to set parameters which are not yet available through their own
20112 /// setters.
20113 ///
20114 /// Please note that this method must not be used to set any of the known parameters
20115 /// which have their own setter method. If done anyway, the request will fail.
20116 ///
20117 /// # Additional Parameters
20118 ///
20119 /// * *$.xgafv* (query-string) - V1 error format.
20120 /// * *access_token* (query-string) - OAuth access token.
20121 /// * *alt* (query-string) - Data format for response.
20122 /// * *callback* (query-string) - JSONP
20123 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20124 /// * *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.
20125 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20126 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20127 /// * *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.
20128 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20129 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20130 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderGetConfigCall<'a, C>
20131 where
20132 T: AsRef<str>,
20133 {
20134 self._additional_params
20135 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20136 self
20137 }
20138
20139 /// Identifies the authorization scope for the method you are building.
20140 ///
20141 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20142 /// [`Scope::CloudPlatform`].
20143 ///
20144 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20145 /// tokens for more than one scope.
20146 ///
20147 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20148 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20149 /// sufficient, a read-write scope will do as well.
20150 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRecommenderGetConfigCall<'a, C>
20151 where
20152 St: AsRef<str>,
20153 {
20154 self._scopes.insert(String::from(scope.as_ref()));
20155 self
20156 }
20157 /// Identifies the authorization scope(s) for the method you are building.
20158 ///
20159 /// See [`Self::add_scope()`] for details.
20160 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderGetConfigCall<'a, C>
20161 where
20162 I: IntoIterator<Item = St>,
20163 St: AsRef<str>,
20164 {
20165 self._scopes
20166 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20167 self
20168 }
20169
20170 /// Removes all scopes, and no default scope will be used either.
20171 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20172 /// for details).
20173 pub fn clear_scopes(mut self) -> ProjectLocationRecommenderGetConfigCall<'a, C> {
20174 self._scopes.clear();
20175 self
20176 }
20177}
20178
20179/// Updates a Recommender Config. This will create a new revision of the config.
20180///
20181/// A builder for the *locations.recommenders.updateConfig* method supported by a *project* resource.
20182/// It is not used directly, but through a [`ProjectMethods`] instance.
20183///
20184/// # Example
20185///
20186/// Instantiate a resource method builder
20187///
20188/// ```test_harness,no_run
20189/// # extern crate hyper;
20190/// # extern crate hyper_rustls;
20191/// # extern crate google_recommender1_beta1 as recommender1_beta1;
20192/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1RecommenderConfig;
20193/// # async fn dox() {
20194/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20195///
20196/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20197/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20198/// # .with_native_roots()
20199/// # .unwrap()
20200/// # .https_only()
20201/// # .enable_http2()
20202/// # .build();
20203///
20204/// # let executor = hyper_util::rt::TokioExecutor::new();
20205/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20206/// # secret,
20207/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20208/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20209/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20210/// # ),
20211/// # ).build().await.unwrap();
20212///
20213/// # let client = hyper_util::client::legacy::Client::builder(
20214/// # hyper_util::rt::TokioExecutor::new()
20215/// # )
20216/// # .build(
20217/// # hyper_rustls::HttpsConnectorBuilder::new()
20218/// # .with_native_roots()
20219/// # .unwrap()
20220/// # .https_or_http()
20221/// # .enable_http2()
20222/// # .build()
20223/// # );
20224/// # let mut hub = Recommender::new(client, auth);
20225/// // As the method needs a request, you would usually fill it with the desired information
20226/// // into the respective structure. Some of the parts shown here might not be applicable !
20227/// // Values shown here are possibly random and not representative !
20228/// let mut req = GoogleCloudRecommenderV1beta1RecommenderConfig::default();
20229///
20230/// // You can configure optional parameters by calling the respective setters at will, and
20231/// // execute the final call using `doit()`.
20232/// // Values shown here are possibly random and not representative !
20233/// let result = hub.projects().locations_recommenders_update_config(req, "name")
20234/// .validate_only(true)
20235/// .update_mask(FieldMask::new::<&str>(&[]))
20236/// .doit().await;
20237/// # }
20238/// ```
20239pub struct ProjectLocationRecommenderUpdateConfigCall<'a, C>
20240where
20241 C: 'a,
20242{
20243 hub: &'a Recommender<C>,
20244 _request: GoogleCloudRecommenderV1beta1RecommenderConfig,
20245 _name: String,
20246 _validate_only: Option<bool>,
20247 _update_mask: Option<common::FieldMask>,
20248 _delegate: Option<&'a mut dyn common::Delegate>,
20249 _additional_params: HashMap<String, String>,
20250 _scopes: BTreeSet<String>,
20251}
20252
20253impl<'a, C> common::CallBuilder for ProjectLocationRecommenderUpdateConfigCall<'a, C> {}
20254
20255impl<'a, C> ProjectLocationRecommenderUpdateConfigCall<'a, C>
20256where
20257 C: common::Connector,
20258{
20259 /// Perform the operation you have build so far.
20260 pub async fn doit(
20261 mut self,
20262 ) -> common::Result<(
20263 common::Response,
20264 GoogleCloudRecommenderV1beta1RecommenderConfig,
20265 )> {
20266 use std::borrow::Cow;
20267 use std::io::{Read, Seek};
20268
20269 use common::{url::Params, ToParts};
20270 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20271
20272 let mut dd = common::DefaultDelegate;
20273 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20274 dlg.begin(common::MethodInfo {
20275 id: "recommender.projects.locations.recommenders.updateConfig",
20276 http_method: hyper::Method::PATCH,
20277 });
20278
20279 for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
20280 if self._additional_params.contains_key(field) {
20281 dlg.finished(false);
20282 return Err(common::Error::FieldClash(field));
20283 }
20284 }
20285
20286 let mut params = Params::with_capacity(6 + self._additional_params.len());
20287 params.push("name", self._name);
20288 if let Some(value) = self._validate_only.as_ref() {
20289 params.push("validateOnly", value.to_string());
20290 }
20291 if let Some(value) = self._update_mask.as_ref() {
20292 params.push("updateMask", value.to_string());
20293 }
20294
20295 params.extend(self._additional_params.iter());
20296
20297 params.push("alt", "json");
20298 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
20299 if self._scopes.is_empty() {
20300 self._scopes
20301 .insert(Scope::CloudPlatform.as_ref().to_string());
20302 }
20303
20304 #[allow(clippy::single_element_loop)]
20305 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20306 url = params.uri_replacement(url, param_name, find_this, true);
20307 }
20308 {
20309 let to_remove = ["name"];
20310 params.remove_params(&to_remove);
20311 }
20312
20313 let url = params.parse_with_url(&url);
20314
20315 let mut json_mime_type = mime::APPLICATION_JSON;
20316 let mut request_value_reader = {
20317 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20318 common::remove_json_null_values(&mut value);
20319 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20320 serde_json::to_writer(&mut dst, &value).unwrap();
20321 dst
20322 };
20323 let request_size = request_value_reader
20324 .seek(std::io::SeekFrom::End(0))
20325 .unwrap();
20326 request_value_reader
20327 .seek(std::io::SeekFrom::Start(0))
20328 .unwrap();
20329
20330 loop {
20331 let token = match self
20332 .hub
20333 .auth
20334 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20335 .await
20336 {
20337 Ok(token) => token,
20338 Err(e) => match dlg.token(e) {
20339 Ok(token) => token,
20340 Err(e) => {
20341 dlg.finished(false);
20342 return Err(common::Error::MissingToken(e));
20343 }
20344 },
20345 };
20346 request_value_reader
20347 .seek(std::io::SeekFrom::Start(0))
20348 .unwrap();
20349 let mut req_result = {
20350 let client = &self.hub.client;
20351 dlg.pre_request();
20352 let mut req_builder = hyper::Request::builder()
20353 .method(hyper::Method::PATCH)
20354 .uri(url.as_str())
20355 .header(USER_AGENT, self.hub._user_agent.clone());
20356
20357 if let Some(token) = token.as_ref() {
20358 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20359 }
20360
20361 let request = req_builder
20362 .header(CONTENT_TYPE, json_mime_type.to_string())
20363 .header(CONTENT_LENGTH, request_size as u64)
20364 .body(common::to_body(
20365 request_value_reader.get_ref().clone().into(),
20366 ));
20367
20368 client.request(request.unwrap()).await
20369 };
20370
20371 match req_result {
20372 Err(err) => {
20373 if let common::Retry::After(d) = dlg.http_error(&err) {
20374 sleep(d).await;
20375 continue;
20376 }
20377 dlg.finished(false);
20378 return Err(common::Error::HttpError(err));
20379 }
20380 Ok(res) => {
20381 let (mut parts, body) = res.into_parts();
20382 let mut body = common::Body::new(body);
20383 if !parts.status.is_success() {
20384 let bytes = common::to_bytes(body).await.unwrap_or_default();
20385 let error = serde_json::from_str(&common::to_string(&bytes));
20386 let response = common::to_response(parts, bytes.into());
20387
20388 if let common::Retry::After(d) =
20389 dlg.http_failure(&response, error.as_ref().ok())
20390 {
20391 sleep(d).await;
20392 continue;
20393 }
20394
20395 dlg.finished(false);
20396
20397 return Err(match error {
20398 Ok(value) => common::Error::BadRequest(value),
20399 _ => common::Error::Failure(response),
20400 });
20401 }
20402 let response = {
20403 let bytes = common::to_bytes(body).await.unwrap_or_default();
20404 let encoded = common::to_string(&bytes);
20405 match serde_json::from_str(&encoded) {
20406 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20407 Err(error) => {
20408 dlg.response_json_decode_error(&encoded, &error);
20409 return Err(common::Error::JsonDecodeError(
20410 encoded.to_string(),
20411 error,
20412 ));
20413 }
20414 }
20415 };
20416
20417 dlg.finished(true);
20418 return Ok(response);
20419 }
20420 }
20421 }
20422 }
20423
20424 ///
20425 /// Sets the *request* property to the given value.
20426 ///
20427 /// Even though the property as already been set when instantiating this call,
20428 /// we provide this method for API completeness.
20429 pub fn request(
20430 mut self,
20431 new_value: GoogleCloudRecommenderV1beta1RecommenderConfig,
20432 ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
20433 self._request = new_value;
20434 self
20435 }
20436 /// Identifier. Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
20437 ///
20438 /// Sets the *name* path property to the given value.
20439 ///
20440 /// Even though the property as already been set when instantiating this call,
20441 /// we provide this method for API completeness.
20442 pub fn name(mut self, new_value: &str) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
20443 self._name = new_value.to_string();
20444 self
20445 }
20446 /// If true, validate the request and preview the change, but do not actually update it.
20447 ///
20448 /// Sets the *validate only* query property to the given value.
20449 pub fn validate_only(
20450 mut self,
20451 new_value: bool,
20452 ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
20453 self._validate_only = Some(new_value);
20454 self
20455 }
20456 /// The list of fields to be updated.
20457 ///
20458 /// Sets the *update mask* query property to the given value.
20459 pub fn update_mask(
20460 mut self,
20461 new_value: common::FieldMask,
20462 ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
20463 self._update_mask = Some(new_value);
20464 self
20465 }
20466 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20467 /// while executing the actual API request.
20468 ///
20469 /// ````text
20470 /// It should be used to handle progress information, and to implement a certain level of resilience.
20471 /// ````
20472 ///
20473 /// Sets the *delegate* property to the given value.
20474 pub fn delegate(
20475 mut self,
20476 new_value: &'a mut dyn common::Delegate,
20477 ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
20478 self._delegate = Some(new_value);
20479 self
20480 }
20481
20482 /// Set any additional parameter of the query string used in the request.
20483 /// It should be used to set parameters which are not yet available through their own
20484 /// setters.
20485 ///
20486 /// Please note that this method must not be used to set any of the known parameters
20487 /// which have their own setter method. If done anyway, the request will fail.
20488 ///
20489 /// # Additional Parameters
20490 ///
20491 /// * *$.xgafv* (query-string) - V1 error format.
20492 /// * *access_token* (query-string) - OAuth access token.
20493 /// * *alt* (query-string) - Data format for response.
20494 /// * *callback* (query-string) - JSONP
20495 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20496 /// * *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.
20497 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20498 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20499 /// * *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.
20500 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20501 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20502 pub fn param<T>(
20503 mut self,
20504 name: T,
20505 value: T,
20506 ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C>
20507 where
20508 T: AsRef<str>,
20509 {
20510 self._additional_params
20511 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20512 self
20513 }
20514
20515 /// Identifies the authorization scope for the method you are building.
20516 ///
20517 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20518 /// [`Scope::CloudPlatform`].
20519 ///
20520 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20521 /// tokens for more than one scope.
20522 ///
20523 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20524 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20525 /// sufficient, a read-write scope will do as well.
20526 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRecommenderUpdateConfigCall<'a, C>
20527 where
20528 St: AsRef<str>,
20529 {
20530 self._scopes.insert(String::from(scope.as_ref()));
20531 self
20532 }
20533 /// Identifies the authorization scope(s) for the method you are building.
20534 ///
20535 /// See [`Self::add_scope()`] for details.
20536 pub fn add_scopes<I, St>(
20537 mut self,
20538 scopes: I,
20539 ) -> ProjectLocationRecommenderUpdateConfigCall<'a, C>
20540 where
20541 I: IntoIterator<Item = St>,
20542 St: AsRef<str>,
20543 {
20544 self._scopes
20545 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20546 self
20547 }
20548
20549 /// Removes all scopes, and no default scope will be used either.
20550 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20551 /// for details).
20552 pub fn clear_scopes(mut self) -> ProjectLocationRecommenderUpdateConfigCall<'a, C> {
20553 self._scopes.clear();
20554 self
20555 }
20556}
20557
20558/// Lists locations with recommendations or insights.
20559///
20560/// A builder for the *locations.list* method supported by a *project* resource.
20561/// It is not used directly, but through a [`ProjectMethods`] instance.
20562///
20563/// # Example
20564///
20565/// Instantiate a resource method builder
20566///
20567/// ```test_harness,no_run
20568/// # extern crate hyper;
20569/// # extern crate hyper_rustls;
20570/// # extern crate google_recommender1_beta1 as recommender1_beta1;
20571/// # async fn dox() {
20572/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20573///
20574/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20575/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20576/// # .with_native_roots()
20577/// # .unwrap()
20578/// # .https_only()
20579/// # .enable_http2()
20580/// # .build();
20581///
20582/// # let executor = hyper_util::rt::TokioExecutor::new();
20583/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20584/// # secret,
20585/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20586/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20587/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20588/// # ),
20589/// # ).build().await.unwrap();
20590///
20591/// # let client = hyper_util::client::legacy::Client::builder(
20592/// # hyper_util::rt::TokioExecutor::new()
20593/// # )
20594/// # .build(
20595/// # hyper_rustls::HttpsConnectorBuilder::new()
20596/// # .with_native_roots()
20597/// # .unwrap()
20598/// # .https_or_http()
20599/// # .enable_http2()
20600/// # .build()
20601/// # );
20602/// # let mut hub = Recommender::new(client, auth);
20603/// // You can configure optional parameters by calling the respective setters at will, and
20604/// // execute the final call using `doit()`.
20605/// // Values shown here are possibly random and not representative !
20606/// let result = hub.projects().locations_list("name")
20607/// .page_token("et")
20608/// .page_size(-39)
20609/// .filter("aliquyam")
20610/// .add_extra_location_types("ipsum")
20611/// .doit().await;
20612/// # }
20613/// ```
20614pub struct ProjectLocationListCall<'a, C>
20615where
20616 C: 'a,
20617{
20618 hub: &'a Recommender<C>,
20619 _name: String,
20620 _page_token: Option<String>,
20621 _page_size: Option<i32>,
20622 _filter: Option<String>,
20623 _extra_location_types: Vec<String>,
20624 _delegate: Option<&'a mut dyn common::Delegate>,
20625 _additional_params: HashMap<String, String>,
20626 _scopes: BTreeSet<String>,
20627}
20628
20629impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
20630
20631impl<'a, C> ProjectLocationListCall<'a, C>
20632where
20633 C: common::Connector,
20634{
20635 /// Perform the operation you have build so far.
20636 pub async fn doit(
20637 mut self,
20638 ) -> common::Result<(common::Response, GoogleCloudLocationListLocationsResponse)> {
20639 use std::borrow::Cow;
20640 use std::io::{Read, Seek};
20641
20642 use common::{url::Params, ToParts};
20643 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20644
20645 let mut dd = common::DefaultDelegate;
20646 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20647 dlg.begin(common::MethodInfo {
20648 id: "recommender.projects.locations.list",
20649 http_method: hyper::Method::GET,
20650 });
20651
20652 for &field in [
20653 "alt",
20654 "name",
20655 "pageToken",
20656 "pageSize",
20657 "filter",
20658 "extraLocationTypes",
20659 ]
20660 .iter()
20661 {
20662 if self._additional_params.contains_key(field) {
20663 dlg.finished(false);
20664 return Err(common::Error::FieldClash(field));
20665 }
20666 }
20667
20668 let mut params = Params::with_capacity(7 + self._additional_params.len());
20669 params.push("name", self._name);
20670 if let Some(value) = self._page_token.as_ref() {
20671 params.push("pageToken", value);
20672 }
20673 if let Some(value) = self._page_size.as_ref() {
20674 params.push("pageSize", value.to_string());
20675 }
20676 if let Some(value) = self._filter.as_ref() {
20677 params.push("filter", value);
20678 }
20679 if !self._extra_location_types.is_empty() {
20680 for f in self._extra_location_types.iter() {
20681 params.push("extraLocationTypes", f);
20682 }
20683 }
20684
20685 params.extend(self._additional_params.iter());
20686
20687 params.push("alt", "json");
20688 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/locations";
20689 if self._scopes.is_empty() {
20690 self._scopes
20691 .insert(Scope::CloudPlatform.as_ref().to_string());
20692 }
20693
20694 #[allow(clippy::single_element_loop)]
20695 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20696 url = params.uri_replacement(url, param_name, find_this, true);
20697 }
20698 {
20699 let to_remove = ["name"];
20700 params.remove_params(&to_remove);
20701 }
20702
20703 let url = params.parse_with_url(&url);
20704
20705 loop {
20706 let token = match self
20707 .hub
20708 .auth
20709 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20710 .await
20711 {
20712 Ok(token) => token,
20713 Err(e) => match dlg.token(e) {
20714 Ok(token) => token,
20715 Err(e) => {
20716 dlg.finished(false);
20717 return Err(common::Error::MissingToken(e));
20718 }
20719 },
20720 };
20721 let mut req_result = {
20722 let client = &self.hub.client;
20723 dlg.pre_request();
20724 let mut req_builder = hyper::Request::builder()
20725 .method(hyper::Method::GET)
20726 .uri(url.as_str())
20727 .header(USER_AGENT, self.hub._user_agent.clone());
20728
20729 if let Some(token) = token.as_ref() {
20730 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20731 }
20732
20733 let request = req_builder
20734 .header(CONTENT_LENGTH, 0_u64)
20735 .body(common::to_body::<String>(None));
20736
20737 client.request(request.unwrap()).await
20738 };
20739
20740 match req_result {
20741 Err(err) => {
20742 if let common::Retry::After(d) = dlg.http_error(&err) {
20743 sleep(d).await;
20744 continue;
20745 }
20746 dlg.finished(false);
20747 return Err(common::Error::HttpError(err));
20748 }
20749 Ok(res) => {
20750 let (mut parts, body) = res.into_parts();
20751 let mut body = common::Body::new(body);
20752 if !parts.status.is_success() {
20753 let bytes = common::to_bytes(body).await.unwrap_or_default();
20754 let error = serde_json::from_str(&common::to_string(&bytes));
20755 let response = common::to_response(parts, bytes.into());
20756
20757 if let common::Retry::After(d) =
20758 dlg.http_failure(&response, error.as_ref().ok())
20759 {
20760 sleep(d).await;
20761 continue;
20762 }
20763
20764 dlg.finished(false);
20765
20766 return Err(match error {
20767 Ok(value) => common::Error::BadRequest(value),
20768 _ => common::Error::Failure(response),
20769 });
20770 }
20771 let response = {
20772 let bytes = common::to_bytes(body).await.unwrap_or_default();
20773 let encoded = common::to_string(&bytes);
20774 match serde_json::from_str(&encoded) {
20775 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20776 Err(error) => {
20777 dlg.response_json_decode_error(&encoded, &error);
20778 return Err(common::Error::JsonDecodeError(
20779 encoded.to_string(),
20780 error,
20781 ));
20782 }
20783 }
20784 };
20785
20786 dlg.finished(true);
20787 return Ok(response);
20788 }
20789 }
20790 }
20791 }
20792
20793 /// The resource that owns the locations collection, if applicable.
20794 ///
20795 /// Sets the *name* path property to the given value.
20796 ///
20797 /// Even though the property as already been set when instantiating this call,
20798 /// we provide this method for API completeness.
20799 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20800 self._name = new_value.to_string();
20801 self
20802 }
20803 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
20804 ///
20805 /// Sets the *page token* query property to the given value.
20806 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20807 self._page_token = Some(new_value.to_string());
20808 self
20809 }
20810 /// The maximum number of results to return. If not set, the service selects a default.
20811 ///
20812 /// Sets the *page size* query property to the given value.
20813 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
20814 self._page_size = Some(new_value);
20815 self
20816 }
20817 /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
20818 ///
20819 /// Sets the *filter* query property to the given value.
20820 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20821 self._filter = Some(new_value.to_string());
20822 self
20823 }
20824 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
20825 ///
20826 /// Append the given value to the *extra location types* query property.
20827 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20828 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20829 self._extra_location_types.push(new_value.to_string());
20830 self
20831 }
20832 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20833 /// while executing the actual API request.
20834 ///
20835 /// ````text
20836 /// It should be used to handle progress information, and to implement a certain level of resilience.
20837 /// ````
20838 ///
20839 /// Sets the *delegate* property to the given value.
20840 pub fn delegate(
20841 mut self,
20842 new_value: &'a mut dyn common::Delegate,
20843 ) -> ProjectLocationListCall<'a, C> {
20844 self._delegate = Some(new_value);
20845 self
20846 }
20847
20848 /// Set any additional parameter of the query string used in the request.
20849 /// It should be used to set parameters which are not yet available through their own
20850 /// setters.
20851 ///
20852 /// Please note that this method must not be used to set any of the known parameters
20853 /// which have their own setter method. If done anyway, the request will fail.
20854 ///
20855 /// # Additional Parameters
20856 ///
20857 /// * *$.xgafv* (query-string) - V1 error format.
20858 /// * *access_token* (query-string) - OAuth access token.
20859 /// * *alt* (query-string) - Data format for response.
20860 /// * *callback* (query-string) - JSONP
20861 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20862 /// * *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.
20863 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20864 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20865 /// * *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.
20866 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20867 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20868 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
20869 where
20870 T: AsRef<str>,
20871 {
20872 self._additional_params
20873 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20874 self
20875 }
20876
20877 /// Identifies the authorization scope for the method you are building.
20878 ///
20879 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20880 /// [`Scope::CloudPlatform`].
20881 ///
20882 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20883 /// tokens for more than one scope.
20884 ///
20885 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20886 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20887 /// sufficient, a read-write scope will do as well.
20888 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
20889 where
20890 St: AsRef<str>,
20891 {
20892 self._scopes.insert(String::from(scope.as_ref()));
20893 self
20894 }
20895 /// Identifies the authorization scope(s) for the method you are building.
20896 ///
20897 /// See [`Self::add_scope()`] for details.
20898 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
20899 where
20900 I: IntoIterator<Item = St>,
20901 St: AsRef<str>,
20902 {
20903 self._scopes
20904 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20905 self
20906 }
20907
20908 /// Removes all scopes, and no default scope will be used either.
20909 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20910 /// for details).
20911 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
20912 self._scopes.clear();
20913 self
20914 }
20915}
20916
20917/// Lists all available Recommenders. No IAM permissions are required.
20918///
20919/// A builder for the *list* method supported by a *recommender* resource.
20920/// It is not used directly, but through a [`RecommenderMethods`] instance.
20921///
20922/// # Example
20923///
20924/// Instantiate a resource method builder
20925///
20926/// ```test_harness,no_run
20927/// # extern crate hyper;
20928/// # extern crate hyper_rustls;
20929/// # extern crate google_recommender1_beta1 as recommender1_beta1;
20930/// # async fn dox() {
20931/// # use recommender1_beta1::{Recommender, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20932///
20933/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20934/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20935/// # .with_native_roots()
20936/// # .unwrap()
20937/// # .https_only()
20938/// # .enable_http2()
20939/// # .build();
20940///
20941/// # let executor = hyper_util::rt::TokioExecutor::new();
20942/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20943/// # secret,
20944/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20945/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20946/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20947/// # ),
20948/// # ).build().await.unwrap();
20949///
20950/// # let client = hyper_util::client::legacy::Client::builder(
20951/// # hyper_util::rt::TokioExecutor::new()
20952/// # )
20953/// # .build(
20954/// # hyper_rustls::HttpsConnectorBuilder::new()
20955/// # .with_native_roots()
20956/// # .unwrap()
20957/// # .https_or_http()
20958/// # .enable_http2()
20959/// # .build()
20960/// # );
20961/// # let mut hub = Recommender::new(client, auth);
20962/// // You can configure optional parameters by calling the respective setters at will, and
20963/// // execute the final call using `doit()`.
20964/// // Values shown here are possibly random and not representative !
20965/// let result = hub.recommenders().list()
20966/// .page_token("et")
20967/// .page_size(-8)
20968/// .doit().await;
20969/// # }
20970/// ```
20971pub struct RecommenderListCall<'a, C>
20972where
20973 C: 'a,
20974{
20975 hub: &'a Recommender<C>,
20976 _page_token: Option<String>,
20977 _page_size: Option<i32>,
20978 _delegate: Option<&'a mut dyn common::Delegate>,
20979 _additional_params: HashMap<String, String>,
20980 _scopes: BTreeSet<String>,
20981}
20982
20983impl<'a, C> common::CallBuilder for RecommenderListCall<'a, C> {}
20984
20985impl<'a, C> RecommenderListCall<'a, C>
20986where
20987 C: common::Connector,
20988{
20989 /// Perform the operation you have build so far.
20990 pub async fn doit(
20991 mut self,
20992 ) -> common::Result<(
20993 common::Response,
20994 GoogleCloudRecommenderV1beta1ListRecommendersResponse,
20995 )> {
20996 use std::borrow::Cow;
20997 use std::io::{Read, Seek};
20998
20999 use common::{url::Params, ToParts};
21000 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21001
21002 let mut dd = common::DefaultDelegate;
21003 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21004 dlg.begin(common::MethodInfo {
21005 id: "recommender.recommenders.list",
21006 http_method: hyper::Method::GET,
21007 });
21008
21009 for &field in ["alt", "pageToken", "pageSize"].iter() {
21010 if self._additional_params.contains_key(field) {
21011 dlg.finished(false);
21012 return Err(common::Error::FieldClash(field));
21013 }
21014 }
21015
21016 let mut params = Params::with_capacity(4 + self._additional_params.len());
21017 if let Some(value) = self._page_token.as_ref() {
21018 params.push("pageToken", value);
21019 }
21020 if let Some(value) = self._page_size.as_ref() {
21021 params.push("pageSize", value.to_string());
21022 }
21023
21024 params.extend(self._additional_params.iter());
21025
21026 params.push("alt", "json");
21027 let mut url = self.hub._base_url.clone() + "v1beta1/recommenders";
21028 if self._scopes.is_empty() {
21029 self._scopes
21030 .insert(Scope::CloudPlatform.as_ref().to_string());
21031 }
21032
21033 let url = params.parse_with_url(&url);
21034
21035 loop {
21036 let token = match self
21037 .hub
21038 .auth
21039 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21040 .await
21041 {
21042 Ok(token) => token,
21043 Err(e) => match dlg.token(e) {
21044 Ok(token) => token,
21045 Err(e) => {
21046 dlg.finished(false);
21047 return Err(common::Error::MissingToken(e));
21048 }
21049 },
21050 };
21051 let mut req_result = {
21052 let client = &self.hub.client;
21053 dlg.pre_request();
21054 let mut req_builder = hyper::Request::builder()
21055 .method(hyper::Method::GET)
21056 .uri(url.as_str())
21057 .header(USER_AGENT, self.hub._user_agent.clone());
21058
21059 if let Some(token) = token.as_ref() {
21060 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21061 }
21062
21063 let request = req_builder
21064 .header(CONTENT_LENGTH, 0_u64)
21065 .body(common::to_body::<String>(None));
21066
21067 client.request(request.unwrap()).await
21068 };
21069
21070 match req_result {
21071 Err(err) => {
21072 if let common::Retry::After(d) = dlg.http_error(&err) {
21073 sleep(d).await;
21074 continue;
21075 }
21076 dlg.finished(false);
21077 return Err(common::Error::HttpError(err));
21078 }
21079 Ok(res) => {
21080 let (mut parts, body) = res.into_parts();
21081 let mut body = common::Body::new(body);
21082 if !parts.status.is_success() {
21083 let bytes = common::to_bytes(body).await.unwrap_or_default();
21084 let error = serde_json::from_str(&common::to_string(&bytes));
21085 let response = common::to_response(parts, bytes.into());
21086
21087 if let common::Retry::After(d) =
21088 dlg.http_failure(&response, error.as_ref().ok())
21089 {
21090 sleep(d).await;
21091 continue;
21092 }
21093
21094 dlg.finished(false);
21095
21096 return Err(match error {
21097 Ok(value) => common::Error::BadRequest(value),
21098 _ => common::Error::Failure(response),
21099 });
21100 }
21101 let response = {
21102 let bytes = common::to_bytes(body).await.unwrap_or_default();
21103 let encoded = common::to_string(&bytes);
21104 match serde_json::from_str(&encoded) {
21105 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21106 Err(error) => {
21107 dlg.response_json_decode_error(&encoded, &error);
21108 return Err(common::Error::JsonDecodeError(
21109 encoded.to_string(),
21110 error,
21111 ));
21112 }
21113 }
21114 };
21115
21116 dlg.finished(true);
21117 return Ok(response);
21118 }
21119 }
21120 }
21121 }
21122
21123 /// Optional. A page token, received from a previous `ListRecommenders` call. Provide this to retrieve the subsequent page.
21124 ///
21125 /// Sets the *page token* query property to the given value.
21126 pub fn page_token(mut self, new_value: &str) -> RecommenderListCall<'a, C> {
21127 self._page_token = Some(new_value.to_string());
21128 self
21129 }
21130 /// Optional. The number of RecommenderTypes to return per page. The service may return fewer than this value.
21131 ///
21132 /// Sets the *page size* query property to the given value.
21133 pub fn page_size(mut self, new_value: i32) -> RecommenderListCall<'a, C> {
21134 self._page_size = Some(new_value);
21135 self
21136 }
21137 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21138 /// while executing the actual API request.
21139 ///
21140 /// ````text
21141 /// It should be used to handle progress information, and to implement a certain level of resilience.
21142 /// ````
21143 ///
21144 /// Sets the *delegate* property to the given value.
21145 pub fn delegate(
21146 mut self,
21147 new_value: &'a mut dyn common::Delegate,
21148 ) -> RecommenderListCall<'a, C> {
21149 self._delegate = Some(new_value);
21150 self
21151 }
21152
21153 /// Set any additional parameter of the query string used in the request.
21154 /// It should be used to set parameters which are not yet available through their own
21155 /// setters.
21156 ///
21157 /// Please note that this method must not be used to set any of the known parameters
21158 /// which have their own setter method. If done anyway, the request will fail.
21159 ///
21160 /// # Additional Parameters
21161 ///
21162 /// * *$.xgafv* (query-string) - V1 error format.
21163 /// * *access_token* (query-string) - OAuth access token.
21164 /// * *alt* (query-string) - Data format for response.
21165 /// * *callback* (query-string) - JSONP
21166 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21167 /// * *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.
21168 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21169 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21170 /// * *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.
21171 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21172 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21173 pub fn param<T>(mut self, name: T, value: T) -> RecommenderListCall<'a, C>
21174 where
21175 T: AsRef<str>,
21176 {
21177 self._additional_params
21178 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21179 self
21180 }
21181
21182 /// Identifies the authorization scope for the method you are building.
21183 ///
21184 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21185 /// [`Scope::CloudPlatform`].
21186 ///
21187 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21188 /// tokens for more than one scope.
21189 ///
21190 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21191 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21192 /// sufficient, a read-write scope will do as well.
21193 pub fn add_scope<St>(mut self, scope: St) -> RecommenderListCall<'a, C>
21194 where
21195 St: AsRef<str>,
21196 {
21197 self._scopes.insert(String::from(scope.as_ref()));
21198 self
21199 }
21200 /// Identifies the authorization scope(s) for the method you are building.
21201 ///
21202 /// See [`Self::add_scope()`] for details.
21203 pub fn add_scopes<I, St>(mut self, scopes: I) -> RecommenderListCall<'a, C>
21204 where
21205 I: IntoIterator<Item = St>,
21206 St: AsRef<str>,
21207 {
21208 self._scopes
21209 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21210 self
21211 }
21212
21213 /// Removes all scopes, and no default scope will be used either.
21214 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21215 /// for details).
21216 pub fn clear_scopes(mut self) -> RecommenderListCall<'a, C> {
21217 self._scopes.clear();
21218 self
21219 }
21220}