google_recommendationengine1_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 RecommendationsAI 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_recommendationengine1_beta1 as recommendationengine1_beta1;
49/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest;
50/// use recommendationengine1_beta1::{Result, Error};
51/// # async fn dox() {
52/// use recommendationengine1_beta1::{RecommendationsAI, 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 = RecommendationsAI::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 = GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest::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.projects().locations_catalogs_catalog_items_import(req, "parent")
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 RecommendationsAI<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 RecommendationsAI<C> {}
130
131impl<'a, C> RecommendationsAI<C> {
132 pub fn new<A: 'static + common::GetToken>(
133 client: common::Client<C>,
134 auth: A,
135 ) -> RecommendationsAI<C> {
136 RecommendationsAI {
137 client,
138 auth: Box::new(auth),
139 _user_agent: "google-api-rust-client/7.0.0".to_string(),
140 _base_url: "https://recommendationengine.googleapis.com/".to_string(),
141 _root_url: "https://recommendationengine.googleapis.com/".to_string(),
142 }
143 }
144
145 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
146 ProjectMethods { hub: self }
147 }
148
149 /// Set the user-agent header field to use in all requests to the server.
150 /// It defaults to `google-api-rust-client/7.0.0`.
151 ///
152 /// Returns the previously set user-agent.
153 pub fn user_agent(&mut self, agent_name: String) -> String {
154 std::mem::replace(&mut self._user_agent, agent_name)
155 }
156
157 /// Set the base url to use in all requests to the server.
158 /// It defaults to `https://recommendationengine.googleapis.com/`.
159 ///
160 /// Returns the previously set base url.
161 pub fn base_url(&mut self, new_base_url: String) -> String {
162 std::mem::replace(&mut self._base_url, new_base_url)
163 }
164
165 /// Set the root url to use in all requests to the server.
166 /// It defaults to `https://recommendationengine.googleapis.com/`.
167 ///
168 /// Returns the previously set root url.
169 pub fn root_url(&mut self, new_root_url: String) -> String {
170 std::mem::replace(&mut self._root_url, new_root_url)
171 }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// Message that represents an arbitrary HTTP body. It should only be used for payload formats that can’t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
178///
179/// # Activities
180///
181/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
182/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
183///
184/// * [locations catalogs event stores user events collect projects](ProjectLocationCatalogEventStoreUserEventCollectCall) (response)
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct GoogleApiHttpBody {
189 /// The HTTP Content-Type header value specifying the content type of the body.
190 #[serde(rename = "contentType")]
191 pub content_type: Option<String>,
192 /// The HTTP request/response body as raw binary.
193 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
194 pub data: Option<Vec<u8>>,
195 /// Application specific response metadata. Must be set in the first response for streaming APIs.
196 pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
197}
198
199impl common::ResponseResult for GoogleApiHttpBody {}
200
201/// BigQuery source import data from.
202///
203/// This type is not used in any activity, and only used as *part* of another schema.
204///
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct GoogleCloudRecommendationengineV1beta1BigQuerySource {
209 /// Optional. The schema to use when parsing the data from the source. Supported values for catalog imports: 1: "catalog_recommendations_ai" using https://cloud.google.com/recommendations-ai/docs/upload-catalog#json (Default for catalogItems.import) 2: "catalog_merchant_center" using https://cloud.google.com/recommendations-ai/docs/upload-catalog#mc Supported values for user event imports: 1: "user_events_recommendations_ai" using https://cloud.google.com/recommendations-ai/docs/manage-user-events#import (Default for userEvents.import) 2. "user_events_ga360" using https://support.google.com/analytics/answer/3437719?hl=en
210 #[serde(rename = "dataSchema")]
211 pub data_schema: Option<String>,
212 /// Required. The BigQuery data set to copy the data from.
213 #[serde(rename = "datasetId")]
214 pub dataset_id: Option<String>,
215 /// Optional. Intermediate Cloud Storage directory used for the import. Can be specified if one wants to have the BigQuery export to a specific Cloud Storage directory.
216 #[serde(rename = "gcsStagingDir")]
217 pub gcs_staging_dir: Option<String>,
218 /// Optional. The project id (can be project # or id) that the BigQuery source is in. If not specified, inherits the project id from the parent request.
219 #[serde(rename = "projectId")]
220 pub project_id: Option<String>,
221 /// Required. The BigQuery table to copy the data from.
222 #[serde(rename = "tableId")]
223 pub table_id: Option<String>,
224}
225
226impl common::Part for GoogleCloudRecommendationengineV1beta1BigQuerySource {}
227
228/// The catalog configuration. Next ID: 5.
229///
230/// # Activities
231///
232/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
233/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
234///
235/// * [locations catalogs patch projects](ProjectLocationCatalogPatchCall) (request|response)
236#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
237#[serde_with::serde_as]
238#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
239pub struct GoogleCloudRecommendationengineV1beta1Catalog {
240 /// Required. The catalog item level configuration.
241 #[serde(rename = "catalogItemLevelConfig")]
242 pub catalog_item_level_config:
243 Option<GoogleCloudRecommendationengineV1beta1CatalogItemLevelConfig>,
244 /// Required. The ID of the default event store.
245 #[serde(rename = "defaultEventStoreId")]
246 pub default_event_store_id: Option<String>,
247 /// Required. The catalog display name.
248 #[serde(rename = "displayName")]
249 pub display_name: Option<String>,
250 /// The fully qualified resource name of the catalog.
251 pub name: Option<String>,
252}
253
254impl common::RequestValue for GoogleCloudRecommendationengineV1beta1Catalog {}
255impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1Catalog {}
256
257/// The inline source for the input config for ImportCatalogItems method.
258///
259/// This type is not used in any activity, and only used as *part* of another schema.
260///
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct GoogleCloudRecommendationengineV1beta1CatalogInlineSource {
265 /// Optional. A list of catalog items to update/create. Recommended max of 10k items.
266 #[serde(rename = "catalogItems")]
267 pub catalog_items: Option<Vec<GoogleCloudRecommendationengineV1beta1CatalogItem>>,
268}
269
270impl common::Part for GoogleCloudRecommendationengineV1beta1CatalogInlineSource {}
271
272/// CatalogItem captures all metadata information of items to be recommended.
273///
274/// # Activities
275///
276/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
277/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
278///
279/// * [locations catalogs catalog items create projects](ProjectLocationCatalogCatalogItemCreateCall) (request|response)
280/// * [locations catalogs catalog items get projects](ProjectLocationCatalogCatalogItemGetCall) (response)
281/// * [locations catalogs catalog items patch projects](ProjectLocationCatalogCatalogItemPatchCall) (request|response)
282#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
283#[serde_with::serde_as]
284#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
285pub struct GoogleCloudRecommendationengineV1beta1CatalogItem {
286 /// Required. Catalog item categories. This field is repeated for supporting one catalog item belonging to several parallel category hierarchies. For example, if a shoes product belongs to both ["Shoes & Accessories" -> "Shoes"] and ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be represented as: "categoryHierarchies": [ { "categories": ["Shoes & Accessories", "Shoes"]}, { "categories": ["Sports & Fitness", "Athletic Clothing", "Shoes"] } ]
287 #[serde(rename = "categoryHierarchies")]
288 pub category_hierarchies:
289 Option<Vec<GoogleCloudRecommendationengineV1beta1CatalogItemCategoryHierarchy>>,
290 /// Optional. Catalog item description. UTF-8 encoded string with a length limit of 5 KiB.
291 pub description: Option<String>,
292 /// Required. Catalog item identifier. UTF-8 encoded string with a length limit of 128 bytes. This id must be unique among all catalog items within the same catalog. It should also be used when logging user events in order for the user events to be joined with the Catalog.
293 pub id: Option<String>,
294 /// Optional. Highly encouraged. Extra catalog item attributes to be included in the recommendation model. For example, for retail products, this could include the store name, vendor, style, color, etc. These are very strong signals for recommendation model, thus we highly recommend providing the item attributes here.
295 #[serde(rename = "itemAttributes")]
296 pub item_attributes: Option<GoogleCloudRecommendationengineV1beta1FeatureMap>,
297 /// Optional. Variant group identifier for prediction results. UTF-8 encoded string with a length limit of 128 bytes. This field must be enabled before it can be used. [Learn more](https://cloud.google.com/recommendations-ai/docs/catalog#item-group-id).
298 #[serde(rename = "itemGroupId")]
299 pub item_group_id: Option<String>,
300 /// Optional. Deprecated. The model automatically detects the text language. Your catalog can include text in different languages, but duplicating catalog items to provide text in multiple languages can result in degraded model performance.
301 #[serde(rename = "languageCode")]
302 pub language_code: Option<String>,
303 /// Optional. Metadata specific to retail products.
304 #[serde(rename = "productMetadata")]
305 pub product_metadata: Option<GoogleCloudRecommendationengineV1beta1ProductCatalogItem>,
306 /// Optional. Filtering tags associated with the catalog item. Each tag should be a UTF-8 encoded string with a length limit of 1 KiB. This tag can be used for filtering recommendation results by passing the tag as part of the predict request filter.
307 pub tags: Option<Vec<String>>,
308 /// Required. Catalog item title. UTF-8 encoded string with a length limit of 1 KiB.
309 pub title: Option<String>,
310}
311
312impl common::RequestValue for GoogleCloudRecommendationengineV1beta1CatalogItem {}
313impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1CatalogItem {}
314
315/// Category represents catalog item category hierarchy.
316///
317/// This type is not used in any activity, and only used as *part* of another schema.
318///
319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
320#[serde_with::serde_as]
321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
322pub struct GoogleCloudRecommendationengineV1beta1CatalogItemCategoryHierarchy {
323 /// Required. Catalog item categories. Each category should be a UTF-8 encoded string with a length limit of 2 KiB. Note that the order in the list denotes the specificity (from least to most specific).
324 pub categories: Option<Vec<String>>,
325}
326
327impl common::Part for GoogleCloudRecommendationengineV1beta1CatalogItemCategoryHierarchy {}
328
329/// Configures the catalog level that users send events to, and the level at which predictions are made.
330///
331/// This type is not used in any activity, and only used as *part* of another schema.
332///
333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
334#[serde_with::serde_as]
335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
336pub struct GoogleCloudRecommendationengineV1beta1CatalogItemLevelConfig {
337 /// Optional. Level of the catalog at which events are uploaded. See https://cloud.google.com/recommendations-ai/docs/catalog#catalog-levels for more details.
338 #[serde(rename = "eventItemLevel")]
339 pub event_item_level: Option<String>,
340 /// Optional. Level of the catalog at which predictions are made. See https://cloud.google.com/recommendations-ai/docs/catalog#catalog-levels for more details.
341 #[serde(rename = "predictItemLevel")]
342 pub predict_item_level: Option<String>,
343}
344
345impl common::Part for GoogleCloudRecommendationengineV1beta1CatalogItemLevelConfig {}
346
347/// Request message for the `CreatePredictionApiKeyRegistration` method.
348///
349/// # Activities
350///
351/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
352/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
353///
354/// * [locations catalogs event stores prediction api key registrations create projects](ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall) (request)
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct GoogleCloudRecommendationengineV1beta1CreatePredictionApiKeyRegistrationRequest {
359 /// Required. The prediction API key registration.
360 #[serde(rename = "predictionApiKeyRegistration")]
361 pub prediction_api_key_registration:
362 Option<GoogleCloudRecommendationengineV1beta1PredictionApiKeyRegistration>,
363}
364
365impl common::RequestValue
366 for GoogleCloudRecommendationengineV1beta1CreatePredictionApiKeyRegistrationRequest
367{
368}
369
370/// User event details shared by all recommendation types.
371///
372/// This type is not used in any activity, and only used as *part* of another schema.
373///
374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
375#[serde_with::serde_as]
376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
377pub struct GoogleCloudRecommendationengineV1beta1EventDetail {
378 /// Optional. Extra user event features to include in the recommendation model. For product recommendation, an example of extra user information is traffic_channel, i.e. how user arrives at the site. Users can arrive at the site by coming to the site directly, or coming through Google search, and etc.
379 #[serde(rename = "eventAttributes")]
380 pub event_attributes: Option<GoogleCloudRecommendationengineV1beta1FeatureMap>,
381 /// Optional. A list of identifiers for the independent experiment groups this user event belongs to. This is used to distinguish between user events associated with different experiment setups (e.g. using Recommendation Engine system, using different recommendation models).
382 #[serde(rename = "experimentIds")]
383 pub experiment_ids: Option<Vec<String>>,
384 /// Optional. A unique id of a web page view. This should be kept the same for all user events triggered from the same pageview. For example, an item detail page view could trigger multiple events as the user is browsing the page. The `pageViewId` property should be kept the same for all these events so that they can be grouped together properly. This `pageViewId` will be automatically generated if using the JavaScript pixel.
385 #[serde(rename = "pageViewId")]
386 pub page_view_id: Option<String>,
387 /// Optional. Recommendation token included in the recommendation prediction response. This field enables accurate attribution of recommendation model performance. This token enables us to accurately attribute page view or purchase back to the event and the particular predict response containing this clicked/purchased item. If user clicks on product K in the recommendation results, pass the `PredictResponse.recommendationToken` property as a url parameter to product K's page. When recording events on product K's page, log the PredictResponse.recommendation_token to this field. Optional, but highly encouraged for user events that are the result of a recommendation prediction query.
388 #[serde(rename = "recommendationToken")]
389 pub recommendation_token: Option<String>,
390 /// Optional. The referrer url of the current page. When using the JavaScript pixel, this value is filled in automatically.
391 #[serde(rename = "referrerUri")]
392 pub referrer_uri: Option<String>,
393 /// Optional. Complete url (window.location.href) of the user's current page. When using the JavaScript pixel, this value is filled in automatically. Maximum length 5KB.
394 pub uri: Option<String>,
395}
396
397impl common::Part for GoogleCloudRecommendationengineV1beta1EventDetail {}
398
399/// FeatureMap represents extra features that customers want to include in the recommendation model for catalogs/user events as categorical/numerical features.
400///
401/// This type is not used in any activity, and only used as *part* of another schema.
402///
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct GoogleCloudRecommendationengineV1beta1FeatureMap {
407 /// Categorical features that can take on one of a limited number of possible values. Some examples would be the brand/maker of a product, or country of a customer. Feature names and values must be UTF-8 encoded strings. For example: `{ "colors": {"value": ["yellow", "green"]}, "sizes": {"value":["S", "M"]}`
408 #[serde(rename = "categoricalFeatures")]
409 pub categorical_features:
410 Option<HashMap<String, GoogleCloudRecommendationengineV1beta1FeatureMapStringList>>,
411 /// Numerical features. Some examples would be the height/weight of a product, or age of a customer. Feature names must be UTF-8 encoded strings. For example: `{ "lengths_cm": {"value":[2.3, 15.4]}, "heights_cm": {"value":[8.1, 6.4]} }`
412 #[serde(rename = "numericalFeatures")]
413 pub numerical_features:
414 Option<HashMap<String, GoogleCloudRecommendationengineV1beta1FeatureMapFloatList>>,
415}
416
417impl common::Part for GoogleCloudRecommendationengineV1beta1FeatureMap {}
418
419/// A list of float features.
420///
421/// This type is not used in any activity, and only used as *part* of another schema.
422///
423#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
424#[serde_with::serde_as]
425#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
426pub struct GoogleCloudRecommendationengineV1beta1FeatureMapFloatList {
427 /// Float feature value.
428 pub value: Option<Vec<f32>>,
429}
430
431impl common::Part for GoogleCloudRecommendationengineV1beta1FeatureMapFloatList {}
432
433/// A list of string features.
434///
435/// This type is not used in any activity, and only used as *part* of another schema.
436///
437#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
438#[serde_with::serde_as]
439#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
440pub struct GoogleCloudRecommendationengineV1beta1FeatureMapStringList {
441 /// String feature value with a length limit of 128 bytes.
442 pub value: Option<Vec<String>>,
443}
444
445impl common::Part for GoogleCloudRecommendationengineV1beta1FeatureMapStringList {}
446
447/// Google Cloud Storage location for input content. format.
448///
449/// This type is not used in any activity, and only used as *part* of another schema.
450///
451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
452#[serde_with::serde_as]
453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
454pub struct GoogleCloudRecommendationengineV1beta1GcsSource {
455 /// Required. Google Cloud Storage URIs to input files. URI can be up to 2000 characters long. URIs can match the full object path (for example, `gs://bucket/directory/object.json`) or a pattern matching one or more files, such as `gs://bucket/directory/*.json`. A request can contain at most 100 files, and each file can be up to 2 GB. See [Importing catalog information](https://cloud.google.com/recommendations-ai/docs/upload-catalog) for the expected file format and setup instructions.
456 #[serde(rename = "inputUris")]
457 pub input_uris: Option<Vec<String>>,
458 /// Optional. The schema to use when parsing the data from the source. Supported values for catalog imports: 1: "catalog_recommendations_ai" using https://cloud.google.com/recommendations-ai/docs/upload-catalog#json (Default for catalogItems.import) 2: "catalog_merchant_center" using https://cloud.google.com/recommendations-ai/docs/upload-catalog#mc Supported values for user events imports: 1: "user_events_recommendations_ai" using https://cloud.google.com/recommendations-ai/docs/manage-user-events#import (Default for userEvents.import) 2. "user_events_ga360" using https://support.google.com/analytics/answer/3437719?hl=en
459 #[serde(rename = "jsonSchema")]
460 pub json_schema: Option<String>,
461}
462
463impl common::Part for GoogleCloudRecommendationengineV1beta1GcsSource {}
464
465/// Catalog item thumbnail/detail image.
466///
467/// This type is not used in any activity, and only used as *part* of another schema.
468///
469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
470#[serde_with::serde_as]
471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
472pub struct GoogleCloudRecommendationengineV1beta1Image {
473 /// Optional. Height of the image in number of pixels.
474 pub height: Option<i32>,
475 /// Required. URL of the image with a length limit of 5 KiB.
476 pub uri: Option<String>,
477 /// Optional. Width of the image in number of pixels.
478 pub width: Option<i32>,
479}
480
481impl common::Part for GoogleCloudRecommendationengineV1beta1Image {}
482
483/// Request message for Import methods.
484///
485/// # Activities
486///
487/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
488/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
489///
490/// * [locations catalogs catalog items import projects](ProjectLocationCatalogCatalogItemImportCall) (request)
491#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
492#[serde_with::serde_as]
493#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
494pub struct GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest {
495 /// Optional. The desired location of errors incurred during the Import.
496 #[serde(rename = "errorsConfig")]
497 pub errors_config: Option<GoogleCloudRecommendationengineV1beta1ImportErrorsConfig>,
498 /// Required. The desired input location of the data.
499 #[serde(rename = "inputConfig")]
500 pub input_config: Option<GoogleCloudRecommendationengineV1beta1InputConfig>,
501 /// Optional. Unique identifier provided by client, within the ancestor dataset scope. Ensures idempotency and used for request deduplication. Server-generated if unspecified. Up to 128 characters long. This is returned as google.longrunning.Operation.name in the response.
502 #[serde(rename = "requestId")]
503 pub request_id: Option<String>,
504 /// Optional. Indicates which fields in the provided imported 'items' to update. If not set, will by default update all fields.
505 #[serde(rename = "updateMask")]
506 pub update_mask: Option<common::FieldMask>,
507}
508
509impl common::RequestValue for GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest {}
510
511/// Configuration of destination for Import related errors.
512///
513/// This type is not used in any activity, and only used as *part* of another schema.
514///
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct GoogleCloudRecommendationengineV1beta1ImportErrorsConfig {
519 /// Google Cloud Storage path for import errors. This must be an empty, existing Cloud Storage bucket. Import errors will be written to a file in this bucket, one per line, as a JSON-encoded `google.rpc.Status` message.
520 #[serde(rename = "gcsPrefix")]
521 pub gcs_prefix: Option<String>,
522}
523
524impl common::Part for GoogleCloudRecommendationengineV1beta1ImportErrorsConfig {}
525
526/// Request message for the ImportUserEvents request.
527///
528/// # Activities
529///
530/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
531/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
532///
533/// * [locations catalogs event stores user events import projects](ProjectLocationCatalogEventStoreUserEventImportCall) (request)
534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
535#[serde_with::serde_as]
536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
537pub struct GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest {
538 /// Optional. The desired location of errors incurred during the Import.
539 #[serde(rename = "errorsConfig")]
540 pub errors_config: Option<GoogleCloudRecommendationengineV1beta1ImportErrorsConfig>,
541 /// Required. The desired input location of the data.
542 #[serde(rename = "inputConfig")]
543 pub input_config: Option<GoogleCloudRecommendationengineV1beta1InputConfig>,
544 /// Optional. Unique identifier provided by client, within the ancestor dataset scope. Ensures idempotency for expensive long running operations. Server-generated if unspecified. Up to 128 characters long. This is returned as google.longrunning.Operation.name in the response. Note that this field must not be set if the desired input config is catalog_inline_source.
545 #[serde(rename = "requestId")]
546 pub request_id: Option<String>,
547}
548
549impl common::RequestValue for GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest {}
550
551/// The input config source.
552///
553/// This type is not used in any activity, and only used as *part* of another schema.
554///
555#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
556#[serde_with::serde_as]
557#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
558pub struct GoogleCloudRecommendationengineV1beta1InputConfig {
559 /// BigQuery input source.
560 #[serde(rename = "bigQuerySource")]
561 pub big_query_source: Option<GoogleCloudRecommendationengineV1beta1BigQuerySource>,
562 /// The Inline source for the input content for Catalog items.
563 #[serde(rename = "catalogInlineSource")]
564 pub catalog_inline_source: Option<GoogleCloudRecommendationengineV1beta1CatalogInlineSource>,
565 /// Google Cloud Storage location for the input content.
566 #[serde(rename = "gcsSource")]
567 pub gcs_source: Option<GoogleCloudRecommendationengineV1beta1GcsSource>,
568 /// The Inline source for the input content for UserEvents.
569 #[serde(rename = "userEventInlineSource")]
570 pub user_event_inline_source:
571 Option<GoogleCloudRecommendationengineV1beta1UserEventInlineSource>,
572}
573
574impl common::Part for GoogleCloudRecommendationengineV1beta1InputConfig {}
575
576/// Response message for ListCatalogItems method.
577///
578/// # Activities
579///
580/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
581/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
582///
583/// * [locations catalogs catalog items list projects](ProjectLocationCatalogCatalogItemListCall) (response)
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct GoogleCloudRecommendationengineV1beta1ListCatalogItemsResponse {
588 /// The catalog items.
589 #[serde(rename = "catalogItems")]
590 pub catalog_items: Option<Vec<GoogleCloudRecommendationengineV1beta1CatalogItem>>,
591 /// If empty, the list is complete. If nonempty, the token to pass to the next request's ListCatalogItemRequest.page_token.
592 #[serde(rename = "nextPageToken")]
593 pub next_page_token: Option<String>,
594}
595
596impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1ListCatalogItemsResponse {}
597
598/// Response for ListCatalogs method.
599///
600/// # Activities
601///
602/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
603/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
604///
605/// * [locations catalogs list projects](ProjectLocationCatalogListCall) (response)
606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
607#[serde_with::serde_as]
608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
609pub struct GoogleCloudRecommendationengineV1beta1ListCatalogsResponse {
610 /// Output only. All the customer's catalogs.
611 pub catalogs: Option<Vec<GoogleCloudRecommendationengineV1beta1Catalog>>,
612 /// Pagination token, if not returned indicates the last page.
613 #[serde(rename = "nextPageToken")]
614 pub next_page_token: Option<String>,
615}
616
617impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1ListCatalogsResponse {}
618
619/// Response message for the `ListPredictionApiKeyRegistrations`.
620///
621/// # Activities
622///
623/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
624/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
625///
626/// * [locations catalogs event stores prediction api key registrations list projects](ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall) (response)
627#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
628#[serde_with::serde_as]
629#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
630pub struct GoogleCloudRecommendationengineV1beta1ListPredictionApiKeyRegistrationsResponse {
631 /// If empty, the list is complete. If nonempty, pass the token to the next request's `ListPredictionApiKeysRegistrationsRequest.pageToken`.
632 #[serde(rename = "nextPageToken")]
633 pub next_page_token: Option<String>,
634 /// The list of registered API keys.
635 #[serde(rename = "predictionApiKeyRegistrations")]
636 pub prediction_api_key_registrations:
637 Option<Vec<GoogleCloudRecommendationengineV1beta1PredictionApiKeyRegistration>>,
638}
639
640impl common::ResponseResult
641 for GoogleCloudRecommendationengineV1beta1ListPredictionApiKeyRegistrationsResponse
642{
643}
644
645/// Response message for ListUserEvents method.
646///
647/// # Activities
648///
649/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
650/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
651///
652/// * [locations catalogs event stores user events list projects](ProjectLocationCatalogEventStoreUserEventListCall) (response)
653#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
654#[serde_with::serde_as]
655#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
656pub struct GoogleCloudRecommendationengineV1beta1ListUserEventsResponse {
657 /// If empty, the list is complete. If nonempty, the token to pass to the next request's ListUserEvents.page_token.
658 #[serde(rename = "nextPageToken")]
659 pub next_page_token: Option<String>,
660 /// The user events.
661 #[serde(rename = "userEvents")]
662 pub user_events: Option<Vec<GoogleCloudRecommendationengineV1beta1UserEvent>>,
663}
664
665impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1ListUserEventsResponse {}
666
667/// Request message for Predict method. Full resource name of the format: `{name=projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/placements/*}` The id of the recommendation engine placement. This id is used to identify the set of models that will be used to make the prediction. We currently support three placements with the following IDs by default: // * `shopping_cart`: Predicts items frequently bought together with one or more catalog items in the same shopping session. Commonly displayed after `add-to-cart` event, on product detail pages, or on the shopping cart page. * `home_page`: Predicts the next product that a user will most likely engage with or purchase based on the shopping or viewing history of the specified `userId` or `visitorId`. For example - Recommendations for you. * `product_detail`: Predicts the next product that a user will most likely engage with or purchase. The prediction is based on the shopping or viewing history of the specified `userId` or `visitorId` and its relevance to a specified `CatalogItem`. Typically used on product detail pages. For example - More items like this. * `recently_viewed_default`: Returns up to 75 items recently viewed by the specified `userId` or `visitorId`, most recent ones first. Returns nothing if neither of them has viewed any items yet. For example - Recently viewed. The full list of available placements can be seen at https://console.cloud.google.com/recommendation/catalogs/default_catalog/placements
668///
669/// # Activities
670///
671/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
672/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
673///
674/// * [locations catalogs event stores placements predict projects](ProjectLocationCatalogEventStorePlacementPredictCall) (request)
675#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
676#[serde_with::serde_as]
677#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
678pub struct GoogleCloudRecommendationengineV1beta1PredictRequest {
679 /// Optional. Use dryRun mode for this prediction query. If set to true, a fake model will be used that returns arbitrary catalog items. Note that the dryRun mode should only be used for testing the API, or if the model is not ready.
680 #[serde(rename = "dryRun")]
681 pub dry_run: Option<bool>,
682 /// Optional. Filter for restricting prediction results. Accepts values for tags and the `filterOutOfStockItems` flag. * Tag expressions. Restricts predictions to items that match all of the specified tags. Boolean operators `OR` and `NOT` are supported if the expression is enclosed in parentheses, and must be separated from the tag values by a space. `-"tagA"` is also supported and is equivalent to `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings with a size limit of 1 KiB. * filterOutOfStockItems. Restricts predictions to items that do not have a stockState value of OUT_OF_STOCK. Examples: * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") * filterOutOfStockItems tag=(-"promotional") * filterOutOfStockItems If your filter blocks all prediction results, nothing will be returned. If you want generic (unfiltered) popular items to be returned instead, set `strictFiltering` to false in `PredictRequest.params`.
683 pub filter: Option<String>,
684 /// Optional. The labels for the predict request. * Label keys can contain lowercase letters, digits and hyphens, must start with a letter, and must end with a letter or digit. * Non-zero label values can contain lowercase letters, digits and hyphens, must start with a letter, and must end with a letter or digit. * No more than 64 labels can be associated with a given request. See https://goo.gl/xmQnxf for more information on and examples of labels.
685 pub labels: Option<HashMap<String, String>>,
686 /// Optional. Maximum number of results to return per page. Set this property to the number of prediction results required. If zero, the service will choose a reasonable default.
687 #[serde(rename = "pageSize")]
688 pub page_size: Option<i32>,
689 /// Optional. The previous PredictResponse.next_page_token.
690 #[serde(rename = "pageToken")]
691 pub page_token: Option<String>,
692 /// Optional. Additional domain specific parameters for the predictions. Allowed values: * `returnCatalogItem`: Boolean. If set to true, the associated catalogItem object will be returned in the `PredictResponse.PredictionResult.itemMetadata` object in the method response. * `returnItemScore`: Boolean. If set to true, the prediction 'score' corresponding to each returned item will be set in the `metadata` field in the prediction response. The given 'score' indicates the probability of an item being clicked/purchased given the user's context and history. * `strictFiltering`: Boolean. True by default. If set to false, the service will return generic (unfiltered) popular items instead of empty if your filter blocks all prediction results. * `priceRerankLevel`: String. Default empty. If set to be non-empty, then it needs to be one of {'no-price-reranking', 'low-price-reranking', 'medium-price-reranking', 'high-price-reranking'}. This gives request level control and adjust prediction results based on product price. * `diversityLevel`: String. Default empty. If set to be non-empty, then it needs to be one of {'no-diversity', 'low-diversity', 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives request level control and adjust prediction results based on product category.
693 pub params: Option<HashMap<String, serde_json::Value>>,
694 /// Required. Context about the user, what they are looking at and what action they took to trigger the predict request. Note that this user event detail won't be ingested to userEvent logs. Thus, a separate userEvent write request is required for event logging. Don't set UserInfo.visitor_id or UserInfo.user_id to the same fixed ID for different users. If you are trying to receive non-personalized recommendations (not recommended; this can negatively impact model performance), instead set UserInfo.visitor_id to a random unique ID and leave UserInfo.user_id unset.
695 #[serde(rename = "userEvent")]
696 pub user_event: Option<GoogleCloudRecommendationengineV1beta1UserEvent>,
697}
698
699impl common::RequestValue for GoogleCloudRecommendationengineV1beta1PredictRequest {}
700
701/// Response message for predict method.
702///
703/// # Activities
704///
705/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
706/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
707///
708/// * [locations catalogs event stores placements predict projects](ProjectLocationCatalogEventStorePlacementPredictCall) (response)
709#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
710#[serde_with::serde_as]
711#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
712pub struct GoogleCloudRecommendationengineV1beta1PredictResponse {
713 /// True if the dryRun property was set in the request.
714 #[serde(rename = "dryRun")]
715 pub dry_run: Option<bool>,
716 /// IDs of items in the request that were missing from the catalog.
717 #[serde(rename = "itemsMissingInCatalog")]
718 pub items_missing_in_catalog: Option<Vec<String>>,
719 /// Additional domain specific prediction response metadata.
720 pub metadata: Option<HashMap<String, serde_json::Value>>,
721 /// If empty, the list is complete. If nonempty, the token to pass to the next request's PredictRequest.page_token.
722 #[serde(rename = "nextPageToken")]
723 pub next_page_token: Option<String>,
724 /// A unique recommendation token. This should be included in the user event logs resulting from this recommendation, which enables accurate attribution of recommendation model performance.
725 #[serde(rename = "recommendationToken")]
726 pub recommendation_token: Option<String>,
727 /// A list of recommended items. The order represents the ranking (from the most relevant item to the least).
728 pub results: Option<Vec<GoogleCloudRecommendationengineV1beta1PredictResponsePredictionResult>>,
729}
730
731impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1PredictResponse {}
732
733/// PredictionResult represents the recommendation prediction results.
734///
735/// This type is not used in any activity, and only used as *part* of another schema.
736///
737#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
738#[serde_with::serde_as]
739#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
740pub struct GoogleCloudRecommendationengineV1beta1PredictResponsePredictionResult {
741 /// ID of the recommended catalog item
742 pub id: Option<String>,
743 /// Additional item metadata / annotations. Possible values: * `catalogItem`: JSON representation of the catalogItem. Will be set if `returnCatalogItem` is set to true in `PredictRequest.params`. * `score`: Prediction score in double value. Will be set if `returnItemScore` is set to true in `PredictRequest.params`.
744 #[serde(rename = "itemMetadata")]
745 pub item_metadata: Option<HashMap<String, serde_json::Value>>,
746}
747
748impl common::Part for GoogleCloudRecommendationengineV1beta1PredictResponsePredictionResult {}
749
750/// Registered Api Key.
751///
752/// # Activities
753///
754/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
755/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
756///
757/// * [locations catalogs event stores prediction api key registrations create projects](ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall) (response)
758#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
759#[serde_with::serde_as]
760#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
761pub struct GoogleCloudRecommendationengineV1beta1PredictionApiKeyRegistration {
762 /// The API key.
763 #[serde(rename = "apiKey")]
764 pub api_key: Option<String>,
765}
766
767impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1PredictionApiKeyRegistration {}
768
769/// ProductCatalogItem captures item metadata specific to retail products.
770///
771/// This type is not used in any activity, and only used as *part* of another schema.
772///
773#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
774#[serde_with::serde_as]
775#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
776pub struct GoogleCloudRecommendationengineV1beta1ProductCatalogItem {
777 /// Optional. The available quantity of the item.
778 #[serde(rename = "availableQuantity")]
779 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
780 pub available_quantity: Option<i64>,
781 /// Optional. Canonical URL directly linking to the item detail page with a length limit of 5 KiB..
782 #[serde(rename = "canonicalProductUri")]
783 pub canonical_product_uri: Option<String>,
784 /// Optional. A map to pass the costs associated with the product. For example: {"manufacturing": 45.5} The profit of selling this item is computed like so: * If 'exactPrice' is provided, profit = displayPrice - sum(costs) * If 'priceRange' is provided, profit = minPrice - sum(costs)
785 pub costs: Option<HashMap<String, f32>>,
786 /// Optional. Only required if the price is set. Currency code for price/costs. Use three-character ISO-4217 code.
787 #[serde(rename = "currencyCode")]
788 pub currency_code: Option<String>,
789 /// Optional. The exact product price.
790 #[serde(rename = "exactPrice")]
791 pub exact_price: Option<GoogleCloudRecommendationengineV1beta1ProductCatalogItemExactPrice>,
792 /// Optional. Product images for the catalog item.
793 pub images: Option<Vec<GoogleCloudRecommendationengineV1beta1Image>>,
794 /// Optional. The product price range.
795 #[serde(rename = "priceRange")]
796 pub price_range: Option<GoogleCloudRecommendationengineV1beta1ProductCatalogItemPriceRange>,
797 /// Optional. Online stock state of the catalog item. Default is `IN_STOCK`.
798 #[serde(rename = "stockState")]
799 pub stock_state: Option<String>,
800}
801
802impl common::Part for GoogleCloudRecommendationengineV1beta1ProductCatalogItem {}
803
804/// Exact product price.
805///
806/// This type is not used in any activity, and only used as *part* of another schema.
807///
808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
809#[serde_with::serde_as]
810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
811pub struct GoogleCloudRecommendationengineV1beta1ProductCatalogItemExactPrice {
812 /// Optional. Display price of the product.
813 #[serde(rename = "displayPrice")]
814 pub display_price: Option<f32>,
815 /// Optional. Price of the product without any discount. If zero, by default set to be the 'displayPrice'.
816 #[serde(rename = "originalPrice")]
817 pub original_price: Option<f32>,
818}
819
820impl common::Part for GoogleCloudRecommendationengineV1beta1ProductCatalogItemExactPrice {}
821
822/// Product price range when there are a range of prices for different variations of the same product.
823///
824/// This type is not used in any activity, and only used as *part* of another schema.
825///
826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
827#[serde_with::serde_as]
828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
829pub struct GoogleCloudRecommendationengineV1beta1ProductCatalogItemPriceRange {
830 /// Required. The maximum product price.
831 pub max: Option<f32>,
832 /// Required. The minimum product price.
833 pub min: Option<f32>,
834}
835
836impl common::Part for GoogleCloudRecommendationengineV1beta1ProductCatalogItemPriceRange {}
837
838/// Detailed product information associated with a user event.
839///
840/// This type is not used in any activity, and only used as *part* of another schema.
841///
842#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
843#[serde_with::serde_as]
844#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
845pub struct GoogleCloudRecommendationengineV1beta1ProductDetail {
846 /// Optional. Quantity of the products in stock when a user event happens. Optional. If provided, this overrides the available quantity in Catalog for this event. and can only be set if `stock_status` is set to `IN_STOCK`. Note that if an item is out of stock, you must set the `stock_state` field to be `OUT_OF_STOCK`. Leaving this field unspecified / as zero is not sufficient to mark the item out of stock.
847 #[serde(rename = "availableQuantity")]
848 pub available_quantity: Option<i32>,
849 /// Optional. Currency code for price/costs. Use three-character ISO-4217 code. Required only if originalPrice or displayPrice is set.
850 #[serde(rename = "currencyCode")]
851 pub currency_code: Option<String>,
852 /// Optional. Display price of the product (e.g. discounted price). If provided, this will override the display price in Catalog for this product.
853 #[serde(rename = "displayPrice")]
854 pub display_price: Option<f32>,
855 /// Required. Catalog item ID. UTF-8 encoded string with a length limit of 128 characters.
856 pub id: Option<String>,
857 /// Optional. Extra features associated with a product in the user event.
858 #[serde(rename = "itemAttributes")]
859 pub item_attributes: Option<GoogleCloudRecommendationengineV1beta1FeatureMap>,
860 /// Optional. Original price of the product. If provided, this will override the original price in Catalog for this product.
861 #[serde(rename = "originalPrice")]
862 pub original_price: Option<f32>,
863 /// Optional. Quantity of the product associated with the user event. For example, this field will be 2 if two products are added to the shopping cart for `add-to-cart` event. Required for `add-to-cart`, `add-to-list`, `remove-from-cart`, `checkout-start`, `purchase-complete`, `refund` event types.
864 pub quantity: Option<i32>,
865 /// Optional. Item stock state. If provided, this overrides the stock state in Catalog for items in this event.
866 #[serde(rename = "stockState")]
867 pub stock_state: Option<String>,
868}
869
870impl common::Part for GoogleCloudRecommendationengineV1beta1ProductDetail {}
871
872/// ProductEventDetail captures user event information specific to retail products.
873///
874/// This type is not used in any activity, and only used as *part* of another schema.
875///
876#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
877#[serde_with::serde_as]
878#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
879pub struct GoogleCloudRecommendationengineV1beta1ProductEventDetail {
880 /// Optional. The id or name of the associated shopping cart. This id is used to associate multiple items added or present in the cart before purchase. This can only be set for `add-to-cart`, `remove-from-cart`, `checkout-start`, `purchase-complete`, or `shopping-cart-page-view` events.
881 #[serde(rename = "cartId")]
882 pub cart_id: Option<String>,
883 /// Required for `add-to-list` and `remove-from-list` events. The id or name of the list that the item is being added to or removed from. Other event types should not set this field.
884 #[serde(rename = "listId")]
885 pub list_id: Option<String>,
886 /// Required for `category-page-view` events. At least one of search_query or page_categories is required for `search` events. Other event types should not set this field. The categories associated with a category page. Category pages include special pages such as sales or promotions. For instance, a special sale page may have the category hierarchy: categories : ["Sales", "2017 Black Friday Deals"].
887 #[serde(rename = "pageCategories")]
888 pub page_categories:
889 Option<Vec<GoogleCloudRecommendationengineV1beta1CatalogItemCategoryHierarchy>>,
890 /// The main product details related to the event. This field is required for the following event types: * `add-to-cart` * `add-to-list` * `checkout-start` * `detail-page-view` * `purchase-complete` * `refund` * `remove-from-cart` * `remove-from-list` This field is optional for the following event types: * `page-visit` * `shopping-cart-page-view` - note that 'product_details' should be set for this unless the shopping cart is empty. * `search` (highly encouraged) In a `search` event, this field represents the products returned to the end user on the current page (the end user may have not finished broswing the whole page yet). When a new page is returned to the end user, after pagination/filtering/ordering even for the same query, a new SEARCH event with different product_details is desired. The end user may have not finished broswing the whole page yet. This field is not allowed for the following event types: * `category-page-view` * `home-page-view`
891 #[serde(rename = "productDetails")]
892 pub product_details: Option<Vec<GoogleCloudRecommendationengineV1beta1ProductDetail>>,
893 /// Optional. A transaction represents the entire purchase transaction. Required for `purchase-complete` events. Optional for `checkout-start` events. Other event types should not set this field.
894 #[serde(rename = "purchaseTransaction")]
895 pub purchase_transaction: Option<GoogleCloudRecommendationengineV1beta1PurchaseTransaction>,
896 /// At least one of search_query or page_categories is required for `search` events. Other event types should not set this field. The user's search query as UTF-8 encoded text with a length limit of 5 KiB.
897 #[serde(rename = "searchQuery")]
898 pub search_query: Option<String>,
899}
900
901impl common::Part for GoogleCloudRecommendationengineV1beta1ProductEventDetail {}
902
903/// A transaction represents the entire purchase transaction.
904///
905/// This type is not used in any activity, and only used as *part* of another schema.
906///
907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
908#[serde_with::serde_as]
909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
910pub struct GoogleCloudRecommendationengineV1beta1PurchaseTransaction {
911 /// Optional. All the costs associated with the product. These can be manufacturing costs, shipping expenses not borne by the end user, or any other costs. Total product cost such that profit = revenue - (sum(taxes) + sum(costs)) If product_cost is not set, then profit = revenue - tax - shipping - sum(CatalogItem.costs). If CatalogItem.cost is not specified for one of the items, CatalogItem.cost based profit *cannot* be calculated for this Transaction.
912 pub costs: Option<HashMap<String, f32>>,
913 /// Required. Currency code. Use three-character ISO-4217 code. This field is not required if the event type is `refund`.
914 #[serde(rename = "currencyCode")]
915 pub currency_code: Option<String>,
916 /// Optional. The transaction ID with a length limit of 128 bytes.
917 pub id: Option<String>,
918 /// Required. Total revenue or grand total associated with the transaction. This value include shipping, tax, or other adjustments to total revenue that you want to include as part of your revenue calculations. This field is not required if the event type is `refund`.
919 pub revenue: Option<f32>,
920 /// Optional. All the taxes associated with the transaction.
921 pub taxes: Option<HashMap<String, f32>>,
922}
923
924impl common::Part for GoogleCloudRecommendationengineV1beta1PurchaseTransaction {}
925
926/// Request message for PurgeUserEvents method.
927///
928/// # Activities
929///
930/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
931/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
932///
933/// * [locations catalogs event stores user events purge projects](ProjectLocationCatalogEventStoreUserEventPurgeCall) (request)
934#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
935#[serde_with::serde_as]
936#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
937pub struct GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest {
938 /// Required. The filter string to specify the events to be deleted. Empty string filter is not allowed. The eligible fields for filtering are: * `eventType`: UserEvent.eventType field of type string. * `eventTime`: in ISO 8601 "zulu" format. * `visitorId`: field of type string. Specifying this will delete all events associated with a visitor. * `userId`: field of type string. Specifying this will delete all events associated with a user. Examples: * Deleting all events in a time range: `eventTime > "2012-04-23T18:25:43.511Z" eventTime < "2012-04-23T18:30:43.511Z"` * Deleting specific eventType in time range: `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` * Deleting all events for a specific visitor: `visitorId = "visitor1024"` The filtering fields are assumed to have an implicit AND.
939 pub filter: Option<String>,
940 /// Optional. The default value is false. Override this flag to true to actually perform the purge. If the field is not set to true, a sampling of events to be deleted will be returned.
941 pub force: Option<bool>,
942}
943
944impl common::RequestValue for GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest {}
945
946/// Request message for CatalogRejoin method.
947///
948/// # Activities
949///
950/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
951/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
952///
953/// * [locations catalogs event stores user events rejoin projects](ProjectLocationCatalogEventStoreUserEventRejoinCall) (request)
954#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
955#[serde_with::serde_as]
956#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
957pub struct GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest {
958 /// Required. The type of the catalog rejoin to define the scope and range of the user events to be rejoined with catalog items.
959 #[serde(rename = "userEventRejoinScope")]
960 pub user_event_rejoin_scope: Option<String>,
961}
962
963impl common::RequestValue for GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest {}
964
965/// UserEvent captures all metadata information recommendation engine needs to know about how end users interact with customers’ website.
966///
967/// # Activities
968///
969/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
970/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
971///
972/// * [locations catalogs event stores user events write projects](ProjectLocationCatalogEventStoreUserEventWriteCall) (request|response)
973#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
974#[serde_with::serde_as]
975#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
976pub struct GoogleCloudRecommendationengineV1beta1UserEvent {
977 /// Optional. User event detailed information common across different recommendation types.
978 #[serde(rename = "eventDetail")]
979 pub event_detail: Option<GoogleCloudRecommendationengineV1beta1EventDetail>,
980 /// Optional. This field should *not* be set when using JavaScript pixel or the Recommendations AI Tag. Defaults to `EVENT_SOURCE_UNSPECIFIED`.
981 #[serde(rename = "eventSource")]
982 pub event_source: Option<String>,
983 /// Optional. Only required for ImportUserEvents method. Timestamp of user event created.
984 #[serde(rename = "eventTime")]
985 pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
986 /// Required. User event type. Allowed values are: * `add-to-cart` Products being added to cart. * `add-to-list` Items being added to a list (shopping list, favorites etc). * `category-page-view` Special pages such as sale or promotion pages viewed. * `checkout-start` User starting a checkout process. * `detail-page-view` Products detail page viewed. * `home-page-view` Homepage viewed. * `page-visit` Generic page visits not included in the event types above. * `purchase-complete` User finishing a purchase. * `refund` Purchased items being refunded or returned. * `remove-from-cart` Products being removed from cart. * `remove-from-list` Items being removed from a list. * `search` Product search. * `shopping-cart-page-view` User viewing a shopping cart. * `impression` List of items displayed. Used by Google Tag Manager.
987 #[serde(rename = "eventType")]
988 pub event_type: Option<String>,
989 /// Optional. Retail product specific user event metadata. This field is required for the following event types: * `add-to-cart` * `add-to-list` * `category-page-view` * `checkout-start` * `detail-page-view` * `purchase-complete` * `refund` * `remove-from-cart` * `remove-from-list` * `search` This field is optional for the following event types: * `page-visit` * `shopping-cart-page-view` - note that 'product_event_detail' should be set for this unless the shopping cart is empty. This field is not allowed for the following event types: * `home-page-view`
990 #[serde(rename = "productEventDetail")]
991 pub product_event_detail: Option<GoogleCloudRecommendationengineV1beta1ProductEventDetail>,
992 /// Required. User information.
993 #[serde(rename = "userInfo")]
994 pub user_info: Option<GoogleCloudRecommendationengineV1beta1UserInfo>,
995}
996
997impl common::RequestValue for GoogleCloudRecommendationengineV1beta1UserEvent {}
998impl common::ResponseResult for GoogleCloudRecommendationengineV1beta1UserEvent {}
999
1000/// The inline source for the input config for ImportUserEvents method.
1001///
1002/// This type is not used in any activity, and only used as *part* of another schema.
1003///
1004#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1005#[serde_with::serde_as]
1006#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1007pub struct GoogleCloudRecommendationengineV1beta1UserEventInlineSource {
1008 /// Optional. A list of user events to import. Recommended max of 10k items.
1009 #[serde(rename = "userEvents")]
1010 pub user_events: Option<Vec<GoogleCloudRecommendationengineV1beta1UserEvent>>,
1011}
1012
1013impl common::Part for GoogleCloudRecommendationengineV1beta1UserEventInlineSource {}
1014
1015/// Information of end users.
1016///
1017/// This type is not used in any activity, and only used as *part* of another schema.
1018///
1019#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1020#[serde_with::serde_as]
1021#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1022pub struct GoogleCloudRecommendationengineV1beta1UserInfo {
1023 /// Optional. Indicates if the request is made directly from the end user in which case the user_agent and ip_address fields can be populated from the HTTP request. This should *not* be set when using the javascript pixel. This flag should be set only if the API request is made directly from the end user such as a mobile app (and not if a gateway or a server is processing and pushing the user events).
1024 #[serde(rename = "directUserRequest")]
1025 pub direct_user_request: Option<bool>,
1026 /// Optional. IP address of the user. This could be either IPv4 (e.g. 104.133.9.80) or IPv6 (e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334). This should *not* be set when using the javascript pixel or if `direct_user_request` is set. Used to extract location information for personalization.
1027 #[serde(rename = "ipAddress")]
1028 pub ip_address: Option<String>,
1029 /// Optional. User agent as included in the HTTP header. UTF-8 encoded string with a length limit of 1 KiB. This should *not* be set when using the JavaScript pixel or if `directUserRequest` is set.
1030 #[serde(rename = "userAgent")]
1031 pub user_agent: Option<String>,
1032 /// Optional. Unique identifier for logged-in user with a length limit of 128 bytes. Required only for logged-in users. Don't set for anonymous users. Don't set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality.
1033 #[serde(rename = "userId")]
1034 pub user_id: Option<String>,
1035 /// Required. A unique identifier for tracking visitors with a length limit of 128 bytes. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor logs in or out of the website. Maximum length 128 bytes. Cannot be empty. Don't set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality.
1036 #[serde(rename = "visitorId")]
1037 pub visitor_id: Option<String>,
1038}
1039
1040impl common::Part for GoogleCloudRecommendationengineV1beta1UserInfo {}
1041
1042/// The response message for Operations.ListOperations.
1043///
1044/// # Activities
1045///
1046/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1047/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1048///
1049/// * [locations catalogs event stores operations list projects](ProjectLocationCatalogEventStoreOperationListCall) (response)
1050/// * [locations catalogs operations list projects](ProjectLocationCatalogOperationListCall) (response)
1051#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1052#[serde_with::serde_as]
1053#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1054pub struct GoogleLongrunningListOperationsResponse {
1055 /// The standard List next-page token.
1056 #[serde(rename = "nextPageToken")]
1057 pub next_page_token: Option<String>,
1058 /// A list of operations that matches the specified filter in the request.
1059 pub operations: Option<Vec<GoogleLongrunningOperation>>,
1060 /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
1061 pub unreachable: Option<Vec<String>>,
1062}
1063
1064impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
1065
1066/// This resource represents a long-running operation that is the result of a network API call.
1067///
1068/// # Activities
1069///
1070/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1071/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1072///
1073/// * [locations catalogs catalog items import projects](ProjectLocationCatalogCatalogItemImportCall) (response)
1074/// * [locations catalogs event stores operations get projects](ProjectLocationCatalogEventStoreOperationGetCall) (response)
1075/// * [locations catalogs event stores user events import projects](ProjectLocationCatalogEventStoreUserEventImportCall) (response)
1076/// * [locations catalogs event stores user events purge projects](ProjectLocationCatalogEventStoreUserEventPurgeCall) (response)
1077/// * [locations catalogs event stores user events rejoin projects](ProjectLocationCatalogEventStoreUserEventRejoinCall) (response)
1078/// * [locations catalogs operations get projects](ProjectLocationCatalogOperationGetCall) (response)
1079#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1080#[serde_with::serde_as]
1081#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1082pub struct GoogleLongrunningOperation {
1083 /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
1084 pub done: Option<bool>,
1085 /// The error result of the operation in case of failure or cancellation.
1086 pub error: Option<GoogleRpcStatus>,
1087 /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
1088 pub metadata: Option<HashMap<String, serde_json::Value>>,
1089 /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
1090 pub name: Option<String>,
1091 /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
1092 pub response: Option<HashMap<String, serde_json::Value>>,
1093}
1094
1095impl common::ResponseResult for GoogleLongrunningOperation {}
1096
1097/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
1098///
1099/// # Activities
1100///
1101/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1102/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1103///
1104/// * [locations catalogs catalog items delete projects](ProjectLocationCatalogCatalogItemDeleteCall) (response)
1105/// * [locations catalogs event stores prediction api key registrations delete projects](ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall) (response)
1106#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1107#[serde_with::serde_as]
1108#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1109pub struct GoogleProtobufEmpty {
1110 _never_set: Option<bool>,
1111}
1112
1113impl common::ResponseResult for GoogleProtobufEmpty {}
1114
1115/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1116///
1117/// This type is not used in any activity, and only used as *part* of another schema.
1118///
1119#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1120#[serde_with::serde_as]
1121#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1122pub struct GoogleRpcStatus {
1123 /// The status code, which should be an enum value of google.rpc.Code.
1124 pub code: Option<i32>,
1125 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1126 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1127 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1128 pub message: Option<String>,
1129}
1130
1131impl common::Part for GoogleRpcStatus {}
1132
1133// ###################
1134// MethodBuilders ###
1135// #################
1136
1137/// A builder providing access to all methods supported on *project* resources.
1138/// It is not used directly, but through the [`RecommendationsAI`] hub.
1139///
1140/// # Example
1141///
1142/// Instantiate a resource builder
1143///
1144/// ```test_harness,no_run
1145/// extern crate hyper;
1146/// extern crate hyper_rustls;
1147/// extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
1148///
1149/// # async fn dox() {
1150/// use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1151///
1152/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1153/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1154/// .with_native_roots()
1155/// .unwrap()
1156/// .https_only()
1157/// .enable_http2()
1158/// .build();
1159///
1160/// let executor = hyper_util::rt::TokioExecutor::new();
1161/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1162/// secret,
1163/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1164/// yup_oauth2::client::CustomHyperClientBuilder::from(
1165/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1166/// ),
1167/// ).build().await.unwrap();
1168///
1169/// let client = hyper_util::client::legacy::Client::builder(
1170/// hyper_util::rt::TokioExecutor::new()
1171/// )
1172/// .build(
1173/// hyper_rustls::HttpsConnectorBuilder::new()
1174/// .with_native_roots()
1175/// .unwrap()
1176/// .https_or_http()
1177/// .enable_http2()
1178/// .build()
1179/// );
1180/// let mut hub = RecommendationsAI::new(client, auth);
1181/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1182/// // like `locations_catalogs_catalog_items_create(...)`, `locations_catalogs_catalog_items_delete(...)`, `locations_catalogs_catalog_items_get(...)`, `locations_catalogs_catalog_items_import(...)`, `locations_catalogs_catalog_items_list(...)`, `locations_catalogs_catalog_items_patch(...)`, `locations_catalogs_event_stores_operations_get(...)`, `locations_catalogs_event_stores_operations_list(...)`, `locations_catalogs_event_stores_placements_predict(...)`, `locations_catalogs_event_stores_prediction_api_key_registrations_create(...)`, `locations_catalogs_event_stores_prediction_api_key_registrations_delete(...)`, `locations_catalogs_event_stores_prediction_api_key_registrations_list(...)`, `locations_catalogs_event_stores_user_events_collect(...)`, `locations_catalogs_event_stores_user_events_import(...)`, `locations_catalogs_event_stores_user_events_list(...)`, `locations_catalogs_event_stores_user_events_purge(...)`, `locations_catalogs_event_stores_user_events_rejoin(...)`, `locations_catalogs_event_stores_user_events_write(...)`, `locations_catalogs_list(...)`, `locations_catalogs_operations_get(...)`, `locations_catalogs_operations_list(...)` and `locations_catalogs_patch(...)`
1183/// // to build up your call.
1184/// let rb = hub.projects();
1185/// # }
1186/// ```
1187pub struct ProjectMethods<'a, C>
1188where
1189 C: 'a,
1190{
1191 hub: &'a RecommendationsAI<C>,
1192}
1193
1194impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1195
1196impl<'a, C> ProjectMethods<'a, C> {
1197 /// Create a builder to help you perform the following task:
1198 ///
1199 /// Creates a catalog item.
1200 ///
1201 /// # Arguments
1202 ///
1203 /// * `request` - No description provided.
1204 /// * `parent` - Required. The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog`.
1205 pub fn locations_catalogs_catalog_items_create(
1206 &self,
1207 request: GoogleCloudRecommendationengineV1beta1CatalogItem,
1208 parent: &str,
1209 ) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C> {
1210 ProjectLocationCatalogCatalogItemCreateCall {
1211 hub: self.hub,
1212 _request: request,
1213 _parent: parent.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 /// Deletes a catalog item.
1223 ///
1224 /// # Arguments
1225 ///
1226 /// * `name` - Required. Full resource name of catalog item, such as `projects/*/locations/global/catalogs/default_catalog/catalogItems/some_catalog_item_id`.
1227 pub fn locations_catalogs_catalog_items_delete(
1228 &self,
1229 name: &str,
1230 ) -> ProjectLocationCatalogCatalogItemDeleteCall<'a, C> {
1231 ProjectLocationCatalogCatalogItemDeleteCall {
1232 hub: self.hub,
1233 _name: name.to_string(),
1234 _delegate: Default::default(),
1235 _additional_params: Default::default(),
1236 _scopes: Default::default(),
1237 }
1238 }
1239
1240 /// Create a builder to help you perform the following task:
1241 ///
1242 /// Gets a specific catalog item.
1243 ///
1244 /// # Arguments
1245 ///
1246 /// * `name` - Required. Full resource name of catalog item, such as `projects/*/locations/global/catalogs/default_catalog/catalogitems/some_catalog_item_id`.
1247 pub fn locations_catalogs_catalog_items_get(
1248 &self,
1249 name: &str,
1250 ) -> ProjectLocationCatalogCatalogItemGetCall<'a, C> {
1251 ProjectLocationCatalogCatalogItemGetCall {
1252 hub: self.hub,
1253 _name: name.to_string(),
1254 _delegate: Default::default(),
1255 _additional_params: Default::default(),
1256 _scopes: Default::default(),
1257 }
1258 }
1259
1260 /// Create a builder to help you perform the following task:
1261 ///
1262 /// Bulk import of multiple catalog items. Request processing may be synchronous. No partial updating supported. Non-existing items will be created. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully updated.
1263 ///
1264 /// # Arguments
1265 ///
1266 /// * `request` - No description provided.
1267 /// * `parent` - Required. `projects/1234/locations/global/catalogs/default_catalog` If no updateMask is specified, requires catalogItems.create permission. If updateMask is specified, requires catalogItems.update permission.
1268 pub fn locations_catalogs_catalog_items_import(
1269 &self,
1270 request: GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest,
1271 parent: &str,
1272 ) -> ProjectLocationCatalogCatalogItemImportCall<'a, C> {
1273 ProjectLocationCatalogCatalogItemImportCall {
1274 hub: self.hub,
1275 _request: request,
1276 _parent: parent.to_string(),
1277 _delegate: Default::default(),
1278 _additional_params: Default::default(),
1279 _scopes: Default::default(),
1280 }
1281 }
1282
1283 /// Create a builder to help you perform the following task:
1284 ///
1285 /// Gets a list of catalog items.
1286 ///
1287 /// # Arguments
1288 ///
1289 /// * `parent` - Required. The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog`.
1290 pub fn locations_catalogs_catalog_items_list(
1291 &self,
1292 parent: &str,
1293 ) -> ProjectLocationCatalogCatalogItemListCall<'a, C> {
1294 ProjectLocationCatalogCatalogItemListCall {
1295 hub: self.hub,
1296 _parent: parent.to_string(),
1297 _page_token: Default::default(),
1298 _page_size: Default::default(),
1299 _filter: Default::default(),
1300 _delegate: Default::default(),
1301 _additional_params: Default::default(),
1302 _scopes: Default::default(),
1303 }
1304 }
1305
1306 /// Create a builder to help you perform the following task:
1307 ///
1308 /// Updates a catalog item. Partial updating is supported. Non-existing items will be created.
1309 ///
1310 /// # Arguments
1311 ///
1312 /// * `request` - No description provided.
1313 /// * `name` - Required. Full resource name of catalog item, such as `projects/*/locations/global/catalogs/default_catalog/catalogItems/some_catalog_item_id`.
1314 pub fn locations_catalogs_catalog_items_patch(
1315 &self,
1316 request: GoogleCloudRecommendationengineV1beta1CatalogItem,
1317 name: &str,
1318 ) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C> {
1319 ProjectLocationCatalogCatalogItemPatchCall {
1320 hub: self.hub,
1321 _request: request,
1322 _name: name.to_string(),
1323 _update_mask: Default::default(),
1324 _delegate: Default::default(),
1325 _additional_params: Default::default(),
1326 _scopes: Default::default(),
1327 }
1328 }
1329
1330 /// Create a builder to help you perform the following task:
1331 ///
1332 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1333 ///
1334 /// # Arguments
1335 ///
1336 /// * `name` - The name of the operation resource.
1337 pub fn locations_catalogs_event_stores_operations_get(
1338 &self,
1339 name: &str,
1340 ) -> ProjectLocationCatalogEventStoreOperationGetCall<'a, C> {
1341 ProjectLocationCatalogEventStoreOperationGetCall {
1342 hub: self.hub,
1343 _name: name.to_string(),
1344 _delegate: Default::default(),
1345 _additional_params: Default::default(),
1346 _scopes: Default::default(),
1347 }
1348 }
1349
1350 /// Create a builder to help you perform the following task:
1351 ///
1352 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1353 ///
1354 /// # Arguments
1355 ///
1356 /// * `name` - The name of the operation's parent resource.
1357 pub fn locations_catalogs_event_stores_operations_list(
1358 &self,
1359 name: &str,
1360 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
1361 ProjectLocationCatalogEventStoreOperationListCall {
1362 hub: self.hub,
1363 _name: name.to_string(),
1364 _return_partial_success: Default::default(),
1365 _page_token: Default::default(),
1366 _page_size: Default::default(),
1367 _filter: Default::default(),
1368 _delegate: Default::default(),
1369 _additional_params: Default::default(),
1370 _scopes: Default::default(),
1371 }
1372 }
1373
1374 /// Create a builder to help you perform the following task:
1375 ///
1376 /// Makes a recommendation prediction. If using API Key based authentication, the API Key must be registered using the PredictionApiKeyRegistry service. [Learn more](https://cloud.google.com/recommendations-ai/docs/setting-up#register-key).
1377 ///
1378 /// # Arguments
1379 ///
1380 /// * `request` - No description provided.
1381 /// * `name` - No description provided.
1382 pub fn locations_catalogs_event_stores_placements_predict(
1383 &self,
1384 request: GoogleCloudRecommendationengineV1beta1PredictRequest,
1385 name: &str,
1386 ) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C> {
1387 ProjectLocationCatalogEventStorePlacementPredictCall {
1388 hub: self.hub,
1389 _request: request,
1390 _name: name.to_string(),
1391 _delegate: Default::default(),
1392 _additional_params: Default::default(),
1393 _scopes: Default::default(),
1394 }
1395 }
1396
1397 /// Create a builder to help you perform the following task:
1398 ///
1399 /// Register an API key for use with predict method.
1400 ///
1401 /// # Arguments
1402 ///
1403 /// * `request` - No description provided.
1404 /// * `parent` - Required. The parent resource path. `projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store`.
1405 pub fn locations_catalogs_event_stores_prediction_api_key_registrations_create(
1406 &self,
1407 request: GoogleCloudRecommendationengineV1beta1CreatePredictionApiKeyRegistrationRequest,
1408 parent: &str,
1409 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C> {
1410 ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall {
1411 hub: self.hub,
1412 _request: request,
1413 _parent: parent.to_string(),
1414 _delegate: Default::default(),
1415 _additional_params: Default::default(),
1416 _scopes: Default::default(),
1417 }
1418 }
1419
1420 /// Create a builder to help you perform the following task:
1421 ///
1422 /// Unregister an apiKey from using for predict method.
1423 ///
1424 /// # Arguments
1425 ///
1426 /// * `name` - Required. The API key to unregister including full resource path. `projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/predictionApiKeyRegistrations/`
1427 pub fn locations_catalogs_event_stores_prediction_api_key_registrations_delete(
1428 &self,
1429 name: &str,
1430 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C> {
1431 ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall {
1432 hub: self.hub,
1433 _name: name.to_string(),
1434 _delegate: Default::default(),
1435 _additional_params: Default::default(),
1436 _scopes: Default::default(),
1437 }
1438 }
1439
1440 /// Create a builder to help you perform the following task:
1441 ///
1442 /// List the registered apiKeys for use with predict method.
1443 ///
1444 /// # Arguments
1445 ///
1446 /// * `parent` - Required. The parent placement resource name such as `projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`
1447 pub fn locations_catalogs_event_stores_prediction_api_key_registrations_list(
1448 &self,
1449 parent: &str,
1450 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C> {
1451 ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall {
1452 hub: self.hub,
1453 _parent: parent.to_string(),
1454 _page_token: Default::default(),
1455 _page_size: Default::default(),
1456 _delegate: Default::default(),
1457 _additional_params: Default::default(),
1458 _scopes: Default::default(),
1459 }
1460 }
1461
1462 /// Create a builder to help you perform the following task:
1463 ///
1464 /// Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Recommendations AI JavaScript pixel. Users should not call this method directly.
1465 ///
1466 /// # Arguments
1467 ///
1468 /// * `parent` - Required. The parent eventStore name, such as `projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`.
1469 pub fn locations_catalogs_event_stores_user_events_collect(
1470 &self,
1471 parent: &str,
1472 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {
1473 ProjectLocationCatalogEventStoreUserEventCollectCall {
1474 hub: self.hub,
1475 _parent: parent.to_string(),
1476 _user_event: Default::default(),
1477 _uri: Default::default(),
1478 _ets: Default::default(),
1479 _delegate: Default::default(),
1480 _additional_params: Default::default(),
1481 _scopes: Default::default(),
1482 }
1483 }
1484
1485 /// Create a builder to help you perform the following task:
1486 ///
1487 /// Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.
1488 ///
1489 /// # Arguments
1490 ///
1491 /// * `request` - No description provided.
1492 /// * `parent` - Required. `projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`
1493 pub fn locations_catalogs_event_stores_user_events_import(
1494 &self,
1495 request: GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest,
1496 parent: &str,
1497 ) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C> {
1498 ProjectLocationCatalogEventStoreUserEventImportCall {
1499 hub: self.hub,
1500 _request: request,
1501 _parent: parent.to_string(),
1502 _delegate: Default::default(),
1503 _additional_params: Default::default(),
1504 _scopes: Default::default(),
1505 }
1506 }
1507
1508 /// Create a builder to help you perform the following task:
1509 ///
1510 /// Gets a list of user events within a time range, with potential filtering. The method does not list unjoined user events. Unjoined user event definition: when a user event is ingested from Recommendations AI User Event APIs, the catalog item included in the user event is connected with the current catalog. If a catalog item of the ingested event is not in the current catalog, it could lead to degraded model quality. This is called an unjoined event.
1511 ///
1512 /// # Arguments
1513 ///
1514 /// * `parent` - Required. The parent eventStore resource name, such as `projects/*/locations/*/catalogs/default_catalog/eventStores/default_event_store`.
1515 pub fn locations_catalogs_event_stores_user_events_list(
1516 &self,
1517 parent: &str,
1518 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {
1519 ProjectLocationCatalogEventStoreUserEventListCall {
1520 hub: self.hub,
1521 _parent: parent.to_string(),
1522 _page_token: Default::default(),
1523 _page_size: Default::default(),
1524 _filter: Default::default(),
1525 _delegate: Default::default(),
1526 _additional_params: Default::default(),
1527 _scopes: Default::default(),
1528 }
1529 }
1530
1531 /// Create a builder to help you perform the following task:
1532 ///
1533 /// Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.
1534 ///
1535 /// # Arguments
1536 ///
1537 /// * `request` - No description provided.
1538 /// * `parent` - Required. The resource name of the event_store under which the events are created. The format is `projects/${projectId}/locations/global/catalogs/${catalogId}/eventStores/${eventStoreId}`
1539 pub fn locations_catalogs_event_stores_user_events_purge(
1540 &self,
1541 request: GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest,
1542 parent: &str,
1543 ) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C> {
1544 ProjectLocationCatalogEventStoreUserEventPurgeCall {
1545 hub: self.hub,
1546 _request: request,
1547 _parent: parent.to_string(),
1548 _delegate: Default::default(),
1549 _additional_params: Default::default(),
1550 _scopes: Default::default(),
1551 }
1552 }
1553
1554 /// Create a builder to help you perform the following task:
1555 ///
1556 /// Triggers a user event rejoin operation with latest catalog data. Events will not be annotated with detailed catalog information if catalog item is missing at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This API can be used to trigger a 'join' operation on specified events with latest version of catalog items. It can also be used to correct events joined with wrong catalog items.
1557 ///
1558 /// # Arguments
1559 ///
1560 /// * `request` - No description provided.
1561 /// * `parent` - Required. Full resource name of user event, such as `projects/*/locations/*/catalogs/default_catalog/eventStores/default_event_store`.
1562 pub fn locations_catalogs_event_stores_user_events_rejoin(
1563 &self,
1564 request: GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest,
1565 parent: &str,
1566 ) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C> {
1567 ProjectLocationCatalogEventStoreUserEventRejoinCall {
1568 hub: self.hub,
1569 _request: request,
1570 _parent: parent.to_string(),
1571 _delegate: Default::default(),
1572 _additional_params: Default::default(),
1573 _scopes: Default::default(),
1574 }
1575 }
1576
1577 /// Create a builder to help you perform the following task:
1578 ///
1579 /// Writes a single user event.
1580 ///
1581 /// # Arguments
1582 ///
1583 /// * `request` - No description provided.
1584 /// * `parent` - Required. The parent eventStore resource name, such as "projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store".
1585 pub fn locations_catalogs_event_stores_user_events_write(
1586 &self,
1587 request: GoogleCloudRecommendationengineV1beta1UserEvent,
1588 parent: &str,
1589 ) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C> {
1590 ProjectLocationCatalogEventStoreUserEventWriteCall {
1591 hub: self.hub,
1592 _request: request,
1593 _parent: parent.to_string(),
1594 _delegate: Default::default(),
1595 _additional_params: Default::default(),
1596 _scopes: Default::default(),
1597 }
1598 }
1599
1600 /// Create a builder to help you perform the following task:
1601 ///
1602 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1603 ///
1604 /// # Arguments
1605 ///
1606 /// * `name` - The name of the operation resource.
1607 pub fn locations_catalogs_operations_get(
1608 &self,
1609 name: &str,
1610 ) -> ProjectLocationCatalogOperationGetCall<'a, C> {
1611 ProjectLocationCatalogOperationGetCall {
1612 hub: self.hub,
1613 _name: name.to_string(),
1614 _delegate: Default::default(),
1615 _additional_params: Default::default(),
1616 _scopes: Default::default(),
1617 }
1618 }
1619
1620 /// Create a builder to help you perform the following task:
1621 ///
1622 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1623 ///
1624 /// # Arguments
1625 ///
1626 /// * `name` - The name of the operation's parent resource.
1627 pub fn locations_catalogs_operations_list(
1628 &self,
1629 name: &str,
1630 ) -> ProjectLocationCatalogOperationListCall<'a, C> {
1631 ProjectLocationCatalogOperationListCall {
1632 hub: self.hub,
1633 _name: name.to_string(),
1634 _return_partial_success: Default::default(),
1635 _page_token: Default::default(),
1636 _page_size: Default::default(),
1637 _filter: Default::default(),
1638 _delegate: Default::default(),
1639 _additional_params: Default::default(),
1640 _scopes: Default::default(),
1641 }
1642 }
1643
1644 /// Create a builder to help you perform the following task:
1645 ///
1646 /// Lists all the catalog configurations associated with the project.
1647 ///
1648 /// # Arguments
1649 ///
1650 /// * `parent` - Required. The account resource name with an associated location.
1651 pub fn locations_catalogs_list(&self, parent: &str) -> ProjectLocationCatalogListCall<'a, C> {
1652 ProjectLocationCatalogListCall {
1653 hub: self.hub,
1654 _parent: parent.to_string(),
1655 _page_token: Default::default(),
1656 _page_size: Default::default(),
1657 _delegate: Default::default(),
1658 _additional_params: Default::default(),
1659 _scopes: Default::default(),
1660 }
1661 }
1662
1663 /// Create a builder to help you perform the following task:
1664 ///
1665 /// Updates the catalog configuration.
1666 ///
1667 /// # Arguments
1668 ///
1669 /// * `request` - No description provided.
1670 /// * `name` - The fully qualified resource name of the catalog.
1671 pub fn locations_catalogs_patch(
1672 &self,
1673 request: GoogleCloudRecommendationengineV1beta1Catalog,
1674 name: &str,
1675 ) -> ProjectLocationCatalogPatchCall<'a, C> {
1676 ProjectLocationCatalogPatchCall {
1677 hub: self.hub,
1678 _request: request,
1679 _name: name.to_string(),
1680 _update_mask: Default::default(),
1681 _delegate: Default::default(),
1682 _additional_params: Default::default(),
1683 _scopes: Default::default(),
1684 }
1685 }
1686}
1687
1688// ###################
1689// CallBuilders ###
1690// #################
1691
1692/// Creates a catalog item.
1693///
1694/// A builder for the *locations.catalogs.catalogItems.create* method supported by a *project* resource.
1695/// It is not used directly, but through a [`ProjectMethods`] instance.
1696///
1697/// # Example
1698///
1699/// Instantiate a resource method builder
1700///
1701/// ```test_harness,no_run
1702/// # extern crate hyper;
1703/// # extern crate hyper_rustls;
1704/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
1705/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1CatalogItem;
1706/// # async fn dox() {
1707/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1708///
1709/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1710/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1711/// # .with_native_roots()
1712/// # .unwrap()
1713/// # .https_only()
1714/// # .enable_http2()
1715/// # .build();
1716///
1717/// # let executor = hyper_util::rt::TokioExecutor::new();
1718/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1719/// # secret,
1720/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1721/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1722/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1723/// # ),
1724/// # ).build().await.unwrap();
1725///
1726/// # let client = hyper_util::client::legacy::Client::builder(
1727/// # hyper_util::rt::TokioExecutor::new()
1728/// # )
1729/// # .build(
1730/// # hyper_rustls::HttpsConnectorBuilder::new()
1731/// # .with_native_roots()
1732/// # .unwrap()
1733/// # .https_or_http()
1734/// # .enable_http2()
1735/// # .build()
1736/// # );
1737/// # let mut hub = RecommendationsAI::new(client, auth);
1738/// // As the method needs a request, you would usually fill it with the desired information
1739/// // into the respective structure. Some of the parts shown here might not be applicable !
1740/// // Values shown here are possibly random and not representative !
1741/// let mut req = GoogleCloudRecommendationengineV1beta1CatalogItem::default();
1742///
1743/// // You can configure optional parameters by calling the respective setters at will, and
1744/// // execute the final call using `doit()`.
1745/// // Values shown here are possibly random and not representative !
1746/// let result = hub.projects().locations_catalogs_catalog_items_create(req, "parent")
1747/// .doit().await;
1748/// # }
1749/// ```
1750pub struct ProjectLocationCatalogCatalogItemCreateCall<'a, C>
1751where
1752 C: 'a,
1753{
1754 hub: &'a RecommendationsAI<C>,
1755 _request: GoogleCloudRecommendationengineV1beta1CatalogItem,
1756 _parent: String,
1757 _delegate: Option<&'a mut dyn common::Delegate>,
1758 _additional_params: HashMap<String, String>,
1759 _scopes: BTreeSet<String>,
1760}
1761
1762impl<'a, C> common::CallBuilder for ProjectLocationCatalogCatalogItemCreateCall<'a, C> {}
1763
1764impl<'a, C> ProjectLocationCatalogCatalogItemCreateCall<'a, C>
1765where
1766 C: common::Connector,
1767{
1768 /// Perform the operation you have build so far.
1769 pub async fn doit(
1770 mut self,
1771 ) -> common::Result<(
1772 common::Response,
1773 GoogleCloudRecommendationengineV1beta1CatalogItem,
1774 )> {
1775 use std::borrow::Cow;
1776 use std::io::{Read, Seek};
1777
1778 use common::{url::Params, ToParts};
1779 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1780
1781 let mut dd = common::DefaultDelegate;
1782 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1783 dlg.begin(common::MethodInfo {
1784 id: "recommendationengine.projects.locations.catalogs.catalogItems.create",
1785 http_method: hyper::Method::POST,
1786 });
1787
1788 for &field in ["alt", "parent"].iter() {
1789 if self._additional_params.contains_key(field) {
1790 dlg.finished(false);
1791 return Err(common::Error::FieldClash(field));
1792 }
1793 }
1794
1795 let mut params = Params::with_capacity(4 + self._additional_params.len());
1796 params.push("parent", self._parent);
1797
1798 params.extend(self._additional_params.iter());
1799
1800 params.push("alt", "json");
1801 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/catalogItems";
1802 if self._scopes.is_empty() {
1803 self._scopes
1804 .insert(Scope::CloudPlatform.as_ref().to_string());
1805 }
1806
1807 #[allow(clippy::single_element_loop)]
1808 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1809 url = params.uri_replacement(url, param_name, find_this, true);
1810 }
1811 {
1812 let to_remove = ["parent"];
1813 params.remove_params(&to_remove);
1814 }
1815
1816 let url = params.parse_with_url(&url);
1817
1818 let mut json_mime_type = mime::APPLICATION_JSON;
1819 let mut request_value_reader = {
1820 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1821 common::remove_json_null_values(&mut value);
1822 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1823 serde_json::to_writer(&mut dst, &value).unwrap();
1824 dst
1825 };
1826 let request_size = request_value_reader
1827 .seek(std::io::SeekFrom::End(0))
1828 .unwrap();
1829 request_value_reader
1830 .seek(std::io::SeekFrom::Start(0))
1831 .unwrap();
1832
1833 loop {
1834 let token = match self
1835 .hub
1836 .auth
1837 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1838 .await
1839 {
1840 Ok(token) => token,
1841 Err(e) => match dlg.token(e) {
1842 Ok(token) => token,
1843 Err(e) => {
1844 dlg.finished(false);
1845 return Err(common::Error::MissingToken(e));
1846 }
1847 },
1848 };
1849 request_value_reader
1850 .seek(std::io::SeekFrom::Start(0))
1851 .unwrap();
1852 let mut req_result = {
1853 let client = &self.hub.client;
1854 dlg.pre_request();
1855 let mut req_builder = hyper::Request::builder()
1856 .method(hyper::Method::POST)
1857 .uri(url.as_str())
1858 .header(USER_AGENT, self.hub._user_agent.clone());
1859
1860 if let Some(token) = token.as_ref() {
1861 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1862 }
1863
1864 let request = req_builder
1865 .header(CONTENT_TYPE, json_mime_type.to_string())
1866 .header(CONTENT_LENGTH, request_size as u64)
1867 .body(common::to_body(
1868 request_value_reader.get_ref().clone().into(),
1869 ));
1870
1871 client.request(request.unwrap()).await
1872 };
1873
1874 match req_result {
1875 Err(err) => {
1876 if let common::Retry::After(d) = dlg.http_error(&err) {
1877 sleep(d).await;
1878 continue;
1879 }
1880 dlg.finished(false);
1881 return Err(common::Error::HttpError(err));
1882 }
1883 Ok(res) => {
1884 let (mut parts, body) = res.into_parts();
1885 let mut body = common::Body::new(body);
1886 if !parts.status.is_success() {
1887 let bytes = common::to_bytes(body).await.unwrap_or_default();
1888 let error = serde_json::from_str(&common::to_string(&bytes));
1889 let response = common::to_response(parts, bytes.into());
1890
1891 if let common::Retry::After(d) =
1892 dlg.http_failure(&response, error.as_ref().ok())
1893 {
1894 sleep(d).await;
1895 continue;
1896 }
1897
1898 dlg.finished(false);
1899
1900 return Err(match error {
1901 Ok(value) => common::Error::BadRequest(value),
1902 _ => common::Error::Failure(response),
1903 });
1904 }
1905 let response = {
1906 let bytes = common::to_bytes(body).await.unwrap_or_default();
1907 let encoded = common::to_string(&bytes);
1908 match serde_json::from_str(&encoded) {
1909 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1910 Err(error) => {
1911 dlg.response_json_decode_error(&encoded, &error);
1912 return Err(common::Error::JsonDecodeError(
1913 encoded.to_string(),
1914 error,
1915 ));
1916 }
1917 }
1918 };
1919
1920 dlg.finished(true);
1921 return Ok(response);
1922 }
1923 }
1924 }
1925 }
1926
1927 ///
1928 /// Sets the *request* property to the given value.
1929 ///
1930 /// Even though the property as already been set when instantiating this call,
1931 /// we provide this method for API completeness.
1932 pub fn request(
1933 mut self,
1934 new_value: GoogleCloudRecommendationengineV1beta1CatalogItem,
1935 ) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C> {
1936 self._request = new_value;
1937 self
1938 }
1939 /// Required. The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog`.
1940 ///
1941 /// Sets the *parent* path property to the given value.
1942 ///
1943 /// Even though the property as already been set when instantiating this call,
1944 /// we provide this method for API completeness.
1945 pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C> {
1946 self._parent = new_value.to_string();
1947 self
1948 }
1949 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1950 /// while executing the actual API request.
1951 ///
1952 /// ````text
1953 /// It should be used to handle progress information, and to implement a certain level of resilience.
1954 /// ````
1955 ///
1956 /// Sets the *delegate* property to the given value.
1957 pub fn delegate(
1958 mut self,
1959 new_value: &'a mut dyn common::Delegate,
1960 ) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C> {
1961 self._delegate = Some(new_value);
1962 self
1963 }
1964
1965 /// Set any additional parameter of the query string used in the request.
1966 /// It should be used to set parameters which are not yet available through their own
1967 /// setters.
1968 ///
1969 /// Please note that this method must not be used to set any of the known parameters
1970 /// which have their own setter method. If done anyway, the request will fail.
1971 ///
1972 /// # Additional Parameters
1973 ///
1974 /// * *$.xgafv* (query-string) - V1 error format.
1975 /// * *access_token* (query-string) - OAuth access token.
1976 /// * *alt* (query-string) - Data format for response.
1977 /// * *callback* (query-string) - JSONP
1978 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1979 /// * *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.
1980 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1981 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1982 /// * *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.
1983 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1984 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1985 pub fn param<T>(
1986 mut self,
1987 name: T,
1988 value: T,
1989 ) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C>
1990 where
1991 T: AsRef<str>,
1992 {
1993 self._additional_params
1994 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1995 self
1996 }
1997
1998 /// Identifies the authorization scope for the method you are building.
1999 ///
2000 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2001 /// [`Scope::CloudPlatform`].
2002 ///
2003 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2004 /// tokens for more than one scope.
2005 ///
2006 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2007 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2008 /// sufficient, a read-write scope will do as well.
2009 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C>
2010 where
2011 St: AsRef<str>,
2012 {
2013 self._scopes.insert(String::from(scope.as_ref()));
2014 self
2015 }
2016 /// Identifies the authorization scope(s) for the method you are building.
2017 ///
2018 /// See [`Self::add_scope()`] for details.
2019 pub fn add_scopes<I, St>(
2020 mut self,
2021 scopes: I,
2022 ) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C>
2023 where
2024 I: IntoIterator<Item = St>,
2025 St: AsRef<str>,
2026 {
2027 self._scopes
2028 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2029 self
2030 }
2031
2032 /// Removes all scopes, and no default scope will be used either.
2033 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2034 /// for details).
2035 pub fn clear_scopes(mut self) -> ProjectLocationCatalogCatalogItemCreateCall<'a, C> {
2036 self._scopes.clear();
2037 self
2038 }
2039}
2040
2041/// Deletes a catalog item.
2042///
2043/// A builder for the *locations.catalogs.catalogItems.delete* method supported by a *project* resource.
2044/// It is not used directly, but through a [`ProjectMethods`] instance.
2045///
2046/// # Example
2047///
2048/// Instantiate a resource method builder
2049///
2050/// ```test_harness,no_run
2051/// # extern crate hyper;
2052/// # extern crate hyper_rustls;
2053/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
2054/// # async fn dox() {
2055/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2056///
2057/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2058/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2059/// # .with_native_roots()
2060/// # .unwrap()
2061/// # .https_only()
2062/// # .enable_http2()
2063/// # .build();
2064///
2065/// # let executor = hyper_util::rt::TokioExecutor::new();
2066/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2067/// # secret,
2068/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2069/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2070/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2071/// # ),
2072/// # ).build().await.unwrap();
2073///
2074/// # let client = hyper_util::client::legacy::Client::builder(
2075/// # hyper_util::rt::TokioExecutor::new()
2076/// # )
2077/// # .build(
2078/// # hyper_rustls::HttpsConnectorBuilder::new()
2079/// # .with_native_roots()
2080/// # .unwrap()
2081/// # .https_or_http()
2082/// # .enable_http2()
2083/// # .build()
2084/// # );
2085/// # let mut hub = RecommendationsAI::new(client, auth);
2086/// // You can configure optional parameters by calling the respective setters at will, and
2087/// // execute the final call using `doit()`.
2088/// // Values shown here are possibly random and not representative !
2089/// let result = hub.projects().locations_catalogs_catalog_items_delete("name")
2090/// .doit().await;
2091/// # }
2092/// ```
2093pub struct ProjectLocationCatalogCatalogItemDeleteCall<'a, C>
2094where
2095 C: 'a,
2096{
2097 hub: &'a RecommendationsAI<C>,
2098 _name: String,
2099 _delegate: Option<&'a mut dyn common::Delegate>,
2100 _additional_params: HashMap<String, String>,
2101 _scopes: BTreeSet<String>,
2102}
2103
2104impl<'a, C> common::CallBuilder for ProjectLocationCatalogCatalogItemDeleteCall<'a, C> {}
2105
2106impl<'a, C> ProjectLocationCatalogCatalogItemDeleteCall<'a, C>
2107where
2108 C: common::Connector,
2109{
2110 /// Perform the operation you have build so far.
2111 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
2112 use std::borrow::Cow;
2113 use std::io::{Read, Seek};
2114
2115 use common::{url::Params, ToParts};
2116 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2117
2118 let mut dd = common::DefaultDelegate;
2119 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2120 dlg.begin(common::MethodInfo {
2121 id: "recommendationengine.projects.locations.catalogs.catalogItems.delete",
2122 http_method: hyper::Method::DELETE,
2123 });
2124
2125 for &field in ["alt", "name"].iter() {
2126 if self._additional_params.contains_key(field) {
2127 dlg.finished(false);
2128 return Err(common::Error::FieldClash(field));
2129 }
2130 }
2131
2132 let mut params = Params::with_capacity(3 + self._additional_params.len());
2133 params.push("name", self._name);
2134
2135 params.extend(self._additional_params.iter());
2136
2137 params.push("alt", "json");
2138 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2139 if self._scopes.is_empty() {
2140 self._scopes
2141 .insert(Scope::CloudPlatform.as_ref().to_string());
2142 }
2143
2144 #[allow(clippy::single_element_loop)]
2145 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2146 url = params.uri_replacement(url, param_name, find_this, true);
2147 }
2148 {
2149 let to_remove = ["name"];
2150 params.remove_params(&to_remove);
2151 }
2152
2153 let url = params.parse_with_url(&url);
2154
2155 loop {
2156 let token = match self
2157 .hub
2158 .auth
2159 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2160 .await
2161 {
2162 Ok(token) => token,
2163 Err(e) => match dlg.token(e) {
2164 Ok(token) => token,
2165 Err(e) => {
2166 dlg.finished(false);
2167 return Err(common::Error::MissingToken(e));
2168 }
2169 },
2170 };
2171 let mut req_result = {
2172 let client = &self.hub.client;
2173 dlg.pre_request();
2174 let mut req_builder = hyper::Request::builder()
2175 .method(hyper::Method::DELETE)
2176 .uri(url.as_str())
2177 .header(USER_AGENT, self.hub._user_agent.clone());
2178
2179 if let Some(token) = token.as_ref() {
2180 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2181 }
2182
2183 let request = req_builder
2184 .header(CONTENT_LENGTH, 0_u64)
2185 .body(common::to_body::<String>(None));
2186
2187 client.request(request.unwrap()).await
2188 };
2189
2190 match req_result {
2191 Err(err) => {
2192 if let common::Retry::After(d) = dlg.http_error(&err) {
2193 sleep(d).await;
2194 continue;
2195 }
2196 dlg.finished(false);
2197 return Err(common::Error::HttpError(err));
2198 }
2199 Ok(res) => {
2200 let (mut parts, body) = res.into_parts();
2201 let mut body = common::Body::new(body);
2202 if !parts.status.is_success() {
2203 let bytes = common::to_bytes(body).await.unwrap_or_default();
2204 let error = serde_json::from_str(&common::to_string(&bytes));
2205 let response = common::to_response(parts, bytes.into());
2206
2207 if let common::Retry::After(d) =
2208 dlg.http_failure(&response, error.as_ref().ok())
2209 {
2210 sleep(d).await;
2211 continue;
2212 }
2213
2214 dlg.finished(false);
2215
2216 return Err(match error {
2217 Ok(value) => common::Error::BadRequest(value),
2218 _ => common::Error::Failure(response),
2219 });
2220 }
2221 let response = {
2222 let bytes = common::to_bytes(body).await.unwrap_or_default();
2223 let encoded = common::to_string(&bytes);
2224 match serde_json::from_str(&encoded) {
2225 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2226 Err(error) => {
2227 dlg.response_json_decode_error(&encoded, &error);
2228 return Err(common::Error::JsonDecodeError(
2229 encoded.to_string(),
2230 error,
2231 ));
2232 }
2233 }
2234 };
2235
2236 dlg.finished(true);
2237 return Ok(response);
2238 }
2239 }
2240 }
2241 }
2242
2243 /// Required. Full resource name of catalog item, such as `projects/*/locations/global/catalogs/default_catalog/catalogItems/some_catalog_item_id`.
2244 ///
2245 /// Sets the *name* path property to the given value.
2246 ///
2247 /// Even though the property as already been set when instantiating this call,
2248 /// we provide this method for API completeness.
2249 pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogCatalogItemDeleteCall<'a, C> {
2250 self._name = new_value.to_string();
2251 self
2252 }
2253 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2254 /// while executing the actual API request.
2255 ///
2256 /// ````text
2257 /// It should be used to handle progress information, and to implement a certain level of resilience.
2258 /// ````
2259 ///
2260 /// Sets the *delegate* property to the given value.
2261 pub fn delegate(
2262 mut self,
2263 new_value: &'a mut dyn common::Delegate,
2264 ) -> ProjectLocationCatalogCatalogItemDeleteCall<'a, C> {
2265 self._delegate = Some(new_value);
2266 self
2267 }
2268
2269 /// Set any additional parameter of the query string used in the request.
2270 /// It should be used to set parameters which are not yet available through their own
2271 /// setters.
2272 ///
2273 /// Please note that this method must not be used to set any of the known parameters
2274 /// which have their own setter method. If done anyway, the request will fail.
2275 ///
2276 /// # Additional Parameters
2277 ///
2278 /// * *$.xgafv* (query-string) - V1 error format.
2279 /// * *access_token* (query-string) - OAuth access token.
2280 /// * *alt* (query-string) - Data format for response.
2281 /// * *callback* (query-string) - JSONP
2282 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2283 /// * *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.
2284 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2285 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2286 /// * *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.
2287 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2288 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2289 pub fn param<T>(
2290 mut self,
2291 name: T,
2292 value: T,
2293 ) -> ProjectLocationCatalogCatalogItemDeleteCall<'a, C>
2294 where
2295 T: AsRef<str>,
2296 {
2297 self._additional_params
2298 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2299 self
2300 }
2301
2302 /// Identifies the authorization scope for the method you are building.
2303 ///
2304 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2305 /// [`Scope::CloudPlatform`].
2306 ///
2307 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2308 /// tokens for more than one scope.
2309 ///
2310 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2311 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2312 /// sufficient, a read-write scope will do as well.
2313 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogCatalogItemDeleteCall<'a, C>
2314 where
2315 St: AsRef<str>,
2316 {
2317 self._scopes.insert(String::from(scope.as_ref()));
2318 self
2319 }
2320 /// Identifies the authorization scope(s) for the method you are building.
2321 ///
2322 /// See [`Self::add_scope()`] for details.
2323 pub fn add_scopes<I, St>(
2324 mut self,
2325 scopes: I,
2326 ) -> ProjectLocationCatalogCatalogItemDeleteCall<'a, C>
2327 where
2328 I: IntoIterator<Item = St>,
2329 St: AsRef<str>,
2330 {
2331 self._scopes
2332 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2333 self
2334 }
2335
2336 /// Removes all scopes, and no default scope will be used either.
2337 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2338 /// for details).
2339 pub fn clear_scopes(mut self) -> ProjectLocationCatalogCatalogItemDeleteCall<'a, C> {
2340 self._scopes.clear();
2341 self
2342 }
2343}
2344
2345/// Gets a specific catalog item.
2346///
2347/// A builder for the *locations.catalogs.catalogItems.get* method supported by a *project* resource.
2348/// It is not used directly, but through a [`ProjectMethods`] instance.
2349///
2350/// # Example
2351///
2352/// Instantiate a resource method builder
2353///
2354/// ```test_harness,no_run
2355/// # extern crate hyper;
2356/// # extern crate hyper_rustls;
2357/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
2358/// # async fn dox() {
2359/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2360///
2361/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2362/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2363/// # .with_native_roots()
2364/// # .unwrap()
2365/// # .https_only()
2366/// # .enable_http2()
2367/// # .build();
2368///
2369/// # let executor = hyper_util::rt::TokioExecutor::new();
2370/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2371/// # secret,
2372/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2373/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2374/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2375/// # ),
2376/// # ).build().await.unwrap();
2377///
2378/// # let client = hyper_util::client::legacy::Client::builder(
2379/// # hyper_util::rt::TokioExecutor::new()
2380/// # )
2381/// # .build(
2382/// # hyper_rustls::HttpsConnectorBuilder::new()
2383/// # .with_native_roots()
2384/// # .unwrap()
2385/// # .https_or_http()
2386/// # .enable_http2()
2387/// # .build()
2388/// # );
2389/// # let mut hub = RecommendationsAI::new(client, auth);
2390/// // You can configure optional parameters by calling the respective setters at will, and
2391/// // execute the final call using `doit()`.
2392/// // Values shown here are possibly random and not representative !
2393/// let result = hub.projects().locations_catalogs_catalog_items_get("name")
2394/// .doit().await;
2395/// # }
2396/// ```
2397pub struct ProjectLocationCatalogCatalogItemGetCall<'a, C>
2398where
2399 C: 'a,
2400{
2401 hub: &'a RecommendationsAI<C>,
2402 _name: String,
2403 _delegate: Option<&'a mut dyn common::Delegate>,
2404 _additional_params: HashMap<String, String>,
2405 _scopes: BTreeSet<String>,
2406}
2407
2408impl<'a, C> common::CallBuilder for ProjectLocationCatalogCatalogItemGetCall<'a, C> {}
2409
2410impl<'a, C> ProjectLocationCatalogCatalogItemGetCall<'a, C>
2411where
2412 C: common::Connector,
2413{
2414 /// Perform the operation you have build so far.
2415 pub async fn doit(
2416 mut self,
2417 ) -> common::Result<(
2418 common::Response,
2419 GoogleCloudRecommendationengineV1beta1CatalogItem,
2420 )> {
2421 use std::borrow::Cow;
2422 use std::io::{Read, Seek};
2423
2424 use common::{url::Params, ToParts};
2425 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2426
2427 let mut dd = common::DefaultDelegate;
2428 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2429 dlg.begin(common::MethodInfo {
2430 id: "recommendationengine.projects.locations.catalogs.catalogItems.get",
2431 http_method: hyper::Method::GET,
2432 });
2433
2434 for &field in ["alt", "name"].iter() {
2435 if self._additional_params.contains_key(field) {
2436 dlg.finished(false);
2437 return Err(common::Error::FieldClash(field));
2438 }
2439 }
2440
2441 let mut params = Params::with_capacity(3 + self._additional_params.len());
2442 params.push("name", self._name);
2443
2444 params.extend(self._additional_params.iter());
2445
2446 params.push("alt", "json");
2447 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2448 if self._scopes.is_empty() {
2449 self._scopes
2450 .insert(Scope::CloudPlatform.as_ref().to_string());
2451 }
2452
2453 #[allow(clippy::single_element_loop)]
2454 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2455 url = params.uri_replacement(url, param_name, find_this, true);
2456 }
2457 {
2458 let to_remove = ["name"];
2459 params.remove_params(&to_remove);
2460 }
2461
2462 let url = params.parse_with_url(&url);
2463
2464 loop {
2465 let token = match self
2466 .hub
2467 .auth
2468 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2469 .await
2470 {
2471 Ok(token) => token,
2472 Err(e) => match dlg.token(e) {
2473 Ok(token) => token,
2474 Err(e) => {
2475 dlg.finished(false);
2476 return Err(common::Error::MissingToken(e));
2477 }
2478 },
2479 };
2480 let mut req_result = {
2481 let client = &self.hub.client;
2482 dlg.pre_request();
2483 let mut req_builder = hyper::Request::builder()
2484 .method(hyper::Method::GET)
2485 .uri(url.as_str())
2486 .header(USER_AGENT, self.hub._user_agent.clone());
2487
2488 if let Some(token) = token.as_ref() {
2489 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2490 }
2491
2492 let request = req_builder
2493 .header(CONTENT_LENGTH, 0_u64)
2494 .body(common::to_body::<String>(None));
2495
2496 client.request(request.unwrap()).await
2497 };
2498
2499 match req_result {
2500 Err(err) => {
2501 if let common::Retry::After(d) = dlg.http_error(&err) {
2502 sleep(d).await;
2503 continue;
2504 }
2505 dlg.finished(false);
2506 return Err(common::Error::HttpError(err));
2507 }
2508 Ok(res) => {
2509 let (mut parts, body) = res.into_parts();
2510 let mut body = common::Body::new(body);
2511 if !parts.status.is_success() {
2512 let bytes = common::to_bytes(body).await.unwrap_or_default();
2513 let error = serde_json::from_str(&common::to_string(&bytes));
2514 let response = common::to_response(parts, bytes.into());
2515
2516 if let common::Retry::After(d) =
2517 dlg.http_failure(&response, error.as_ref().ok())
2518 {
2519 sleep(d).await;
2520 continue;
2521 }
2522
2523 dlg.finished(false);
2524
2525 return Err(match error {
2526 Ok(value) => common::Error::BadRequest(value),
2527 _ => common::Error::Failure(response),
2528 });
2529 }
2530 let response = {
2531 let bytes = common::to_bytes(body).await.unwrap_or_default();
2532 let encoded = common::to_string(&bytes);
2533 match serde_json::from_str(&encoded) {
2534 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2535 Err(error) => {
2536 dlg.response_json_decode_error(&encoded, &error);
2537 return Err(common::Error::JsonDecodeError(
2538 encoded.to_string(),
2539 error,
2540 ));
2541 }
2542 }
2543 };
2544
2545 dlg.finished(true);
2546 return Ok(response);
2547 }
2548 }
2549 }
2550 }
2551
2552 /// Required. Full resource name of catalog item, such as `projects/*/locations/global/catalogs/default_catalog/catalogitems/some_catalog_item_id`.
2553 ///
2554 /// Sets the *name* path property to the given value.
2555 ///
2556 /// Even though the property as already been set when instantiating this call,
2557 /// we provide this method for API completeness.
2558 pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogCatalogItemGetCall<'a, C> {
2559 self._name = new_value.to_string();
2560 self
2561 }
2562 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2563 /// while executing the actual API request.
2564 ///
2565 /// ````text
2566 /// It should be used to handle progress information, and to implement a certain level of resilience.
2567 /// ````
2568 ///
2569 /// Sets the *delegate* property to the given value.
2570 pub fn delegate(
2571 mut self,
2572 new_value: &'a mut dyn common::Delegate,
2573 ) -> ProjectLocationCatalogCatalogItemGetCall<'a, C> {
2574 self._delegate = Some(new_value);
2575 self
2576 }
2577
2578 /// Set any additional parameter of the query string used in the request.
2579 /// It should be used to set parameters which are not yet available through their own
2580 /// setters.
2581 ///
2582 /// Please note that this method must not be used to set any of the known parameters
2583 /// which have their own setter method. If done anyway, the request will fail.
2584 ///
2585 /// # Additional Parameters
2586 ///
2587 /// * *$.xgafv* (query-string) - V1 error format.
2588 /// * *access_token* (query-string) - OAuth access token.
2589 /// * *alt* (query-string) - Data format for response.
2590 /// * *callback* (query-string) - JSONP
2591 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2592 /// * *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.
2593 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2594 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2595 /// * *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.
2596 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2597 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2598 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogCatalogItemGetCall<'a, C>
2599 where
2600 T: AsRef<str>,
2601 {
2602 self._additional_params
2603 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2604 self
2605 }
2606
2607 /// Identifies the authorization scope for the method you are building.
2608 ///
2609 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2610 /// [`Scope::CloudPlatform`].
2611 ///
2612 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2613 /// tokens for more than one scope.
2614 ///
2615 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2616 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2617 /// sufficient, a read-write scope will do as well.
2618 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogCatalogItemGetCall<'a, C>
2619 where
2620 St: AsRef<str>,
2621 {
2622 self._scopes.insert(String::from(scope.as_ref()));
2623 self
2624 }
2625 /// Identifies the authorization scope(s) for the method you are building.
2626 ///
2627 /// See [`Self::add_scope()`] for details.
2628 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogCatalogItemGetCall<'a, C>
2629 where
2630 I: IntoIterator<Item = St>,
2631 St: AsRef<str>,
2632 {
2633 self._scopes
2634 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2635 self
2636 }
2637
2638 /// Removes all scopes, and no default scope will be used either.
2639 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2640 /// for details).
2641 pub fn clear_scopes(mut self) -> ProjectLocationCatalogCatalogItemGetCall<'a, C> {
2642 self._scopes.clear();
2643 self
2644 }
2645}
2646
2647/// Bulk import of multiple catalog items. Request processing may be synchronous. No partial updating supported. Non-existing items will be created. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully updated.
2648///
2649/// A builder for the *locations.catalogs.catalogItems.import* method supported by a *project* resource.
2650/// It is not used directly, but through a [`ProjectMethods`] instance.
2651///
2652/// # Example
2653///
2654/// Instantiate a resource method builder
2655///
2656/// ```test_harness,no_run
2657/// # extern crate hyper;
2658/// # extern crate hyper_rustls;
2659/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
2660/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest;
2661/// # async fn dox() {
2662/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2663///
2664/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2665/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2666/// # .with_native_roots()
2667/// # .unwrap()
2668/// # .https_only()
2669/// # .enable_http2()
2670/// # .build();
2671///
2672/// # let executor = hyper_util::rt::TokioExecutor::new();
2673/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2674/// # secret,
2675/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2676/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2677/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2678/// # ),
2679/// # ).build().await.unwrap();
2680///
2681/// # let client = hyper_util::client::legacy::Client::builder(
2682/// # hyper_util::rt::TokioExecutor::new()
2683/// # )
2684/// # .build(
2685/// # hyper_rustls::HttpsConnectorBuilder::new()
2686/// # .with_native_roots()
2687/// # .unwrap()
2688/// # .https_or_http()
2689/// # .enable_http2()
2690/// # .build()
2691/// # );
2692/// # let mut hub = RecommendationsAI::new(client, auth);
2693/// // As the method needs a request, you would usually fill it with the desired information
2694/// // into the respective structure. Some of the parts shown here might not be applicable !
2695/// // Values shown here are possibly random and not representative !
2696/// let mut req = GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest::default();
2697///
2698/// // You can configure optional parameters by calling the respective setters at will, and
2699/// // execute the final call using `doit()`.
2700/// // Values shown here are possibly random and not representative !
2701/// let result = hub.projects().locations_catalogs_catalog_items_import(req, "parent")
2702/// .doit().await;
2703/// # }
2704/// ```
2705pub struct ProjectLocationCatalogCatalogItemImportCall<'a, C>
2706where
2707 C: 'a,
2708{
2709 hub: &'a RecommendationsAI<C>,
2710 _request: GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest,
2711 _parent: String,
2712 _delegate: Option<&'a mut dyn common::Delegate>,
2713 _additional_params: HashMap<String, String>,
2714 _scopes: BTreeSet<String>,
2715}
2716
2717impl<'a, C> common::CallBuilder for ProjectLocationCatalogCatalogItemImportCall<'a, C> {}
2718
2719impl<'a, C> ProjectLocationCatalogCatalogItemImportCall<'a, C>
2720where
2721 C: common::Connector,
2722{
2723 /// Perform the operation you have build so far.
2724 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
2725 use std::borrow::Cow;
2726 use std::io::{Read, Seek};
2727
2728 use common::{url::Params, ToParts};
2729 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2730
2731 let mut dd = common::DefaultDelegate;
2732 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2733 dlg.begin(common::MethodInfo {
2734 id: "recommendationengine.projects.locations.catalogs.catalogItems.import",
2735 http_method: hyper::Method::POST,
2736 });
2737
2738 for &field in ["alt", "parent"].iter() {
2739 if self._additional_params.contains_key(field) {
2740 dlg.finished(false);
2741 return Err(common::Error::FieldClash(field));
2742 }
2743 }
2744
2745 let mut params = Params::with_capacity(4 + self._additional_params.len());
2746 params.push("parent", self._parent);
2747
2748 params.extend(self._additional_params.iter());
2749
2750 params.push("alt", "json");
2751 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/catalogItems:import";
2752 if self._scopes.is_empty() {
2753 self._scopes
2754 .insert(Scope::CloudPlatform.as_ref().to_string());
2755 }
2756
2757 #[allow(clippy::single_element_loop)]
2758 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2759 url = params.uri_replacement(url, param_name, find_this, true);
2760 }
2761 {
2762 let to_remove = ["parent"];
2763 params.remove_params(&to_remove);
2764 }
2765
2766 let url = params.parse_with_url(&url);
2767
2768 let mut json_mime_type = mime::APPLICATION_JSON;
2769 let mut request_value_reader = {
2770 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2771 common::remove_json_null_values(&mut value);
2772 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2773 serde_json::to_writer(&mut dst, &value).unwrap();
2774 dst
2775 };
2776 let request_size = request_value_reader
2777 .seek(std::io::SeekFrom::End(0))
2778 .unwrap();
2779 request_value_reader
2780 .seek(std::io::SeekFrom::Start(0))
2781 .unwrap();
2782
2783 loop {
2784 let token = match self
2785 .hub
2786 .auth
2787 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2788 .await
2789 {
2790 Ok(token) => token,
2791 Err(e) => match dlg.token(e) {
2792 Ok(token) => token,
2793 Err(e) => {
2794 dlg.finished(false);
2795 return Err(common::Error::MissingToken(e));
2796 }
2797 },
2798 };
2799 request_value_reader
2800 .seek(std::io::SeekFrom::Start(0))
2801 .unwrap();
2802 let mut req_result = {
2803 let client = &self.hub.client;
2804 dlg.pre_request();
2805 let mut req_builder = hyper::Request::builder()
2806 .method(hyper::Method::POST)
2807 .uri(url.as_str())
2808 .header(USER_AGENT, self.hub._user_agent.clone());
2809
2810 if let Some(token) = token.as_ref() {
2811 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2812 }
2813
2814 let request = req_builder
2815 .header(CONTENT_TYPE, json_mime_type.to_string())
2816 .header(CONTENT_LENGTH, request_size as u64)
2817 .body(common::to_body(
2818 request_value_reader.get_ref().clone().into(),
2819 ));
2820
2821 client.request(request.unwrap()).await
2822 };
2823
2824 match req_result {
2825 Err(err) => {
2826 if let common::Retry::After(d) = dlg.http_error(&err) {
2827 sleep(d).await;
2828 continue;
2829 }
2830 dlg.finished(false);
2831 return Err(common::Error::HttpError(err));
2832 }
2833 Ok(res) => {
2834 let (mut parts, body) = res.into_parts();
2835 let mut body = common::Body::new(body);
2836 if !parts.status.is_success() {
2837 let bytes = common::to_bytes(body).await.unwrap_or_default();
2838 let error = serde_json::from_str(&common::to_string(&bytes));
2839 let response = common::to_response(parts, bytes.into());
2840
2841 if let common::Retry::After(d) =
2842 dlg.http_failure(&response, error.as_ref().ok())
2843 {
2844 sleep(d).await;
2845 continue;
2846 }
2847
2848 dlg.finished(false);
2849
2850 return Err(match error {
2851 Ok(value) => common::Error::BadRequest(value),
2852 _ => common::Error::Failure(response),
2853 });
2854 }
2855 let response = {
2856 let bytes = common::to_bytes(body).await.unwrap_or_default();
2857 let encoded = common::to_string(&bytes);
2858 match serde_json::from_str(&encoded) {
2859 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2860 Err(error) => {
2861 dlg.response_json_decode_error(&encoded, &error);
2862 return Err(common::Error::JsonDecodeError(
2863 encoded.to_string(),
2864 error,
2865 ));
2866 }
2867 }
2868 };
2869
2870 dlg.finished(true);
2871 return Ok(response);
2872 }
2873 }
2874 }
2875 }
2876
2877 ///
2878 /// Sets the *request* property to the given value.
2879 ///
2880 /// Even though the property as already been set when instantiating this call,
2881 /// we provide this method for API completeness.
2882 pub fn request(
2883 mut self,
2884 new_value: GoogleCloudRecommendationengineV1beta1ImportCatalogItemsRequest,
2885 ) -> ProjectLocationCatalogCatalogItemImportCall<'a, C> {
2886 self._request = new_value;
2887 self
2888 }
2889 /// Required. `projects/1234/locations/global/catalogs/default_catalog` If no updateMask is specified, requires catalogItems.create permission. If updateMask is specified, requires catalogItems.update permission.
2890 ///
2891 /// Sets the *parent* path property to the given value.
2892 ///
2893 /// Even though the property as already been set when instantiating this call,
2894 /// we provide this method for API completeness.
2895 pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogCatalogItemImportCall<'a, C> {
2896 self._parent = new_value.to_string();
2897 self
2898 }
2899 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2900 /// while executing the actual API request.
2901 ///
2902 /// ````text
2903 /// It should be used to handle progress information, and to implement a certain level of resilience.
2904 /// ````
2905 ///
2906 /// Sets the *delegate* property to the given value.
2907 pub fn delegate(
2908 mut self,
2909 new_value: &'a mut dyn common::Delegate,
2910 ) -> ProjectLocationCatalogCatalogItemImportCall<'a, C> {
2911 self._delegate = Some(new_value);
2912 self
2913 }
2914
2915 /// Set any additional parameter of the query string used in the request.
2916 /// It should be used to set parameters which are not yet available through their own
2917 /// setters.
2918 ///
2919 /// Please note that this method must not be used to set any of the known parameters
2920 /// which have their own setter method. If done anyway, the request will fail.
2921 ///
2922 /// # Additional Parameters
2923 ///
2924 /// * *$.xgafv* (query-string) - V1 error format.
2925 /// * *access_token* (query-string) - OAuth access token.
2926 /// * *alt* (query-string) - Data format for response.
2927 /// * *callback* (query-string) - JSONP
2928 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2929 /// * *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.
2930 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2931 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2932 /// * *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.
2933 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2934 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2935 pub fn param<T>(
2936 mut self,
2937 name: T,
2938 value: T,
2939 ) -> ProjectLocationCatalogCatalogItemImportCall<'a, C>
2940 where
2941 T: AsRef<str>,
2942 {
2943 self._additional_params
2944 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2945 self
2946 }
2947
2948 /// Identifies the authorization scope for the method you are building.
2949 ///
2950 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2951 /// [`Scope::CloudPlatform`].
2952 ///
2953 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2954 /// tokens for more than one scope.
2955 ///
2956 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2957 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2958 /// sufficient, a read-write scope will do as well.
2959 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogCatalogItemImportCall<'a, C>
2960 where
2961 St: AsRef<str>,
2962 {
2963 self._scopes.insert(String::from(scope.as_ref()));
2964 self
2965 }
2966 /// Identifies the authorization scope(s) for the method you are building.
2967 ///
2968 /// See [`Self::add_scope()`] for details.
2969 pub fn add_scopes<I, St>(
2970 mut self,
2971 scopes: I,
2972 ) -> ProjectLocationCatalogCatalogItemImportCall<'a, C>
2973 where
2974 I: IntoIterator<Item = St>,
2975 St: AsRef<str>,
2976 {
2977 self._scopes
2978 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2979 self
2980 }
2981
2982 /// Removes all scopes, and no default scope will be used either.
2983 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2984 /// for details).
2985 pub fn clear_scopes(mut self) -> ProjectLocationCatalogCatalogItemImportCall<'a, C> {
2986 self._scopes.clear();
2987 self
2988 }
2989}
2990
2991/// Gets a list of catalog items.
2992///
2993/// A builder for the *locations.catalogs.catalogItems.list* method supported by a *project* resource.
2994/// It is not used directly, but through a [`ProjectMethods`] instance.
2995///
2996/// # Example
2997///
2998/// Instantiate a resource method builder
2999///
3000/// ```test_harness,no_run
3001/// # extern crate hyper;
3002/// # extern crate hyper_rustls;
3003/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
3004/// # async fn dox() {
3005/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3006///
3007/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3008/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3009/// # .with_native_roots()
3010/// # .unwrap()
3011/// # .https_only()
3012/// # .enable_http2()
3013/// # .build();
3014///
3015/// # let executor = hyper_util::rt::TokioExecutor::new();
3016/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3017/// # secret,
3018/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3019/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3020/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3021/// # ),
3022/// # ).build().await.unwrap();
3023///
3024/// # let client = hyper_util::client::legacy::Client::builder(
3025/// # hyper_util::rt::TokioExecutor::new()
3026/// # )
3027/// # .build(
3028/// # hyper_rustls::HttpsConnectorBuilder::new()
3029/// # .with_native_roots()
3030/// # .unwrap()
3031/// # .https_or_http()
3032/// # .enable_http2()
3033/// # .build()
3034/// # );
3035/// # let mut hub = RecommendationsAI::new(client, auth);
3036/// // You can configure optional parameters by calling the respective setters at will, and
3037/// // execute the final call using `doit()`.
3038/// // Values shown here are possibly random and not representative !
3039/// let result = hub.projects().locations_catalogs_catalog_items_list("parent")
3040/// .page_token("amet.")
3041/// .page_size(-59)
3042/// .filter("amet.")
3043/// .doit().await;
3044/// # }
3045/// ```
3046pub struct ProjectLocationCatalogCatalogItemListCall<'a, C>
3047where
3048 C: 'a,
3049{
3050 hub: &'a RecommendationsAI<C>,
3051 _parent: String,
3052 _page_token: Option<String>,
3053 _page_size: Option<i32>,
3054 _filter: Option<String>,
3055 _delegate: Option<&'a mut dyn common::Delegate>,
3056 _additional_params: HashMap<String, String>,
3057 _scopes: BTreeSet<String>,
3058}
3059
3060impl<'a, C> common::CallBuilder for ProjectLocationCatalogCatalogItemListCall<'a, C> {}
3061
3062impl<'a, C> ProjectLocationCatalogCatalogItemListCall<'a, C>
3063where
3064 C: common::Connector,
3065{
3066 /// Perform the operation you have build so far.
3067 pub async fn doit(
3068 mut self,
3069 ) -> common::Result<(
3070 common::Response,
3071 GoogleCloudRecommendationengineV1beta1ListCatalogItemsResponse,
3072 )> {
3073 use std::borrow::Cow;
3074 use std::io::{Read, Seek};
3075
3076 use common::{url::Params, ToParts};
3077 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3078
3079 let mut dd = common::DefaultDelegate;
3080 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3081 dlg.begin(common::MethodInfo {
3082 id: "recommendationengine.projects.locations.catalogs.catalogItems.list",
3083 http_method: hyper::Method::GET,
3084 });
3085
3086 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
3087 if self._additional_params.contains_key(field) {
3088 dlg.finished(false);
3089 return Err(common::Error::FieldClash(field));
3090 }
3091 }
3092
3093 let mut params = Params::with_capacity(6 + self._additional_params.len());
3094 params.push("parent", self._parent);
3095 if let Some(value) = self._page_token.as_ref() {
3096 params.push("pageToken", value);
3097 }
3098 if let Some(value) = self._page_size.as_ref() {
3099 params.push("pageSize", value.to_string());
3100 }
3101 if let Some(value) = self._filter.as_ref() {
3102 params.push("filter", value);
3103 }
3104
3105 params.extend(self._additional_params.iter());
3106
3107 params.push("alt", "json");
3108 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/catalogItems";
3109 if self._scopes.is_empty() {
3110 self._scopes
3111 .insert(Scope::CloudPlatform.as_ref().to_string());
3112 }
3113
3114 #[allow(clippy::single_element_loop)]
3115 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3116 url = params.uri_replacement(url, param_name, find_this, true);
3117 }
3118 {
3119 let to_remove = ["parent"];
3120 params.remove_params(&to_remove);
3121 }
3122
3123 let url = params.parse_with_url(&url);
3124
3125 loop {
3126 let token = match self
3127 .hub
3128 .auth
3129 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3130 .await
3131 {
3132 Ok(token) => token,
3133 Err(e) => match dlg.token(e) {
3134 Ok(token) => token,
3135 Err(e) => {
3136 dlg.finished(false);
3137 return Err(common::Error::MissingToken(e));
3138 }
3139 },
3140 };
3141 let mut req_result = {
3142 let client = &self.hub.client;
3143 dlg.pre_request();
3144 let mut req_builder = hyper::Request::builder()
3145 .method(hyper::Method::GET)
3146 .uri(url.as_str())
3147 .header(USER_AGENT, self.hub._user_agent.clone());
3148
3149 if let Some(token) = token.as_ref() {
3150 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3151 }
3152
3153 let request = req_builder
3154 .header(CONTENT_LENGTH, 0_u64)
3155 .body(common::to_body::<String>(None));
3156
3157 client.request(request.unwrap()).await
3158 };
3159
3160 match req_result {
3161 Err(err) => {
3162 if let common::Retry::After(d) = dlg.http_error(&err) {
3163 sleep(d).await;
3164 continue;
3165 }
3166 dlg.finished(false);
3167 return Err(common::Error::HttpError(err));
3168 }
3169 Ok(res) => {
3170 let (mut parts, body) = res.into_parts();
3171 let mut body = common::Body::new(body);
3172 if !parts.status.is_success() {
3173 let bytes = common::to_bytes(body).await.unwrap_or_default();
3174 let error = serde_json::from_str(&common::to_string(&bytes));
3175 let response = common::to_response(parts, bytes.into());
3176
3177 if let common::Retry::After(d) =
3178 dlg.http_failure(&response, error.as_ref().ok())
3179 {
3180 sleep(d).await;
3181 continue;
3182 }
3183
3184 dlg.finished(false);
3185
3186 return Err(match error {
3187 Ok(value) => common::Error::BadRequest(value),
3188 _ => common::Error::Failure(response),
3189 });
3190 }
3191 let response = {
3192 let bytes = common::to_bytes(body).await.unwrap_or_default();
3193 let encoded = common::to_string(&bytes);
3194 match serde_json::from_str(&encoded) {
3195 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3196 Err(error) => {
3197 dlg.response_json_decode_error(&encoded, &error);
3198 return Err(common::Error::JsonDecodeError(
3199 encoded.to_string(),
3200 error,
3201 ));
3202 }
3203 }
3204 };
3205
3206 dlg.finished(true);
3207 return Ok(response);
3208 }
3209 }
3210 }
3211 }
3212
3213 /// Required. The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog`.
3214 ///
3215 /// Sets the *parent* path property to the given value.
3216 ///
3217 /// Even though the property as already been set when instantiating this call,
3218 /// we provide this method for API completeness.
3219 pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogCatalogItemListCall<'a, C> {
3220 self._parent = new_value.to_string();
3221 self
3222 }
3223 /// Optional. The previous ListCatalogItemsResponse.next_page_token.
3224 ///
3225 /// Sets the *page token* query property to the given value.
3226 pub fn page_token(
3227 mut self,
3228 new_value: &str,
3229 ) -> ProjectLocationCatalogCatalogItemListCall<'a, C> {
3230 self._page_token = Some(new_value.to_string());
3231 self
3232 }
3233 /// Optional. Maximum number of results to return per page. If zero, the service will choose a reasonable default.
3234 ///
3235 /// Sets the *page size* query property to the given value.
3236 pub fn page_size(mut self, new_value: i32) -> ProjectLocationCatalogCatalogItemListCall<'a, C> {
3237 self._page_size = Some(new_value);
3238 self
3239 }
3240 /// Optional. Use of this field is not supported by version v1beta1.
3241 ///
3242 /// Sets the *filter* query property to the given value.
3243 pub fn filter(mut self, new_value: &str) -> ProjectLocationCatalogCatalogItemListCall<'a, C> {
3244 self._filter = Some(new_value.to_string());
3245 self
3246 }
3247 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3248 /// while executing the actual API request.
3249 ///
3250 /// ````text
3251 /// It should be used to handle progress information, and to implement a certain level of resilience.
3252 /// ````
3253 ///
3254 /// Sets the *delegate* property to the given value.
3255 pub fn delegate(
3256 mut self,
3257 new_value: &'a mut dyn common::Delegate,
3258 ) -> ProjectLocationCatalogCatalogItemListCall<'a, C> {
3259 self._delegate = Some(new_value);
3260 self
3261 }
3262
3263 /// Set any additional parameter of the query string used in the request.
3264 /// It should be used to set parameters which are not yet available through their own
3265 /// setters.
3266 ///
3267 /// Please note that this method must not be used to set any of the known parameters
3268 /// which have their own setter method. If done anyway, the request will fail.
3269 ///
3270 /// # Additional Parameters
3271 ///
3272 /// * *$.xgafv* (query-string) - V1 error format.
3273 /// * *access_token* (query-string) - OAuth access token.
3274 /// * *alt* (query-string) - Data format for response.
3275 /// * *callback* (query-string) - JSONP
3276 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3277 /// * *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.
3278 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3279 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3280 /// * *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.
3281 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3282 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3283 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogCatalogItemListCall<'a, C>
3284 where
3285 T: AsRef<str>,
3286 {
3287 self._additional_params
3288 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3289 self
3290 }
3291
3292 /// Identifies the authorization scope for the method you are building.
3293 ///
3294 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3295 /// [`Scope::CloudPlatform`].
3296 ///
3297 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3298 /// tokens for more than one scope.
3299 ///
3300 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3301 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3302 /// sufficient, a read-write scope will do as well.
3303 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogCatalogItemListCall<'a, C>
3304 where
3305 St: AsRef<str>,
3306 {
3307 self._scopes.insert(String::from(scope.as_ref()));
3308 self
3309 }
3310 /// Identifies the authorization scope(s) for the method you are building.
3311 ///
3312 /// See [`Self::add_scope()`] for details.
3313 pub fn add_scopes<I, St>(
3314 mut self,
3315 scopes: I,
3316 ) -> ProjectLocationCatalogCatalogItemListCall<'a, C>
3317 where
3318 I: IntoIterator<Item = St>,
3319 St: AsRef<str>,
3320 {
3321 self._scopes
3322 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3323 self
3324 }
3325
3326 /// Removes all scopes, and no default scope will be used either.
3327 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3328 /// for details).
3329 pub fn clear_scopes(mut self) -> ProjectLocationCatalogCatalogItemListCall<'a, C> {
3330 self._scopes.clear();
3331 self
3332 }
3333}
3334
3335/// Updates a catalog item. Partial updating is supported. Non-existing items will be created.
3336///
3337/// A builder for the *locations.catalogs.catalogItems.patch* method supported by a *project* resource.
3338/// It is not used directly, but through a [`ProjectMethods`] instance.
3339///
3340/// # Example
3341///
3342/// Instantiate a resource method builder
3343///
3344/// ```test_harness,no_run
3345/// # extern crate hyper;
3346/// # extern crate hyper_rustls;
3347/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
3348/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1CatalogItem;
3349/// # async fn dox() {
3350/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3351///
3352/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3353/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3354/// # .with_native_roots()
3355/// # .unwrap()
3356/// # .https_only()
3357/// # .enable_http2()
3358/// # .build();
3359///
3360/// # let executor = hyper_util::rt::TokioExecutor::new();
3361/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3362/// # secret,
3363/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3364/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3365/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3366/// # ),
3367/// # ).build().await.unwrap();
3368///
3369/// # let client = hyper_util::client::legacy::Client::builder(
3370/// # hyper_util::rt::TokioExecutor::new()
3371/// # )
3372/// # .build(
3373/// # hyper_rustls::HttpsConnectorBuilder::new()
3374/// # .with_native_roots()
3375/// # .unwrap()
3376/// # .https_or_http()
3377/// # .enable_http2()
3378/// # .build()
3379/// # );
3380/// # let mut hub = RecommendationsAI::new(client, auth);
3381/// // As the method needs a request, you would usually fill it with the desired information
3382/// // into the respective structure. Some of the parts shown here might not be applicable !
3383/// // Values shown here are possibly random and not representative !
3384/// let mut req = GoogleCloudRecommendationengineV1beta1CatalogItem::default();
3385///
3386/// // You can configure optional parameters by calling the respective setters at will, and
3387/// // execute the final call using `doit()`.
3388/// // Values shown here are possibly random and not representative !
3389/// let result = hub.projects().locations_catalogs_catalog_items_patch(req, "name")
3390/// .update_mask(FieldMask::new::<&str>(&[]))
3391/// .doit().await;
3392/// # }
3393/// ```
3394pub struct ProjectLocationCatalogCatalogItemPatchCall<'a, C>
3395where
3396 C: 'a,
3397{
3398 hub: &'a RecommendationsAI<C>,
3399 _request: GoogleCloudRecommendationengineV1beta1CatalogItem,
3400 _name: String,
3401 _update_mask: Option<common::FieldMask>,
3402 _delegate: Option<&'a mut dyn common::Delegate>,
3403 _additional_params: HashMap<String, String>,
3404 _scopes: BTreeSet<String>,
3405}
3406
3407impl<'a, C> common::CallBuilder for ProjectLocationCatalogCatalogItemPatchCall<'a, C> {}
3408
3409impl<'a, C> ProjectLocationCatalogCatalogItemPatchCall<'a, C>
3410where
3411 C: common::Connector,
3412{
3413 /// Perform the operation you have build so far.
3414 pub async fn doit(
3415 mut self,
3416 ) -> common::Result<(
3417 common::Response,
3418 GoogleCloudRecommendationengineV1beta1CatalogItem,
3419 )> {
3420 use std::borrow::Cow;
3421 use std::io::{Read, Seek};
3422
3423 use common::{url::Params, ToParts};
3424 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3425
3426 let mut dd = common::DefaultDelegate;
3427 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3428 dlg.begin(common::MethodInfo {
3429 id: "recommendationengine.projects.locations.catalogs.catalogItems.patch",
3430 http_method: hyper::Method::PATCH,
3431 });
3432
3433 for &field in ["alt", "name", "updateMask"].iter() {
3434 if self._additional_params.contains_key(field) {
3435 dlg.finished(false);
3436 return Err(common::Error::FieldClash(field));
3437 }
3438 }
3439
3440 let mut params = Params::with_capacity(5 + self._additional_params.len());
3441 params.push("name", self._name);
3442 if let Some(value) = self._update_mask.as_ref() {
3443 params.push("updateMask", value.to_string());
3444 }
3445
3446 params.extend(self._additional_params.iter());
3447
3448 params.push("alt", "json");
3449 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3450 if self._scopes.is_empty() {
3451 self._scopes
3452 .insert(Scope::CloudPlatform.as_ref().to_string());
3453 }
3454
3455 #[allow(clippy::single_element_loop)]
3456 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3457 url = params.uri_replacement(url, param_name, find_this, true);
3458 }
3459 {
3460 let to_remove = ["name"];
3461 params.remove_params(&to_remove);
3462 }
3463
3464 let url = params.parse_with_url(&url);
3465
3466 let mut json_mime_type = mime::APPLICATION_JSON;
3467 let mut request_value_reader = {
3468 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3469 common::remove_json_null_values(&mut value);
3470 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3471 serde_json::to_writer(&mut dst, &value).unwrap();
3472 dst
3473 };
3474 let request_size = request_value_reader
3475 .seek(std::io::SeekFrom::End(0))
3476 .unwrap();
3477 request_value_reader
3478 .seek(std::io::SeekFrom::Start(0))
3479 .unwrap();
3480
3481 loop {
3482 let token = match self
3483 .hub
3484 .auth
3485 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3486 .await
3487 {
3488 Ok(token) => token,
3489 Err(e) => match dlg.token(e) {
3490 Ok(token) => token,
3491 Err(e) => {
3492 dlg.finished(false);
3493 return Err(common::Error::MissingToken(e));
3494 }
3495 },
3496 };
3497 request_value_reader
3498 .seek(std::io::SeekFrom::Start(0))
3499 .unwrap();
3500 let mut req_result = {
3501 let client = &self.hub.client;
3502 dlg.pre_request();
3503 let mut req_builder = hyper::Request::builder()
3504 .method(hyper::Method::PATCH)
3505 .uri(url.as_str())
3506 .header(USER_AGENT, self.hub._user_agent.clone());
3507
3508 if let Some(token) = token.as_ref() {
3509 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3510 }
3511
3512 let request = req_builder
3513 .header(CONTENT_TYPE, json_mime_type.to_string())
3514 .header(CONTENT_LENGTH, request_size as u64)
3515 .body(common::to_body(
3516 request_value_reader.get_ref().clone().into(),
3517 ));
3518
3519 client.request(request.unwrap()).await
3520 };
3521
3522 match req_result {
3523 Err(err) => {
3524 if let common::Retry::After(d) = dlg.http_error(&err) {
3525 sleep(d).await;
3526 continue;
3527 }
3528 dlg.finished(false);
3529 return Err(common::Error::HttpError(err));
3530 }
3531 Ok(res) => {
3532 let (mut parts, body) = res.into_parts();
3533 let mut body = common::Body::new(body);
3534 if !parts.status.is_success() {
3535 let bytes = common::to_bytes(body).await.unwrap_or_default();
3536 let error = serde_json::from_str(&common::to_string(&bytes));
3537 let response = common::to_response(parts, bytes.into());
3538
3539 if let common::Retry::After(d) =
3540 dlg.http_failure(&response, error.as_ref().ok())
3541 {
3542 sleep(d).await;
3543 continue;
3544 }
3545
3546 dlg.finished(false);
3547
3548 return Err(match error {
3549 Ok(value) => common::Error::BadRequest(value),
3550 _ => common::Error::Failure(response),
3551 });
3552 }
3553 let response = {
3554 let bytes = common::to_bytes(body).await.unwrap_or_default();
3555 let encoded = common::to_string(&bytes);
3556 match serde_json::from_str(&encoded) {
3557 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3558 Err(error) => {
3559 dlg.response_json_decode_error(&encoded, &error);
3560 return Err(common::Error::JsonDecodeError(
3561 encoded.to_string(),
3562 error,
3563 ));
3564 }
3565 }
3566 };
3567
3568 dlg.finished(true);
3569 return Ok(response);
3570 }
3571 }
3572 }
3573 }
3574
3575 ///
3576 /// Sets the *request* property to the given value.
3577 ///
3578 /// Even though the property as already been set when instantiating this call,
3579 /// we provide this method for API completeness.
3580 pub fn request(
3581 mut self,
3582 new_value: GoogleCloudRecommendationengineV1beta1CatalogItem,
3583 ) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C> {
3584 self._request = new_value;
3585 self
3586 }
3587 /// Required. Full resource name of catalog item, such as `projects/*/locations/global/catalogs/default_catalog/catalogItems/some_catalog_item_id`.
3588 ///
3589 /// Sets the *name* path property to the given value.
3590 ///
3591 /// Even though the property as already been set when instantiating this call,
3592 /// we provide this method for API completeness.
3593 pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C> {
3594 self._name = new_value.to_string();
3595 self
3596 }
3597 /// Optional. Indicates which fields in the provided 'item' to update. If not set, will by default update all fields.
3598 ///
3599 /// Sets the *update mask* query property to the given value.
3600 pub fn update_mask(
3601 mut self,
3602 new_value: common::FieldMask,
3603 ) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C> {
3604 self._update_mask = Some(new_value);
3605 self
3606 }
3607 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3608 /// while executing the actual API request.
3609 ///
3610 /// ````text
3611 /// It should be used to handle progress information, and to implement a certain level of resilience.
3612 /// ````
3613 ///
3614 /// Sets the *delegate* property to the given value.
3615 pub fn delegate(
3616 mut self,
3617 new_value: &'a mut dyn common::Delegate,
3618 ) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C> {
3619 self._delegate = Some(new_value);
3620 self
3621 }
3622
3623 /// Set any additional parameter of the query string used in the request.
3624 /// It should be used to set parameters which are not yet available through their own
3625 /// setters.
3626 ///
3627 /// Please note that this method must not be used to set any of the known parameters
3628 /// which have their own setter method. If done anyway, the request will fail.
3629 ///
3630 /// # Additional Parameters
3631 ///
3632 /// * *$.xgafv* (query-string) - V1 error format.
3633 /// * *access_token* (query-string) - OAuth access token.
3634 /// * *alt* (query-string) - Data format for response.
3635 /// * *callback* (query-string) - JSONP
3636 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3637 /// * *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.
3638 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3639 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3640 /// * *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.
3641 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3642 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3643 pub fn param<T>(
3644 mut self,
3645 name: T,
3646 value: T,
3647 ) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C>
3648 where
3649 T: AsRef<str>,
3650 {
3651 self._additional_params
3652 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3653 self
3654 }
3655
3656 /// Identifies the authorization scope for the method you are building.
3657 ///
3658 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3659 /// [`Scope::CloudPlatform`].
3660 ///
3661 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3662 /// tokens for more than one scope.
3663 ///
3664 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3665 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3666 /// sufficient, a read-write scope will do as well.
3667 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C>
3668 where
3669 St: AsRef<str>,
3670 {
3671 self._scopes.insert(String::from(scope.as_ref()));
3672 self
3673 }
3674 /// Identifies the authorization scope(s) for the method you are building.
3675 ///
3676 /// See [`Self::add_scope()`] for details.
3677 pub fn add_scopes<I, St>(
3678 mut self,
3679 scopes: I,
3680 ) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C>
3681 where
3682 I: IntoIterator<Item = St>,
3683 St: AsRef<str>,
3684 {
3685 self._scopes
3686 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3687 self
3688 }
3689
3690 /// Removes all scopes, and no default scope will be used either.
3691 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3692 /// for details).
3693 pub fn clear_scopes(mut self) -> ProjectLocationCatalogCatalogItemPatchCall<'a, C> {
3694 self._scopes.clear();
3695 self
3696 }
3697}
3698
3699/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3700///
3701/// A builder for the *locations.catalogs.eventStores.operations.get* method supported by a *project* resource.
3702/// It is not used directly, but through a [`ProjectMethods`] instance.
3703///
3704/// # Example
3705///
3706/// Instantiate a resource method builder
3707///
3708/// ```test_harness,no_run
3709/// # extern crate hyper;
3710/// # extern crate hyper_rustls;
3711/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
3712/// # async fn dox() {
3713/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3714///
3715/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3716/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3717/// # .with_native_roots()
3718/// # .unwrap()
3719/// # .https_only()
3720/// # .enable_http2()
3721/// # .build();
3722///
3723/// # let executor = hyper_util::rt::TokioExecutor::new();
3724/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3725/// # secret,
3726/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3727/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3728/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3729/// # ),
3730/// # ).build().await.unwrap();
3731///
3732/// # let client = hyper_util::client::legacy::Client::builder(
3733/// # hyper_util::rt::TokioExecutor::new()
3734/// # )
3735/// # .build(
3736/// # hyper_rustls::HttpsConnectorBuilder::new()
3737/// # .with_native_roots()
3738/// # .unwrap()
3739/// # .https_or_http()
3740/// # .enable_http2()
3741/// # .build()
3742/// # );
3743/// # let mut hub = RecommendationsAI::new(client, auth);
3744/// // You can configure optional parameters by calling the respective setters at will, and
3745/// // execute the final call using `doit()`.
3746/// // Values shown here are possibly random and not representative !
3747/// let result = hub.projects().locations_catalogs_event_stores_operations_get("name")
3748/// .doit().await;
3749/// # }
3750/// ```
3751pub struct ProjectLocationCatalogEventStoreOperationGetCall<'a, C>
3752where
3753 C: 'a,
3754{
3755 hub: &'a RecommendationsAI<C>,
3756 _name: String,
3757 _delegate: Option<&'a mut dyn common::Delegate>,
3758 _additional_params: HashMap<String, String>,
3759 _scopes: BTreeSet<String>,
3760}
3761
3762impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreOperationGetCall<'a, C> {}
3763
3764impl<'a, C> ProjectLocationCatalogEventStoreOperationGetCall<'a, C>
3765where
3766 C: common::Connector,
3767{
3768 /// Perform the operation you have build so far.
3769 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
3770 use std::borrow::Cow;
3771 use std::io::{Read, Seek};
3772
3773 use common::{url::Params, ToParts};
3774 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3775
3776 let mut dd = common::DefaultDelegate;
3777 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3778 dlg.begin(common::MethodInfo {
3779 id: "recommendationengine.projects.locations.catalogs.eventStores.operations.get",
3780 http_method: hyper::Method::GET,
3781 });
3782
3783 for &field in ["alt", "name"].iter() {
3784 if self._additional_params.contains_key(field) {
3785 dlg.finished(false);
3786 return Err(common::Error::FieldClash(field));
3787 }
3788 }
3789
3790 let mut params = Params::with_capacity(3 + self._additional_params.len());
3791 params.push("name", self._name);
3792
3793 params.extend(self._additional_params.iter());
3794
3795 params.push("alt", "json");
3796 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3797 if self._scopes.is_empty() {
3798 self._scopes
3799 .insert(Scope::CloudPlatform.as_ref().to_string());
3800 }
3801
3802 #[allow(clippy::single_element_loop)]
3803 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3804 url = params.uri_replacement(url, param_name, find_this, true);
3805 }
3806 {
3807 let to_remove = ["name"];
3808 params.remove_params(&to_remove);
3809 }
3810
3811 let url = params.parse_with_url(&url);
3812
3813 loop {
3814 let token = match self
3815 .hub
3816 .auth
3817 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3818 .await
3819 {
3820 Ok(token) => token,
3821 Err(e) => match dlg.token(e) {
3822 Ok(token) => token,
3823 Err(e) => {
3824 dlg.finished(false);
3825 return Err(common::Error::MissingToken(e));
3826 }
3827 },
3828 };
3829 let mut req_result = {
3830 let client = &self.hub.client;
3831 dlg.pre_request();
3832 let mut req_builder = hyper::Request::builder()
3833 .method(hyper::Method::GET)
3834 .uri(url.as_str())
3835 .header(USER_AGENT, self.hub._user_agent.clone());
3836
3837 if let Some(token) = token.as_ref() {
3838 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3839 }
3840
3841 let request = req_builder
3842 .header(CONTENT_LENGTH, 0_u64)
3843 .body(common::to_body::<String>(None));
3844
3845 client.request(request.unwrap()).await
3846 };
3847
3848 match req_result {
3849 Err(err) => {
3850 if let common::Retry::After(d) = dlg.http_error(&err) {
3851 sleep(d).await;
3852 continue;
3853 }
3854 dlg.finished(false);
3855 return Err(common::Error::HttpError(err));
3856 }
3857 Ok(res) => {
3858 let (mut parts, body) = res.into_parts();
3859 let mut body = common::Body::new(body);
3860 if !parts.status.is_success() {
3861 let bytes = common::to_bytes(body).await.unwrap_or_default();
3862 let error = serde_json::from_str(&common::to_string(&bytes));
3863 let response = common::to_response(parts, bytes.into());
3864
3865 if let common::Retry::After(d) =
3866 dlg.http_failure(&response, error.as_ref().ok())
3867 {
3868 sleep(d).await;
3869 continue;
3870 }
3871
3872 dlg.finished(false);
3873
3874 return Err(match error {
3875 Ok(value) => common::Error::BadRequest(value),
3876 _ => common::Error::Failure(response),
3877 });
3878 }
3879 let response = {
3880 let bytes = common::to_bytes(body).await.unwrap_or_default();
3881 let encoded = common::to_string(&bytes);
3882 match serde_json::from_str(&encoded) {
3883 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3884 Err(error) => {
3885 dlg.response_json_decode_error(&encoded, &error);
3886 return Err(common::Error::JsonDecodeError(
3887 encoded.to_string(),
3888 error,
3889 ));
3890 }
3891 }
3892 };
3893
3894 dlg.finished(true);
3895 return Ok(response);
3896 }
3897 }
3898 }
3899 }
3900
3901 /// The name of the operation resource.
3902 ///
3903 /// Sets the *name* path property to the given value.
3904 ///
3905 /// Even though the property as already been set when instantiating this call,
3906 /// we provide this method for API completeness.
3907 pub fn name(
3908 mut self,
3909 new_value: &str,
3910 ) -> ProjectLocationCatalogEventStoreOperationGetCall<'a, C> {
3911 self._name = new_value.to_string();
3912 self
3913 }
3914 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3915 /// while executing the actual API request.
3916 ///
3917 /// ````text
3918 /// It should be used to handle progress information, and to implement a certain level of resilience.
3919 /// ````
3920 ///
3921 /// Sets the *delegate* property to the given value.
3922 pub fn delegate(
3923 mut self,
3924 new_value: &'a mut dyn common::Delegate,
3925 ) -> ProjectLocationCatalogEventStoreOperationGetCall<'a, C> {
3926 self._delegate = Some(new_value);
3927 self
3928 }
3929
3930 /// Set any additional parameter of the query string used in the request.
3931 /// It should be used to set parameters which are not yet available through their own
3932 /// setters.
3933 ///
3934 /// Please note that this method must not be used to set any of the known parameters
3935 /// which have their own setter method. If done anyway, the request will fail.
3936 ///
3937 /// # Additional Parameters
3938 ///
3939 /// * *$.xgafv* (query-string) - V1 error format.
3940 /// * *access_token* (query-string) - OAuth access token.
3941 /// * *alt* (query-string) - Data format for response.
3942 /// * *callback* (query-string) - JSONP
3943 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3944 /// * *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.
3945 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3946 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3947 /// * *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.
3948 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3949 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3950 pub fn param<T>(
3951 mut self,
3952 name: T,
3953 value: T,
3954 ) -> ProjectLocationCatalogEventStoreOperationGetCall<'a, C>
3955 where
3956 T: AsRef<str>,
3957 {
3958 self._additional_params
3959 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3960 self
3961 }
3962
3963 /// Identifies the authorization scope for the method you are building.
3964 ///
3965 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3966 /// [`Scope::CloudPlatform`].
3967 ///
3968 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3969 /// tokens for more than one scope.
3970 ///
3971 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3972 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3973 /// sufficient, a read-write scope will do as well.
3974 pub fn add_scope<St>(
3975 mut self,
3976 scope: St,
3977 ) -> ProjectLocationCatalogEventStoreOperationGetCall<'a, C>
3978 where
3979 St: AsRef<str>,
3980 {
3981 self._scopes.insert(String::from(scope.as_ref()));
3982 self
3983 }
3984 /// Identifies the authorization scope(s) for the method you are building.
3985 ///
3986 /// See [`Self::add_scope()`] for details.
3987 pub fn add_scopes<I, St>(
3988 mut self,
3989 scopes: I,
3990 ) -> ProjectLocationCatalogEventStoreOperationGetCall<'a, C>
3991 where
3992 I: IntoIterator<Item = St>,
3993 St: AsRef<str>,
3994 {
3995 self._scopes
3996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3997 self
3998 }
3999
4000 /// Removes all scopes, and no default scope will be used either.
4001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4002 /// for details).
4003 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreOperationGetCall<'a, C> {
4004 self._scopes.clear();
4005 self
4006 }
4007}
4008
4009/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4010///
4011/// A builder for the *locations.catalogs.eventStores.operations.list* method supported by a *project* resource.
4012/// It is not used directly, but through a [`ProjectMethods`] instance.
4013///
4014/// # Example
4015///
4016/// Instantiate a resource method builder
4017///
4018/// ```test_harness,no_run
4019/// # extern crate hyper;
4020/// # extern crate hyper_rustls;
4021/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
4022/// # async fn dox() {
4023/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4024///
4025/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4026/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4027/// # .with_native_roots()
4028/// # .unwrap()
4029/// # .https_only()
4030/// # .enable_http2()
4031/// # .build();
4032///
4033/// # let executor = hyper_util::rt::TokioExecutor::new();
4034/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4035/// # secret,
4036/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4037/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4038/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4039/// # ),
4040/// # ).build().await.unwrap();
4041///
4042/// # let client = hyper_util::client::legacy::Client::builder(
4043/// # hyper_util::rt::TokioExecutor::new()
4044/// # )
4045/// # .build(
4046/// # hyper_rustls::HttpsConnectorBuilder::new()
4047/// # .with_native_roots()
4048/// # .unwrap()
4049/// # .https_or_http()
4050/// # .enable_http2()
4051/// # .build()
4052/// # );
4053/// # let mut hub = RecommendationsAI::new(client, auth);
4054/// // You can configure optional parameters by calling the respective setters at will, and
4055/// // execute the final call using `doit()`.
4056/// // Values shown here are possibly random and not representative !
4057/// let result = hub.projects().locations_catalogs_event_stores_operations_list("name")
4058/// .return_partial_success(true)
4059/// .page_token("gubergren")
4060/// .page_size(-75)
4061/// .filter("dolor")
4062/// .doit().await;
4063/// # }
4064/// ```
4065pub struct ProjectLocationCatalogEventStoreOperationListCall<'a, C>
4066where
4067 C: 'a,
4068{
4069 hub: &'a RecommendationsAI<C>,
4070 _name: String,
4071 _return_partial_success: Option<bool>,
4072 _page_token: Option<String>,
4073 _page_size: Option<i32>,
4074 _filter: Option<String>,
4075 _delegate: Option<&'a mut dyn common::Delegate>,
4076 _additional_params: HashMap<String, String>,
4077 _scopes: BTreeSet<String>,
4078}
4079
4080impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreOperationListCall<'a, C> {}
4081
4082impl<'a, C> ProjectLocationCatalogEventStoreOperationListCall<'a, C>
4083where
4084 C: common::Connector,
4085{
4086 /// Perform the operation you have build so far.
4087 pub async fn doit(
4088 mut self,
4089 ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
4090 use std::borrow::Cow;
4091 use std::io::{Read, Seek};
4092
4093 use common::{url::Params, ToParts};
4094 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4095
4096 let mut dd = common::DefaultDelegate;
4097 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4098 dlg.begin(common::MethodInfo {
4099 id: "recommendationengine.projects.locations.catalogs.eventStores.operations.list",
4100 http_method: hyper::Method::GET,
4101 });
4102
4103 for &field in [
4104 "alt",
4105 "name",
4106 "returnPartialSuccess",
4107 "pageToken",
4108 "pageSize",
4109 "filter",
4110 ]
4111 .iter()
4112 {
4113 if self._additional_params.contains_key(field) {
4114 dlg.finished(false);
4115 return Err(common::Error::FieldClash(field));
4116 }
4117 }
4118
4119 let mut params = Params::with_capacity(7 + self._additional_params.len());
4120 params.push("name", self._name);
4121 if let Some(value) = self._return_partial_success.as_ref() {
4122 params.push("returnPartialSuccess", value.to_string());
4123 }
4124 if let Some(value) = self._page_token.as_ref() {
4125 params.push("pageToken", value);
4126 }
4127 if let Some(value) = self._page_size.as_ref() {
4128 params.push("pageSize", value.to_string());
4129 }
4130 if let Some(value) = self._filter.as_ref() {
4131 params.push("filter", value);
4132 }
4133
4134 params.extend(self._additional_params.iter());
4135
4136 params.push("alt", "json");
4137 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/operations";
4138 if self._scopes.is_empty() {
4139 self._scopes
4140 .insert(Scope::CloudPlatform.as_ref().to_string());
4141 }
4142
4143 #[allow(clippy::single_element_loop)]
4144 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4145 url = params.uri_replacement(url, param_name, find_this, true);
4146 }
4147 {
4148 let to_remove = ["name"];
4149 params.remove_params(&to_remove);
4150 }
4151
4152 let url = params.parse_with_url(&url);
4153
4154 loop {
4155 let token = match self
4156 .hub
4157 .auth
4158 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4159 .await
4160 {
4161 Ok(token) => token,
4162 Err(e) => match dlg.token(e) {
4163 Ok(token) => token,
4164 Err(e) => {
4165 dlg.finished(false);
4166 return Err(common::Error::MissingToken(e));
4167 }
4168 },
4169 };
4170 let mut req_result = {
4171 let client = &self.hub.client;
4172 dlg.pre_request();
4173 let mut req_builder = hyper::Request::builder()
4174 .method(hyper::Method::GET)
4175 .uri(url.as_str())
4176 .header(USER_AGENT, self.hub._user_agent.clone());
4177
4178 if let Some(token) = token.as_ref() {
4179 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4180 }
4181
4182 let request = req_builder
4183 .header(CONTENT_LENGTH, 0_u64)
4184 .body(common::to_body::<String>(None));
4185
4186 client.request(request.unwrap()).await
4187 };
4188
4189 match req_result {
4190 Err(err) => {
4191 if let common::Retry::After(d) = dlg.http_error(&err) {
4192 sleep(d).await;
4193 continue;
4194 }
4195 dlg.finished(false);
4196 return Err(common::Error::HttpError(err));
4197 }
4198 Ok(res) => {
4199 let (mut parts, body) = res.into_parts();
4200 let mut body = common::Body::new(body);
4201 if !parts.status.is_success() {
4202 let bytes = common::to_bytes(body).await.unwrap_or_default();
4203 let error = serde_json::from_str(&common::to_string(&bytes));
4204 let response = common::to_response(parts, bytes.into());
4205
4206 if let common::Retry::After(d) =
4207 dlg.http_failure(&response, error.as_ref().ok())
4208 {
4209 sleep(d).await;
4210 continue;
4211 }
4212
4213 dlg.finished(false);
4214
4215 return Err(match error {
4216 Ok(value) => common::Error::BadRequest(value),
4217 _ => common::Error::Failure(response),
4218 });
4219 }
4220 let response = {
4221 let bytes = common::to_bytes(body).await.unwrap_or_default();
4222 let encoded = common::to_string(&bytes);
4223 match serde_json::from_str(&encoded) {
4224 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4225 Err(error) => {
4226 dlg.response_json_decode_error(&encoded, &error);
4227 return Err(common::Error::JsonDecodeError(
4228 encoded.to_string(),
4229 error,
4230 ));
4231 }
4232 }
4233 };
4234
4235 dlg.finished(true);
4236 return Ok(response);
4237 }
4238 }
4239 }
4240 }
4241
4242 /// The name of the operation's parent resource.
4243 ///
4244 /// Sets the *name* path property to the given value.
4245 ///
4246 /// Even though the property as already been set when instantiating this call,
4247 /// we provide this method for API completeness.
4248 pub fn name(
4249 mut self,
4250 new_value: &str,
4251 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
4252 self._name = new_value.to_string();
4253 self
4254 }
4255 /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
4256 ///
4257 /// Sets the *return partial success* query property to the given value.
4258 pub fn return_partial_success(
4259 mut self,
4260 new_value: bool,
4261 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
4262 self._return_partial_success = Some(new_value);
4263 self
4264 }
4265 /// The standard list page token.
4266 ///
4267 /// Sets the *page token* query property to the given value.
4268 pub fn page_token(
4269 mut self,
4270 new_value: &str,
4271 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
4272 self._page_token = Some(new_value.to_string());
4273 self
4274 }
4275 /// The standard list page size.
4276 ///
4277 /// Sets the *page size* query property to the given value.
4278 pub fn page_size(
4279 mut self,
4280 new_value: i32,
4281 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
4282 self._page_size = Some(new_value);
4283 self
4284 }
4285 /// The standard list filter.
4286 ///
4287 /// Sets the *filter* query property to the given value.
4288 pub fn filter(
4289 mut self,
4290 new_value: &str,
4291 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
4292 self._filter = Some(new_value.to_string());
4293 self
4294 }
4295 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4296 /// while executing the actual API request.
4297 ///
4298 /// ````text
4299 /// It should be used to handle progress information, and to implement a certain level of resilience.
4300 /// ````
4301 ///
4302 /// Sets the *delegate* property to the given value.
4303 pub fn delegate(
4304 mut self,
4305 new_value: &'a mut dyn common::Delegate,
4306 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
4307 self._delegate = Some(new_value);
4308 self
4309 }
4310
4311 /// Set any additional parameter of the query string used in the request.
4312 /// It should be used to set parameters which are not yet available through their own
4313 /// setters.
4314 ///
4315 /// Please note that this method must not be used to set any of the known parameters
4316 /// which have their own setter method. If done anyway, the request will fail.
4317 ///
4318 /// # Additional Parameters
4319 ///
4320 /// * *$.xgafv* (query-string) - V1 error format.
4321 /// * *access_token* (query-string) - OAuth access token.
4322 /// * *alt* (query-string) - Data format for response.
4323 /// * *callback* (query-string) - JSONP
4324 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4325 /// * *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.
4326 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4327 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4328 /// * *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.
4329 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4330 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4331 pub fn param<T>(
4332 mut self,
4333 name: T,
4334 value: T,
4335 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C>
4336 where
4337 T: AsRef<str>,
4338 {
4339 self._additional_params
4340 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4341 self
4342 }
4343
4344 /// Identifies the authorization scope for the method you are building.
4345 ///
4346 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4347 /// [`Scope::CloudPlatform`].
4348 ///
4349 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4350 /// tokens for more than one scope.
4351 ///
4352 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4353 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4354 /// sufficient, a read-write scope will do as well.
4355 pub fn add_scope<St>(
4356 mut self,
4357 scope: St,
4358 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C>
4359 where
4360 St: AsRef<str>,
4361 {
4362 self._scopes.insert(String::from(scope.as_ref()));
4363 self
4364 }
4365 /// Identifies the authorization scope(s) for the method you are building.
4366 ///
4367 /// See [`Self::add_scope()`] for details.
4368 pub fn add_scopes<I, St>(
4369 mut self,
4370 scopes: I,
4371 ) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C>
4372 where
4373 I: IntoIterator<Item = St>,
4374 St: AsRef<str>,
4375 {
4376 self._scopes
4377 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4378 self
4379 }
4380
4381 /// Removes all scopes, and no default scope will be used either.
4382 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4383 /// for details).
4384 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreOperationListCall<'a, C> {
4385 self._scopes.clear();
4386 self
4387 }
4388}
4389
4390/// Makes a recommendation prediction. If using API Key based authentication, the API Key must be registered using the PredictionApiKeyRegistry service. [Learn more](https://cloud.google.com/recommendations-ai/docs/setting-up#register-key).
4391///
4392/// A builder for the *locations.catalogs.eventStores.placements.predict* method supported by a *project* resource.
4393/// It is not used directly, but through a [`ProjectMethods`] instance.
4394///
4395/// # Example
4396///
4397/// Instantiate a resource method builder
4398///
4399/// ```test_harness,no_run
4400/// # extern crate hyper;
4401/// # extern crate hyper_rustls;
4402/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
4403/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1PredictRequest;
4404/// # async fn dox() {
4405/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4406///
4407/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4408/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4409/// # .with_native_roots()
4410/// # .unwrap()
4411/// # .https_only()
4412/// # .enable_http2()
4413/// # .build();
4414///
4415/// # let executor = hyper_util::rt::TokioExecutor::new();
4416/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4417/// # secret,
4418/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4419/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4420/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4421/// # ),
4422/// # ).build().await.unwrap();
4423///
4424/// # let client = hyper_util::client::legacy::Client::builder(
4425/// # hyper_util::rt::TokioExecutor::new()
4426/// # )
4427/// # .build(
4428/// # hyper_rustls::HttpsConnectorBuilder::new()
4429/// # .with_native_roots()
4430/// # .unwrap()
4431/// # .https_or_http()
4432/// # .enable_http2()
4433/// # .build()
4434/// # );
4435/// # let mut hub = RecommendationsAI::new(client, auth);
4436/// // As the method needs a request, you would usually fill it with the desired information
4437/// // into the respective structure. Some of the parts shown here might not be applicable !
4438/// // Values shown here are possibly random and not representative !
4439/// let mut req = GoogleCloudRecommendationengineV1beta1PredictRequest::default();
4440///
4441/// // You can configure optional parameters by calling the respective setters at will, and
4442/// // execute the final call using `doit()`.
4443/// // Values shown here are possibly random and not representative !
4444/// let result = hub.projects().locations_catalogs_event_stores_placements_predict(req, "name")
4445/// .doit().await;
4446/// # }
4447/// ```
4448pub struct ProjectLocationCatalogEventStorePlacementPredictCall<'a, C>
4449where
4450 C: 'a,
4451{
4452 hub: &'a RecommendationsAI<C>,
4453 _request: GoogleCloudRecommendationengineV1beta1PredictRequest,
4454 _name: String,
4455 _delegate: Option<&'a mut dyn common::Delegate>,
4456 _additional_params: HashMap<String, String>,
4457 _scopes: BTreeSet<String>,
4458}
4459
4460impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStorePlacementPredictCall<'a, C> {}
4461
4462impl<'a, C> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C>
4463where
4464 C: common::Connector,
4465{
4466 /// Perform the operation you have build so far.
4467 pub async fn doit(
4468 mut self,
4469 ) -> common::Result<(
4470 common::Response,
4471 GoogleCloudRecommendationengineV1beta1PredictResponse,
4472 )> {
4473 use std::borrow::Cow;
4474 use std::io::{Read, Seek};
4475
4476 use common::{url::Params, ToParts};
4477 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4478
4479 let mut dd = common::DefaultDelegate;
4480 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4481 dlg.begin(common::MethodInfo {
4482 id: "recommendationengine.projects.locations.catalogs.eventStores.placements.predict",
4483 http_method: hyper::Method::POST,
4484 });
4485
4486 for &field in ["alt", "name"].iter() {
4487 if self._additional_params.contains_key(field) {
4488 dlg.finished(false);
4489 return Err(common::Error::FieldClash(field));
4490 }
4491 }
4492
4493 let mut params = Params::with_capacity(4 + self._additional_params.len());
4494 params.push("name", self._name);
4495
4496 params.extend(self._additional_params.iter());
4497
4498 params.push("alt", "json");
4499 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:predict";
4500 if self._scopes.is_empty() {
4501 self._scopes
4502 .insert(Scope::CloudPlatform.as_ref().to_string());
4503 }
4504
4505 #[allow(clippy::single_element_loop)]
4506 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4507 url = params.uri_replacement(url, param_name, find_this, true);
4508 }
4509 {
4510 let to_remove = ["name"];
4511 params.remove_params(&to_remove);
4512 }
4513
4514 let url = params.parse_with_url(&url);
4515
4516 let mut json_mime_type = mime::APPLICATION_JSON;
4517 let mut request_value_reader = {
4518 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4519 common::remove_json_null_values(&mut value);
4520 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4521 serde_json::to_writer(&mut dst, &value).unwrap();
4522 dst
4523 };
4524 let request_size = request_value_reader
4525 .seek(std::io::SeekFrom::End(0))
4526 .unwrap();
4527 request_value_reader
4528 .seek(std::io::SeekFrom::Start(0))
4529 .unwrap();
4530
4531 loop {
4532 let token = match self
4533 .hub
4534 .auth
4535 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4536 .await
4537 {
4538 Ok(token) => token,
4539 Err(e) => match dlg.token(e) {
4540 Ok(token) => token,
4541 Err(e) => {
4542 dlg.finished(false);
4543 return Err(common::Error::MissingToken(e));
4544 }
4545 },
4546 };
4547 request_value_reader
4548 .seek(std::io::SeekFrom::Start(0))
4549 .unwrap();
4550 let mut req_result = {
4551 let client = &self.hub.client;
4552 dlg.pre_request();
4553 let mut req_builder = hyper::Request::builder()
4554 .method(hyper::Method::POST)
4555 .uri(url.as_str())
4556 .header(USER_AGENT, self.hub._user_agent.clone());
4557
4558 if let Some(token) = token.as_ref() {
4559 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4560 }
4561
4562 let request = req_builder
4563 .header(CONTENT_TYPE, json_mime_type.to_string())
4564 .header(CONTENT_LENGTH, request_size as u64)
4565 .body(common::to_body(
4566 request_value_reader.get_ref().clone().into(),
4567 ));
4568
4569 client.request(request.unwrap()).await
4570 };
4571
4572 match req_result {
4573 Err(err) => {
4574 if let common::Retry::After(d) = dlg.http_error(&err) {
4575 sleep(d).await;
4576 continue;
4577 }
4578 dlg.finished(false);
4579 return Err(common::Error::HttpError(err));
4580 }
4581 Ok(res) => {
4582 let (mut parts, body) = res.into_parts();
4583 let mut body = common::Body::new(body);
4584 if !parts.status.is_success() {
4585 let bytes = common::to_bytes(body).await.unwrap_or_default();
4586 let error = serde_json::from_str(&common::to_string(&bytes));
4587 let response = common::to_response(parts, bytes.into());
4588
4589 if let common::Retry::After(d) =
4590 dlg.http_failure(&response, error.as_ref().ok())
4591 {
4592 sleep(d).await;
4593 continue;
4594 }
4595
4596 dlg.finished(false);
4597
4598 return Err(match error {
4599 Ok(value) => common::Error::BadRequest(value),
4600 _ => common::Error::Failure(response),
4601 });
4602 }
4603 let response = {
4604 let bytes = common::to_bytes(body).await.unwrap_or_default();
4605 let encoded = common::to_string(&bytes);
4606 match serde_json::from_str(&encoded) {
4607 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4608 Err(error) => {
4609 dlg.response_json_decode_error(&encoded, &error);
4610 return Err(common::Error::JsonDecodeError(
4611 encoded.to_string(),
4612 error,
4613 ));
4614 }
4615 }
4616 };
4617
4618 dlg.finished(true);
4619 return Ok(response);
4620 }
4621 }
4622 }
4623 }
4624
4625 ///
4626 /// Sets the *request* property to the given value.
4627 ///
4628 /// Even though the property as already been set when instantiating this call,
4629 /// we provide this method for API completeness.
4630 pub fn request(
4631 mut self,
4632 new_value: GoogleCloudRecommendationengineV1beta1PredictRequest,
4633 ) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C> {
4634 self._request = new_value;
4635 self
4636 }
4637 ///
4638 /// Sets the *name* path property to the given value.
4639 ///
4640 /// Even though the property as already been set when instantiating this call,
4641 /// we provide this method for API completeness.
4642 pub fn name(
4643 mut self,
4644 new_value: &str,
4645 ) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C> {
4646 self._name = new_value.to_string();
4647 self
4648 }
4649 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4650 /// while executing the actual API request.
4651 ///
4652 /// ````text
4653 /// It should be used to handle progress information, and to implement a certain level of resilience.
4654 /// ````
4655 ///
4656 /// Sets the *delegate* property to the given value.
4657 pub fn delegate(
4658 mut self,
4659 new_value: &'a mut dyn common::Delegate,
4660 ) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C> {
4661 self._delegate = Some(new_value);
4662 self
4663 }
4664
4665 /// Set any additional parameter of the query string used in the request.
4666 /// It should be used to set parameters which are not yet available through their own
4667 /// setters.
4668 ///
4669 /// Please note that this method must not be used to set any of the known parameters
4670 /// which have their own setter method. If done anyway, the request will fail.
4671 ///
4672 /// # Additional Parameters
4673 ///
4674 /// * *$.xgafv* (query-string) - V1 error format.
4675 /// * *access_token* (query-string) - OAuth access token.
4676 /// * *alt* (query-string) - Data format for response.
4677 /// * *callback* (query-string) - JSONP
4678 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4679 /// * *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.
4680 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4681 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4682 /// * *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.
4683 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4684 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4685 pub fn param<T>(
4686 mut self,
4687 name: T,
4688 value: T,
4689 ) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C>
4690 where
4691 T: AsRef<str>,
4692 {
4693 self._additional_params
4694 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4695 self
4696 }
4697
4698 /// Identifies the authorization scope for the method you are building.
4699 ///
4700 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4701 /// [`Scope::CloudPlatform`].
4702 ///
4703 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4704 /// tokens for more than one scope.
4705 ///
4706 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4707 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4708 /// sufficient, a read-write scope will do as well.
4709 pub fn add_scope<St>(
4710 mut self,
4711 scope: St,
4712 ) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C>
4713 where
4714 St: AsRef<str>,
4715 {
4716 self._scopes.insert(String::from(scope.as_ref()));
4717 self
4718 }
4719 /// Identifies the authorization scope(s) for the method you are building.
4720 ///
4721 /// See [`Self::add_scope()`] for details.
4722 pub fn add_scopes<I, St>(
4723 mut self,
4724 scopes: I,
4725 ) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C>
4726 where
4727 I: IntoIterator<Item = St>,
4728 St: AsRef<str>,
4729 {
4730 self._scopes
4731 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4732 self
4733 }
4734
4735 /// Removes all scopes, and no default scope will be used either.
4736 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4737 /// for details).
4738 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStorePlacementPredictCall<'a, C> {
4739 self._scopes.clear();
4740 self
4741 }
4742}
4743
4744/// Register an API key for use with predict method.
4745///
4746/// A builder for the *locations.catalogs.eventStores.predictionApiKeyRegistrations.create* method supported by a *project* resource.
4747/// It is not used directly, but through a [`ProjectMethods`] instance.
4748///
4749/// # Example
4750///
4751/// Instantiate a resource method builder
4752///
4753/// ```test_harness,no_run
4754/// # extern crate hyper;
4755/// # extern crate hyper_rustls;
4756/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
4757/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1CreatePredictionApiKeyRegistrationRequest;
4758/// # async fn dox() {
4759/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4760///
4761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4762/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4763/// # .with_native_roots()
4764/// # .unwrap()
4765/// # .https_only()
4766/// # .enable_http2()
4767/// # .build();
4768///
4769/// # let executor = hyper_util::rt::TokioExecutor::new();
4770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4771/// # secret,
4772/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4773/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4774/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4775/// # ),
4776/// # ).build().await.unwrap();
4777///
4778/// # let client = hyper_util::client::legacy::Client::builder(
4779/// # hyper_util::rt::TokioExecutor::new()
4780/// # )
4781/// # .build(
4782/// # hyper_rustls::HttpsConnectorBuilder::new()
4783/// # .with_native_roots()
4784/// # .unwrap()
4785/// # .https_or_http()
4786/// # .enable_http2()
4787/// # .build()
4788/// # );
4789/// # let mut hub = RecommendationsAI::new(client, auth);
4790/// // As the method needs a request, you would usually fill it with the desired information
4791/// // into the respective structure. Some of the parts shown here might not be applicable !
4792/// // Values shown here are possibly random and not representative !
4793/// let mut req = GoogleCloudRecommendationengineV1beta1CreatePredictionApiKeyRegistrationRequest::default();
4794///
4795/// // You can configure optional parameters by calling the respective setters at will, and
4796/// // execute the final call using `doit()`.
4797/// // Values shown here are possibly random and not representative !
4798/// let result = hub.projects().locations_catalogs_event_stores_prediction_api_key_registrations_create(req, "parent")
4799/// .doit().await;
4800/// # }
4801/// ```
4802pub struct ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C>
4803where
4804 C: 'a,
4805{
4806 hub: &'a RecommendationsAI<C>,
4807 _request: GoogleCloudRecommendationengineV1beta1CreatePredictionApiKeyRegistrationRequest,
4808 _parent: String,
4809 _delegate: Option<&'a mut dyn common::Delegate>,
4810 _additional_params: HashMap<String, String>,
4811 _scopes: BTreeSet<String>,
4812}
4813
4814impl<'a, C> common::CallBuilder
4815 for ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C>
4816{
4817}
4818
4819impl<'a, C> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C>
4820where
4821 C: common::Connector,
4822{
4823 /// Perform the operation you have build so far.
4824 pub async fn doit(
4825 mut self,
4826 ) -> common::Result<(
4827 common::Response,
4828 GoogleCloudRecommendationengineV1beta1PredictionApiKeyRegistration,
4829 )> {
4830 use std::borrow::Cow;
4831 use std::io::{Read, Seek};
4832
4833 use common::{url::Params, ToParts};
4834 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4835
4836 let mut dd = common::DefaultDelegate;
4837 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4838 dlg.begin(common::MethodInfo { id: "recommendationengine.projects.locations.catalogs.eventStores.predictionApiKeyRegistrations.create",
4839 http_method: hyper::Method::POST });
4840
4841 for &field in ["alt", "parent"].iter() {
4842 if self._additional_params.contains_key(field) {
4843 dlg.finished(false);
4844 return Err(common::Error::FieldClash(field));
4845 }
4846 }
4847
4848 let mut params = Params::with_capacity(4 + self._additional_params.len());
4849 params.push("parent", self._parent);
4850
4851 params.extend(self._additional_params.iter());
4852
4853 params.push("alt", "json");
4854 let mut url =
4855 self.hub._base_url.clone() + "v1beta1/{+parent}/predictionApiKeyRegistrations";
4856 if self._scopes.is_empty() {
4857 self._scopes
4858 .insert(Scope::CloudPlatform.as_ref().to_string());
4859 }
4860
4861 #[allow(clippy::single_element_loop)]
4862 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4863 url = params.uri_replacement(url, param_name, find_this, true);
4864 }
4865 {
4866 let to_remove = ["parent"];
4867 params.remove_params(&to_remove);
4868 }
4869
4870 let url = params.parse_with_url(&url);
4871
4872 let mut json_mime_type = mime::APPLICATION_JSON;
4873 let mut request_value_reader = {
4874 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4875 common::remove_json_null_values(&mut value);
4876 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4877 serde_json::to_writer(&mut dst, &value).unwrap();
4878 dst
4879 };
4880 let request_size = request_value_reader
4881 .seek(std::io::SeekFrom::End(0))
4882 .unwrap();
4883 request_value_reader
4884 .seek(std::io::SeekFrom::Start(0))
4885 .unwrap();
4886
4887 loop {
4888 let token = match self
4889 .hub
4890 .auth
4891 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4892 .await
4893 {
4894 Ok(token) => token,
4895 Err(e) => match dlg.token(e) {
4896 Ok(token) => token,
4897 Err(e) => {
4898 dlg.finished(false);
4899 return Err(common::Error::MissingToken(e));
4900 }
4901 },
4902 };
4903 request_value_reader
4904 .seek(std::io::SeekFrom::Start(0))
4905 .unwrap();
4906 let mut req_result = {
4907 let client = &self.hub.client;
4908 dlg.pre_request();
4909 let mut req_builder = hyper::Request::builder()
4910 .method(hyper::Method::POST)
4911 .uri(url.as_str())
4912 .header(USER_AGENT, self.hub._user_agent.clone());
4913
4914 if let Some(token) = token.as_ref() {
4915 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4916 }
4917
4918 let request = req_builder
4919 .header(CONTENT_TYPE, json_mime_type.to_string())
4920 .header(CONTENT_LENGTH, request_size as u64)
4921 .body(common::to_body(
4922 request_value_reader.get_ref().clone().into(),
4923 ));
4924
4925 client.request(request.unwrap()).await
4926 };
4927
4928 match req_result {
4929 Err(err) => {
4930 if let common::Retry::After(d) = dlg.http_error(&err) {
4931 sleep(d).await;
4932 continue;
4933 }
4934 dlg.finished(false);
4935 return Err(common::Error::HttpError(err));
4936 }
4937 Ok(res) => {
4938 let (mut parts, body) = res.into_parts();
4939 let mut body = common::Body::new(body);
4940 if !parts.status.is_success() {
4941 let bytes = common::to_bytes(body).await.unwrap_or_default();
4942 let error = serde_json::from_str(&common::to_string(&bytes));
4943 let response = common::to_response(parts, bytes.into());
4944
4945 if let common::Retry::After(d) =
4946 dlg.http_failure(&response, error.as_ref().ok())
4947 {
4948 sleep(d).await;
4949 continue;
4950 }
4951
4952 dlg.finished(false);
4953
4954 return Err(match error {
4955 Ok(value) => common::Error::BadRequest(value),
4956 _ => common::Error::Failure(response),
4957 });
4958 }
4959 let response = {
4960 let bytes = common::to_bytes(body).await.unwrap_or_default();
4961 let encoded = common::to_string(&bytes);
4962 match serde_json::from_str(&encoded) {
4963 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4964 Err(error) => {
4965 dlg.response_json_decode_error(&encoded, &error);
4966 return Err(common::Error::JsonDecodeError(
4967 encoded.to_string(),
4968 error,
4969 ));
4970 }
4971 }
4972 };
4973
4974 dlg.finished(true);
4975 return Ok(response);
4976 }
4977 }
4978 }
4979 }
4980
4981 ///
4982 /// Sets the *request* property to the given value.
4983 ///
4984 /// Even though the property as already been set when instantiating this call,
4985 /// we provide this method for API completeness.
4986 pub fn request(
4987 mut self,
4988 new_value: GoogleCloudRecommendationengineV1beta1CreatePredictionApiKeyRegistrationRequest,
4989 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C> {
4990 self._request = new_value;
4991 self
4992 }
4993 /// Required. The parent resource path. `projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store`.
4994 ///
4995 /// Sets the *parent* path property to the given value.
4996 ///
4997 /// Even though the property as already been set when instantiating this call,
4998 /// we provide this method for API completeness.
4999 pub fn parent(
5000 mut self,
5001 new_value: &str,
5002 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C> {
5003 self._parent = new_value.to_string();
5004 self
5005 }
5006 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5007 /// while executing the actual API request.
5008 ///
5009 /// ````text
5010 /// It should be used to handle progress information, and to implement a certain level of resilience.
5011 /// ````
5012 ///
5013 /// Sets the *delegate* property to the given value.
5014 pub fn delegate(
5015 mut self,
5016 new_value: &'a mut dyn common::Delegate,
5017 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C> {
5018 self._delegate = Some(new_value);
5019 self
5020 }
5021
5022 /// Set any additional parameter of the query string used in the request.
5023 /// It should be used to set parameters which are not yet available through their own
5024 /// setters.
5025 ///
5026 /// Please note that this method must not be used to set any of the known parameters
5027 /// which have their own setter method. If done anyway, the request will fail.
5028 ///
5029 /// # Additional Parameters
5030 ///
5031 /// * *$.xgafv* (query-string) - V1 error format.
5032 /// * *access_token* (query-string) - OAuth access token.
5033 /// * *alt* (query-string) - Data format for response.
5034 /// * *callback* (query-string) - JSONP
5035 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5036 /// * *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.
5037 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5038 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5039 /// * *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.
5040 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5041 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5042 pub fn param<T>(
5043 mut self,
5044 name: T,
5045 value: T,
5046 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C>
5047 where
5048 T: AsRef<str>,
5049 {
5050 self._additional_params
5051 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5052 self
5053 }
5054
5055 /// Identifies the authorization scope for the method you are building.
5056 ///
5057 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5058 /// [`Scope::CloudPlatform`].
5059 ///
5060 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5061 /// tokens for more than one scope.
5062 ///
5063 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5064 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5065 /// sufficient, a read-write scope will do as well.
5066 pub fn add_scope<St>(
5067 mut self,
5068 scope: St,
5069 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C>
5070 where
5071 St: AsRef<str>,
5072 {
5073 self._scopes.insert(String::from(scope.as_ref()));
5074 self
5075 }
5076 /// Identifies the authorization scope(s) for the method you are building.
5077 ///
5078 /// See [`Self::add_scope()`] for details.
5079 pub fn add_scopes<I, St>(
5080 mut self,
5081 scopes: I,
5082 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C>
5083 where
5084 I: IntoIterator<Item = St>,
5085 St: AsRef<str>,
5086 {
5087 self._scopes
5088 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5089 self
5090 }
5091
5092 /// Removes all scopes, and no default scope will be used either.
5093 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5094 /// for details).
5095 pub fn clear_scopes(
5096 mut self,
5097 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationCreateCall<'a, C> {
5098 self._scopes.clear();
5099 self
5100 }
5101}
5102
5103/// Unregister an apiKey from using for predict method.
5104///
5105/// A builder for the *locations.catalogs.eventStores.predictionApiKeyRegistrations.delete* method supported by a *project* resource.
5106/// It is not used directly, but through a [`ProjectMethods`] instance.
5107///
5108/// # Example
5109///
5110/// Instantiate a resource method builder
5111///
5112/// ```test_harness,no_run
5113/// # extern crate hyper;
5114/// # extern crate hyper_rustls;
5115/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
5116/// # async fn dox() {
5117/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5118///
5119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5120/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5121/// # .with_native_roots()
5122/// # .unwrap()
5123/// # .https_only()
5124/// # .enable_http2()
5125/// # .build();
5126///
5127/// # let executor = hyper_util::rt::TokioExecutor::new();
5128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5129/// # secret,
5130/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5131/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5132/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5133/// # ),
5134/// # ).build().await.unwrap();
5135///
5136/// # let client = hyper_util::client::legacy::Client::builder(
5137/// # hyper_util::rt::TokioExecutor::new()
5138/// # )
5139/// # .build(
5140/// # hyper_rustls::HttpsConnectorBuilder::new()
5141/// # .with_native_roots()
5142/// # .unwrap()
5143/// # .https_or_http()
5144/// # .enable_http2()
5145/// # .build()
5146/// # );
5147/// # let mut hub = RecommendationsAI::new(client, auth);
5148/// // You can configure optional parameters by calling the respective setters at will, and
5149/// // execute the final call using `doit()`.
5150/// // Values shown here are possibly random and not representative !
5151/// let result = hub.projects().locations_catalogs_event_stores_prediction_api_key_registrations_delete("name")
5152/// .doit().await;
5153/// # }
5154/// ```
5155pub struct ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C>
5156where
5157 C: 'a,
5158{
5159 hub: &'a RecommendationsAI<C>,
5160 _name: String,
5161 _delegate: Option<&'a mut dyn common::Delegate>,
5162 _additional_params: HashMap<String, String>,
5163 _scopes: BTreeSet<String>,
5164}
5165
5166impl<'a, C> common::CallBuilder
5167 for ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C>
5168{
5169}
5170
5171impl<'a, C> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C>
5172where
5173 C: common::Connector,
5174{
5175 /// Perform the operation you have build so far.
5176 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
5177 use std::borrow::Cow;
5178 use std::io::{Read, Seek};
5179
5180 use common::{url::Params, ToParts};
5181 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5182
5183 let mut dd = common::DefaultDelegate;
5184 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5185 dlg.begin(common::MethodInfo { id: "recommendationengine.projects.locations.catalogs.eventStores.predictionApiKeyRegistrations.delete",
5186 http_method: hyper::Method::DELETE });
5187
5188 for &field in ["alt", "name"].iter() {
5189 if self._additional_params.contains_key(field) {
5190 dlg.finished(false);
5191 return Err(common::Error::FieldClash(field));
5192 }
5193 }
5194
5195 let mut params = Params::with_capacity(3 + self._additional_params.len());
5196 params.push("name", self._name);
5197
5198 params.extend(self._additional_params.iter());
5199
5200 params.push("alt", "json");
5201 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
5202 if self._scopes.is_empty() {
5203 self._scopes
5204 .insert(Scope::CloudPlatform.as_ref().to_string());
5205 }
5206
5207 #[allow(clippy::single_element_loop)]
5208 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5209 url = params.uri_replacement(url, param_name, find_this, true);
5210 }
5211 {
5212 let to_remove = ["name"];
5213 params.remove_params(&to_remove);
5214 }
5215
5216 let url = params.parse_with_url(&url);
5217
5218 loop {
5219 let token = match self
5220 .hub
5221 .auth
5222 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5223 .await
5224 {
5225 Ok(token) => token,
5226 Err(e) => match dlg.token(e) {
5227 Ok(token) => token,
5228 Err(e) => {
5229 dlg.finished(false);
5230 return Err(common::Error::MissingToken(e));
5231 }
5232 },
5233 };
5234 let mut req_result = {
5235 let client = &self.hub.client;
5236 dlg.pre_request();
5237 let mut req_builder = hyper::Request::builder()
5238 .method(hyper::Method::DELETE)
5239 .uri(url.as_str())
5240 .header(USER_AGENT, self.hub._user_agent.clone());
5241
5242 if let Some(token) = token.as_ref() {
5243 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5244 }
5245
5246 let request = req_builder
5247 .header(CONTENT_LENGTH, 0_u64)
5248 .body(common::to_body::<String>(None));
5249
5250 client.request(request.unwrap()).await
5251 };
5252
5253 match req_result {
5254 Err(err) => {
5255 if let common::Retry::After(d) = dlg.http_error(&err) {
5256 sleep(d).await;
5257 continue;
5258 }
5259 dlg.finished(false);
5260 return Err(common::Error::HttpError(err));
5261 }
5262 Ok(res) => {
5263 let (mut parts, body) = res.into_parts();
5264 let mut body = common::Body::new(body);
5265 if !parts.status.is_success() {
5266 let bytes = common::to_bytes(body).await.unwrap_or_default();
5267 let error = serde_json::from_str(&common::to_string(&bytes));
5268 let response = common::to_response(parts, bytes.into());
5269
5270 if let common::Retry::After(d) =
5271 dlg.http_failure(&response, error.as_ref().ok())
5272 {
5273 sleep(d).await;
5274 continue;
5275 }
5276
5277 dlg.finished(false);
5278
5279 return Err(match error {
5280 Ok(value) => common::Error::BadRequest(value),
5281 _ => common::Error::Failure(response),
5282 });
5283 }
5284 let response = {
5285 let bytes = common::to_bytes(body).await.unwrap_or_default();
5286 let encoded = common::to_string(&bytes);
5287 match serde_json::from_str(&encoded) {
5288 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5289 Err(error) => {
5290 dlg.response_json_decode_error(&encoded, &error);
5291 return Err(common::Error::JsonDecodeError(
5292 encoded.to_string(),
5293 error,
5294 ));
5295 }
5296 }
5297 };
5298
5299 dlg.finished(true);
5300 return Ok(response);
5301 }
5302 }
5303 }
5304 }
5305
5306 /// Required. The API key to unregister including full resource path. `projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/predictionApiKeyRegistrations/`
5307 ///
5308 /// Sets the *name* path property to the given value.
5309 ///
5310 /// Even though the property as already been set when instantiating this call,
5311 /// we provide this method for API completeness.
5312 pub fn name(
5313 mut self,
5314 new_value: &str,
5315 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C> {
5316 self._name = new_value.to_string();
5317 self
5318 }
5319 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5320 /// while executing the actual API request.
5321 ///
5322 /// ````text
5323 /// It should be used to handle progress information, and to implement a certain level of resilience.
5324 /// ````
5325 ///
5326 /// Sets the *delegate* property to the given value.
5327 pub fn delegate(
5328 mut self,
5329 new_value: &'a mut dyn common::Delegate,
5330 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C> {
5331 self._delegate = Some(new_value);
5332 self
5333 }
5334
5335 /// Set any additional parameter of the query string used in the request.
5336 /// It should be used to set parameters which are not yet available through their own
5337 /// setters.
5338 ///
5339 /// Please note that this method must not be used to set any of the known parameters
5340 /// which have their own setter method. If done anyway, the request will fail.
5341 ///
5342 /// # Additional Parameters
5343 ///
5344 /// * *$.xgafv* (query-string) - V1 error format.
5345 /// * *access_token* (query-string) - OAuth access token.
5346 /// * *alt* (query-string) - Data format for response.
5347 /// * *callback* (query-string) - JSONP
5348 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5349 /// * *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.
5350 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5351 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5352 /// * *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.
5353 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5354 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5355 pub fn param<T>(
5356 mut self,
5357 name: T,
5358 value: T,
5359 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C>
5360 where
5361 T: AsRef<str>,
5362 {
5363 self._additional_params
5364 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5365 self
5366 }
5367
5368 /// Identifies the authorization scope for the method you are building.
5369 ///
5370 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5371 /// [`Scope::CloudPlatform`].
5372 ///
5373 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5374 /// tokens for more than one scope.
5375 ///
5376 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5377 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5378 /// sufficient, a read-write scope will do as well.
5379 pub fn add_scope<St>(
5380 mut self,
5381 scope: St,
5382 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C>
5383 where
5384 St: AsRef<str>,
5385 {
5386 self._scopes.insert(String::from(scope.as_ref()));
5387 self
5388 }
5389 /// Identifies the authorization scope(s) for the method you are building.
5390 ///
5391 /// See [`Self::add_scope()`] for details.
5392 pub fn add_scopes<I, St>(
5393 mut self,
5394 scopes: I,
5395 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C>
5396 where
5397 I: IntoIterator<Item = St>,
5398 St: AsRef<str>,
5399 {
5400 self._scopes
5401 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5402 self
5403 }
5404
5405 /// Removes all scopes, and no default scope will be used either.
5406 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5407 /// for details).
5408 pub fn clear_scopes(
5409 mut self,
5410 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationDeleteCall<'a, C> {
5411 self._scopes.clear();
5412 self
5413 }
5414}
5415
5416/// List the registered apiKeys for use with predict method.
5417///
5418/// A builder for the *locations.catalogs.eventStores.predictionApiKeyRegistrations.list* method supported by a *project* resource.
5419/// It is not used directly, but through a [`ProjectMethods`] instance.
5420///
5421/// # Example
5422///
5423/// Instantiate a resource method builder
5424///
5425/// ```test_harness,no_run
5426/// # extern crate hyper;
5427/// # extern crate hyper_rustls;
5428/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
5429/// # async fn dox() {
5430/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5431///
5432/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5433/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5434/// # .with_native_roots()
5435/// # .unwrap()
5436/// # .https_only()
5437/// # .enable_http2()
5438/// # .build();
5439///
5440/// # let executor = hyper_util::rt::TokioExecutor::new();
5441/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5442/// # secret,
5443/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5444/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5445/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5446/// # ),
5447/// # ).build().await.unwrap();
5448///
5449/// # let client = hyper_util::client::legacy::Client::builder(
5450/// # hyper_util::rt::TokioExecutor::new()
5451/// # )
5452/// # .build(
5453/// # hyper_rustls::HttpsConnectorBuilder::new()
5454/// # .with_native_roots()
5455/// # .unwrap()
5456/// # .https_or_http()
5457/// # .enable_http2()
5458/// # .build()
5459/// # );
5460/// # let mut hub = RecommendationsAI::new(client, auth);
5461/// // You can configure optional parameters by calling the respective setters at will, and
5462/// // execute the final call using `doit()`.
5463/// // Values shown here are possibly random and not representative !
5464/// let result = hub.projects().locations_catalogs_event_stores_prediction_api_key_registrations_list("parent")
5465/// .page_token("duo")
5466/// .page_size(-50)
5467/// .doit().await;
5468/// # }
5469/// ```
5470pub struct ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C>
5471where
5472 C: 'a,
5473{
5474 hub: &'a RecommendationsAI<C>,
5475 _parent: String,
5476 _page_token: Option<String>,
5477 _page_size: Option<i32>,
5478 _delegate: Option<&'a mut dyn common::Delegate>,
5479 _additional_params: HashMap<String, String>,
5480 _scopes: BTreeSet<String>,
5481}
5482
5483impl<'a, C> common::CallBuilder
5484 for ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C>
5485{
5486}
5487
5488impl<'a, C> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C>
5489where
5490 C: common::Connector,
5491{
5492 /// Perform the operation you have build so far.
5493 pub async fn doit(
5494 mut self,
5495 ) -> common::Result<(
5496 common::Response,
5497 GoogleCloudRecommendationengineV1beta1ListPredictionApiKeyRegistrationsResponse,
5498 )> {
5499 use std::borrow::Cow;
5500 use std::io::{Read, Seek};
5501
5502 use common::{url::Params, ToParts};
5503 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5504
5505 let mut dd = common::DefaultDelegate;
5506 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5507 dlg.begin(common::MethodInfo { id: "recommendationengine.projects.locations.catalogs.eventStores.predictionApiKeyRegistrations.list",
5508 http_method: hyper::Method::GET });
5509
5510 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5511 if self._additional_params.contains_key(field) {
5512 dlg.finished(false);
5513 return Err(common::Error::FieldClash(field));
5514 }
5515 }
5516
5517 let mut params = Params::with_capacity(5 + self._additional_params.len());
5518 params.push("parent", self._parent);
5519 if let Some(value) = self._page_token.as_ref() {
5520 params.push("pageToken", value);
5521 }
5522 if let Some(value) = self._page_size.as_ref() {
5523 params.push("pageSize", value.to_string());
5524 }
5525
5526 params.extend(self._additional_params.iter());
5527
5528 params.push("alt", "json");
5529 let mut url =
5530 self.hub._base_url.clone() + "v1beta1/{+parent}/predictionApiKeyRegistrations";
5531 if self._scopes.is_empty() {
5532 self._scopes
5533 .insert(Scope::CloudPlatform.as_ref().to_string());
5534 }
5535
5536 #[allow(clippy::single_element_loop)]
5537 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5538 url = params.uri_replacement(url, param_name, find_this, true);
5539 }
5540 {
5541 let to_remove = ["parent"];
5542 params.remove_params(&to_remove);
5543 }
5544
5545 let url = params.parse_with_url(&url);
5546
5547 loop {
5548 let token = match self
5549 .hub
5550 .auth
5551 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5552 .await
5553 {
5554 Ok(token) => token,
5555 Err(e) => match dlg.token(e) {
5556 Ok(token) => token,
5557 Err(e) => {
5558 dlg.finished(false);
5559 return Err(common::Error::MissingToken(e));
5560 }
5561 },
5562 };
5563 let mut req_result = {
5564 let client = &self.hub.client;
5565 dlg.pre_request();
5566 let mut req_builder = hyper::Request::builder()
5567 .method(hyper::Method::GET)
5568 .uri(url.as_str())
5569 .header(USER_AGENT, self.hub._user_agent.clone());
5570
5571 if let Some(token) = token.as_ref() {
5572 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5573 }
5574
5575 let request = req_builder
5576 .header(CONTENT_LENGTH, 0_u64)
5577 .body(common::to_body::<String>(None));
5578
5579 client.request(request.unwrap()).await
5580 };
5581
5582 match req_result {
5583 Err(err) => {
5584 if let common::Retry::After(d) = dlg.http_error(&err) {
5585 sleep(d).await;
5586 continue;
5587 }
5588 dlg.finished(false);
5589 return Err(common::Error::HttpError(err));
5590 }
5591 Ok(res) => {
5592 let (mut parts, body) = res.into_parts();
5593 let mut body = common::Body::new(body);
5594 if !parts.status.is_success() {
5595 let bytes = common::to_bytes(body).await.unwrap_or_default();
5596 let error = serde_json::from_str(&common::to_string(&bytes));
5597 let response = common::to_response(parts, bytes.into());
5598
5599 if let common::Retry::After(d) =
5600 dlg.http_failure(&response, error.as_ref().ok())
5601 {
5602 sleep(d).await;
5603 continue;
5604 }
5605
5606 dlg.finished(false);
5607
5608 return Err(match error {
5609 Ok(value) => common::Error::BadRequest(value),
5610 _ => common::Error::Failure(response),
5611 });
5612 }
5613 let response = {
5614 let bytes = common::to_bytes(body).await.unwrap_or_default();
5615 let encoded = common::to_string(&bytes);
5616 match serde_json::from_str(&encoded) {
5617 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5618 Err(error) => {
5619 dlg.response_json_decode_error(&encoded, &error);
5620 return Err(common::Error::JsonDecodeError(
5621 encoded.to_string(),
5622 error,
5623 ));
5624 }
5625 }
5626 };
5627
5628 dlg.finished(true);
5629 return Ok(response);
5630 }
5631 }
5632 }
5633 }
5634
5635 /// Required. The parent placement resource name such as `projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`
5636 ///
5637 /// Sets the *parent* path property to the given value.
5638 ///
5639 /// Even though the property as already been set when instantiating this call,
5640 /// we provide this method for API completeness.
5641 pub fn parent(
5642 mut self,
5643 new_value: &str,
5644 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C> {
5645 self._parent = new_value.to_string();
5646 self
5647 }
5648 /// Optional. The previous `ListPredictionApiKeyRegistration.nextPageToken`.
5649 ///
5650 /// Sets the *page token* query property to the given value.
5651 pub fn page_token(
5652 mut self,
5653 new_value: &str,
5654 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C> {
5655 self._page_token = Some(new_value.to_string());
5656 self
5657 }
5658 /// Optional. Maximum number of results to return per page. If unset, the service will choose a reasonable default.
5659 ///
5660 /// Sets the *page size* query property to the given value.
5661 pub fn page_size(
5662 mut self,
5663 new_value: i32,
5664 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C> {
5665 self._page_size = Some(new_value);
5666 self
5667 }
5668 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5669 /// while executing the actual API request.
5670 ///
5671 /// ````text
5672 /// It should be used to handle progress information, and to implement a certain level of resilience.
5673 /// ````
5674 ///
5675 /// Sets the *delegate* property to the given value.
5676 pub fn delegate(
5677 mut self,
5678 new_value: &'a mut dyn common::Delegate,
5679 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C> {
5680 self._delegate = Some(new_value);
5681 self
5682 }
5683
5684 /// Set any additional parameter of the query string used in the request.
5685 /// It should be used to set parameters which are not yet available through their own
5686 /// setters.
5687 ///
5688 /// Please note that this method must not be used to set any of the known parameters
5689 /// which have their own setter method. If done anyway, the request will fail.
5690 ///
5691 /// # Additional Parameters
5692 ///
5693 /// * *$.xgafv* (query-string) - V1 error format.
5694 /// * *access_token* (query-string) - OAuth access token.
5695 /// * *alt* (query-string) - Data format for response.
5696 /// * *callback* (query-string) - JSONP
5697 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5698 /// * *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.
5699 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5700 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5701 /// * *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.
5702 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5703 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5704 pub fn param<T>(
5705 mut self,
5706 name: T,
5707 value: T,
5708 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C>
5709 where
5710 T: AsRef<str>,
5711 {
5712 self._additional_params
5713 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5714 self
5715 }
5716
5717 /// Identifies the authorization scope for the method you are building.
5718 ///
5719 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5720 /// [`Scope::CloudPlatform`].
5721 ///
5722 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5723 /// tokens for more than one scope.
5724 ///
5725 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5726 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5727 /// sufficient, a read-write scope will do as well.
5728 pub fn add_scope<St>(
5729 mut self,
5730 scope: St,
5731 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C>
5732 where
5733 St: AsRef<str>,
5734 {
5735 self._scopes.insert(String::from(scope.as_ref()));
5736 self
5737 }
5738 /// Identifies the authorization scope(s) for the method you are building.
5739 ///
5740 /// See [`Self::add_scope()`] for details.
5741 pub fn add_scopes<I, St>(
5742 mut self,
5743 scopes: I,
5744 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C>
5745 where
5746 I: IntoIterator<Item = St>,
5747 St: AsRef<str>,
5748 {
5749 self._scopes
5750 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5751 self
5752 }
5753
5754 /// Removes all scopes, and no default scope will be used either.
5755 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5756 /// for details).
5757 pub fn clear_scopes(
5758 mut self,
5759 ) -> ProjectLocationCatalogEventStorePredictionApiKeyRegistrationListCall<'a, C> {
5760 self._scopes.clear();
5761 self
5762 }
5763}
5764
5765/// Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Recommendations AI JavaScript pixel. Users should not call this method directly.
5766///
5767/// A builder for the *locations.catalogs.eventStores.userEvents.collect* method supported by a *project* resource.
5768/// It is not used directly, but through a [`ProjectMethods`] instance.
5769///
5770/// # Example
5771///
5772/// Instantiate a resource method builder
5773///
5774/// ```test_harness,no_run
5775/// # extern crate hyper;
5776/// # extern crate hyper_rustls;
5777/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
5778/// # async fn dox() {
5779/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5780///
5781/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5782/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5783/// # .with_native_roots()
5784/// # .unwrap()
5785/// # .https_only()
5786/// # .enable_http2()
5787/// # .build();
5788///
5789/// # let executor = hyper_util::rt::TokioExecutor::new();
5790/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5791/// # secret,
5792/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5793/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5794/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5795/// # ),
5796/// # ).build().await.unwrap();
5797///
5798/// # let client = hyper_util::client::legacy::Client::builder(
5799/// # hyper_util::rt::TokioExecutor::new()
5800/// # )
5801/// # .build(
5802/// # hyper_rustls::HttpsConnectorBuilder::new()
5803/// # .with_native_roots()
5804/// # .unwrap()
5805/// # .https_or_http()
5806/// # .enable_http2()
5807/// # .build()
5808/// # );
5809/// # let mut hub = RecommendationsAI::new(client, auth);
5810/// // You can configure optional parameters by calling the respective setters at will, and
5811/// // execute the final call using `doit()`.
5812/// // Values shown here are possibly random and not representative !
5813/// let result = hub.projects().locations_catalogs_event_stores_user_events_collect("parent")
5814/// .user_event("ut")
5815/// .uri("gubergren")
5816/// .ets(-16)
5817/// .doit().await;
5818/// # }
5819/// ```
5820pub struct ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C>
5821where
5822 C: 'a,
5823{
5824 hub: &'a RecommendationsAI<C>,
5825 _parent: String,
5826 _user_event: Option<String>,
5827 _uri: Option<String>,
5828 _ets: Option<i64>,
5829 _delegate: Option<&'a mut dyn common::Delegate>,
5830 _additional_params: HashMap<String, String>,
5831 _scopes: BTreeSet<String>,
5832}
5833
5834impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {}
5835
5836impl<'a, C> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C>
5837where
5838 C: common::Connector,
5839{
5840 /// Perform the operation you have build so far.
5841 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleApiHttpBody)> {
5842 use std::borrow::Cow;
5843 use std::io::{Read, Seek};
5844
5845 use common::{url::Params, ToParts};
5846 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5847
5848 let mut dd = common::DefaultDelegate;
5849 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5850 dlg.begin(common::MethodInfo {
5851 id: "recommendationengine.projects.locations.catalogs.eventStores.userEvents.collect",
5852 http_method: hyper::Method::GET,
5853 });
5854
5855 for &field in ["alt", "parent", "userEvent", "uri", "ets"].iter() {
5856 if self._additional_params.contains_key(field) {
5857 dlg.finished(false);
5858 return Err(common::Error::FieldClash(field));
5859 }
5860 }
5861
5862 let mut params = Params::with_capacity(6 + self._additional_params.len());
5863 params.push("parent", self._parent);
5864 if let Some(value) = self._user_event.as_ref() {
5865 params.push("userEvent", value);
5866 }
5867 if let Some(value) = self._uri.as_ref() {
5868 params.push("uri", value);
5869 }
5870 if let Some(value) = self._ets.as_ref() {
5871 params.push("ets", value.to_string());
5872 }
5873
5874 params.extend(self._additional_params.iter());
5875
5876 params.push("alt", "json");
5877 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/userEvents:collect";
5878 if self._scopes.is_empty() {
5879 self._scopes
5880 .insert(Scope::CloudPlatform.as_ref().to_string());
5881 }
5882
5883 #[allow(clippy::single_element_loop)]
5884 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5885 url = params.uri_replacement(url, param_name, find_this, true);
5886 }
5887 {
5888 let to_remove = ["parent"];
5889 params.remove_params(&to_remove);
5890 }
5891
5892 let url = params.parse_with_url(&url);
5893
5894 loop {
5895 let token = match self
5896 .hub
5897 .auth
5898 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5899 .await
5900 {
5901 Ok(token) => token,
5902 Err(e) => match dlg.token(e) {
5903 Ok(token) => token,
5904 Err(e) => {
5905 dlg.finished(false);
5906 return Err(common::Error::MissingToken(e));
5907 }
5908 },
5909 };
5910 let mut req_result = {
5911 let client = &self.hub.client;
5912 dlg.pre_request();
5913 let mut req_builder = hyper::Request::builder()
5914 .method(hyper::Method::GET)
5915 .uri(url.as_str())
5916 .header(USER_AGENT, self.hub._user_agent.clone());
5917
5918 if let Some(token) = token.as_ref() {
5919 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5920 }
5921
5922 let request = req_builder
5923 .header(CONTENT_LENGTH, 0_u64)
5924 .body(common::to_body::<String>(None));
5925
5926 client.request(request.unwrap()).await
5927 };
5928
5929 match req_result {
5930 Err(err) => {
5931 if let common::Retry::After(d) = dlg.http_error(&err) {
5932 sleep(d).await;
5933 continue;
5934 }
5935 dlg.finished(false);
5936 return Err(common::Error::HttpError(err));
5937 }
5938 Ok(res) => {
5939 let (mut parts, body) = res.into_parts();
5940 let mut body = common::Body::new(body);
5941 if !parts.status.is_success() {
5942 let bytes = common::to_bytes(body).await.unwrap_or_default();
5943 let error = serde_json::from_str(&common::to_string(&bytes));
5944 let response = common::to_response(parts, bytes.into());
5945
5946 if let common::Retry::After(d) =
5947 dlg.http_failure(&response, error.as_ref().ok())
5948 {
5949 sleep(d).await;
5950 continue;
5951 }
5952
5953 dlg.finished(false);
5954
5955 return Err(match error {
5956 Ok(value) => common::Error::BadRequest(value),
5957 _ => common::Error::Failure(response),
5958 });
5959 }
5960 let response = {
5961 let bytes = common::to_bytes(body).await.unwrap_or_default();
5962 let encoded = common::to_string(&bytes);
5963 match serde_json::from_str(&encoded) {
5964 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5965 Err(error) => {
5966 dlg.response_json_decode_error(&encoded, &error);
5967 return Err(common::Error::JsonDecodeError(
5968 encoded.to_string(),
5969 error,
5970 ));
5971 }
5972 }
5973 };
5974
5975 dlg.finished(true);
5976 return Ok(response);
5977 }
5978 }
5979 }
5980 }
5981
5982 /// Required. The parent eventStore name, such as `projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`.
5983 ///
5984 /// Sets the *parent* path property to the given value.
5985 ///
5986 /// Even though the property as already been set when instantiating this call,
5987 /// we provide this method for API completeness.
5988 pub fn parent(
5989 mut self,
5990 new_value: &str,
5991 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {
5992 self._parent = new_value.to_string();
5993 self
5994 }
5995 /// Required. URL encoded UserEvent proto.
5996 ///
5997 /// Sets the *user event* query property to the given value.
5998 pub fn user_event(
5999 mut self,
6000 new_value: &str,
6001 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {
6002 self._user_event = Some(new_value.to_string());
6003 self
6004 }
6005 /// Optional. The url including cgi-parameters but excluding the hash fragment. The URL must be truncated to 1.5K bytes to conservatively be under the 2K bytes. This is often more useful than the referer url, because many browsers only send the domain for 3rd party requests.
6006 ///
6007 /// Sets the *uri* query property to the given value.
6008 pub fn uri(
6009 mut self,
6010 new_value: &str,
6011 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {
6012 self._uri = Some(new_value.to_string());
6013 self
6014 }
6015 /// Optional. The event timestamp in milliseconds. This prevents browser caching of otherwise identical get requests. The name is abbreviated to reduce the payload bytes.
6016 ///
6017 /// Sets the *ets* query property to the given value.
6018 pub fn ets(
6019 mut self,
6020 new_value: i64,
6021 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {
6022 self._ets = Some(new_value);
6023 self
6024 }
6025 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6026 /// while executing the actual API request.
6027 ///
6028 /// ````text
6029 /// It should be used to handle progress information, and to implement a certain level of resilience.
6030 /// ````
6031 ///
6032 /// Sets the *delegate* property to the given value.
6033 pub fn delegate(
6034 mut self,
6035 new_value: &'a mut dyn common::Delegate,
6036 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {
6037 self._delegate = Some(new_value);
6038 self
6039 }
6040
6041 /// Set any additional parameter of the query string used in the request.
6042 /// It should be used to set parameters which are not yet available through their own
6043 /// setters.
6044 ///
6045 /// Please note that this method must not be used to set any of the known parameters
6046 /// which have their own setter method. If done anyway, the request will fail.
6047 ///
6048 /// # Additional Parameters
6049 ///
6050 /// * *$.xgafv* (query-string) - V1 error format.
6051 /// * *access_token* (query-string) - OAuth access token.
6052 /// * *alt* (query-string) - Data format for response.
6053 /// * *callback* (query-string) - JSONP
6054 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6055 /// * *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.
6056 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6057 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6058 /// * *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.
6059 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6060 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6061 pub fn param<T>(
6062 mut self,
6063 name: T,
6064 value: T,
6065 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C>
6066 where
6067 T: AsRef<str>,
6068 {
6069 self._additional_params
6070 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6071 self
6072 }
6073
6074 /// Identifies the authorization scope for the method you are building.
6075 ///
6076 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6077 /// [`Scope::CloudPlatform`].
6078 ///
6079 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6080 /// tokens for more than one scope.
6081 ///
6082 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6083 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6084 /// sufficient, a read-write scope will do as well.
6085 pub fn add_scope<St>(
6086 mut self,
6087 scope: St,
6088 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C>
6089 where
6090 St: AsRef<str>,
6091 {
6092 self._scopes.insert(String::from(scope.as_ref()));
6093 self
6094 }
6095 /// Identifies the authorization scope(s) for the method you are building.
6096 ///
6097 /// See [`Self::add_scope()`] for details.
6098 pub fn add_scopes<I, St>(
6099 mut self,
6100 scopes: I,
6101 ) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C>
6102 where
6103 I: IntoIterator<Item = St>,
6104 St: AsRef<str>,
6105 {
6106 self._scopes
6107 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6108 self
6109 }
6110
6111 /// Removes all scopes, and no default scope will be used either.
6112 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6113 /// for details).
6114 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreUserEventCollectCall<'a, C> {
6115 self._scopes.clear();
6116 self
6117 }
6118}
6119
6120/// Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.
6121///
6122/// A builder for the *locations.catalogs.eventStores.userEvents.import* method supported by a *project* resource.
6123/// It is not used directly, but through a [`ProjectMethods`] instance.
6124///
6125/// # Example
6126///
6127/// Instantiate a resource method builder
6128///
6129/// ```test_harness,no_run
6130/// # extern crate hyper;
6131/// # extern crate hyper_rustls;
6132/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
6133/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest;
6134/// # async fn dox() {
6135/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6136///
6137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6138/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6139/// # .with_native_roots()
6140/// # .unwrap()
6141/// # .https_only()
6142/// # .enable_http2()
6143/// # .build();
6144///
6145/// # let executor = hyper_util::rt::TokioExecutor::new();
6146/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6147/// # secret,
6148/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6149/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6150/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6151/// # ),
6152/// # ).build().await.unwrap();
6153///
6154/// # let client = hyper_util::client::legacy::Client::builder(
6155/// # hyper_util::rt::TokioExecutor::new()
6156/// # )
6157/// # .build(
6158/// # hyper_rustls::HttpsConnectorBuilder::new()
6159/// # .with_native_roots()
6160/// # .unwrap()
6161/// # .https_or_http()
6162/// # .enable_http2()
6163/// # .build()
6164/// # );
6165/// # let mut hub = RecommendationsAI::new(client, auth);
6166/// // As the method needs a request, you would usually fill it with the desired information
6167/// // into the respective structure. Some of the parts shown here might not be applicable !
6168/// // Values shown here are possibly random and not representative !
6169/// let mut req = GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest::default();
6170///
6171/// // You can configure optional parameters by calling the respective setters at will, and
6172/// // execute the final call using `doit()`.
6173/// // Values shown here are possibly random and not representative !
6174/// let result = hub.projects().locations_catalogs_event_stores_user_events_import(req, "parent")
6175/// .doit().await;
6176/// # }
6177/// ```
6178pub struct ProjectLocationCatalogEventStoreUserEventImportCall<'a, C>
6179where
6180 C: 'a,
6181{
6182 hub: &'a RecommendationsAI<C>,
6183 _request: GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest,
6184 _parent: String,
6185 _delegate: Option<&'a mut dyn common::Delegate>,
6186 _additional_params: HashMap<String, String>,
6187 _scopes: BTreeSet<String>,
6188}
6189
6190impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreUserEventImportCall<'a, C> {}
6191
6192impl<'a, C> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C>
6193where
6194 C: common::Connector,
6195{
6196 /// Perform the operation you have build so far.
6197 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6198 use std::borrow::Cow;
6199 use std::io::{Read, Seek};
6200
6201 use common::{url::Params, ToParts};
6202 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6203
6204 let mut dd = common::DefaultDelegate;
6205 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6206 dlg.begin(common::MethodInfo {
6207 id: "recommendationengine.projects.locations.catalogs.eventStores.userEvents.import",
6208 http_method: hyper::Method::POST,
6209 });
6210
6211 for &field in ["alt", "parent"].iter() {
6212 if self._additional_params.contains_key(field) {
6213 dlg.finished(false);
6214 return Err(common::Error::FieldClash(field));
6215 }
6216 }
6217
6218 let mut params = Params::with_capacity(4 + self._additional_params.len());
6219 params.push("parent", self._parent);
6220
6221 params.extend(self._additional_params.iter());
6222
6223 params.push("alt", "json");
6224 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/userEvents:import";
6225 if self._scopes.is_empty() {
6226 self._scopes
6227 .insert(Scope::CloudPlatform.as_ref().to_string());
6228 }
6229
6230 #[allow(clippy::single_element_loop)]
6231 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6232 url = params.uri_replacement(url, param_name, find_this, true);
6233 }
6234 {
6235 let to_remove = ["parent"];
6236 params.remove_params(&to_remove);
6237 }
6238
6239 let url = params.parse_with_url(&url);
6240
6241 let mut json_mime_type = mime::APPLICATION_JSON;
6242 let mut request_value_reader = {
6243 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6244 common::remove_json_null_values(&mut value);
6245 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6246 serde_json::to_writer(&mut dst, &value).unwrap();
6247 dst
6248 };
6249 let request_size = request_value_reader
6250 .seek(std::io::SeekFrom::End(0))
6251 .unwrap();
6252 request_value_reader
6253 .seek(std::io::SeekFrom::Start(0))
6254 .unwrap();
6255
6256 loop {
6257 let token = match self
6258 .hub
6259 .auth
6260 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6261 .await
6262 {
6263 Ok(token) => token,
6264 Err(e) => match dlg.token(e) {
6265 Ok(token) => token,
6266 Err(e) => {
6267 dlg.finished(false);
6268 return Err(common::Error::MissingToken(e));
6269 }
6270 },
6271 };
6272 request_value_reader
6273 .seek(std::io::SeekFrom::Start(0))
6274 .unwrap();
6275 let mut req_result = {
6276 let client = &self.hub.client;
6277 dlg.pre_request();
6278 let mut req_builder = hyper::Request::builder()
6279 .method(hyper::Method::POST)
6280 .uri(url.as_str())
6281 .header(USER_AGENT, self.hub._user_agent.clone());
6282
6283 if let Some(token) = token.as_ref() {
6284 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6285 }
6286
6287 let request = req_builder
6288 .header(CONTENT_TYPE, json_mime_type.to_string())
6289 .header(CONTENT_LENGTH, request_size as u64)
6290 .body(common::to_body(
6291 request_value_reader.get_ref().clone().into(),
6292 ));
6293
6294 client.request(request.unwrap()).await
6295 };
6296
6297 match req_result {
6298 Err(err) => {
6299 if let common::Retry::After(d) = dlg.http_error(&err) {
6300 sleep(d).await;
6301 continue;
6302 }
6303 dlg.finished(false);
6304 return Err(common::Error::HttpError(err));
6305 }
6306 Ok(res) => {
6307 let (mut parts, body) = res.into_parts();
6308 let mut body = common::Body::new(body);
6309 if !parts.status.is_success() {
6310 let bytes = common::to_bytes(body).await.unwrap_or_default();
6311 let error = serde_json::from_str(&common::to_string(&bytes));
6312 let response = common::to_response(parts, bytes.into());
6313
6314 if let common::Retry::After(d) =
6315 dlg.http_failure(&response, error.as_ref().ok())
6316 {
6317 sleep(d).await;
6318 continue;
6319 }
6320
6321 dlg.finished(false);
6322
6323 return Err(match error {
6324 Ok(value) => common::Error::BadRequest(value),
6325 _ => common::Error::Failure(response),
6326 });
6327 }
6328 let response = {
6329 let bytes = common::to_bytes(body).await.unwrap_or_default();
6330 let encoded = common::to_string(&bytes);
6331 match serde_json::from_str(&encoded) {
6332 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6333 Err(error) => {
6334 dlg.response_json_decode_error(&encoded, &error);
6335 return Err(common::Error::JsonDecodeError(
6336 encoded.to_string(),
6337 error,
6338 ));
6339 }
6340 }
6341 };
6342
6343 dlg.finished(true);
6344 return Ok(response);
6345 }
6346 }
6347 }
6348 }
6349
6350 ///
6351 /// Sets the *request* property to the given value.
6352 ///
6353 /// Even though the property as already been set when instantiating this call,
6354 /// we provide this method for API completeness.
6355 pub fn request(
6356 mut self,
6357 new_value: GoogleCloudRecommendationengineV1beta1ImportUserEventsRequest,
6358 ) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C> {
6359 self._request = new_value;
6360 self
6361 }
6362 /// Required. `projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`
6363 ///
6364 /// Sets the *parent* path property to the given value.
6365 ///
6366 /// Even though the property as already been set when instantiating this call,
6367 /// we provide this method for API completeness.
6368 pub fn parent(
6369 mut self,
6370 new_value: &str,
6371 ) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C> {
6372 self._parent = new_value.to_string();
6373 self
6374 }
6375 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6376 /// while executing the actual API request.
6377 ///
6378 /// ````text
6379 /// It should be used to handle progress information, and to implement a certain level of resilience.
6380 /// ````
6381 ///
6382 /// Sets the *delegate* property to the given value.
6383 pub fn delegate(
6384 mut self,
6385 new_value: &'a mut dyn common::Delegate,
6386 ) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C> {
6387 self._delegate = Some(new_value);
6388 self
6389 }
6390
6391 /// Set any additional parameter of the query string used in the request.
6392 /// It should be used to set parameters which are not yet available through their own
6393 /// setters.
6394 ///
6395 /// Please note that this method must not be used to set any of the known parameters
6396 /// which have their own setter method. If done anyway, the request will fail.
6397 ///
6398 /// # Additional Parameters
6399 ///
6400 /// * *$.xgafv* (query-string) - V1 error format.
6401 /// * *access_token* (query-string) - OAuth access token.
6402 /// * *alt* (query-string) - Data format for response.
6403 /// * *callback* (query-string) - JSONP
6404 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6405 /// * *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.
6406 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6407 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6408 /// * *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.
6409 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6410 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6411 pub fn param<T>(
6412 mut self,
6413 name: T,
6414 value: T,
6415 ) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C>
6416 where
6417 T: AsRef<str>,
6418 {
6419 self._additional_params
6420 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6421 self
6422 }
6423
6424 /// Identifies the authorization scope for the method you are building.
6425 ///
6426 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6427 /// [`Scope::CloudPlatform`].
6428 ///
6429 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6430 /// tokens for more than one scope.
6431 ///
6432 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6433 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6434 /// sufficient, a read-write scope will do as well.
6435 pub fn add_scope<St>(
6436 mut self,
6437 scope: St,
6438 ) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C>
6439 where
6440 St: AsRef<str>,
6441 {
6442 self._scopes.insert(String::from(scope.as_ref()));
6443 self
6444 }
6445 /// Identifies the authorization scope(s) for the method you are building.
6446 ///
6447 /// See [`Self::add_scope()`] for details.
6448 pub fn add_scopes<I, St>(
6449 mut self,
6450 scopes: I,
6451 ) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C>
6452 where
6453 I: IntoIterator<Item = St>,
6454 St: AsRef<str>,
6455 {
6456 self._scopes
6457 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6458 self
6459 }
6460
6461 /// Removes all scopes, and no default scope will be used either.
6462 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6463 /// for details).
6464 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreUserEventImportCall<'a, C> {
6465 self._scopes.clear();
6466 self
6467 }
6468}
6469
6470/// Gets a list of user events within a time range, with potential filtering. The method does not list unjoined user events. Unjoined user event definition: when a user event is ingested from Recommendations AI User Event APIs, the catalog item included in the user event is connected with the current catalog. If a catalog item of the ingested event is not in the current catalog, it could lead to degraded model quality. This is called an unjoined event.
6471///
6472/// A builder for the *locations.catalogs.eventStores.userEvents.list* method supported by a *project* resource.
6473/// It is not used directly, but through a [`ProjectMethods`] instance.
6474///
6475/// # Example
6476///
6477/// Instantiate a resource method builder
6478///
6479/// ```test_harness,no_run
6480/// # extern crate hyper;
6481/// # extern crate hyper_rustls;
6482/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
6483/// # async fn dox() {
6484/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6485///
6486/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6487/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6488/// # .with_native_roots()
6489/// # .unwrap()
6490/// # .https_only()
6491/// # .enable_http2()
6492/// # .build();
6493///
6494/// # let executor = hyper_util::rt::TokioExecutor::new();
6495/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6496/// # secret,
6497/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6498/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6499/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6500/// # ),
6501/// # ).build().await.unwrap();
6502///
6503/// # let client = hyper_util::client::legacy::Client::builder(
6504/// # hyper_util::rt::TokioExecutor::new()
6505/// # )
6506/// # .build(
6507/// # hyper_rustls::HttpsConnectorBuilder::new()
6508/// # .with_native_roots()
6509/// # .unwrap()
6510/// # .https_or_http()
6511/// # .enable_http2()
6512/// # .build()
6513/// # );
6514/// # let mut hub = RecommendationsAI::new(client, auth);
6515/// // You can configure optional parameters by calling the respective setters at will, and
6516/// // execute the final call using `doit()`.
6517/// // Values shown here are possibly random and not representative !
6518/// let result = hub.projects().locations_catalogs_event_stores_user_events_list("parent")
6519/// .page_token("ipsum")
6520/// .page_size(-7)
6521/// .filter("gubergren")
6522/// .doit().await;
6523/// # }
6524/// ```
6525pub struct ProjectLocationCatalogEventStoreUserEventListCall<'a, C>
6526where
6527 C: 'a,
6528{
6529 hub: &'a RecommendationsAI<C>,
6530 _parent: String,
6531 _page_token: Option<String>,
6532 _page_size: Option<i32>,
6533 _filter: Option<String>,
6534 _delegate: Option<&'a mut dyn common::Delegate>,
6535 _additional_params: HashMap<String, String>,
6536 _scopes: BTreeSet<String>,
6537}
6538
6539impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {}
6540
6541impl<'a, C> ProjectLocationCatalogEventStoreUserEventListCall<'a, C>
6542where
6543 C: common::Connector,
6544{
6545 /// Perform the operation you have build so far.
6546 pub async fn doit(
6547 mut self,
6548 ) -> common::Result<(
6549 common::Response,
6550 GoogleCloudRecommendationengineV1beta1ListUserEventsResponse,
6551 )> {
6552 use std::borrow::Cow;
6553 use std::io::{Read, Seek};
6554
6555 use common::{url::Params, ToParts};
6556 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6557
6558 let mut dd = common::DefaultDelegate;
6559 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6560 dlg.begin(common::MethodInfo {
6561 id: "recommendationengine.projects.locations.catalogs.eventStores.userEvents.list",
6562 http_method: hyper::Method::GET,
6563 });
6564
6565 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
6566 if self._additional_params.contains_key(field) {
6567 dlg.finished(false);
6568 return Err(common::Error::FieldClash(field));
6569 }
6570 }
6571
6572 let mut params = Params::with_capacity(6 + self._additional_params.len());
6573 params.push("parent", self._parent);
6574 if let Some(value) = self._page_token.as_ref() {
6575 params.push("pageToken", value);
6576 }
6577 if let Some(value) = self._page_size.as_ref() {
6578 params.push("pageSize", value.to_string());
6579 }
6580 if let Some(value) = self._filter.as_ref() {
6581 params.push("filter", value);
6582 }
6583
6584 params.extend(self._additional_params.iter());
6585
6586 params.push("alt", "json");
6587 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/userEvents";
6588 if self._scopes.is_empty() {
6589 self._scopes
6590 .insert(Scope::CloudPlatform.as_ref().to_string());
6591 }
6592
6593 #[allow(clippy::single_element_loop)]
6594 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6595 url = params.uri_replacement(url, param_name, find_this, true);
6596 }
6597 {
6598 let to_remove = ["parent"];
6599 params.remove_params(&to_remove);
6600 }
6601
6602 let url = params.parse_with_url(&url);
6603
6604 loop {
6605 let token = match self
6606 .hub
6607 .auth
6608 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6609 .await
6610 {
6611 Ok(token) => token,
6612 Err(e) => match dlg.token(e) {
6613 Ok(token) => token,
6614 Err(e) => {
6615 dlg.finished(false);
6616 return Err(common::Error::MissingToken(e));
6617 }
6618 },
6619 };
6620 let mut req_result = {
6621 let client = &self.hub.client;
6622 dlg.pre_request();
6623 let mut req_builder = hyper::Request::builder()
6624 .method(hyper::Method::GET)
6625 .uri(url.as_str())
6626 .header(USER_AGENT, self.hub._user_agent.clone());
6627
6628 if let Some(token) = token.as_ref() {
6629 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6630 }
6631
6632 let request = req_builder
6633 .header(CONTENT_LENGTH, 0_u64)
6634 .body(common::to_body::<String>(None));
6635
6636 client.request(request.unwrap()).await
6637 };
6638
6639 match req_result {
6640 Err(err) => {
6641 if let common::Retry::After(d) = dlg.http_error(&err) {
6642 sleep(d).await;
6643 continue;
6644 }
6645 dlg.finished(false);
6646 return Err(common::Error::HttpError(err));
6647 }
6648 Ok(res) => {
6649 let (mut parts, body) = res.into_parts();
6650 let mut body = common::Body::new(body);
6651 if !parts.status.is_success() {
6652 let bytes = common::to_bytes(body).await.unwrap_or_default();
6653 let error = serde_json::from_str(&common::to_string(&bytes));
6654 let response = common::to_response(parts, bytes.into());
6655
6656 if let common::Retry::After(d) =
6657 dlg.http_failure(&response, error.as_ref().ok())
6658 {
6659 sleep(d).await;
6660 continue;
6661 }
6662
6663 dlg.finished(false);
6664
6665 return Err(match error {
6666 Ok(value) => common::Error::BadRequest(value),
6667 _ => common::Error::Failure(response),
6668 });
6669 }
6670 let response = {
6671 let bytes = common::to_bytes(body).await.unwrap_or_default();
6672 let encoded = common::to_string(&bytes);
6673 match serde_json::from_str(&encoded) {
6674 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6675 Err(error) => {
6676 dlg.response_json_decode_error(&encoded, &error);
6677 return Err(common::Error::JsonDecodeError(
6678 encoded.to_string(),
6679 error,
6680 ));
6681 }
6682 }
6683 };
6684
6685 dlg.finished(true);
6686 return Ok(response);
6687 }
6688 }
6689 }
6690 }
6691
6692 /// Required. The parent eventStore resource name, such as `projects/*/locations/*/catalogs/default_catalog/eventStores/default_event_store`.
6693 ///
6694 /// Sets the *parent* path property to the given value.
6695 ///
6696 /// Even though the property as already been set when instantiating this call,
6697 /// we provide this method for API completeness.
6698 pub fn parent(
6699 mut self,
6700 new_value: &str,
6701 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {
6702 self._parent = new_value.to_string();
6703 self
6704 }
6705 /// Optional. The previous ListUserEventsResponse.next_page_token.
6706 ///
6707 /// Sets the *page token* query property to the given value.
6708 pub fn page_token(
6709 mut self,
6710 new_value: &str,
6711 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {
6712 self._page_token = Some(new_value.to_string());
6713 self
6714 }
6715 /// Optional. Maximum number of results to return per page. If zero, the service will choose a reasonable default.
6716 ///
6717 /// Sets the *page size* query property to the given value.
6718 pub fn page_size(
6719 mut self,
6720 new_value: i32,
6721 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {
6722 self._page_size = Some(new_value);
6723 self
6724 }
6725 /// Optional. Filtering expression to specify restrictions over returned events. This is a sequence of terms, where each term applies some kind of a restriction to the returned user events. Use this expression to restrict results to a specific time range, or filter events by eventType. eg: eventTime > "2012-04-23T18:25:43.511Z" eventsMissingCatalogItems eventTime<"2012-04-23T18:25:43.511Z" eventType=search We expect only 3 types of fields: * eventTime: this can be specified a maximum of 2 times, once with a less than operator and once with a greater than operator. The eventTime restrict should result in one contiguous valid eventTime range. * eventType: only 1 eventType restriction can be specified. * eventsMissingCatalogItems: specififying this will restrict results to events for which catalog items were not found in the catalog. The default behavior is to return only those events for which catalog items were found. Some examples of valid filters expressions: * Example 1: eventTime > "2012-04-23T18:25:43.511Z" eventTime < "2012-04-23T18:30:43.511Z" * Example 2: eventTime > "2012-04-23T18:25:43.511Z" eventType = detail-page-view * Example 3: eventsMissingCatalogItems eventType = search eventTime < "2018-04-23T18:30:43.511Z" * Example 4: eventTime > "2012-04-23T18:25:43.511Z" * Example 5: eventType = search * Example 6: eventsMissingCatalogItems
6726 ///
6727 /// Sets the *filter* query property to the given value.
6728 pub fn filter(
6729 mut self,
6730 new_value: &str,
6731 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {
6732 self._filter = Some(new_value.to_string());
6733 self
6734 }
6735 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6736 /// while executing the actual API request.
6737 ///
6738 /// ````text
6739 /// It should be used to handle progress information, and to implement a certain level of resilience.
6740 /// ````
6741 ///
6742 /// Sets the *delegate* property to the given value.
6743 pub fn delegate(
6744 mut self,
6745 new_value: &'a mut dyn common::Delegate,
6746 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {
6747 self._delegate = Some(new_value);
6748 self
6749 }
6750
6751 /// Set any additional parameter of the query string used in the request.
6752 /// It should be used to set parameters which are not yet available through their own
6753 /// setters.
6754 ///
6755 /// Please note that this method must not be used to set any of the known parameters
6756 /// which have their own setter method. If done anyway, the request will fail.
6757 ///
6758 /// # Additional Parameters
6759 ///
6760 /// * *$.xgafv* (query-string) - V1 error format.
6761 /// * *access_token* (query-string) - OAuth access token.
6762 /// * *alt* (query-string) - Data format for response.
6763 /// * *callback* (query-string) - JSONP
6764 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6765 /// * *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.
6766 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6767 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6768 /// * *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.
6769 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6770 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6771 pub fn param<T>(
6772 mut self,
6773 name: T,
6774 value: T,
6775 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C>
6776 where
6777 T: AsRef<str>,
6778 {
6779 self._additional_params
6780 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6781 self
6782 }
6783
6784 /// Identifies the authorization scope for the method you are building.
6785 ///
6786 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6787 /// [`Scope::CloudPlatform`].
6788 ///
6789 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6790 /// tokens for more than one scope.
6791 ///
6792 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6793 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6794 /// sufficient, a read-write scope will do as well.
6795 pub fn add_scope<St>(
6796 mut self,
6797 scope: St,
6798 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C>
6799 where
6800 St: AsRef<str>,
6801 {
6802 self._scopes.insert(String::from(scope.as_ref()));
6803 self
6804 }
6805 /// Identifies the authorization scope(s) for the method you are building.
6806 ///
6807 /// See [`Self::add_scope()`] for details.
6808 pub fn add_scopes<I, St>(
6809 mut self,
6810 scopes: I,
6811 ) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C>
6812 where
6813 I: IntoIterator<Item = St>,
6814 St: AsRef<str>,
6815 {
6816 self._scopes
6817 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6818 self
6819 }
6820
6821 /// Removes all scopes, and no default scope will be used either.
6822 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6823 /// for details).
6824 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreUserEventListCall<'a, C> {
6825 self._scopes.clear();
6826 self
6827 }
6828}
6829
6830/// Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.
6831///
6832/// A builder for the *locations.catalogs.eventStores.userEvents.purge* method supported by a *project* resource.
6833/// It is not used directly, but through a [`ProjectMethods`] instance.
6834///
6835/// # Example
6836///
6837/// Instantiate a resource method builder
6838///
6839/// ```test_harness,no_run
6840/// # extern crate hyper;
6841/// # extern crate hyper_rustls;
6842/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
6843/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest;
6844/// # async fn dox() {
6845/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6846///
6847/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6848/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6849/// # .with_native_roots()
6850/// # .unwrap()
6851/// # .https_only()
6852/// # .enable_http2()
6853/// # .build();
6854///
6855/// # let executor = hyper_util::rt::TokioExecutor::new();
6856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6857/// # secret,
6858/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6859/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6860/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6861/// # ),
6862/// # ).build().await.unwrap();
6863///
6864/// # let client = hyper_util::client::legacy::Client::builder(
6865/// # hyper_util::rt::TokioExecutor::new()
6866/// # )
6867/// # .build(
6868/// # hyper_rustls::HttpsConnectorBuilder::new()
6869/// # .with_native_roots()
6870/// # .unwrap()
6871/// # .https_or_http()
6872/// # .enable_http2()
6873/// # .build()
6874/// # );
6875/// # let mut hub = RecommendationsAI::new(client, auth);
6876/// // As the method needs a request, you would usually fill it with the desired information
6877/// // into the respective structure. Some of the parts shown here might not be applicable !
6878/// // Values shown here are possibly random and not representative !
6879/// let mut req = GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest::default();
6880///
6881/// // You can configure optional parameters by calling the respective setters at will, and
6882/// // execute the final call using `doit()`.
6883/// // Values shown here are possibly random and not representative !
6884/// let result = hub.projects().locations_catalogs_event_stores_user_events_purge(req, "parent")
6885/// .doit().await;
6886/// # }
6887/// ```
6888pub struct ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C>
6889where
6890 C: 'a,
6891{
6892 hub: &'a RecommendationsAI<C>,
6893 _request: GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest,
6894 _parent: String,
6895 _delegate: Option<&'a mut dyn common::Delegate>,
6896 _additional_params: HashMap<String, String>,
6897 _scopes: BTreeSet<String>,
6898}
6899
6900impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C> {}
6901
6902impl<'a, C> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C>
6903where
6904 C: common::Connector,
6905{
6906 /// Perform the operation you have build so far.
6907 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6908 use std::borrow::Cow;
6909 use std::io::{Read, Seek};
6910
6911 use common::{url::Params, ToParts};
6912 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6913
6914 let mut dd = common::DefaultDelegate;
6915 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6916 dlg.begin(common::MethodInfo {
6917 id: "recommendationengine.projects.locations.catalogs.eventStores.userEvents.purge",
6918 http_method: hyper::Method::POST,
6919 });
6920
6921 for &field in ["alt", "parent"].iter() {
6922 if self._additional_params.contains_key(field) {
6923 dlg.finished(false);
6924 return Err(common::Error::FieldClash(field));
6925 }
6926 }
6927
6928 let mut params = Params::with_capacity(4 + self._additional_params.len());
6929 params.push("parent", self._parent);
6930
6931 params.extend(self._additional_params.iter());
6932
6933 params.push("alt", "json");
6934 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/userEvents:purge";
6935 if self._scopes.is_empty() {
6936 self._scopes
6937 .insert(Scope::CloudPlatform.as_ref().to_string());
6938 }
6939
6940 #[allow(clippy::single_element_loop)]
6941 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6942 url = params.uri_replacement(url, param_name, find_this, true);
6943 }
6944 {
6945 let to_remove = ["parent"];
6946 params.remove_params(&to_remove);
6947 }
6948
6949 let url = params.parse_with_url(&url);
6950
6951 let mut json_mime_type = mime::APPLICATION_JSON;
6952 let mut request_value_reader = {
6953 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6954 common::remove_json_null_values(&mut value);
6955 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6956 serde_json::to_writer(&mut dst, &value).unwrap();
6957 dst
6958 };
6959 let request_size = request_value_reader
6960 .seek(std::io::SeekFrom::End(0))
6961 .unwrap();
6962 request_value_reader
6963 .seek(std::io::SeekFrom::Start(0))
6964 .unwrap();
6965
6966 loop {
6967 let token = match self
6968 .hub
6969 .auth
6970 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6971 .await
6972 {
6973 Ok(token) => token,
6974 Err(e) => match dlg.token(e) {
6975 Ok(token) => token,
6976 Err(e) => {
6977 dlg.finished(false);
6978 return Err(common::Error::MissingToken(e));
6979 }
6980 },
6981 };
6982 request_value_reader
6983 .seek(std::io::SeekFrom::Start(0))
6984 .unwrap();
6985 let mut req_result = {
6986 let client = &self.hub.client;
6987 dlg.pre_request();
6988 let mut req_builder = hyper::Request::builder()
6989 .method(hyper::Method::POST)
6990 .uri(url.as_str())
6991 .header(USER_AGENT, self.hub._user_agent.clone());
6992
6993 if let Some(token) = token.as_ref() {
6994 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6995 }
6996
6997 let request = req_builder
6998 .header(CONTENT_TYPE, json_mime_type.to_string())
6999 .header(CONTENT_LENGTH, request_size as u64)
7000 .body(common::to_body(
7001 request_value_reader.get_ref().clone().into(),
7002 ));
7003
7004 client.request(request.unwrap()).await
7005 };
7006
7007 match req_result {
7008 Err(err) => {
7009 if let common::Retry::After(d) = dlg.http_error(&err) {
7010 sleep(d).await;
7011 continue;
7012 }
7013 dlg.finished(false);
7014 return Err(common::Error::HttpError(err));
7015 }
7016 Ok(res) => {
7017 let (mut parts, body) = res.into_parts();
7018 let mut body = common::Body::new(body);
7019 if !parts.status.is_success() {
7020 let bytes = common::to_bytes(body).await.unwrap_or_default();
7021 let error = serde_json::from_str(&common::to_string(&bytes));
7022 let response = common::to_response(parts, bytes.into());
7023
7024 if let common::Retry::After(d) =
7025 dlg.http_failure(&response, error.as_ref().ok())
7026 {
7027 sleep(d).await;
7028 continue;
7029 }
7030
7031 dlg.finished(false);
7032
7033 return Err(match error {
7034 Ok(value) => common::Error::BadRequest(value),
7035 _ => common::Error::Failure(response),
7036 });
7037 }
7038 let response = {
7039 let bytes = common::to_bytes(body).await.unwrap_or_default();
7040 let encoded = common::to_string(&bytes);
7041 match serde_json::from_str(&encoded) {
7042 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7043 Err(error) => {
7044 dlg.response_json_decode_error(&encoded, &error);
7045 return Err(common::Error::JsonDecodeError(
7046 encoded.to_string(),
7047 error,
7048 ));
7049 }
7050 }
7051 };
7052
7053 dlg.finished(true);
7054 return Ok(response);
7055 }
7056 }
7057 }
7058 }
7059
7060 ///
7061 /// Sets the *request* property to the given value.
7062 ///
7063 /// Even though the property as already been set when instantiating this call,
7064 /// we provide this method for API completeness.
7065 pub fn request(
7066 mut self,
7067 new_value: GoogleCloudRecommendationengineV1beta1PurgeUserEventsRequest,
7068 ) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C> {
7069 self._request = new_value;
7070 self
7071 }
7072 /// Required. The resource name of the event_store under which the events are created. The format is `projects/${projectId}/locations/global/catalogs/${catalogId}/eventStores/${eventStoreId}`
7073 ///
7074 /// Sets the *parent* path property to the given value.
7075 ///
7076 /// Even though the property as already been set when instantiating this call,
7077 /// we provide this method for API completeness.
7078 pub fn parent(
7079 mut self,
7080 new_value: &str,
7081 ) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C> {
7082 self._parent = new_value.to_string();
7083 self
7084 }
7085 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7086 /// while executing the actual API request.
7087 ///
7088 /// ````text
7089 /// It should be used to handle progress information, and to implement a certain level of resilience.
7090 /// ````
7091 ///
7092 /// Sets the *delegate* property to the given value.
7093 pub fn delegate(
7094 mut self,
7095 new_value: &'a mut dyn common::Delegate,
7096 ) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C> {
7097 self._delegate = Some(new_value);
7098 self
7099 }
7100
7101 /// Set any additional parameter of the query string used in the request.
7102 /// It should be used to set parameters which are not yet available through their own
7103 /// setters.
7104 ///
7105 /// Please note that this method must not be used to set any of the known parameters
7106 /// which have their own setter method. If done anyway, the request will fail.
7107 ///
7108 /// # Additional Parameters
7109 ///
7110 /// * *$.xgafv* (query-string) - V1 error format.
7111 /// * *access_token* (query-string) - OAuth access token.
7112 /// * *alt* (query-string) - Data format for response.
7113 /// * *callback* (query-string) - JSONP
7114 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7115 /// * *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.
7116 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7117 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7118 /// * *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.
7119 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7120 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7121 pub fn param<T>(
7122 mut self,
7123 name: T,
7124 value: T,
7125 ) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C>
7126 where
7127 T: AsRef<str>,
7128 {
7129 self._additional_params
7130 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7131 self
7132 }
7133
7134 /// Identifies the authorization scope for the method you are building.
7135 ///
7136 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7137 /// [`Scope::CloudPlatform`].
7138 ///
7139 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7140 /// tokens for more than one scope.
7141 ///
7142 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7143 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7144 /// sufficient, a read-write scope will do as well.
7145 pub fn add_scope<St>(
7146 mut self,
7147 scope: St,
7148 ) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C>
7149 where
7150 St: AsRef<str>,
7151 {
7152 self._scopes.insert(String::from(scope.as_ref()));
7153 self
7154 }
7155 /// Identifies the authorization scope(s) for the method you are building.
7156 ///
7157 /// See [`Self::add_scope()`] for details.
7158 pub fn add_scopes<I, St>(
7159 mut self,
7160 scopes: I,
7161 ) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C>
7162 where
7163 I: IntoIterator<Item = St>,
7164 St: AsRef<str>,
7165 {
7166 self._scopes
7167 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7168 self
7169 }
7170
7171 /// Removes all scopes, and no default scope will be used either.
7172 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7173 /// for details).
7174 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreUserEventPurgeCall<'a, C> {
7175 self._scopes.clear();
7176 self
7177 }
7178}
7179
7180/// Triggers a user event rejoin operation with latest catalog data. Events will not be annotated with detailed catalog information if catalog item is missing at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This API can be used to trigger a 'join' operation on specified events with latest version of catalog items. It can also be used to correct events joined with wrong catalog items.
7181///
7182/// A builder for the *locations.catalogs.eventStores.userEvents.rejoin* method supported by a *project* resource.
7183/// It is not used directly, but through a [`ProjectMethods`] instance.
7184///
7185/// # Example
7186///
7187/// Instantiate a resource method builder
7188///
7189/// ```test_harness,no_run
7190/// # extern crate hyper;
7191/// # extern crate hyper_rustls;
7192/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
7193/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest;
7194/// # async fn dox() {
7195/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7196///
7197/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7198/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7199/// # .with_native_roots()
7200/// # .unwrap()
7201/// # .https_only()
7202/// # .enable_http2()
7203/// # .build();
7204///
7205/// # let executor = hyper_util::rt::TokioExecutor::new();
7206/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7207/// # secret,
7208/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7209/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7210/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7211/// # ),
7212/// # ).build().await.unwrap();
7213///
7214/// # let client = hyper_util::client::legacy::Client::builder(
7215/// # hyper_util::rt::TokioExecutor::new()
7216/// # )
7217/// # .build(
7218/// # hyper_rustls::HttpsConnectorBuilder::new()
7219/// # .with_native_roots()
7220/// # .unwrap()
7221/// # .https_or_http()
7222/// # .enable_http2()
7223/// # .build()
7224/// # );
7225/// # let mut hub = RecommendationsAI::new(client, auth);
7226/// // As the method needs a request, you would usually fill it with the desired information
7227/// // into the respective structure. Some of the parts shown here might not be applicable !
7228/// // Values shown here are possibly random and not representative !
7229/// let mut req = GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest::default();
7230///
7231/// // You can configure optional parameters by calling the respective setters at will, and
7232/// // execute the final call using `doit()`.
7233/// // Values shown here are possibly random and not representative !
7234/// let result = hub.projects().locations_catalogs_event_stores_user_events_rejoin(req, "parent")
7235/// .doit().await;
7236/// # }
7237/// ```
7238pub struct ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C>
7239where
7240 C: 'a,
7241{
7242 hub: &'a RecommendationsAI<C>,
7243 _request: GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest,
7244 _parent: String,
7245 _delegate: Option<&'a mut dyn common::Delegate>,
7246 _additional_params: HashMap<String, String>,
7247 _scopes: BTreeSet<String>,
7248}
7249
7250impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C> {}
7251
7252impl<'a, C> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C>
7253where
7254 C: common::Connector,
7255{
7256 /// Perform the operation you have build so far.
7257 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7258 use std::borrow::Cow;
7259 use std::io::{Read, Seek};
7260
7261 use common::{url::Params, ToParts};
7262 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7263
7264 let mut dd = common::DefaultDelegate;
7265 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7266 dlg.begin(common::MethodInfo {
7267 id: "recommendationengine.projects.locations.catalogs.eventStores.userEvents.rejoin",
7268 http_method: hyper::Method::POST,
7269 });
7270
7271 for &field in ["alt", "parent"].iter() {
7272 if self._additional_params.contains_key(field) {
7273 dlg.finished(false);
7274 return Err(common::Error::FieldClash(field));
7275 }
7276 }
7277
7278 let mut params = Params::with_capacity(4 + self._additional_params.len());
7279 params.push("parent", self._parent);
7280
7281 params.extend(self._additional_params.iter());
7282
7283 params.push("alt", "json");
7284 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/userEvents:rejoin";
7285 if self._scopes.is_empty() {
7286 self._scopes
7287 .insert(Scope::CloudPlatform.as_ref().to_string());
7288 }
7289
7290 #[allow(clippy::single_element_loop)]
7291 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7292 url = params.uri_replacement(url, param_name, find_this, true);
7293 }
7294 {
7295 let to_remove = ["parent"];
7296 params.remove_params(&to_remove);
7297 }
7298
7299 let url = params.parse_with_url(&url);
7300
7301 let mut json_mime_type = mime::APPLICATION_JSON;
7302 let mut request_value_reader = {
7303 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7304 common::remove_json_null_values(&mut value);
7305 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7306 serde_json::to_writer(&mut dst, &value).unwrap();
7307 dst
7308 };
7309 let request_size = request_value_reader
7310 .seek(std::io::SeekFrom::End(0))
7311 .unwrap();
7312 request_value_reader
7313 .seek(std::io::SeekFrom::Start(0))
7314 .unwrap();
7315
7316 loop {
7317 let token = match self
7318 .hub
7319 .auth
7320 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7321 .await
7322 {
7323 Ok(token) => token,
7324 Err(e) => match dlg.token(e) {
7325 Ok(token) => token,
7326 Err(e) => {
7327 dlg.finished(false);
7328 return Err(common::Error::MissingToken(e));
7329 }
7330 },
7331 };
7332 request_value_reader
7333 .seek(std::io::SeekFrom::Start(0))
7334 .unwrap();
7335 let mut req_result = {
7336 let client = &self.hub.client;
7337 dlg.pre_request();
7338 let mut req_builder = hyper::Request::builder()
7339 .method(hyper::Method::POST)
7340 .uri(url.as_str())
7341 .header(USER_AGENT, self.hub._user_agent.clone());
7342
7343 if let Some(token) = token.as_ref() {
7344 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7345 }
7346
7347 let request = req_builder
7348 .header(CONTENT_TYPE, json_mime_type.to_string())
7349 .header(CONTENT_LENGTH, request_size as u64)
7350 .body(common::to_body(
7351 request_value_reader.get_ref().clone().into(),
7352 ));
7353
7354 client.request(request.unwrap()).await
7355 };
7356
7357 match req_result {
7358 Err(err) => {
7359 if let common::Retry::After(d) = dlg.http_error(&err) {
7360 sleep(d).await;
7361 continue;
7362 }
7363 dlg.finished(false);
7364 return Err(common::Error::HttpError(err));
7365 }
7366 Ok(res) => {
7367 let (mut parts, body) = res.into_parts();
7368 let mut body = common::Body::new(body);
7369 if !parts.status.is_success() {
7370 let bytes = common::to_bytes(body).await.unwrap_or_default();
7371 let error = serde_json::from_str(&common::to_string(&bytes));
7372 let response = common::to_response(parts, bytes.into());
7373
7374 if let common::Retry::After(d) =
7375 dlg.http_failure(&response, error.as_ref().ok())
7376 {
7377 sleep(d).await;
7378 continue;
7379 }
7380
7381 dlg.finished(false);
7382
7383 return Err(match error {
7384 Ok(value) => common::Error::BadRequest(value),
7385 _ => common::Error::Failure(response),
7386 });
7387 }
7388 let response = {
7389 let bytes = common::to_bytes(body).await.unwrap_or_default();
7390 let encoded = common::to_string(&bytes);
7391 match serde_json::from_str(&encoded) {
7392 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7393 Err(error) => {
7394 dlg.response_json_decode_error(&encoded, &error);
7395 return Err(common::Error::JsonDecodeError(
7396 encoded.to_string(),
7397 error,
7398 ));
7399 }
7400 }
7401 };
7402
7403 dlg.finished(true);
7404 return Ok(response);
7405 }
7406 }
7407 }
7408 }
7409
7410 ///
7411 /// Sets the *request* property to the given value.
7412 ///
7413 /// Even though the property as already been set when instantiating this call,
7414 /// we provide this method for API completeness.
7415 pub fn request(
7416 mut self,
7417 new_value: GoogleCloudRecommendationengineV1beta1RejoinUserEventsRequest,
7418 ) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C> {
7419 self._request = new_value;
7420 self
7421 }
7422 /// Required. Full resource name of user event, such as `projects/*/locations/*/catalogs/default_catalog/eventStores/default_event_store`.
7423 ///
7424 /// Sets the *parent* path property to the given value.
7425 ///
7426 /// Even though the property as already been set when instantiating this call,
7427 /// we provide this method for API completeness.
7428 pub fn parent(
7429 mut self,
7430 new_value: &str,
7431 ) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C> {
7432 self._parent = new_value.to_string();
7433 self
7434 }
7435 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7436 /// while executing the actual API request.
7437 ///
7438 /// ````text
7439 /// It should be used to handle progress information, and to implement a certain level of resilience.
7440 /// ````
7441 ///
7442 /// Sets the *delegate* property to the given value.
7443 pub fn delegate(
7444 mut self,
7445 new_value: &'a mut dyn common::Delegate,
7446 ) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C> {
7447 self._delegate = Some(new_value);
7448 self
7449 }
7450
7451 /// Set any additional parameter of the query string used in the request.
7452 /// It should be used to set parameters which are not yet available through their own
7453 /// setters.
7454 ///
7455 /// Please note that this method must not be used to set any of the known parameters
7456 /// which have their own setter method. If done anyway, the request will fail.
7457 ///
7458 /// # Additional Parameters
7459 ///
7460 /// * *$.xgafv* (query-string) - V1 error format.
7461 /// * *access_token* (query-string) - OAuth access token.
7462 /// * *alt* (query-string) - Data format for response.
7463 /// * *callback* (query-string) - JSONP
7464 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7465 /// * *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.
7466 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7467 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7468 /// * *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.
7469 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7470 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7471 pub fn param<T>(
7472 mut self,
7473 name: T,
7474 value: T,
7475 ) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C>
7476 where
7477 T: AsRef<str>,
7478 {
7479 self._additional_params
7480 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7481 self
7482 }
7483
7484 /// Identifies the authorization scope for the method you are building.
7485 ///
7486 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7487 /// [`Scope::CloudPlatform`].
7488 ///
7489 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7490 /// tokens for more than one scope.
7491 ///
7492 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7493 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7494 /// sufficient, a read-write scope will do as well.
7495 pub fn add_scope<St>(
7496 mut self,
7497 scope: St,
7498 ) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C>
7499 where
7500 St: AsRef<str>,
7501 {
7502 self._scopes.insert(String::from(scope.as_ref()));
7503 self
7504 }
7505 /// Identifies the authorization scope(s) for the method you are building.
7506 ///
7507 /// See [`Self::add_scope()`] for details.
7508 pub fn add_scopes<I, St>(
7509 mut self,
7510 scopes: I,
7511 ) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C>
7512 where
7513 I: IntoIterator<Item = St>,
7514 St: AsRef<str>,
7515 {
7516 self._scopes
7517 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7518 self
7519 }
7520
7521 /// Removes all scopes, and no default scope will be used either.
7522 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7523 /// for details).
7524 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreUserEventRejoinCall<'a, C> {
7525 self._scopes.clear();
7526 self
7527 }
7528}
7529
7530/// Writes a single user event.
7531///
7532/// A builder for the *locations.catalogs.eventStores.userEvents.write* method supported by a *project* resource.
7533/// It is not used directly, but through a [`ProjectMethods`] instance.
7534///
7535/// # Example
7536///
7537/// Instantiate a resource method builder
7538///
7539/// ```test_harness,no_run
7540/// # extern crate hyper;
7541/// # extern crate hyper_rustls;
7542/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
7543/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1UserEvent;
7544/// # async fn dox() {
7545/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7546///
7547/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7548/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7549/// # .with_native_roots()
7550/// # .unwrap()
7551/// # .https_only()
7552/// # .enable_http2()
7553/// # .build();
7554///
7555/// # let executor = hyper_util::rt::TokioExecutor::new();
7556/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7557/// # secret,
7558/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7559/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7560/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7561/// # ),
7562/// # ).build().await.unwrap();
7563///
7564/// # let client = hyper_util::client::legacy::Client::builder(
7565/// # hyper_util::rt::TokioExecutor::new()
7566/// # )
7567/// # .build(
7568/// # hyper_rustls::HttpsConnectorBuilder::new()
7569/// # .with_native_roots()
7570/// # .unwrap()
7571/// # .https_or_http()
7572/// # .enable_http2()
7573/// # .build()
7574/// # );
7575/// # let mut hub = RecommendationsAI::new(client, auth);
7576/// // As the method needs a request, you would usually fill it with the desired information
7577/// // into the respective structure. Some of the parts shown here might not be applicable !
7578/// // Values shown here are possibly random and not representative !
7579/// let mut req = GoogleCloudRecommendationengineV1beta1UserEvent::default();
7580///
7581/// // You can configure optional parameters by calling the respective setters at will, and
7582/// // execute the final call using `doit()`.
7583/// // Values shown here are possibly random and not representative !
7584/// let result = hub.projects().locations_catalogs_event_stores_user_events_write(req, "parent")
7585/// .doit().await;
7586/// # }
7587/// ```
7588pub struct ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C>
7589where
7590 C: 'a,
7591{
7592 hub: &'a RecommendationsAI<C>,
7593 _request: GoogleCloudRecommendationengineV1beta1UserEvent,
7594 _parent: String,
7595 _delegate: Option<&'a mut dyn common::Delegate>,
7596 _additional_params: HashMap<String, String>,
7597 _scopes: BTreeSet<String>,
7598}
7599
7600impl<'a, C> common::CallBuilder for ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C> {}
7601
7602impl<'a, C> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C>
7603where
7604 C: common::Connector,
7605{
7606 /// Perform the operation you have build so far.
7607 pub async fn doit(
7608 mut self,
7609 ) -> common::Result<(
7610 common::Response,
7611 GoogleCloudRecommendationengineV1beta1UserEvent,
7612 )> {
7613 use std::borrow::Cow;
7614 use std::io::{Read, Seek};
7615
7616 use common::{url::Params, ToParts};
7617 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7618
7619 let mut dd = common::DefaultDelegate;
7620 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7621 dlg.begin(common::MethodInfo {
7622 id: "recommendationengine.projects.locations.catalogs.eventStores.userEvents.write",
7623 http_method: hyper::Method::POST,
7624 });
7625
7626 for &field in ["alt", "parent"].iter() {
7627 if self._additional_params.contains_key(field) {
7628 dlg.finished(false);
7629 return Err(common::Error::FieldClash(field));
7630 }
7631 }
7632
7633 let mut params = Params::with_capacity(4 + self._additional_params.len());
7634 params.push("parent", self._parent);
7635
7636 params.extend(self._additional_params.iter());
7637
7638 params.push("alt", "json");
7639 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/userEvents:write";
7640 if self._scopes.is_empty() {
7641 self._scopes
7642 .insert(Scope::CloudPlatform.as_ref().to_string());
7643 }
7644
7645 #[allow(clippy::single_element_loop)]
7646 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7647 url = params.uri_replacement(url, param_name, find_this, true);
7648 }
7649 {
7650 let to_remove = ["parent"];
7651 params.remove_params(&to_remove);
7652 }
7653
7654 let url = params.parse_with_url(&url);
7655
7656 let mut json_mime_type = mime::APPLICATION_JSON;
7657 let mut request_value_reader = {
7658 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7659 common::remove_json_null_values(&mut value);
7660 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7661 serde_json::to_writer(&mut dst, &value).unwrap();
7662 dst
7663 };
7664 let request_size = request_value_reader
7665 .seek(std::io::SeekFrom::End(0))
7666 .unwrap();
7667 request_value_reader
7668 .seek(std::io::SeekFrom::Start(0))
7669 .unwrap();
7670
7671 loop {
7672 let token = match self
7673 .hub
7674 .auth
7675 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7676 .await
7677 {
7678 Ok(token) => token,
7679 Err(e) => match dlg.token(e) {
7680 Ok(token) => token,
7681 Err(e) => {
7682 dlg.finished(false);
7683 return Err(common::Error::MissingToken(e));
7684 }
7685 },
7686 };
7687 request_value_reader
7688 .seek(std::io::SeekFrom::Start(0))
7689 .unwrap();
7690 let mut req_result = {
7691 let client = &self.hub.client;
7692 dlg.pre_request();
7693 let mut req_builder = hyper::Request::builder()
7694 .method(hyper::Method::POST)
7695 .uri(url.as_str())
7696 .header(USER_AGENT, self.hub._user_agent.clone());
7697
7698 if let Some(token) = token.as_ref() {
7699 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7700 }
7701
7702 let request = req_builder
7703 .header(CONTENT_TYPE, json_mime_type.to_string())
7704 .header(CONTENT_LENGTH, request_size as u64)
7705 .body(common::to_body(
7706 request_value_reader.get_ref().clone().into(),
7707 ));
7708
7709 client.request(request.unwrap()).await
7710 };
7711
7712 match req_result {
7713 Err(err) => {
7714 if let common::Retry::After(d) = dlg.http_error(&err) {
7715 sleep(d).await;
7716 continue;
7717 }
7718 dlg.finished(false);
7719 return Err(common::Error::HttpError(err));
7720 }
7721 Ok(res) => {
7722 let (mut parts, body) = res.into_parts();
7723 let mut body = common::Body::new(body);
7724 if !parts.status.is_success() {
7725 let bytes = common::to_bytes(body).await.unwrap_or_default();
7726 let error = serde_json::from_str(&common::to_string(&bytes));
7727 let response = common::to_response(parts, bytes.into());
7728
7729 if let common::Retry::After(d) =
7730 dlg.http_failure(&response, error.as_ref().ok())
7731 {
7732 sleep(d).await;
7733 continue;
7734 }
7735
7736 dlg.finished(false);
7737
7738 return Err(match error {
7739 Ok(value) => common::Error::BadRequest(value),
7740 _ => common::Error::Failure(response),
7741 });
7742 }
7743 let response = {
7744 let bytes = common::to_bytes(body).await.unwrap_or_default();
7745 let encoded = common::to_string(&bytes);
7746 match serde_json::from_str(&encoded) {
7747 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7748 Err(error) => {
7749 dlg.response_json_decode_error(&encoded, &error);
7750 return Err(common::Error::JsonDecodeError(
7751 encoded.to_string(),
7752 error,
7753 ));
7754 }
7755 }
7756 };
7757
7758 dlg.finished(true);
7759 return Ok(response);
7760 }
7761 }
7762 }
7763 }
7764
7765 ///
7766 /// Sets the *request* property to the given value.
7767 ///
7768 /// Even though the property as already been set when instantiating this call,
7769 /// we provide this method for API completeness.
7770 pub fn request(
7771 mut self,
7772 new_value: GoogleCloudRecommendationengineV1beta1UserEvent,
7773 ) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C> {
7774 self._request = new_value;
7775 self
7776 }
7777 /// Required. The parent eventStore resource name, such as "projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store".
7778 ///
7779 /// Sets the *parent* path property to the given value.
7780 ///
7781 /// Even though the property as already been set when instantiating this call,
7782 /// we provide this method for API completeness.
7783 pub fn parent(
7784 mut self,
7785 new_value: &str,
7786 ) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C> {
7787 self._parent = new_value.to_string();
7788 self
7789 }
7790 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7791 /// while executing the actual API request.
7792 ///
7793 /// ````text
7794 /// It should be used to handle progress information, and to implement a certain level of resilience.
7795 /// ````
7796 ///
7797 /// Sets the *delegate* property to the given value.
7798 pub fn delegate(
7799 mut self,
7800 new_value: &'a mut dyn common::Delegate,
7801 ) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C> {
7802 self._delegate = Some(new_value);
7803 self
7804 }
7805
7806 /// Set any additional parameter of the query string used in the request.
7807 /// It should be used to set parameters which are not yet available through their own
7808 /// setters.
7809 ///
7810 /// Please note that this method must not be used to set any of the known parameters
7811 /// which have their own setter method. If done anyway, the request will fail.
7812 ///
7813 /// # Additional Parameters
7814 ///
7815 /// * *$.xgafv* (query-string) - V1 error format.
7816 /// * *access_token* (query-string) - OAuth access token.
7817 /// * *alt* (query-string) - Data format for response.
7818 /// * *callback* (query-string) - JSONP
7819 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7820 /// * *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.
7821 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7822 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7823 /// * *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.
7824 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7825 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7826 pub fn param<T>(
7827 mut self,
7828 name: T,
7829 value: T,
7830 ) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C>
7831 where
7832 T: AsRef<str>,
7833 {
7834 self._additional_params
7835 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7836 self
7837 }
7838
7839 /// Identifies the authorization scope for the method you are building.
7840 ///
7841 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7842 /// [`Scope::CloudPlatform`].
7843 ///
7844 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7845 /// tokens for more than one scope.
7846 ///
7847 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7848 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7849 /// sufficient, a read-write scope will do as well.
7850 pub fn add_scope<St>(
7851 mut self,
7852 scope: St,
7853 ) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C>
7854 where
7855 St: AsRef<str>,
7856 {
7857 self._scopes.insert(String::from(scope.as_ref()));
7858 self
7859 }
7860 /// Identifies the authorization scope(s) for the method you are building.
7861 ///
7862 /// See [`Self::add_scope()`] for details.
7863 pub fn add_scopes<I, St>(
7864 mut self,
7865 scopes: I,
7866 ) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C>
7867 where
7868 I: IntoIterator<Item = St>,
7869 St: AsRef<str>,
7870 {
7871 self._scopes
7872 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7873 self
7874 }
7875
7876 /// Removes all scopes, and no default scope will be used either.
7877 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7878 /// for details).
7879 pub fn clear_scopes(mut self) -> ProjectLocationCatalogEventStoreUserEventWriteCall<'a, C> {
7880 self._scopes.clear();
7881 self
7882 }
7883}
7884
7885/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
7886///
7887/// A builder for the *locations.catalogs.operations.get* method supported by a *project* resource.
7888/// It is not used directly, but through a [`ProjectMethods`] instance.
7889///
7890/// # Example
7891///
7892/// Instantiate a resource method builder
7893///
7894/// ```test_harness,no_run
7895/// # extern crate hyper;
7896/// # extern crate hyper_rustls;
7897/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
7898/// # async fn dox() {
7899/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7900///
7901/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7902/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7903/// # .with_native_roots()
7904/// # .unwrap()
7905/// # .https_only()
7906/// # .enable_http2()
7907/// # .build();
7908///
7909/// # let executor = hyper_util::rt::TokioExecutor::new();
7910/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7911/// # secret,
7912/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7913/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7914/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7915/// # ),
7916/// # ).build().await.unwrap();
7917///
7918/// # let client = hyper_util::client::legacy::Client::builder(
7919/// # hyper_util::rt::TokioExecutor::new()
7920/// # )
7921/// # .build(
7922/// # hyper_rustls::HttpsConnectorBuilder::new()
7923/// # .with_native_roots()
7924/// # .unwrap()
7925/// # .https_or_http()
7926/// # .enable_http2()
7927/// # .build()
7928/// # );
7929/// # let mut hub = RecommendationsAI::new(client, auth);
7930/// // You can configure optional parameters by calling the respective setters at will, and
7931/// // execute the final call using `doit()`.
7932/// // Values shown here are possibly random and not representative !
7933/// let result = hub.projects().locations_catalogs_operations_get("name")
7934/// .doit().await;
7935/// # }
7936/// ```
7937pub struct ProjectLocationCatalogOperationGetCall<'a, C>
7938where
7939 C: 'a,
7940{
7941 hub: &'a RecommendationsAI<C>,
7942 _name: String,
7943 _delegate: Option<&'a mut dyn common::Delegate>,
7944 _additional_params: HashMap<String, String>,
7945 _scopes: BTreeSet<String>,
7946}
7947
7948impl<'a, C> common::CallBuilder for ProjectLocationCatalogOperationGetCall<'a, C> {}
7949
7950impl<'a, C> ProjectLocationCatalogOperationGetCall<'a, C>
7951where
7952 C: common::Connector,
7953{
7954 /// Perform the operation you have build so far.
7955 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7956 use std::borrow::Cow;
7957 use std::io::{Read, Seek};
7958
7959 use common::{url::Params, ToParts};
7960 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7961
7962 let mut dd = common::DefaultDelegate;
7963 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7964 dlg.begin(common::MethodInfo {
7965 id: "recommendationengine.projects.locations.catalogs.operations.get",
7966 http_method: hyper::Method::GET,
7967 });
7968
7969 for &field in ["alt", "name"].iter() {
7970 if self._additional_params.contains_key(field) {
7971 dlg.finished(false);
7972 return Err(common::Error::FieldClash(field));
7973 }
7974 }
7975
7976 let mut params = Params::with_capacity(3 + self._additional_params.len());
7977 params.push("name", self._name);
7978
7979 params.extend(self._additional_params.iter());
7980
7981 params.push("alt", "json");
7982 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7983 if self._scopes.is_empty() {
7984 self._scopes
7985 .insert(Scope::CloudPlatform.as_ref().to_string());
7986 }
7987
7988 #[allow(clippy::single_element_loop)]
7989 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7990 url = params.uri_replacement(url, param_name, find_this, true);
7991 }
7992 {
7993 let to_remove = ["name"];
7994 params.remove_params(&to_remove);
7995 }
7996
7997 let url = params.parse_with_url(&url);
7998
7999 loop {
8000 let token = match self
8001 .hub
8002 .auth
8003 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8004 .await
8005 {
8006 Ok(token) => token,
8007 Err(e) => match dlg.token(e) {
8008 Ok(token) => token,
8009 Err(e) => {
8010 dlg.finished(false);
8011 return Err(common::Error::MissingToken(e));
8012 }
8013 },
8014 };
8015 let mut req_result = {
8016 let client = &self.hub.client;
8017 dlg.pre_request();
8018 let mut req_builder = hyper::Request::builder()
8019 .method(hyper::Method::GET)
8020 .uri(url.as_str())
8021 .header(USER_AGENT, self.hub._user_agent.clone());
8022
8023 if let Some(token) = token.as_ref() {
8024 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8025 }
8026
8027 let request = req_builder
8028 .header(CONTENT_LENGTH, 0_u64)
8029 .body(common::to_body::<String>(None));
8030
8031 client.request(request.unwrap()).await
8032 };
8033
8034 match req_result {
8035 Err(err) => {
8036 if let common::Retry::After(d) = dlg.http_error(&err) {
8037 sleep(d).await;
8038 continue;
8039 }
8040 dlg.finished(false);
8041 return Err(common::Error::HttpError(err));
8042 }
8043 Ok(res) => {
8044 let (mut parts, body) = res.into_parts();
8045 let mut body = common::Body::new(body);
8046 if !parts.status.is_success() {
8047 let bytes = common::to_bytes(body).await.unwrap_or_default();
8048 let error = serde_json::from_str(&common::to_string(&bytes));
8049 let response = common::to_response(parts, bytes.into());
8050
8051 if let common::Retry::After(d) =
8052 dlg.http_failure(&response, error.as_ref().ok())
8053 {
8054 sleep(d).await;
8055 continue;
8056 }
8057
8058 dlg.finished(false);
8059
8060 return Err(match error {
8061 Ok(value) => common::Error::BadRequest(value),
8062 _ => common::Error::Failure(response),
8063 });
8064 }
8065 let response = {
8066 let bytes = common::to_bytes(body).await.unwrap_or_default();
8067 let encoded = common::to_string(&bytes);
8068 match serde_json::from_str(&encoded) {
8069 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8070 Err(error) => {
8071 dlg.response_json_decode_error(&encoded, &error);
8072 return Err(common::Error::JsonDecodeError(
8073 encoded.to_string(),
8074 error,
8075 ));
8076 }
8077 }
8078 };
8079
8080 dlg.finished(true);
8081 return Ok(response);
8082 }
8083 }
8084 }
8085 }
8086
8087 /// The name of the operation resource.
8088 ///
8089 /// Sets the *name* path property to the given value.
8090 ///
8091 /// Even though the property as already been set when instantiating this call,
8092 /// we provide this method for API completeness.
8093 pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogOperationGetCall<'a, C> {
8094 self._name = new_value.to_string();
8095 self
8096 }
8097 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8098 /// while executing the actual API request.
8099 ///
8100 /// ````text
8101 /// It should be used to handle progress information, and to implement a certain level of resilience.
8102 /// ````
8103 ///
8104 /// Sets the *delegate* property to the given value.
8105 pub fn delegate(
8106 mut self,
8107 new_value: &'a mut dyn common::Delegate,
8108 ) -> ProjectLocationCatalogOperationGetCall<'a, C> {
8109 self._delegate = Some(new_value);
8110 self
8111 }
8112
8113 /// Set any additional parameter of the query string used in the request.
8114 /// It should be used to set parameters which are not yet available through their own
8115 /// setters.
8116 ///
8117 /// Please note that this method must not be used to set any of the known parameters
8118 /// which have their own setter method. If done anyway, the request will fail.
8119 ///
8120 /// # Additional Parameters
8121 ///
8122 /// * *$.xgafv* (query-string) - V1 error format.
8123 /// * *access_token* (query-string) - OAuth access token.
8124 /// * *alt* (query-string) - Data format for response.
8125 /// * *callback* (query-string) - JSONP
8126 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8127 /// * *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.
8128 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8129 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8130 /// * *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.
8131 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8132 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8133 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogOperationGetCall<'a, C>
8134 where
8135 T: AsRef<str>,
8136 {
8137 self._additional_params
8138 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8139 self
8140 }
8141
8142 /// Identifies the authorization scope for the method you are building.
8143 ///
8144 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8145 /// [`Scope::CloudPlatform`].
8146 ///
8147 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8148 /// tokens for more than one scope.
8149 ///
8150 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8151 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8152 /// sufficient, a read-write scope will do as well.
8153 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogOperationGetCall<'a, C>
8154 where
8155 St: AsRef<str>,
8156 {
8157 self._scopes.insert(String::from(scope.as_ref()));
8158 self
8159 }
8160 /// Identifies the authorization scope(s) for the method you are building.
8161 ///
8162 /// See [`Self::add_scope()`] for details.
8163 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogOperationGetCall<'a, C>
8164 where
8165 I: IntoIterator<Item = St>,
8166 St: AsRef<str>,
8167 {
8168 self._scopes
8169 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8170 self
8171 }
8172
8173 /// Removes all scopes, and no default scope will be used either.
8174 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8175 /// for details).
8176 pub fn clear_scopes(mut self) -> ProjectLocationCatalogOperationGetCall<'a, C> {
8177 self._scopes.clear();
8178 self
8179 }
8180}
8181
8182/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
8183///
8184/// A builder for the *locations.catalogs.operations.list* method supported by a *project* resource.
8185/// It is not used directly, but through a [`ProjectMethods`] instance.
8186///
8187/// # Example
8188///
8189/// Instantiate a resource method builder
8190///
8191/// ```test_harness,no_run
8192/// # extern crate hyper;
8193/// # extern crate hyper_rustls;
8194/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
8195/// # async fn dox() {
8196/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8197///
8198/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8199/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8200/// # .with_native_roots()
8201/// # .unwrap()
8202/// # .https_only()
8203/// # .enable_http2()
8204/// # .build();
8205///
8206/// # let executor = hyper_util::rt::TokioExecutor::new();
8207/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8208/// # secret,
8209/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8210/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8211/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8212/// # ),
8213/// # ).build().await.unwrap();
8214///
8215/// # let client = hyper_util::client::legacy::Client::builder(
8216/// # hyper_util::rt::TokioExecutor::new()
8217/// # )
8218/// # .build(
8219/// # hyper_rustls::HttpsConnectorBuilder::new()
8220/// # .with_native_roots()
8221/// # .unwrap()
8222/// # .https_or_http()
8223/// # .enable_http2()
8224/// # .build()
8225/// # );
8226/// # let mut hub = RecommendationsAI::new(client, auth);
8227/// // You can configure optional parameters by calling the respective setters at will, and
8228/// // execute the final call using `doit()`.
8229/// // Values shown here are possibly random and not representative !
8230/// let result = hub.projects().locations_catalogs_operations_list("name")
8231/// .return_partial_success(true)
8232/// .page_token("duo")
8233/// .page_size(-80)
8234/// .filter("no")
8235/// .doit().await;
8236/// # }
8237/// ```
8238pub struct ProjectLocationCatalogOperationListCall<'a, C>
8239where
8240 C: 'a,
8241{
8242 hub: &'a RecommendationsAI<C>,
8243 _name: String,
8244 _return_partial_success: Option<bool>,
8245 _page_token: Option<String>,
8246 _page_size: Option<i32>,
8247 _filter: Option<String>,
8248 _delegate: Option<&'a mut dyn common::Delegate>,
8249 _additional_params: HashMap<String, String>,
8250 _scopes: BTreeSet<String>,
8251}
8252
8253impl<'a, C> common::CallBuilder for ProjectLocationCatalogOperationListCall<'a, C> {}
8254
8255impl<'a, C> ProjectLocationCatalogOperationListCall<'a, C>
8256where
8257 C: common::Connector,
8258{
8259 /// Perform the operation you have build so far.
8260 pub async fn doit(
8261 mut self,
8262 ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
8263 use std::borrow::Cow;
8264 use std::io::{Read, Seek};
8265
8266 use common::{url::Params, ToParts};
8267 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8268
8269 let mut dd = common::DefaultDelegate;
8270 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8271 dlg.begin(common::MethodInfo {
8272 id: "recommendationengine.projects.locations.catalogs.operations.list",
8273 http_method: hyper::Method::GET,
8274 });
8275
8276 for &field in [
8277 "alt",
8278 "name",
8279 "returnPartialSuccess",
8280 "pageToken",
8281 "pageSize",
8282 "filter",
8283 ]
8284 .iter()
8285 {
8286 if self._additional_params.contains_key(field) {
8287 dlg.finished(false);
8288 return Err(common::Error::FieldClash(field));
8289 }
8290 }
8291
8292 let mut params = Params::with_capacity(7 + self._additional_params.len());
8293 params.push("name", self._name);
8294 if let Some(value) = self._return_partial_success.as_ref() {
8295 params.push("returnPartialSuccess", value.to_string());
8296 }
8297 if let Some(value) = self._page_token.as_ref() {
8298 params.push("pageToken", value);
8299 }
8300 if let Some(value) = self._page_size.as_ref() {
8301 params.push("pageSize", value.to_string());
8302 }
8303 if let Some(value) = self._filter.as_ref() {
8304 params.push("filter", value);
8305 }
8306
8307 params.extend(self._additional_params.iter());
8308
8309 params.push("alt", "json");
8310 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/operations";
8311 if self._scopes.is_empty() {
8312 self._scopes
8313 .insert(Scope::CloudPlatform.as_ref().to_string());
8314 }
8315
8316 #[allow(clippy::single_element_loop)]
8317 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8318 url = params.uri_replacement(url, param_name, find_this, true);
8319 }
8320 {
8321 let to_remove = ["name"];
8322 params.remove_params(&to_remove);
8323 }
8324
8325 let url = params.parse_with_url(&url);
8326
8327 loop {
8328 let token = match self
8329 .hub
8330 .auth
8331 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8332 .await
8333 {
8334 Ok(token) => token,
8335 Err(e) => match dlg.token(e) {
8336 Ok(token) => token,
8337 Err(e) => {
8338 dlg.finished(false);
8339 return Err(common::Error::MissingToken(e));
8340 }
8341 },
8342 };
8343 let mut req_result = {
8344 let client = &self.hub.client;
8345 dlg.pre_request();
8346 let mut req_builder = hyper::Request::builder()
8347 .method(hyper::Method::GET)
8348 .uri(url.as_str())
8349 .header(USER_AGENT, self.hub._user_agent.clone());
8350
8351 if let Some(token) = token.as_ref() {
8352 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8353 }
8354
8355 let request = req_builder
8356 .header(CONTENT_LENGTH, 0_u64)
8357 .body(common::to_body::<String>(None));
8358
8359 client.request(request.unwrap()).await
8360 };
8361
8362 match req_result {
8363 Err(err) => {
8364 if let common::Retry::After(d) = dlg.http_error(&err) {
8365 sleep(d).await;
8366 continue;
8367 }
8368 dlg.finished(false);
8369 return Err(common::Error::HttpError(err));
8370 }
8371 Ok(res) => {
8372 let (mut parts, body) = res.into_parts();
8373 let mut body = common::Body::new(body);
8374 if !parts.status.is_success() {
8375 let bytes = common::to_bytes(body).await.unwrap_or_default();
8376 let error = serde_json::from_str(&common::to_string(&bytes));
8377 let response = common::to_response(parts, bytes.into());
8378
8379 if let common::Retry::After(d) =
8380 dlg.http_failure(&response, error.as_ref().ok())
8381 {
8382 sleep(d).await;
8383 continue;
8384 }
8385
8386 dlg.finished(false);
8387
8388 return Err(match error {
8389 Ok(value) => common::Error::BadRequest(value),
8390 _ => common::Error::Failure(response),
8391 });
8392 }
8393 let response = {
8394 let bytes = common::to_bytes(body).await.unwrap_or_default();
8395 let encoded = common::to_string(&bytes);
8396 match serde_json::from_str(&encoded) {
8397 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8398 Err(error) => {
8399 dlg.response_json_decode_error(&encoded, &error);
8400 return Err(common::Error::JsonDecodeError(
8401 encoded.to_string(),
8402 error,
8403 ));
8404 }
8405 }
8406 };
8407
8408 dlg.finished(true);
8409 return Ok(response);
8410 }
8411 }
8412 }
8413 }
8414
8415 /// The name of the operation's parent resource.
8416 ///
8417 /// Sets the *name* path property to the given value.
8418 ///
8419 /// Even though the property as already been set when instantiating this call,
8420 /// we provide this method for API completeness.
8421 pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogOperationListCall<'a, C> {
8422 self._name = new_value.to_string();
8423 self
8424 }
8425 /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
8426 ///
8427 /// Sets the *return partial success* query property to the given value.
8428 pub fn return_partial_success(
8429 mut self,
8430 new_value: bool,
8431 ) -> ProjectLocationCatalogOperationListCall<'a, C> {
8432 self._return_partial_success = Some(new_value);
8433 self
8434 }
8435 /// The standard list page token.
8436 ///
8437 /// Sets the *page token* query property to the given value.
8438 pub fn page_token(mut self, new_value: &str) -> ProjectLocationCatalogOperationListCall<'a, C> {
8439 self._page_token = Some(new_value.to_string());
8440 self
8441 }
8442 /// The standard list page size.
8443 ///
8444 /// Sets the *page size* query property to the given value.
8445 pub fn page_size(mut self, new_value: i32) -> ProjectLocationCatalogOperationListCall<'a, C> {
8446 self._page_size = Some(new_value);
8447 self
8448 }
8449 /// The standard list filter.
8450 ///
8451 /// Sets the *filter* query property to the given value.
8452 pub fn filter(mut self, new_value: &str) -> ProjectLocationCatalogOperationListCall<'a, C> {
8453 self._filter = Some(new_value.to_string());
8454 self
8455 }
8456 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8457 /// while executing the actual API request.
8458 ///
8459 /// ````text
8460 /// It should be used to handle progress information, and to implement a certain level of resilience.
8461 /// ````
8462 ///
8463 /// Sets the *delegate* property to the given value.
8464 pub fn delegate(
8465 mut self,
8466 new_value: &'a mut dyn common::Delegate,
8467 ) -> ProjectLocationCatalogOperationListCall<'a, C> {
8468 self._delegate = Some(new_value);
8469 self
8470 }
8471
8472 /// Set any additional parameter of the query string used in the request.
8473 /// It should be used to set parameters which are not yet available through their own
8474 /// setters.
8475 ///
8476 /// Please note that this method must not be used to set any of the known parameters
8477 /// which have their own setter method. If done anyway, the request will fail.
8478 ///
8479 /// # Additional Parameters
8480 ///
8481 /// * *$.xgafv* (query-string) - V1 error format.
8482 /// * *access_token* (query-string) - OAuth access token.
8483 /// * *alt* (query-string) - Data format for response.
8484 /// * *callback* (query-string) - JSONP
8485 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8486 /// * *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.
8487 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8488 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8489 /// * *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.
8490 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8491 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8492 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogOperationListCall<'a, C>
8493 where
8494 T: AsRef<str>,
8495 {
8496 self._additional_params
8497 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8498 self
8499 }
8500
8501 /// Identifies the authorization scope for the method you are building.
8502 ///
8503 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8504 /// [`Scope::CloudPlatform`].
8505 ///
8506 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8507 /// tokens for more than one scope.
8508 ///
8509 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8510 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8511 /// sufficient, a read-write scope will do as well.
8512 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogOperationListCall<'a, C>
8513 where
8514 St: AsRef<str>,
8515 {
8516 self._scopes.insert(String::from(scope.as_ref()));
8517 self
8518 }
8519 /// Identifies the authorization scope(s) for the method you are building.
8520 ///
8521 /// See [`Self::add_scope()`] for details.
8522 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogOperationListCall<'a, C>
8523 where
8524 I: IntoIterator<Item = St>,
8525 St: AsRef<str>,
8526 {
8527 self._scopes
8528 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8529 self
8530 }
8531
8532 /// Removes all scopes, and no default scope will be used either.
8533 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8534 /// for details).
8535 pub fn clear_scopes(mut self) -> ProjectLocationCatalogOperationListCall<'a, C> {
8536 self._scopes.clear();
8537 self
8538 }
8539}
8540
8541/// Lists all the catalog configurations associated with the project.
8542///
8543/// A builder for the *locations.catalogs.list* method supported by a *project* resource.
8544/// It is not used directly, but through a [`ProjectMethods`] instance.
8545///
8546/// # Example
8547///
8548/// Instantiate a resource method builder
8549///
8550/// ```test_harness,no_run
8551/// # extern crate hyper;
8552/// # extern crate hyper_rustls;
8553/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
8554/// # async fn dox() {
8555/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8556///
8557/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8558/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8559/// # .with_native_roots()
8560/// # .unwrap()
8561/// # .https_only()
8562/// # .enable_http2()
8563/// # .build();
8564///
8565/// # let executor = hyper_util::rt::TokioExecutor::new();
8566/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8567/// # secret,
8568/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8569/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8570/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8571/// # ),
8572/// # ).build().await.unwrap();
8573///
8574/// # let client = hyper_util::client::legacy::Client::builder(
8575/// # hyper_util::rt::TokioExecutor::new()
8576/// # )
8577/// # .build(
8578/// # hyper_rustls::HttpsConnectorBuilder::new()
8579/// # .with_native_roots()
8580/// # .unwrap()
8581/// # .https_or_http()
8582/// # .enable_http2()
8583/// # .build()
8584/// # );
8585/// # let mut hub = RecommendationsAI::new(client, auth);
8586/// // You can configure optional parameters by calling the respective setters at will, and
8587/// // execute the final call using `doit()`.
8588/// // Values shown here are possibly random and not representative !
8589/// let result = hub.projects().locations_catalogs_list("parent")
8590/// .page_token("kasd")
8591/// .page_size(-24)
8592/// .doit().await;
8593/// # }
8594/// ```
8595pub struct ProjectLocationCatalogListCall<'a, C>
8596where
8597 C: 'a,
8598{
8599 hub: &'a RecommendationsAI<C>,
8600 _parent: String,
8601 _page_token: Option<String>,
8602 _page_size: Option<i32>,
8603 _delegate: Option<&'a mut dyn common::Delegate>,
8604 _additional_params: HashMap<String, String>,
8605 _scopes: BTreeSet<String>,
8606}
8607
8608impl<'a, C> common::CallBuilder for ProjectLocationCatalogListCall<'a, C> {}
8609
8610impl<'a, C> ProjectLocationCatalogListCall<'a, C>
8611where
8612 C: common::Connector,
8613{
8614 /// Perform the operation you have build so far.
8615 pub async fn doit(
8616 mut self,
8617 ) -> common::Result<(
8618 common::Response,
8619 GoogleCloudRecommendationengineV1beta1ListCatalogsResponse,
8620 )> {
8621 use std::borrow::Cow;
8622 use std::io::{Read, Seek};
8623
8624 use common::{url::Params, ToParts};
8625 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8626
8627 let mut dd = common::DefaultDelegate;
8628 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8629 dlg.begin(common::MethodInfo {
8630 id: "recommendationengine.projects.locations.catalogs.list",
8631 http_method: hyper::Method::GET,
8632 });
8633
8634 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8635 if self._additional_params.contains_key(field) {
8636 dlg.finished(false);
8637 return Err(common::Error::FieldClash(field));
8638 }
8639 }
8640
8641 let mut params = Params::with_capacity(5 + self._additional_params.len());
8642 params.push("parent", self._parent);
8643 if let Some(value) = self._page_token.as_ref() {
8644 params.push("pageToken", value);
8645 }
8646 if let Some(value) = self._page_size.as_ref() {
8647 params.push("pageSize", value.to_string());
8648 }
8649
8650 params.extend(self._additional_params.iter());
8651
8652 params.push("alt", "json");
8653 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/catalogs";
8654 if self._scopes.is_empty() {
8655 self._scopes
8656 .insert(Scope::CloudPlatform.as_ref().to_string());
8657 }
8658
8659 #[allow(clippy::single_element_loop)]
8660 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8661 url = params.uri_replacement(url, param_name, find_this, true);
8662 }
8663 {
8664 let to_remove = ["parent"];
8665 params.remove_params(&to_remove);
8666 }
8667
8668 let url = params.parse_with_url(&url);
8669
8670 loop {
8671 let token = match self
8672 .hub
8673 .auth
8674 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8675 .await
8676 {
8677 Ok(token) => token,
8678 Err(e) => match dlg.token(e) {
8679 Ok(token) => token,
8680 Err(e) => {
8681 dlg.finished(false);
8682 return Err(common::Error::MissingToken(e));
8683 }
8684 },
8685 };
8686 let mut req_result = {
8687 let client = &self.hub.client;
8688 dlg.pre_request();
8689 let mut req_builder = hyper::Request::builder()
8690 .method(hyper::Method::GET)
8691 .uri(url.as_str())
8692 .header(USER_AGENT, self.hub._user_agent.clone());
8693
8694 if let Some(token) = token.as_ref() {
8695 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8696 }
8697
8698 let request = req_builder
8699 .header(CONTENT_LENGTH, 0_u64)
8700 .body(common::to_body::<String>(None));
8701
8702 client.request(request.unwrap()).await
8703 };
8704
8705 match req_result {
8706 Err(err) => {
8707 if let common::Retry::After(d) = dlg.http_error(&err) {
8708 sleep(d).await;
8709 continue;
8710 }
8711 dlg.finished(false);
8712 return Err(common::Error::HttpError(err));
8713 }
8714 Ok(res) => {
8715 let (mut parts, body) = res.into_parts();
8716 let mut body = common::Body::new(body);
8717 if !parts.status.is_success() {
8718 let bytes = common::to_bytes(body).await.unwrap_or_default();
8719 let error = serde_json::from_str(&common::to_string(&bytes));
8720 let response = common::to_response(parts, bytes.into());
8721
8722 if let common::Retry::After(d) =
8723 dlg.http_failure(&response, error.as_ref().ok())
8724 {
8725 sleep(d).await;
8726 continue;
8727 }
8728
8729 dlg.finished(false);
8730
8731 return Err(match error {
8732 Ok(value) => common::Error::BadRequest(value),
8733 _ => common::Error::Failure(response),
8734 });
8735 }
8736 let response = {
8737 let bytes = common::to_bytes(body).await.unwrap_or_default();
8738 let encoded = common::to_string(&bytes);
8739 match serde_json::from_str(&encoded) {
8740 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8741 Err(error) => {
8742 dlg.response_json_decode_error(&encoded, &error);
8743 return Err(common::Error::JsonDecodeError(
8744 encoded.to_string(),
8745 error,
8746 ));
8747 }
8748 }
8749 };
8750
8751 dlg.finished(true);
8752 return Ok(response);
8753 }
8754 }
8755 }
8756 }
8757
8758 /// Required. The account resource name with an associated location.
8759 ///
8760 /// Sets the *parent* path property to the given value.
8761 ///
8762 /// Even though the property as already been set when instantiating this call,
8763 /// we provide this method for API completeness.
8764 pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogListCall<'a, C> {
8765 self._parent = new_value.to_string();
8766 self
8767 }
8768 /// Optional. A page token, received from a previous `ListCatalogs` call. Provide this to retrieve the subsequent page.
8769 ///
8770 /// Sets the *page token* query property to the given value.
8771 pub fn page_token(mut self, new_value: &str) -> ProjectLocationCatalogListCall<'a, C> {
8772 self._page_token = Some(new_value.to_string());
8773 self
8774 }
8775 /// Optional. Maximum number of results to return. If unspecified, defaults to 50. Max allowed value is 1000.
8776 ///
8777 /// Sets the *page size* query property to the given value.
8778 pub fn page_size(mut self, new_value: i32) -> ProjectLocationCatalogListCall<'a, C> {
8779 self._page_size = Some(new_value);
8780 self
8781 }
8782 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8783 /// while executing the actual API request.
8784 ///
8785 /// ````text
8786 /// It should be used to handle progress information, and to implement a certain level of resilience.
8787 /// ````
8788 ///
8789 /// Sets the *delegate* property to the given value.
8790 pub fn delegate(
8791 mut self,
8792 new_value: &'a mut dyn common::Delegate,
8793 ) -> ProjectLocationCatalogListCall<'a, C> {
8794 self._delegate = Some(new_value);
8795 self
8796 }
8797
8798 /// Set any additional parameter of the query string used in the request.
8799 /// It should be used to set parameters which are not yet available through their own
8800 /// setters.
8801 ///
8802 /// Please note that this method must not be used to set any of the known parameters
8803 /// which have their own setter method. If done anyway, the request will fail.
8804 ///
8805 /// # Additional Parameters
8806 ///
8807 /// * *$.xgafv* (query-string) - V1 error format.
8808 /// * *access_token* (query-string) - OAuth access token.
8809 /// * *alt* (query-string) - Data format for response.
8810 /// * *callback* (query-string) - JSONP
8811 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8812 /// * *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.
8813 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8814 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8815 /// * *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.
8816 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8817 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8818 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogListCall<'a, C>
8819 where
8820 T: AsRef<str>,
8821 {
8822 self._additional_params
8823 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8824 self
8825 }
8826
8827 /// Identifies the authorization scope for the method you are building.
8828 ///
8829 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8830 /// [`Scope::CloudPlatform`].
8831 ///
8832 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8833 /// tokens for more than one scope.
8834 ///
8835 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8836 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8837 /// sufficient, a read-write scope will do as well.
8838 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogListCall<'a, C>
8839 where
8840 St: AsRef<str>,
8841 {
8842 self._scopes.insert(String::from(scope.as_ref()));
8843 self
8844 }
8845 /// Identifies the authorization scope(s) for the method you are building.
8846 ///
8847 /// See [`Self::add_scope()`] for details.
8848 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogListCall<'a, C>
8849 where
8850 I: IntoIterator<Item = St>,
8851 St: AsRef<str>,
8852 {
8853 self._scopes
8854 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8855 self
8856 }
8857
8858 /// Removes all scopes, and no default scope will be used either.
8859 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8860 /// for details).
8861 pub fn clear_scopes(mut self) -> ProjectLocationCatalogListCall<'a, C> {
8862 self._scopes.clear();
8863 self
8864 }
8865}
8866
8867/// Updates the catalog configuration.
8868///
8869/// A builder for the *locations.catalogs.patch* method supported by a *project* resource.
8870/// It is not used directly, but through a [`ProjectMethods`] instance.
8871///
8872/// # Example
8873///
8874/// Instantiate a resource method builder
8875///
8876/// ```test_harness,no_run
8877/// # extern crate hyper;
8878/// # extern crate hyper_rustls;
8879/// # extern crate google_recommendationengine1_beta1 as recommendationengine1_beta1;
8880/// use recommendationengine1_beta1::api::GoogleCloudRecommendationengineV1beta1Catalog;
8881/// # async fn dox() {
8882/// # use recommendationengine1_beta1::{RecommendationsAI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8883///
8884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8885/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8886/// # .with_native_roots()
8887/// # .unwrap()
8888/// # .https_only()
8889/// # .enable_http2()
8890/// # .build();
8891///
8892/// # let executor = hyper_util::rt::TokioExecutor::new();
8893/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8894/// # secret,
8895/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8896/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8897/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8898/// # ),
8899/// # ).build().await.unwrap();
8900///
8901/// # let client = hyper_util::client::legacy::Client::builder(
8902/// # hyper_util::rt::TokioExecutor::new()
8903/// # )
8904/// # .build(
8905/// # hyper_rustls::HttpsConnectorBuilder::new()
8906/// # .with_native_roots()
8907/// # .unwrap()
8908/// # .https_or_http()
8909/// # .enable_http2()
8910/// # .build()
8911/// # );
8912/// # let mut hub = RecommendationsAI::new(client, auth);
8913/// // As the method needs a request, you would usually fill it with the desired information
8914/// // into the respective structure. Some of the parts shown here might not be applicable !
8915/// // Values shown here are possibly random and not representative !
8916/// let mut req = GoogleCloudRecommendationengineV1beta1Catalog::default();
8917///
8918/// // You can configure optional parameters by calling the respective setters at will, and
8919/// // execute the final call using `doit()`.
8920/// // Values shown here are possibly random and not representative !
8921/// let result = hub.projects().locations_catalogs_patch(req, "name")
8922/// .update_mask(FieldMask::new::<&str>(&[]))
8923/// .doit().await;
8924/// # }
8925/// ```
8926pub struct ProjectLocationCatalogPatchCall<'a, C>
8927where
8928 C: 'a,
8929{
8930 hub: &'a RecommendationsAI<C>,
8931 _request: GoogleCloudRecommendationengineV1beta1Catalog,
8932 _name: String,
8933 _update_mask: Option<common::FieldMask>,
8934 _delegate: Option<&'a mut dyn common::Delegate>,
8935 _additional_params: HashMap<String, String>,
8936 _scopes: BTreeSet<String>,
8937}
8938
8939impl<'a, C> common::CallBuilder for ProjectLocationCatalogPatchCall<'a, C> {}
8940
8941impl<'a, C> ProjectLocationCatalogPatchCall<'a, C>
8942where
8943 C: common::Connector,
8944{
8945 /// Perform the operation you have build so far.
8946 pub async fn doit(
8947 mut self,
8948 ) -> common::Result<(
8949 common::Response,
8950 GoogleCloudRecommendationengineV1beta1Catalog,
8951 )> {
8952 use std::borrow::Cow;
8953 use std::io::{Read, Seek};
8954
8955 use common::{url::Params, ToParts};
8956 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8957
8958 let mut dd = common::DefaultDelegate;
8959 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8960 dlg.begin(common::MethodInfo {
8961 id: "recommendationengine.projects.locations.catalogs.patch",
8962 http_method: hyper::Method::PATCH,
8963 });
8964
8965 for &field in ["alt", "name", "updateMask"].iter() {
8966 if self._additional_params.contains_key(field) {
8967 dlg.finished(false);
8968 return Err(common::Error::FieldClash(field));
8969 }
8970 }
8971
8972 let mut params = Params::with_capacity(5 + self._additional_params.len());
8973 params.push("name", self._name);
8974 if let Some(value) = self._update_mask.as_ref() {
8975 params.push("updateMask", value.to_string());
8976 }
8977
8978 params.extend(self._additional_params.iter());
8979
8980 params.push("alt", "json");
8981 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
8982 if self._scopes.is_empty() {
8983 self._scopes
8984 .insert(Scope::CloudPlatform.as_ref().to_string());
8985 }
8986
8987 #[allow(clippy::single_element_loop)]
8988 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8989 url = params.uri_replacement(url, param_name, find_this, true);
8990 }
8991 {
8992 let to_remove = ["name"];
8993 params.remove_params(&to_remove);
8994 }
8995
8996 let url = params.parse_with_url(&url);
8997
8998 let mut json_mime_type = mime::APPLICATION_JSON;
8999 let mut request_value_reader = {
9000 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9001 common::remove_json_null_values(&mut value);
9002 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9003 serde_json::to_writer(&mut dst, &value).unwrap();
9004 dst
9005 };
9006 let request_size = request_value_reader
9007 .seek(std::io::SeekFrom::End(0))
9008 .unwrap();
9009 request_value_reader
9010 .seek(std::io::SeekFrom::Start(0))
9011 .unwrap();
9012
9013 loop {
9014 let token = match self
9015 .hub
9016 .auth
9017 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9018 .await
9019 {
9020 Ok(token) => token,
9021 Err(e) => match dlg.token(e) {
9022 Ok(token) => token,
9023 Err(e) => {
9024 dlg.finished(false);
9025 return Err(common::Error::MissingToken(e));
9026 }
9027 },
9028 };
9029 request_value_reader
9030 .seek(std::io::SeekFrom::Start(0))
9031 .unwrap();
9032 let mut req_result = {
9033 let client = &self.hub.client;
9034 dlg.pre_request();
9035 let mut req_builder = hyper::Request::builder()
9036 .method(hyper::Method::PATCH)
9037 .uri(url.as_str())
9038 .header(USER_AGENT, self.hub._user_agent.clone());
9039
9040 if let Some(token) = token.as_ref() {
9041 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9042 }
9043
9044 let request = req_builder
9045 .header(CONTENT_TYPE, json_mime_type.to_string())
9046 .header(CONTENT_LENGTH, request_size as u64)
9047 .body(common::to_body(
9048 request_value_reader.get_ref().clone().into(),
9049 ));
9050
9051 client.request(request.unwrap()).await
9052 };
9053
9054 match req_result {
9055 Err(err) => {
9056 if let common::Retry::After(d) = dlg.http_error(&err) {
9057 sleep(d).await;
9058 continue;
9059 }
9060 dlg.finished(false);
9061 return Err(common::Error::HttpError(err));
9062 }
9063 Ok(res) => {
9064 let (mut parts, body) = res.into_parts();
9065 let mut body = common::Body::new(body);
9066 if !parts.status.is_success() {
9067 let bytes = common::to_bytes(body).await.unwrap_or_default();
9068 let error = serde_json::from_str(&common::to_string(&bytes));
9069 let response = common::to_response(parts, bytes.into());
9070
9071 if let common::Retry::After(d) =
9072 dlg.http_failure(&response, error.as_ref().ok())
9073 {
9074 sleep(d).await;
9075 continue;
9076 }
9077
9078 dlg.finished(false);
9079
9080 return Err(match error {
9081 Ok(value) => common::Error::BadRequest(value),
9082 _ => common::Error::Failure(response),
9083 });
9084 }
9085 let response = {
9086 let bytes = common::to_bytes(body).await.unwrap_or_default();
9087 let encoded = common::to_string(&bytes);
9088 match serde_json::from_str(&encoded) {
9089 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9090 Err(error) => {
9091 dlg.response_json_decode_error(&encoded, &error);
9092 return Err(common::Error::JsonDecodeError(
9093 encoded.to_string(),
9094 error,
9095 ));
9096 }
9097 }
9098 };
9099
9100 dlg.finished(true);
9101 return Ok(response);
9102 }
9103 }
9104 }
9105 }
9106
9107 ///
9108 /// Sets the *request* property to the given value.
9109 ///
9110 /// Even though the property as already been set when instantiating this call,
9111 /// we provide this method for API completeness.
9112 pub fn request(
9113 mut self,
9114 new_value: GoogleCloudRecommendationengineV1beta1Catalog,
9115 ) -> ProjectLocationCatalogPatchCall<'a, C> {
9116 self._request = new_value;
9117 self
9118 }
9119 /// The fully qualified resource name of the catalog.
9120 ///
9121 /// Sets the *name* path property to the given value.
9122 ///
9123 /// Even though the property as already been set when instantiating this call,
9124 /// we provide this method for API completeness.
9125 pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogPatchCall<'a, C> {
9126 self._name = new_value.to_string();
9127 self
9128 }
9129 /// Optional. Indicates which fields in the provided 'catalog' to update. If not set, will only update the catalog_item_level_config field. Currently only fields that can be updated are catalog_item_level_config.
9130 ///
9131 /// Sets the *update mask* query property to the given value.
9132 pub fn update_mask(
9133 mut self,
9134 new_value: common::FieldMask,
9135 ) -> ProjectLocationCatalogPatchCall<'a, C> {
9136 self._update_mask = Some(new_value);
9137 self
9138 }
9139 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9140 /// while executing the actual API request.
9141 ///
9142 /// ````text
9143 /// It should be used to handle progress information, and to implement a certain level of resilience.
9144 /// ````
9145 ///
9146 /// Sets the *delegate* property to the given value.
9147 pub fn delegate(
9148 mut self,
9149 new_value: &'a mut dyn common::Delegate,
9150 ) -> ProjectLocationCatalogPatchCall<'a, C> {
9151 self._delegate = Some(new_value);
9152 self
9153 }
9154
9155 /// Set any additional parameter of the query string used in the request.
9156 /// It should be used to set parameters which are not yet available through their own
9157 /// setters.
9158 ///
9159 /// Please note that this method must not be used to set any of the known parameters
9160 /// which have their own setter method. If done anyway, the request will fail.
9161 ///
9162 /// # Additional Parameters
9163 ///
9164 /// * *$.xgafv* (query-string) - V1 error format.
9165 /// * *access_token* (query-string) - OAuth access token.
9166 /// * *alt* (query-string) - Data format for response.
9167 /// * *callback* (query-string) - JSONP
9168 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9169 /// * *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.
9170 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9171 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9172 /// * *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.
9173 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9174 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9175 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogPatchCall<'a, C>
9176 where
9177 T: AsRef<str>,
9178 {
9179 self._additional_params
9180 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9181 self
9182 }
9183
9184 /// Identifies the authorization scope for the method you are building.
9185 ///
9186 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9187 /// [`Scope::CloudPlatform`].
9188 ///
9189 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9190 /// tokens for more than one scope.
9191 ///
9192 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9193 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9194 /// sufficient, a read-write scope will do as well.
9195 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogPatchCall<'a, C>
9196 where
9197 St: AsRef<str>,
9198 {
9199 self._scopes.insert(String::from(scope.as_ref()));
9200 self
9201 }
9202 /// Identifies the authorization scope(s) for the method you are building.
9203 ///
9204 /// See [`Self::add_scope()`] for details.
9205 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogPatchCall<'a, C>
9206 where
9207 I: IntoIterator<Item = St>,
9208 St: AsRef<str>,
9209 {
9210 self._scopes
9211 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9212 self
9213 }
9214
9215 /// Removes all scopes, and no default scope will be used either.
9216 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9217 /// for details).
9218 pub fn clear_scopes(mut self) -> ProjectLocationCatalogPatchCall<'a, C> {
9219 self._scopes.clear();
9220 self
9221 }
9222}