google_retail2/
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 CloudRetail 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_retail2 as retail2;
49/// use retail2::api::GoogleCloudRetailV2Model;
50/// use retail2::{Result, Error};
51/// # async fn dox() {
52/// use retail2::{CloudRetail, 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 = CloudRetail::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 = GoogleCloudRetailV2Model::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_models_create(req, "parent")
99///              .dry_run(true)
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct CloudRetail<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for CloudRetail<C> {}
131
132impl<'a, C> CloudRetail<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> CloudRetail<C> {
137        CloudRetail {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://retail.googleapis.com/".to_string(),
142            _root_url: "https://retail.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147        ProjectMethods { hub: self }
148    }
149
150    /// Set the user-agent header field to use in all requests to the server.
151    /// It defaults to `google-api-rust-client/7.0.0`.
152    ///
153    /// Returns the previously set user-agent.
154    pub fn user_agent(&mut self, agent_name: String) -> String {
155        std::mem::replace(&mut self._user_agent, agent_name)
156    }
157
158    /// Set the base url to use in all requests to the server.
159    /// It defaults to `https://retail.googleapis.com/`.
160    ///
161    /// Returns the previously set base url.
162    pub fn base_url(&mut self, new_base_url: String) -> String {
163        std::mem::replace(&mut self._base_url, new_base_url)
164    }
165
166    /// Set the root url to use in all requests to the server.
167    /// It defaults to `https://retail.googleapis.com/`.
168    ///
169    /// Returns the previously set root url.
170    pub fn root_url(&mut self, new_root_url: String) -> String {
171        std::mem::replace(&mut self._root_url, new_root_url)
172    }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// 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.
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [locations catalogs user events collect projects](ProjectLocationCatalogUserEventCollectCall) (response)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct GoogleApiHttpBody {
190    /// The HTTP Content-Type header value specifying the content type of the body.
191    #[serde(rename = "contentType")]
192    pub content_type: Option<String>,
193    /// The HTTP request/response body as raw binary.
194    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
195    pub data: Option<Vec<u8>>,
196    /// Application specific response metadata. Must be set in the first response for streaming APIs.
197    pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
198}
199
200impl common::ResponseResult for GoogleApiHttpBody {}
201
202/// Request for CatalogService.AddCatalogAttribute method.
203///
204/// # Activities
205///
206/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
207/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
208///
209/// * [locations catalogs attributes config add catalog attribute projects](ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall) (request)
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct GoogleCloudRetailV2AddCatalogAttributeRequest {
214    /// Required. The CatalogAttribute to add.
215    #[serde(rename = "catalogAttribute")]
216    pub catalog_attribute: Option<GoogleCloudRetailV2CatalogAttribute>,
217}
218
219impl common::RequestValue for GoogleCloudRetailV2AddCatalogAttributeRequest {}
220
221/// Request for AddControl method.
222///
223/// # Activities
224///
225/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
226/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
227///
228/// * [locations catalogs serving configs add control projects](ProjectLocationCatalogServingConfigAddControlCall) (request)
229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
230#[serde_with::serde_as]
231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
232pub struct GoogleCloudRetailV2AddControlRequest {
233    /// Required. The id of the control to apply. Assumed to be in the same catalog as the serving config - if id is not found a NOT_FOUND error is returned.
234    #[serde(rename = "controlId")]
235    pub control_id: Option<String>,
236}
237
238impl common::RequestValue for GoogleCloudRetailV2AddControlRequest {}
239
240/// Request message for ProductService.AddFulfillmentPlaces method.
241///
242/// # Activities
243///
244/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
245/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
246///
247/// * [locations catalogs branches products add fulfillment places projects](ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall) (request)
248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
249#[serde_with::serde_as]
250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
251pub struct GoogleCloudRetailV2AddFulfillmentPlacesRequest {
252    /// The time when the fulfillment updates are issued, used to prevent out-of-order updates on fulfillment information. If not provided, the internal system time will be used.
253    #[serde(rename = "addTime")]
254    pub add_time: Option<chrono::DateTime<chrono::offset::Utc>>,
255    /// If set to true, and the Product is not found, the fulfillment information will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.
256    #[serde(rename = "allowMissing")]
257    pub allow_missing: Option<bool>,
258    /// Required. The IDs for this type, such as the store IDs for "pickup-in-store" or the region IDs for "same-day-delivery" to be added for this type. Duplicate IDs will be automatically ignored. At least 1 value is required, and a maximum of 2000 values are allowed. Each value must be a string with a length limit of 10 characters, matching the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is returned. If the total number of place IDs exceeds 2000 for this type after adding, then the update will be rejected.
259    #[serde(rename = "placeIds")]
260    pub place_ids: Option<Vec<String>>,
261    /// Required. The fulfillment type, including commonly used types (such as pickup in store and same day delivery), and custom types. Supported values: * "pickup-in-store" * "ship-to-store" * "same-day-delivery" * "next-day-delivery" * "custom-type-1" * "custom-type-2" * "custom-type-3" * "custom-type-4" * "custom-type-5" If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned. This field directly corresponds to Product.fulfillment_info.type.
262    #[serde(rename = "type")]
263    pub type_: Option<String>,
264}
265
266impl common::RequestValue for GoogleCloudRetailV2AddFulfillmentPlacesRequest {}
267
268/// Request message for ProductService.AddLocalInventories method.
269///
270/// # Activities
271///
272/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
273/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
274///
275/// * [locations catalogs branches products add local inventories projects](ProjectLocationCatalogBranchProductAddLocalInventoryCall) (request)
276#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
277#[serde_with::serde_as]
278#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
279pub struct GoogleCloudRetailV2AddLocalInventoriesRequest {
280    /// Indicates which inventory fields in the provided list of LocalInventory to update. The field is updated to the provided value. If a field is set while the place does not have a previous local inventory, the local inventory at that store is created. If a field is set while the value of that field is not provided, the original field value, if it exists, is deleted. If the mask is not set or set with empty paths, all inventory fields will be updated. If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned and the entire update will be ignored.
281    #[serde(rename = "addMask")]
282    pub add_mask: Option<common::FieldMask>,
283    /// The time when the inventory updates are issued. Used to prevent out-of-order updates on local inventory fields. If not provided, the internal system time will be used.
284    #[serde(rename = "addTime")]
285    pub add_time: Option<chrono::DateTime<chrono::offset::Utc>>,
286    /// If set to true, and the Product is not found, the local inventory will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.
287    #[serde(rename = "allowMissing")]
288    pub allow_missing: Option<bool>,
289    /// Required. A list of inventory information at difference places. Each place is identified by its place ID. At most 3000 inventories are allowed per request.
290    #[serde(rename = "localInventories")]
291    pub local_inventories: Option<Vec<GoogleCloudRetailV2LocalInventory>>,
292}
293
294impl common::RequestValue for GoogleCloudRetailV2AddLocalInventoriesRequest {}
295
296/// Catalog level attribute config.
297///
298/// # Activities
299///
300/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
301/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
302///
303/// * [locations catalogs attributes config add catalog attribute projects](ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall) (response)
304/// * [locations catalogs attributes config remove catalog attribute projects](ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall) (response)
305/// * [locations catalogs attributes config replace catalog attribute projects](ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall) (response)
306/// * [locations catalogs get attributes config projects](ProjectLocationCatalogGetAttributesConfigCall) (response)
307/// * [locations catalogs update attributes config projects](ProjectLocationCatalogUpdateAttributesConfigCall) (request|response)
308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
309#[serde_with::serde_as]
310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
311pub struct GoogleCloudRetailV2AttributesConfig {
312    /// Output only. The AttributeConfigLevel used for this catalog.
313    #[serde(rename = "attributeConfigLevel")]
314    pub attribute_config_level: Option<String>,
315    /// Enable attribute(s) config at catalog level. For example, indexable, dynamic_facetable, or searchable for each attribute. The key is catalog attribute's name. For example: `color`, `brands`, `attributes.custom_attribute`, such as `attributes.xyz`. The maximum number of catalog attributes allowed in a request is 1000.
316    #[serde(rename = "catalogAttributes")]
317    pub catalog_attributes: Option<HashMap<String, GoogleCloudRetailV2CatalogAttribute>>,
318    /// Required. Immutable. The fully qualified resource name of the attribute config. Format: `projects/*/locations/*/catalogs/*/attributesConfig`
319    pub name: Option<String>,
320}
321
322impl common::RequestValue for GoogleCloudRetailV2AttributesConfig {}
323impl common::ResponseResult for GoogleCloudRetailV2AttributesConfig {}
324
325/// An intended audience of the Product for whom it's sold.
326///
327/// This type is not used in any activity, and only used as *part* of another schema.
328///
329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
330#[serde_with::serde_as]
331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
332pub struct GoogleCloudRetailV2Audience {
333    /// The age groups of the audience. Strongly encouraged to use the standard values: "newborn" (up to 3 months old), "infant" (3–12 months old), "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically teens or older). At most 5 values are allowed. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Google Merchant Center property [age_group](https://support.google.com/merchants/answer/6324463). Schema.org property [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge).
334    #[serde(rename = "ageGroups")]
335    pub age_groups: Option<Vec<String>>,
336    /// The genders of the audience. Strongly encouraged to use the standard values: "male", "female", "unisex". At most 5 values are allowed. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Google Merchant Center property [gender](https://support.google.com/merchants/answer/6324479). Schema.org property [Product.audience.suggestedGender](https://schema.org/suggestedGender).
337    pub genders: Option<Vec<String>>,
338}
339
340impl common::Part for GoogleCloudRetailV2Audience {}
341
342/// Request for BatchUpdateGenerativeQuestionConfig method.
343///
344/// # Activities
345///
346/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
347/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
348///
349/// * [locations catalogs generative question batch update projects](ProjectLocationCatalogGenerativeQuestionBatchUpdateCall) (request)
350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
351#[serde_with::serde_as]
352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
353pub struct GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsRequest {
354    /// Required. The updates question configs.
355    pub requests: Option<Vec<GoogleCloudRetailV2UpdateGenerativeQuestionConfigRequest>>,
356}
357
358impl common::RequestValue for GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsRequest {}
359
360/// Aggregated response for UpdateGenerativeQuestionConfig method.
361///
362/// # Activities
363///
364/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
365/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
366///
367/// * [locations catalogs generative question batch update projects](ProjectLocationCatalogGenerativeQuestionBatchUpdateCall) (response)
368#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
369#[serde_with::serde_as]
370#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
371pub struct GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsResponse {
372    /// Optional. The updates question configs.
373    #[serde(rename = "generativeQuestionConfigs")]
374    pub generative_question_configs: Option<Vec<GoogleCloudRetailV2GenerativeQuestionConfig>>,
375}
376
377impl common::ResponseResult for GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsResponse {}
378
379/// BigQuery source import data from.
380///
381/// This type is not used in any activity, and only used as *part* of another schema.
382///
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct GoogleCloudRetailV2BigQuerySource {
387    /// The schema to use when parsing the data from the source. Supported values for product imports: * `product` (default): One JSON Product per line. Each product must have a valid Product.id. * `product_merchant_center`: See [Importing catalog data from Merchant Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). Supported values for user events imports: * `user_event` (default): One JSON UserEvent per line. * `user_event_ga360`: The schema is available here: https://support.google.com/analytics/answer/3437719. * `user_event_ga4`: The schema is available here: https://support.google.com/analytics/answer/7029846. Supported values for autocomplete imports: * `suggestions` (default): One JSON completion suggestion per line. * `denylist`: One JSON deny suggestion per line. * `allowlist`: One JSON allow suggestion per line.
388    #[serde(rename = "dataSchema")]
389    pub data_schema: Option<String>,
390    /// Required. The BigQuery data set to copy the data from with a length limit of 1,024 characters.
391    #[serde(rename = "datasetId")]
392    pub dataset_id: Option<String>,
393    /// Intermediate Cloud Storage directory used for the import with a length limit of 2,000 characters. Can be specified if one wants to have the BigQuery export to a specific Cloud Storage directory.
394    #[serde(rename = "gcsStagingDir")]
395    pub gcs_staging_dir: Option<String>,
396    /// BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format.
397    #[serde(rename = "partitionDate")]
398    pub partition_date: Option<GoogleTypeDate>,
399    /// The project ID (can be project # or ID) that the BigQuery source is in with a length limit of 128 characters. If not specified, inherits the project ID from the parent request.
400    #[serde(rename = "projectId")]
401    pub project_id: Option<String>,
402    /// Required. The BigQuery table to copy the data from with a length limit of 1,024 characters.
403    #[serde(rename = "tableId")]
404    pub table_id: Option<String>,
405}
406
407impl common::Part for GoogleCloudRetailV2BigQuerySource {}
408
409/// The catalog configuration.
410///
411/// # Activities
412///
413/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
414/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
415///
416/// * [locations catalogs patch projects](ProjectLocationCatalogPatchCall) (request|response)
417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
418#[serde_with::serde_as]
419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
420pub struct GoogleCloudRetailV2Catalog {
421    /// Required. Immutable. The catalog display name. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
422    #[serde(rename = "displayName")]
423    pub display_name: Option<String>,
424    /// Required. Immutable. The fully qualified resource name of the catalog.
425    pub name: Option<String>,
426    /// Required. The product level configuration.
427    #[serde(rename = "productLevelConfig")]
428    pub product_level_config: Option<GoogleCloudRetailV2ProductLevelConfig>,
429}
430
431impl common::RequestValue for GoogleCloudRetailV2Catalog {}
432impl common::ResponseResult for GoogleCloudRetailV2Catalog {}
433
434/// Catalog level attribute config for an attribute. For example, if customers want to enable/disable facet for a specific attribute.
435///
436/// This type is not used in any activity, and only used as *part* of another schema.
437///
438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
439#[serde_with::serde_as]
440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
441pub struct GoogleCloudRetailV2CatalogAttribute {
442    /// If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic facet. Could only be DYNAMIC_FACETABLE_DISABLED if CatalogAttribute.indexable_option is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. Must be specified, otherwise throws INVALID_FORMAT error.
443    #[serde(rename = "dynamicFacetableOption")]
444    pub dynamic_facetable_option: Option<String>,
445    /// If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. This property only applies to textual custom attributes and requires indexable set to enabled to enable exact-searchable. If unset, the server behavior defaults to EXACT_SEARCHABLE_DISABLED.
446    #[serde(rename = "exactSearchableOption")]
447    pub exact_searchable_option: Option<String>,
448    /// Contains facet options.
449    #[serde(rename = "facetConfig")]
450    pub facet_config: Option<GoogleCloudRetailV2CatalogAttributeFacetConfig>,
451    /// Output only. Indicates whether this attribute has been used by any products. `True` if at least one Product is using this attribute in Product.attributes. Otherwise, this field is `False`. CatalogAttribute can be pre-loaded by using CatalogService.AddCatalogAttribute or CatalogService.UpdateAttributesConfig APIs. This field is `False` for pre-loaded CatalogAttributes. Only pre-loaded catalog attributes that are neither in use by products nor predefined can be deleted. Catalog attributes that are either in use by products or are predefined attributes cannot be deleted; however, their configuration properties will reset to default values upon removal request. After catalog changes, it takes about 10 minutes for this field to update.
452    #[serde(rename = "inUse")]
453    pub in_use: Option<bool>,
454    /// When AttributesConfig.attribute_config_level is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values are indexed so that it can be filtered, faceted, or boosted in SearchService.Search. Must be specified when AttributesConfig.attribute_config_level is CATALOG_LEVEL_ATTRIBUTE_CONFIG, otherwise throws INVALID_FORMAT error.
455    #[serde(rename = "indexableOption")]
456    pub indexable_option: Option<String>,
457    /// Required. Attribute name. For example: `color`, `brands`, `attributes.custom_attribute`, such as `attributes.xyz`. To be indexable, the attribute name can contain only alpha-numeric characters and underscores. For example, an attribute named `attributes.abc_xyz` can be indexed, but an attribute named `attributes.abc-xyz` cannot be indexed. If the attribute key starts with `attributes.`, then the attribute is a custom attribute. Attributes such as `brands`, `patterns`, and `title` are built-in and called system attributes.
458    pub key: Option<String>,
459    /// If RETRIEVABLE_ENABLED, attribute values are retrievable in the search results. If unset, the server behavior defaults to RETRIEVABLE_DISABLED.
460    #[serde(rename = "retrievableOption")]
461    pub retrievable_option: Option<String>,
462    /// When AttributesConfig.attribute_config_level is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values are searchable by text queries in SearchService.Search. If SEARCHABLE_ENABLED but attribute type is numerical, attribute values will not be searchable by text queries in SearchService.Search, as there are no text values associated to numerical attributes. Must be specified, when AttributesConfig.attribute_config_level is CATALOG_LEVEL_ATTRIBUTE_CONFIG, otherwise throws INVALID_FORMAT error.
463    #[serde(rename = "searchableOption")]
464    pub searchable_option: Option<String>,
465    /// Output only. The type of this attribute. This is derived from the attribute in Product.attributes.
466    #[serde(rename = "type")]
467    pub type_: Option<String>,
468}
469
470impl common::Part for GoogleCloudRetailV2CatalogAttribute {}
471
472/// Possible options for the facet that corresponds to the current attribute config.
473///
474/// This type is not used in any activity, and only used as *part* of another schema.
475///
476#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
477#[serde_with::serde_as]
478#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
479pub struct GoogleCloudRetailV2CatalogAttributeFacetConfig {
480    /// If you don't set the facet SearchRequest.FacetSpec.FacetKey.intervals in the request to a numerical attribute, then we use the computed intervals with rounded bounds obtained from all its product numerical attribute values. The computed intervals might not be ideal for some attributes. Therefore, we give you the option to overwrite them with the facet_intervals field. The maximum of facet intervals per CatalogAttribute is 40. Each interval must have a lower bound or an upper bound. If both bounds are provided, then the lower bound must be smaller or equal than the upper bound.
481    #[serde(rename = "facetIntervals")]
482    pub facet_intervals: Option<Vec<GoogleCloudRetailV2Interval>>,
483    /// Each instance represents a list of attribute values to ignore as facet values for a specific time range. The maximum number of instances per CatalogAttribute is 25.
484    #[serde(rename = "ignoredFacetValues")]
485    pub ignored_facet_values:
486        Option<Vec<GoogleCloudRetailV2CatalogAttributeFacetConfigIgnoredFacetValues>>,
487    /// Use this field only if you want to merge a facet key into another facet key.
488    #[serde(rename = "mergedFacet")]
489    pub merged_facet: Option<GoogleCloudRetailV2CatalogAttributeFacetConfigMergedFacet>,
490    /// Each instance replaces a list of facet values by a merged facet value. If a facet value is not in any list, then it will stay the same. To avoid conflicts, only paths of length 1 are accepted. In other words, if "dark_blue" merged into "BLUE", then the latter can't merge into "blues" because this would create a path of length 2. The maximum number of instances of MergedFacetValue per CatalogAttribute is 100. This feature is available only for textual custom attributes.
491    #[serde(rename = "mergedFacetValues")]
492    pub merged_facet_values:
493        Option<Vec<GoogleCloudRetailV2CatalogAttributeFacetConfigMergedFacetValue>>,
494    /// Set this field only if you want to rerank based on facet values engaged by the user for the current key. This option is only possible for custom facetable textual keys.
495    #[serde(rename = "rerankConfig")]
496    pub rerank_config: Option<GoogleCloudRetailV2CatalogAttributeFacetConfigRerankConfig>,
497}
498
499impl common::Part for GoogleCloudRetailV2CatalogAttributeFacetConfig {}
500
501/// Facet values to ignore on facets during the specified time range for the given SearchResponse.Facet.key attribute.
502///
503/// This type is not used in any activity, and only used as *part* of another schema.
504///
505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
506#[serde_with::serde_as]
507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
508pub struct GoogleCloudRetailV2CatalogAttributeFacetConfigIgnoredFacetValues {
509    /// If start time is empty and end time is not empty, then ignore these facet values before end time.
510    #[serde(rename = "endTime")]
511    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
512    /// Time range for the current list of facet values to ignore. If multiple time ranges are specified for an facet value for the current attribute, consider all of them. If both are empty, ignore always. If start time and end time are set, then start time must be before end time. If start time is not empty and end time is empty, then will ignore these facet values after the start time.
513    #[serde(rename = "startTime")]
514    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
515    /// List of facet values to ignore for the following time range. The facet values are the same as the attribute values. There is a limit of 10 values per instance of IgnoredFacetValues. Each value can have at most 128 characters.
516    pub values: Option<Vec<String>>,
517}
518
519impl common::Part for GoogleCloudRetailV2CatalogAttributeFacetConfigIgnoredFacetValues {}
520
521/// The current facet key (i.e. attribute config) maps into the merged_facet_key. A facet key can have at most one child. The current facet key and the merged facet key need both to be textual custom attributes or both numerical custom attributes (same type).
522///
523/// This type is not used in any activity, and only used as *part* of another schema.
524///
525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
526#[serde_with::serde_as]
527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
528pub struct GoogleCloudRetailV2CatalogAttributeFacetConfigMergedFacet {
529    /// The merged facet key should be a valid facet key that is different than the facet key of the current catalog attribute. We refer this is merged facet key as the child of the current catalog attribute. This merged facet key can't be a parent of another facet key (i.e. no directed path of length 2). This merged facet key needs to be either a textual custom attribute or a numerical custom attribute.
530    #[serde(rename = "mergedFacetKey")]
531    pub merged_facet_key: Option<String>,
532}
533
534impl common::Part for GoogleCloudRetailV2CatalogAttributeFacetConfigMergedFacet {}
535
536/// Replaces a set of textual facet values by the same (possibly different) merged facet value. Each facet value should appear at most once as a value per CatalogAttribute. This feature is available only for textual custom attributes.
537///
538/// This type is not used in any activity, and only used as *part* of another schema.
539///
540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
541#[serde_with::serde_as]
542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
543pub struct GoogleCloudRetailV2CatalogAttributeFacetConfigMergedFacetValue {
544    /// All the previous values are replaced by this merged facet value. This merged_value must be non-empty and can have up to 128 characters.
545    #[serde(rename = "mergedValue")]
546    pub merged_value: Option<String>,
547    /// All the facet values that are replaces by the same merged_value that follows. The maximum number of values per MergedFacetValue is 25. Each value can have up to 128 characters.
548    pub values: Option<Vec<String>>,
549}
550
551impl common::Part for GoogleCloudRetailV2CatalogAttributeFacetConfigMergedFacetValue {}
552
553/// Options to rerank based on facet values engaged by the user for the current key. That key needs to be a custom textual key and facetable. To use this control, you also need to pass all the facet keys engaged by the user in the request using the field [SearchRequest.FacetSpec]. In particular, if you don't pass the facet keys engaged that you want to rerank on, this control won't be effective. Moreover, to obtain better results, the facet values that you want to rerank on should be close to English (ideally made of words, underscores, and spaces).
554///
555/// This type is not used in any activity, and only used as *part* of another schema.
556///
557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
558#[serde_with::serde_as]
559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
560pub struct GoogleCloudRetailV2CatalogAttributeFacetConfigRerankConfig {
561    /// If empty, rerank on all facet values for the current key. Otherwise, will rerank on the facet values from this list only.
562    #[serde(rename = "facetValues")]
563    pub facet_values: Option<Vec<String>>,
564    /// If set to true, then we also rerank the dynamic facets based on the facet values engaged by the user for the current attribute key during serving.
565    #[serde(rename = "rerankFacet")]
566    pub rerank_facet: Option<bool>,
567}
568
569impl common::Part for GoogleCloudRetailV2CatalogAttributeFacetConfigRerankConfig {}
570
571/// Request message for CollectUserEvent method.
572///
573/// # Activities
574///
575/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
576/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
577///
578/// * [locations catalogs user events collect projects](ProjectLocationCatalogUserEventCollectCall) (request)
579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
580#[serde_with::serde_as]
581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
582pub struct GoogleCloudRetailV2CollectUserEventRequest {
583    /// The event timestamp in milliseconds. This prevents browser caching of otherwise identical get requests. The name is abbreviated to reduce the payload bytes.
584    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
585    pub ets: Option<i64>,
586    /// The prebuilt rule name that can convert a specific type of raw_json. For example: "ga4_bq" rule for the GA4 user event schema.
587    #[serde(rename = "prebuiltRule")]
588    pub prebuilt_rule: Option<String>,
589    /// An arbitrary serialized JSON string that contains necessary information that can comprise a user event. When this field is specified, the user_event field will be ignored. Note: line-delimited JSON is not supported, a single JSON only.
590    #[serde(rename = "rawJson")]
591    pub raw_json: Option<String>,
592    /// The URL including cgi-parameters but excluding the hash fragment with a length limit of 5,000 characters. This is often more useful than the referer URL, because many browsers only send the domain for 3rd party requests.
593    pub uri: Option<String>,
594    /// Required. URL encoded UserEvent proto with a length limit of 2,000,000 characters.
595    #[serde(rename = "userEvent")]
596    pub user_event: Option<String>,
597}
598
599impl common::RequestValue for GoogleCloudRetailV2CollectUserEventRequest {}
600
601/// The color information of a Product.
602///
603/// This type is not used in any activity, and only used as *part* of another schema.
604///
605#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
606#[serde_with::serde_as]
607#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
608pub struct GoogleCloudRetailV2ColorInfo {
609    /// The standard color families. Strongly recommended to use the following standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and "Mixed". Normally it is expected to have only 1 color family. May consider using single "Mixed" instead of multiple values. A maximum of 5 values are allowed. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Google Merchant Center property [color](https://support.google.com/merchants/answer/6324487). Schema.org property [Product.color](https://schema.org/color). The colorFamilies field as a system attribute is not a required field but strongly recommended to be specified. Google Search models treat this field as more important than a custom product attribute when specified.
610    #[serde(rename = "colorFamilies")]
611    pub color_families: Option<Vec<String>>,
612    /// The color display names, which may be different from standard color family names, such as the color aliases used in the website frontend. Normally it is expected to have only 1 color. May consider using single "Mixed" instead of multiple values. A maximum of 75 colors are allowed. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Google Merchant Center property [color](https://support.google.com/merchants/answer/6324487). Schema.org property [Product.color](https://schema.org/color).
613    pub colors: Option<Vec<String>>,
614}
615
616impl common::Part for GoogleCloudRetailV2ColorInfo {}
617
618/// Response of the autocomplete query.
619///
620/// # Activities
621///
622/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
623/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
624///
625/// * [locations catalogs complete query projects](ProjectLocationCatalogCompleteQueryCall) (response)
626#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
627#[serde_with::serde_as]
628#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
629pub struct GoogleCloudRetailV2CompleteQueryResponse {
630    /// A map of matched attribute suggestions. This field is only available for `cloud-retail` dataset. Current supported keys: * `brands` * `categories`
631    #[serde(rename = "attributeResults")]
632    pub attribute_results:
633        Option<HashMap<String, GoogleCloudRetailV2CompleteQueryResponseAttributeResult>>,
634    /// A unique complete token. This should be included in the UserEvent.completion_detail for search events resulting from this completion, which enables accurate attribution of complete model performance.
635    #[serde(rename = "attributionToken")]
636    pub attribution_token: Option<String>,
637    /// Results of the matching suggestions. The result list is ordered and the first result is top suggestion.
638    #[serde(rename = "completionResults")]
639    pub completion_results: Option<Vec<GoogleCloudRetailV2CompleteQueryResponseCompletionResult>>,
640    /// Deprecated. Matched recent searches of this user. The maximum number of recent searches is 10. This field is a restricted feature. If you want to enable it, contact Retail Search support. This feature is only available when CompleteQueryRequest.visitor_id field is set and UserEvent is imported. The recent searches satisfy the follow rules: * They are ordered from latest to oldest. * They are matched with CompleteQueryRequest.query case insensitively. * They are transformed to lower case. * They are UTF-8 safe. Recent searches are deduplicated. More recent searches will be reserved when duplication happens.
641    #[serde(rename = "recentSearchResults")]
642    pub recent_search_results:
643        Option<Vec<GoogleCloudRetailV2CompleteQueryResponseRecentSearchResult>>,
644}
645
646impl common::ResponseResult for GoogleCloudRetailV2CompleteQueryResponse {}
647
648/// Resource that represents attribute results.
649///
650/// This type is not used in any activity, and only used as *part* of another schema.
651///
652#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
653#[serde_with::serde_as]
654#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
655pub struct GoogleCloudRetailV2CompleteQueryResponseAttributeResult {
656    /// The list of suggestions for the attribute.
657    pub suggestions: Option<Vec<String>>,
658}
659
660impl common::Part for GoogleCloudRetailV2CompleteQueryResponseAttributeResult {}
661
662/// Resource that represents completion results.
663///
664/// This type is not used in any activity, and only used as *part* of another schema.
665///
666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
667#[serde_with::serde_as]
668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
669pub struct GoogleCloudRetailV2CompleteQueryResponseCompletionResult {
670    /// Custom attributes for the suggestion term. * For `user-data`, the attributes are additional custom attributes ingested through BigQuery. * For `cloud-retail`, the attributes are product attributes generated by Cloud Retail. It requires UserEvent.product_details is imported properly.
671    pub attributes: Option<HashMap<String, GoogleCloudRetailV2CustomAttribute>>,
672    /// The suggestion for the query.
673    pub suggestion: Option<String>,
674}
675
676impl common::Part for GoogleCloudRetailV2CompleteQueryResponseCompletionResult {}
677
678/// Deprecated: Recent search of this user.
679///
680/// This type is not used in any activity, and only used as *part* of another schema.
681///
682#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
683#[serde_with::serde_as]
684#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
685pub struct GoogleCloudRetailV2CompleteQueryResponseRecentSearchResult {
686    /// The recent search query.
687    #[serde(rename = "recentSearch")]
688    pub recent_search: Option<String>,
689}
690
691impl common::Part for GoogleCloudRetailV2CompleteQueryResponseRecentSearchResult {}
692
693/// Catalog level autocomplete config for customers to customize autocomplete feature’s settings.
694///
695/// # Activities
696///
697/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
698/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
699///
700/// * [locations catalogs get completion config projects](ProjectLocationCatalogGetCompletionConfigCall) (response)
701/// * [locations catalogs update completion config projects](ProjectLocationCatalogUpdateCompletionConfigCall) (request|response)
702#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
703#[serde_with::serde_as]
704#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
705pub struct GoogleCloudRetailV2CompletionConfig {
706    /// Output only. The source data for the latest import of the autocomplete allowlist phrases.
707    #[serde(rename = "allowlistInputConfig")]
708    pub allowlist_input_config: Option<GoogleCloudRetailV2CompletionDataInputConfig>,
709    /// If set to true, the auto learning function is enabled. Auto learning uses user data to generate suggestions using ML techniques. Default value is false. Only after enabling auto learning can users use `cloud-retail` data in CompleteQueryRequest.
710    #[serde(rename = "autoLearning")]
711    pub auto_learning: Option<bool>,
712    /// Output only. The source data for the latest import of the autocomplete denylist phrases.
713    #[serde(rename = "denylistInputConfig")]
714    pub denylist_input_config: Option<GoogleCloudRetailV2CompletionDataInputConfig>,
715    /// Output only. Name of the LRO corresponding to the latest allowlist import. Can use GetOperation API to retrieve the latest state of the Long Running Operation.
716    #[serde(rename = "lastAllowlistImportOperation")]
717    pub last_allowlist_import_operation: Option<String>,
718    /// Output only. Name of the LRO corresponding to the latest denylist import. Can use GetOperation API to retrieve the latest state of the Long Running Operation.
719    #[serde(rename = "lastDenylistImportOperation")]
720    pub last_denylist_import_operation: Option<String>,
721    /// Output only. Name of the LRO corresponding to the latest suggestion terms list import. Can use GetOperation API method to retrieve the latest state of the Long Running Operation.
722    #[serde(rename = "lastSuggestionsImportOperation")]
723    pub last_suggestions_import_operation: Option<String>,
724    /// Specifies the matching order for autocomplete suggestions, e.g., a query consisting of 'sh' with 'out-of-order' specified would suggest "women's shoes", whereas a query of 'red s' with 'exact-prefix' specified would suggest "red shoes". Currently supported values: * 'out-of-order' * 'exact-prefix' Default value: 'exact-prefix'.
725    #[serde(rename = "matchingOrder")]
726    pub matching_order: Option<String>,
727    /// The maximum number of autocomplete suggestions returned per term. Default value is 20. If left unset or set to 0, then will fallback to default value. Value range is 1 to 20.
728    #[serde(rename = "maxSuggestions")]
729    pub max_suggestions: Option<i32>,
730    /// The minimum number of characters needed to be typed in order to get suggestions. Default value is 2. If left unset or set to 0, then will fallback to default value. Value range is 1 to 20.
731    #[serde(rename = "minPrefixLength")]
732    pub min_prefix_length: Option<i32>,
733    /// Required. Immutable. Fully qualified name `projects/*/locations/*/catalogs/*/completionConfig`
734    pub name: Option<String>,
735    /// Output only. The source data for the latest import of the autocomplete suggestion phrases.
736    #[serde(rename = "suggestionsInputConfig")]
737    pub suggestions_input_config: Option<GoogleCloudRetailV2CompletionDataInputConfig>,
738}
739
740impl common::RequestValue for GoogleCloudRetailV2CompletionConfig {}
741impl common::ResponseResult for GoogleCloudRetailV2CompletionConfig {}
742
743/// The input config source for completion data.
744///
745/// This type is not used in any activity, and only used as *part* of another schema.
746///
747#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
748#[serde_with::serde_as]
749#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
750pub struct GoogleCloudRetailV2CompletionDataInputConfig {
751    /// Required. BigQuery input source. Add the IAM permission "BigQuery Data Viewer" for cloud-retail-customer-data-access@system.gserviceaccount.com before using this feature otherwise an error is thrown.
752    #[serde(rename = "bigQuerySource")]
753    pub big_query_source: Option<GoogleCloudRetailV2BigQuerySource>,
754}
755
756impl common::Part for GoogleCloudRetailV2CompletionDataInputConfig {}
757
758/// Detailed completion information including completion attribution token and clicked completion info.
759///
760/// This type is not used in any activity, and only used as *part* of another schema.
761///
762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
763#[serde_with::serde_as]
764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
765pub struct GoogleCloudRetailV2CompletionDetail {
766    /// Completion attribution token in CompleteQueryResponse.attribution_token.
767    #[serde(rename = "completionAttributionToken")]
768    pub completion_attribution_token: Option<String>,
769    /// End user selected CompleteQueryResponse.CompletionResult.suggestion position, starting from 0.
770    #[serde(rename = "selectedPosition")]
771    pub selected_position: Option<i32>,
772    /// End user selected CompleteQueryResponse.CompletionResult.suggestion.
773    #[serde(rename = "selectedSuggestion")]
774    pub selected_suggestion: Option<String>,
775}
776
777impl common::Part for GoogleCloudRetailV2CompletionDetail {}
778
779/// Metadata that is used to define a condition that triggers an action. A valid condition must specify at least one of 'query_terms' or 'products_filter'. If multiple fields are specified, the condition is met if all the fields are satisfied e.g. if a set of query terms and product_filter are set, then only items matching the product_filter for requests with a query matching the query terms wil get boosted.
780///
781/// This type is not used in any activity, and only used as *part* of another schema.
782///
783#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
784#[serde_with::serde_as]
785#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
786pub struct GoogleCloudRetailV2Condition {
787    /// Range of time(s) specifying when Condition is active. Condition true if any time range matches.
788    #[serde(rename = "activeTimeRange")]
789    pub active_time_range: Option<Vec<GoogleCloudRetailV2ConditionTimeRange>>,
790    /// Used to support browse uses cases. A list (up to 10 entries) of categories or departments. The format should be the same as UserEvent.page_categories;
791    #[serde(rename = "pageCategories")]
792    pub page_categories: Option<Vec<String>>,
793    /// A list (up to 10 entries) of terms to match the query on. If not specified, match all queries. If many query terms are specified, the condition is matched if any of the terms is a match (i.e. using the OR operator).
794    #[serde(rename = "queryTerms")]
795    pub query_terms: Option<Vec<GoogleCloudRetailV2ConditionQueryTerm>>,
796}
797
798impl common::Part for GoogleCloudRetailV2Condition {}
799
800/// Query terms that we want to match on.
801///
802/// This type is not used in any activity, and only used as *part* of another schema.
803///
804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
805#[serde_with::serde_as]
806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
807pub struct GoogleCloudRetailV2ConditionQueryTerm {
808    /// Whether this is supposed to be a full or partial match.
809    #[serde(rename = "fullMatch")]
810    pub full_match: Option<bool>,
811    /// The value of the term to match on. Value cannot be empty. Value can have at most 3 terms if specified as a partial match. Each space separated string is considered as one term. For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms and not allowed for a partial match.
812    pub value: Option<String>,
813}
814
815impl common::Part for GoogleCloudRetailV2ConditionQueryTerm {}
816
817/// Used for time-dependent conditions. Example: Want to have rule applied for week long sale.
818///
819/// This type is not used in any activity, and only used as *part* of another schema.
820///
821#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
822#[serde_with::serde_as]
823#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
824pub struct GoogleCloudRetailV2ConditionTimeRange {
825    /// End of time range. Range is inclusive.
826    #[serde(rename = "endTime")]
827    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
828    /// Start of time range. Range is inclusive.
829    #[serde(rename = "startTime")]
830    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
831}
832
833impl common::Part for GoogleCloudRetailV2ConditionTimeRange {}
834
835/// Configures dynamic metadata that can be linked to a ServingConfig and affect search or recommendation results at serving time.
836///
837/// # Activities
838///
839/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
840/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
841///
842/// * [locations catalogs controls create projects](ProjectLocationCatalogControlCreateCall) (request|response)
843/// * [locations catalogs controls get projects](ProjectLocationCatalogControlGetCall) (response)
844/// * [locations catalogs controls patch projects](ProjectLocationCatalogControlPatchCall) (request|response)
845#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
846#[serde_with::serde_as]
847#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
848pub struct GoogleCloudRetailV2Control {
849    /// Output only. List of serving config ids that are associated with this control in the same Catalog. Note the association is managed via the ServingConfig, this is an output only denormalized view.
850    #[serde(rename = "associatedServingConfigIds")]
851    pub associated_serving_config_ids: Option<Vec<String>>,
852    /// Required. The human readable control display name. Used in Retail UI. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is thrown.
853    #[serde(rename = "displayName")]
854    pub display_name: Option<String>,
855    /// Immutable. Fully qualified name `projects/*/locations/global/catalogs/*/controls/*`
856    pub name: Option<String>,
857    /// A rule control - a condition-action pair. Enacts a set action when the condition is triggered. For example: Boost "gShoe" when query full matches "Running Shoes".
858    pub rule: Option<GoogleCloudRetailV2Rule>,
859    /// Specifies the use case for the control. Affects what condition fields can be set. Only settable by search controls. Will default to SEARCH_SOLUTION_USE_CASE_SEARCH if not specified. Currently only allow one search_solution_use_case per control.
860    #[serde(rename = "searchSolutionUseCase")]
861    pub search_solution_use_case: Option<Vec<String>>,
862    /// Required. Immutable. The solution types that the control is used for. Currently we support setting only one type of solution at creation time. Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. If no solution type is provided at creation time, will default to SOLUTION_TYPE_SEARCH.
863    #[serde(rename = "solutionTypes")]
864    pub solution_types: Option<Vec<String>>,
865}
866
867impl common::RequestValue for GoogleCloudRetailV2Control {}
868impl common::ResponseResult for GoogleCloudRetailV2Control {}
869
870/// The public proto to represent the conversational search customization config. It will be converted to the internal proto in the backend.
871///
872/// # Activities
873///
874/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
875/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
876///
877/// * [locations catalogs get conversational search customization config projects](ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall) (response)
878/// * [locations catalogs update conversational search customization config projects](ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall) (request|response)
879#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
880#[serde_with::serde_as]
881#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
882pub struct GoogleCloudRetailV2ConversationalSearchCustomizationConfig {
883    /// Required. Resource name of the catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
884    pub catalog: Option<String>,
885    /// Optional. The configs for intent classification.
886    #[serde(rename = "intentClassificationConfig")]
887    pub intent_classification_config: Option<GoogleCloudRetailV2IntentClassificationConfig>,
888    /// Optional. The retailer's display name that could be used in our LLM answers. Example - "Google"
889    #[serde(rename = "retailerDisplayName")]
890    pub retailer_display_name: Option<String>,
891}
892
893impl common::RequestValue for GoogleCloudRetailV2ConversationalSearchCustomizationConfig {}
894impl common::ResponseResult for GoogleCloudRetailV2ConversationalSearchCustomizationConfig {}
895
896/// Request message for ConversationalSearchService.ConversationalSearch method.
897///
898/// # Activities
899///
900/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
901/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
902///
903/// * [locations catalogs placements conversational search projects](ProjectLocationCatalogPlacementConversationalSearchCall) (request)
904/// * [locations catalogs serving configs conversational search projects](ProjectLocationCatalogServingConfigConversationalSearchCall) (request)
905#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
906#[serde_with::serde_as]
907#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
908pub struct GoogleCloudRetailV2ConversationalSearchRequest {
909    /// Required. The branch resource name, such as `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use "default_branch" as the branch ID or leave this field empty, to search products under the default branch.
910    pub branch: Option<String>,
911    /// Optional. This field specifies the conversation id, which maintains the state of the conversation between client side and server side. Use the value from the previous ConversationalSearchResponse.conversation_id. For the initial request, this should be empty.
912    #[serde(rename = "conversationId")]
913    pub conversation_id: Option<String>,
914    /// Optional. This field specifies all conversational filtering related parameters.
915    #[serde(rename = "conversationalFilteringSpec")]
916    pub conversational_filtering_spec:
917        Option<GoogleCloudRetailV2ConversationalSearchRequestConversationalFilteringSpec>,
918    /// Optional. The categories associated with a category page. Must be set for category navigation queries to achieve good search quality. The format should be the same as UserEvent.page_categories; To represent full path of category, use '>' sign to separate different hierarchies. If '>' is part of the category name, replace it with other character(s). Category pages include special pages such as sales or promotions. For instance, a special sale page may have the category hierarchy: "pageCategories" : ["Sales > 2017 Black Friday Deals"].
919    #[serde(rename = "pageCategories")]
920    pub page_categories: Option<Vec<String>>,
921    /// Optional. Raw search query to be searched for. If this field is empty, the request is considered a category browsing request.
922    pub query: Option<String>,
923    /// Optional. The safety settings to be applied to the generated content.
924    #[serde(rename = "safetySettings")]
925    pub safety_settings: Option<Vec<GoogleCloudRetailV2SafetySetting>>,
926    /// Optional. Search parameters.
927    #[serde(rename = "searchParams")]
928    pub search_params: Option<GoogleCloudRetailV2ConversationalSearchRequestSearchParams>,
929    /// Optional. User information.
930    #[serde(rename = "userInfo")]
931    pub user_info: Option<GoogleCloudRetailV2UserInfo>,
932    /// Optional. The user labels applied to a resource must meet the following requirements: * Each resource can have multiple labels, up to a maximum of 64. * Each label must be a key-value pair. * Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters. * Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. * The key portion of a label must be unique. However, you can use the same key with multiple resources. * Keys must start with a lowercase letter or international character. See [Google Cloud Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) for more details.
933    #[serde(rename = "userLabels")]
934    pub user_labels: Option<HashMap<String, String>>,
935    /// Required. A unique identifier for tracking visitors. 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. This should be the same identifier as UserEvent.visitor_id. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
936    #[serde(rename = "visitorId")]
937    pub visitor_id: Option<String>,
938}
939
940impl common::RequestValue for GoogleCloudRetailV2ConversationalSearchRequest {}
941
942/// This field specifies all conversational filtering related parameters addition to conversational retail search.
943///
944/// This type is not used in any activity, and only used as *part* of another schema.
945///
946#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
947#[serde_with::serde_as]
948#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
949pub struct GoogleCloudRetailV2ConversationalSearchRequestConversationalFilteringSpec {
950    /// Optional. Mode to control Conversational Filtering. Defaults to Mode.DISABLED if it's unset.
951    #[serde(rename = "conversationalFilteringMode")]
952    pub conversational_filtering_mode: Option<String>,
953    /// Optional. This field is deprecated. Please use ConversationalFilteringSpec.conversational_filtering_mode instead.
954    #[serde(rename = "enableConversationalFiltering")]
955    pub enable_conversational_filtering: Option<bool>,
956    /// Optional. This field specifies the current user answer during the conversational filtering search. It can be either user selected from suggested answers or user input plain text.
957    #[serde(rename = "userAnswer")]
958    pub user_answer: Option<GoogleCloudRetailV2ConversationalSearchRequestUserAnswer>,
959}
960
961impl common::Part for GoogleCloudRetailV2ConversationalSearchRequestConversationalFilteringSpec {}
962
963/// Search parameters.
964///
965/// This type is not used in any activity, and only used as *part* of another schema.
966///
967#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
968#[serde_with::serde_as]
969#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
970pub struct GoogleCloudRetailV2ConversationalSearchRequestSearchParams {
971    /// Optional. The boost spec to specify the boosting of search results. The syntax of the boost spec is the same as SearchRequest.boost_spec.
972    #[serde(rename = "boostSpec")]
973    pub boost_spec: Option<GoogleCloudRetailV2SearchRequestBoostSpec>,
974    /// Optional. The canonical filter string to restrict search results. The syntax of the canonical filter string is the same as SearchRequest.canonical_filter.
975    #[serde(rename = "canonicalFilter")]
976    pub canonical_filter: Option<String>,
977    /// Optional. The filter string to restrict search results. The syntax of the filter string is the same as SearchRequest.filter.
978    pub filter: Option<String>,
979    /// Optional. The sort string to specify the sorting of search results. The syntax of the sort string is the same as SearchRequest.sort.
980    #[serde(rename = "sortBy")]
981    pub sort_by: Option<String>,
982}
983
984impl common::Part for GoogleCloudRetailV2ConversationalSearchRequestSearchParams {}
985
986/// This field specifies the current user answer during the conversational filtering search. This can be either user selected from suggested answers or user input plain text.
987///
988/// This type is not used in any activity, and only used as *part* of another schema.
989///
990#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
991#[serde_with::serde_as]
992#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
993pub struct GoogleCloudRetailV2ConversationalSearchRequestUserAnswer {
994    /// Optional. This field specifies the selected answer during the conversational search. This should be a subset of ConversationalSearchResponse.followup_question.suggested_answers.
995    #[serde(rename = "selectedAnswer")]
996    pub selected_answer:
997        Option<GoogleCloudRetailV2ConversationalSearchRequestUserAnswerSelectedAnswer>,
998    /// This field specifies the incremental input text from the user during the conversational search.
999    #[serde(rename = "textAnswer")]
1000    pub text_answer: Option<String>,
1001}
1002
1003impl common::Part for GoogleCloudRetailV2ConversationalSearchRequestUserAnswer {}
1004
1005/// This field specifies the selected answers during the conversational search.
1006///
1007/// This type is not used in any activity, and only used as *part* of another schema.
1008///
1009#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1010#[serde_with::serde_as]
1011#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1012pub struct GoogleCloudRetailV2ConversationalSearchRequestUserAnswerSelectedAnswer {
1013    /// Optional. This field specifies the selected answer which is a attribute key-value.
1014    #[serde(rename = "productAttributeValue")]
1015    pub product_attribute_value: Option<GoogleCloudRetailV2ProductAttributeValue>,
1016}
1017
1018impl common::Part for GoogleCloudRetailV2ConversationalSearchRequestUserAnswerSelectedAnswer {}
1019
1020/// Response message for ConversationalSearchService.ConversationalSearch method.
1021///
1022/// # Activities
1023///
1024/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1025/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1026///
1027/// * [locations catalogs placements conversational search projects](ProjectLocationCatalogPlacementConversationalSearchCall) (response)
1028/// * [locations catalogs serving configs conversational search projects](ProjectLocationCatalogServingConfigConversationalSearchCall) (response)
1029#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1030#[serde_with::serde_as]
1031#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1032pub struct GoogleCloudRetailV2ConversationalSearchResponse {
1033    /// Conversation UUID. This field will be stored in client side storage to maintain the conversation session with server and will be used for next search request's ConversationalSearchRequest.conversation_id to restore conversation state in server.
1034    #[serde(rename = "conversationId")]
1035    pub conversation_id: Option<String>,
1036    /// This field specifies all related information that is needed on client side for UI rendering of conversational filtering search.
1037    #[serde(rename = "conversationalFilteringResult")]
1038    pub conversational_filtering_result:
1039        Option<GoogleCloudRetailV2ConversationalSearchResponseConversationalFilteringResult>,
1040    /// The conversational answer-based text response generated by the Server.
1041    #[serde(rename = "conversationalTextResponse")]
1042    pub conversational_text_response: Option<String>,
1043    /// The conversational followup question generated for Intent refinement.
1044    #[serde(rename = "followupQuestion")]
1045    pub followup_question: Option<GoogleCloudRetailV2ConversationalSearchResponseFollowupQuestion>,
1046    /// The proposed refined search queries. They can be used to fetch the relevant search results. When using CONVERSATIONAL_FILTER_ONLY mode, the refined_query from search response will be populated here.
1047    #[serde(rename = "refinedSearch")]
1048    pub refined_search: Option<Vec<GoogleCloudRetailV2ConversationalSearchResponseRefinedSearch>>,
1049    /// Output only. The state of the response generation.
1050    pub state: Option<String>,
1051    /// The types Retail classifies the search query as. Supported values are: - "ORDER_SUPPORT" - "SIMPLE_PRODUCT_SEARCH" - "INTENT_REFINEMENT" - "PRODUCT_DETAILS" - "PRODUCT_COMPARISON" - "DEALS_AND_COUPONS" - "STORE_RELEVANT" - "BLOCKLISTED" - "BEST_PRODUCT" - "RETAIL_SUPPORT" - "DISABLED"
1052    #[serde(rename = "userQueryTypes")]
1053    pub user_query_types: Option<Vec<String>>,
1054}
1055
1056impl common::ResponseResult for GoogleCloudRetailV2ConversationalSearchResponse {}
1057
1058/// This field specifies all related information that is needed on client side for UI rendering of conversational filtering search.
1059///
1060/// This type is not used in any activity, and only used as *part* of another schema.
1061///
1062#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1063#[serde_with::serde_as]
1064#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1065pub struct GoogleCloudRetailV2ConversationalSearchResponseConversationalFilteringResult {
1066    /// This is the incremental additional filters implied from the current user answer. User should add the suggested addition filters to the previous ConversationalSearchRequest.search_params.filter and SearchRequest.filter, and use the merged filter in the follow up requests.
1067    #[serde(rename="additionalFilter")]
1068        pub additional_filter: Option<GoogleCloudRetailV2ConversationalSearchResponseConversationalFilteringResultAdditionalFilter>,
1069    /// The conversational filtering question.
1070    #[serde(rename="followupQuestion")]
1071        pub followup_question: Option<GoogleCloudRetailV2ConversationalSearchResponseFollowupQuestion>,
1072}
1073
1074impl common::Part for GoogleCloudRetailV2ConversationalSearchResponseConversationalFilteringResult {}
1075
1076/// Additional filter that client side need to apply.
1077///
1078/// This type is not used in any activity, and only used as *part* of another schema.
1079///
1080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1081#[serde_with::serde_as]
1082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1083pub struct GoogleCloudRetailV2ConversationalSearchResponseConversationalFilteringResultAdditionalFilter
1084{
1085    /// Product attribute value, including an attribute key and an attribute value. Other types can be added here in the future.
1086    #[serde(rename = "productAttributeValue")]
1087    pub product_attribute_value: Option<GoogleCloudRetailV2ProductAttributeValue>,
1088}
1089
1090impl common::Part
1091    for GoogleCloudRetailV2ConversationalSearchResponseConversationalFilteringResultAdditionalFilter
1092{
1093}
1094
1095/// The conversational followup question generated for Intent refinement.
1096///
1097/// This type is not used in any activity, and only used as *part* of another schema.
1098///
1099#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1100#[serde_with::serde_as]
1101#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1102pub struct GoogleCloudRetailV2ConversationalSearchResponseFollowupQuestion {
1103    /// The conversational followup question generated for Intent refinement.
1104    #[serde(rename = "followupQuestion")]
1105    pub followup_question: Option<String>,
1106    /// The answer options provided to client for the follow-up question.
1107    #[serde(rename = "suggestedAnswers")]
1108    pub suggested_answers:
1109        Option<Vec<GoogleCloudRetailV2ConversationalSearchResponseFollowupQuestionSuggestedAnswer>>,
1110}
1111
1112impl common::Part for GoogleCloudRetailV2ConversationalSearchResponseFollowupQuestion {}
1113
1114/// Suggested answers to the follow-up question. If it's numerical attribute, only ProductAttributeInterval will be set. If it's textual attribute, only productAttributeValue will be set.
1115///
1116/// This type is not used in any activity, and only used as *part* of another schema.
1117///
1118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1119#[serde_with::serde_as]
1120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1121pub struct GoogleCloudRetailV2ConversationalSearchResponseFollowupQuestionSuggestedAnswer {
1122    /// Product attribute value, including an attribute key and an attribute value. Other types can be added here in the future.
1123    #[serde(rename = "productAttributeValue")]
1124    pub product_attribute_value: Option<GoogleCloudRetailV2ProductAttributeValue>,
1125}
1126
1127impl common::Part
1128    for GoogleCloudRetailV2ConversationalSearchResponseFollowupQuestionSuggestedAnswer
1129{
1130}
1131
1132/// The proposed refined search for intent-refinement/bundled shopping conversation. When using CONVERSATIONAL_FILTER_ONLY mode, the refined_query from search response will be populated here.
1133///
1134/// This type is not used in any activity, and only used as *part* of another schema.
1135///
1136#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1137#[serde_with::serde_as]
1138#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1139pub struct GoogleCloudRetailV2ConversationalSearchResponseRefinedSearch {
1140    /// The query to be used for search.
1141    pub query: Option<String>,
1142}
1143
1144impl common::Part for GoogleCloudRetailV2ConversationalSearchResponseRefinedSearch {}
1145
1146/// A custom attribute that is not explicitly modeled in Product.
1147///
1148/// This type is not used in any activity, and only used as *part* of another schema.
1149///
1150#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1151#[serde_with::serde_as]
1152#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1153pub struct GoogleCloudRetailV2CustomAttribute {
1154    /// This field is normally ignored unless AttributesConfig.attribute_config_level of the Catalog is set to the deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level attribute configuration, see [Configuration modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). If true, custom attribute values are indexed, so that they can be filtered, faceted or boosted in SearchService.Search. This field is ignored in a UserEvent. See SearchRequest.filter, SearchRequest.facet_specs and SearchRequest.boost_spec for more details.
1155    pub indexable: Option<bool>,
1156    /// The numerical values of this custom attribute. For example, `[2.3, 15.4]` when the key is "lengths_cm". Exactly one of text or numbers should be set. Otherwise, an INVALID_ARGUMENT error is returned.
1157    pub numbers: Option<Vec<f64>>,
1158    /// This field is normally ignored unless AttributesConfig.attribute_config_level of the Catalog is set to the deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level attribute configuration, see [Configuration modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). If true, custom attribute values are searchable by text queries in SearchService.Search. This field is ignored in a UserEvent. Only set if type text is set. Otherwise, a INVALID_ARGUMENT error is returned.
1159    pub searchable: Option<bool>,
1160    /// The textual values of this custom attribute. For example, `["yellow", "green"]` when the key is "color". Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is returned. Exactly one of text or numbers should be set. Otherwise, an INVALID_ARGUMENT error is returned.
1161    pub text: Option<Vec<String>>,
1162}
1163
1164impl common::Part for GoogleCloudRetailV2CustomAttribute {}
1165
1166/// A message with a list of double values.
1167///
1168/// This type is not used in any activity, and only used as *part* of another schema.
1169///
1170#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1171#[serde_with::serde_as]
1172#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1173pub struct GoogleCloudRetailV2DoubleList {
1174    /// The list of double values.
1175    pub values: Option<Vec<f64>>,
1176}
1177
1178impl common::Part for GoogleCloudRetailV2DoubleList {}
1179
1180/// Metadata for active A/B testing experiment.
1181///
1182/// This type is not used in any activity, and only used as *part* of another schema.
1183///
1184#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1185#[serde_with::serde_as]
1186#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1187pub struct GoogleCloudRetailV2ExperimentInfo {
1188    /// The fully qualified resource name of the experiment that provides the serving config under test, should an active experiment exist. For example: `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id`
1189    pub experiment: Option<String>,
1190    /// A/B test between existing Cloud Retail Search ServingConfigs.
1191    #[serde(rename = "servingConfigExperiment")]
1192    pub serving_config_experiment: Option<GoogleCloudRetailV2ExperimentInfoServingConfigExperiment>,
1193}
1194
1195impl common::Part for GoogleCloudRetailV2ExperimentInfo {}
1196
1197/// Metadata for active serving config A/B tests.
1198///
1199/// This type is not used in any activity, and only used as *part* of another schema.
1200///
1201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1202#[serde_with::serde_as]
1203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1204pub struct GoogleCloudRetailV2ExperimentInfoServingConfigExperiment {
1205    /// The fully qualified resource name of the serving config `Experiment.VariantArm.serving_config_id` responsible for generating the search response. For example: `projects/*/locations/*/catalogs/*/servingConfigs/*`.
1206    #[serde(rename = "experimentServingConfig")]
1207    pub experiment_serving_config: Option<String>,
1208    /// The fully qualified resource name of the original SearchRequest.placement in the search request prior to reassignment by experiment API. For example: `projects/*/locations/*/catalogs/*/servingConfigs/*`.
1209    #[serde(rename = "originalServingConfig")]
1210    pub original_serving_config: Option<String>,
1211}
1212
1213impl common::Part for GoogleCloudRetailV2ExperimentInfoServingConfigExperiment {}
1214
1215/// Request message for the `ExportAnalyticsMetrics` method.
1216///
1217/// # Activities
1218///
1219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1221///
1222/// * [locations catalogs export analytics metrics projects](ProjectLocationCatalogExportAnalyticsMetricCall) (request)
1223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1224#[serde_with::serde_as]
1225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1226pub struct GoogleCloudRetailV2ExportAnalyticsMetricsRequest {
1227    /// A filtering expression to specify restrictions on returned metrics. The expression is a sequence of terms. Each term applies a restriction to the returned metrics. Use this expression to restrict results to a specific time range. Currently we expect only one types of fields: * `timestamp`: This can be specified twice, once with a less than operator and once with a greater than operator. The `timestamp` restriction should result in one, contiguous, valid, `timestamp` range. Some examples of valid filters expressions: * Example 1: `timestamp > "2012-04-23T18:25:43.511Z" timestamp < "2012-04-23T18:30:43.511Z"` * Example 2: `timestamp > "2012-04-23T18:25:43.511Z"`
1228    pub filter: Option<String>,
1229    /// Required. The output location of the data.
1230    #[serde(rename = "outputConfig")]
1231    pub output_config: Option<GoogleCloudRetailV2OutputConfig>,
1232}
1233
1234impl common::RequestValue for GoogleCloudRetailV2ExportAnalyticsMetricsRequest {}
1235
1236/// Fulfillment information, such as the store IDs for in-store pickup or region IDs for different shipping methods.
1237///
1238/// This type is not used in any activity, and only used as *part* of another schema.
1239///
1240#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1241#[serde_with::serde_as]
1242#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1243pub struct GoogleCloudRetailV2FulfillmentInfo {
1244    /// The IDs for this type, such as the store IDs for FulfillmentInfo.type.pickup-in-store or the region IDs for FulfillmentInfo.type.same-day-delivery. A maximum of 3000 values are allowed. Each value must be a string with a length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is returned.
1245    #[serde(rename = "placeIds")]
1246    pub place_ids: Option<Vec<String>>,
1247    /// The fulfillment type, including commonly used types (such as pickup in store and same day delivery), and custom types. Customers have to map custom types to their display names before rendering UI. Supported values: * "pickup-in-store" * "ship-to-store" * "same-day-delivery" * "next-day-delivery" * "custom-type-1" * "custom-type-2" * "custom-type-3" * "custom-type-4" * "custom-type-5" If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned.
1248    #[serde(rename = "type")]
1249    pub type_: Option<String>,
1250}
1251
1252impl common::Part for GoogleCloudRetailV2FulfillmentInfo {}
1253
1254/// Google Cloud Storage location for input content.
1255///
1256/// This type is not used in any activity, and only used as *part* of another schema.
1257///
1258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1259#[serde_with::serde_as]
1260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1261pub struct GoogleCloudRetailV2GcsSource {
1262    /// The schema to use when parsing the data from the source. Supported values for product imports: * `product` (default): One JSON Product per line. Each product must have a valid Product.id. * `product_merchant_center`: See [Importing catalog data from Merchant Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). Supported values for user events imports: * `user_event` (default): One JSON UserEvent per line. * `user_event_ga360`: Using https://support.google.com/analytics/answer/3437719. Supported values for control imports: * `control` (default): One JSON Control per line. Supported values for catalog attribute imports: * `catalog_attribute` (default): One CSV CatalogAttribute per line.
1263    #[serde(rename = "dataSchema")]
1264    pub data_schema: Option<String>,
1265    /// 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 product information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) for the expected file format and setup instructions.
1266    #[serde(rename = "inputUris")]
1267    pub input_uris: Option<Vec<String>>,
1268}
1269
1270impl common::Part for GoogleCloudRetailV2GcsSource {}
1271
1272/// Configuration for a single generated question.
1273///
1274/// # Activities
1275///
1276/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1277/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1278///
1279/// * [locations catalogs update generative question projects](ProjectLocationCatalogUpdateGenerativeQuestionCall) (request|response)
1280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1281#[serde_with::serde_as]
1282#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1283pub struct GoogleCloudRetailV2GenerativeQuestionConfig {
1284    /// Optional. Whether the question is asked at serving time.
1285    #[serde(rename = "allowedInConversation")]
1286    pub allowed_in_conversation: Option<bool>,
1287    /// Required. Resource name of the catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
1288    pub catalog: Option<String>,
1289    /// Output only. Values that can be used to answer the question.
1290    #[serde(rename = "exampleValues")]
1291    pub example_values: Option<Vec<String>>,
1292    /// Required. The facet to which the question is associated.
1293    pub facet: Option<String>,
1294    /// Optional. The question that will be used at serving time. Question can have a max length of 300 bytes. When not populated, generated_question should be used.
1295    #[serde(rename = "finalQuestion")]
1296    pub final_question: Option<String>,
1297    /// Output only. The ratio of how often a question was asked.
1298    pub frequency: Option<f32>,
1299    /// Output only. The LLM generated question.
1300    #[serde(rename = "generatedQuestion")]
1301    pub generated_question: Option<String>,
1302}
1303
1304impl common::RequestValue for GoogleCloudRetailV2GenerativeQuestionConfig {}
1305impl common::ResponseResult for GoogleCloudRetailV2GenerativeQuestionConfig {}
1306
1307/// Configuration for overall generative question feature state.
1308///
1309/// # Activities
1310///
1311/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1312/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1313///
1314/// * [locations catalogs get generative question feature projects](ProjectLocationCatalogGetGenerativeQuestionFeatureCall) (response)
1315/// * [locations catalogs update generative question feature projects](ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall) (request|response)
1316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1317#[serde_with::serde_as]
1318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1319pub struct GoogleCloudRetailV2GenerativeQuestionsFeatureConfig {
1320    /// Required. Resource name of the affected catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
1321    pub catalog: Option<String>,
1322    /// Optional. Determines whether questions will be used at serving time. Note: This feature cannot be enabled until initial data requirements are satisfied.
1323    #[serde(rename = "featureEnabled")]
1324    pub feature_enabled: Option<bool>,
1325    /// Optional. Minimum number of products in the response to trigger follow-up questions. Value must be 0 or positive.
1326    #[serde(rename = "minimumProducts")]
1327    pub minimum_products: Option<i32>,
1328}
1329
1330impl common::RequestValue for GoogleCloudRetailV2GenerativeQuestionsFeatureConfig {}
1331impl common::ResponseResult for GoogleCloudRetailV2GenerativeQuestionsFeatureConfig {}
1332
1333/// Response message of CatalogService.GetDefaultBranch.
1334///
1335/// # Activities
1336///
1337/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1338/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1339///
1340/// * [locations catalogs get default branch projects](ProjectLocationCatalogGetDefaultBranchCall) (response)
1341#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1342#[serde_with::serde_as]
1343#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1344pub struct GoogleCloudRetailV2GetDefaultBranchResponse {
1345    /// Full resource name of the branch id currently set as default branch.
1346    pub branch: Option<String>,
1347    /// This corresponds to SetDefaultBranchRequest.note field, when this branch was set as default.
1348    pub note: Option<String>,
1349    /// The time when this branch is set to default.
1350    #[serde(rename = "setTime")]
1351    pub set_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1352}
1353
1354impl common::ResponseResult for GoogleCloudRetailV2GetDefaultBranchResponse {}
1355
1356/// Product image. Recommendations AI and Retail Search use product images to improve prediction and search results. Product images can be returned in results, and are shown in prediction or search previews in the console. Please try to provide correct product images and avoid using images with size too small.
1357///
1358/// This type is not used in any activity, and only used as *part* of another schema.
1359///
1360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1361#[serde_with::serde_as]
1362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1363pub struct GoogleCloudRetailV2Image {
1364    /// Height of the image in number of pixels. This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is returned.
1365    pub height: Option<i32>,
1366    /// Required. URI of the image. This field must be a valid UTF-8 encoded URI with a length limit of 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. Google Merchant Center property [image_link](https://support.google.com/merchants/answer/6324350). Schema.org property [Product.image](https://schema.org/image).
1367    pub uri: Option<String>,
1368    /// Width of the image in number of pixels. This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is returned.
1369    pub width: Option<i32>,
1370}
1371
1372impl common::Part for GoogleCloudRetailV2Image {}
1373
1374/// Request message for ImportCompletionData methods.
1375///
1376/// # Activities
1377///
1378/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1379/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1380///
1381/// * [locations catalogs completion data import projects](ProjectLocationCatalogCompletionDataImportCall) (request)
1382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1383#[serde_with::serde_as]
1384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1385pub struct GoogleCloudRetailV2ImportCompletionDataRequest {
1386    /// Required. The desired input location of the data.
1387    #[serde(rename = "inputConfig")]
1388    pub input_config: Option<GoogleCloudRetailV2CompletionDataInputConfig>,
1389    /// Pub/Sub topic for receiving notification. If this field is set, when the import is finished, a notification is sent to specified Pub/Sub topic. The message data is JSON string of a Operation. Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`.
1390    #[serde(rename = "notificationPubsubTopic")]
1391    pub notification_pubsub_topic: Option<String>,
1392}
1393
1394impl common::RequestValue for GoogleCloudRetailV2ImportCompletionDataRequest {}
1395
1396/// Configuration of destination for Import related errors.
1397///
1398/// This type is not used in any activity, and only used as *part* of another schema.
1399///
1400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1401#[serde_with::serde_as]
1402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1403pub struct GoogleCloudRetailV2ImportErrorsConfig {
1404    /// Google Cloud Storage prefix for import errors. This must be an empty, existing Cloud Storage directory. Import errors are written to sharded files in this directory, one per line, as a JSON-encoded `google.rpc.Status` message.
1405    #[serde(rename = "gcsPrefix")]
1406    pub gcs_prefix: Option<String>,
1407}
1408
1409impl common::Part for GoogleCloudRetailV2ImportErrorsConfig {}
1410
1411/// Request message for Import methods.
1412///
1413/// # Activities
1414///
1415/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1416/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1417///
1418/// * [locations catalogs branches products import projects](ProjectLocationCatalogBranchProductImportCall) (request)
1419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1420#[serde_with::serde_as]
1421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1422pub struct GoogleCloudRetailV2ImportProductsRequest {
1423    /// The desired location of errors incurred during the Import.
1424    #[serde(rename = "errorsConfig")]
1425    pub errors_config: Option<GoogleCloudRetailV2ImportErrorsConfig>,
1426    /// Required. The desired input location of the data.
1427    #[serde(rename = "inputConfig")]
1428    pub input_config: Option<GoogleCloudRetailV2ProductInputConfig>,
1429    /// Full Pub/Sub topic name for receiving notification. If this field is set, when the import is finished, a notification is sent to specified Pub/Sub topic. The message data is JSON string of a Operation. Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has to be within the same project as ImportProductsRequest.parent. Make sure that both `cloud-retail-customer-data-access@system.gserviceaccount.com` and `service-@gcp-sa-retail.iam.gserviceaccount.com` have the `pubsub.topics.publish` IAM permission on the topic. Only supported when ImportProductsRequest.reconciliation_mode is set to `FULL`.
1430    #[serde(rename = "notificationPubsubTopic")]
1431    pub notification_pubsub_topic: Option<String>,
1432    /// The mode of reconciliation between existing products and the products to be imported. Defaults to ReconciliationMode.INCREMENTAL.
1433    #[serde(rename = "reconciliationMode")]
1434    pub reconciliation_mode: Option<String>,
1435    /// Deprecated. This field has no effect.
1436    #[serde(rename = "requestId")]
1437    pub request_id: Option<String>,
1438    /// Indicates which fields in the provided imported `products` to update. If not set, all fields are updated. If provided, only the existing product fields are updated. Missing products will not be created.
1439    #[serde(rename = "updateMask")]
1440    pub update_mask: Option<common::FieldMask>,
1441}
1442
1443impl common::RequestValue for GoogleCloudRetailV2ImportProductsRequest {}
1444
1445/// Request message for the ImportUserEvents request.
1446///
1447/// # Activities
1448///
1449/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1450/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1451///
1452/// * [locations catalogs user events import projects](ProjectLocationCatalogUserEventImportCall) (request)
1453#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1454#[serde_with::serde_as]
1455#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1456pub struct GoogleCloudRetailV2ImportUserEventsRequest {
1457    /// The desired location of errors incurred during the Import. Cannot be set for inline user event imports.
1458    #[serde(rename = "errorsConfig")]
1459    pub errors_config: Option<GoogleCloudRetailV2ImportErrorsConfig>,
1460    /// Required. The desired input location of the data.
1461    #[serde(rename = "inputConfig")]
1462    pub input_config: Option<GoogleCloudRetailV2UserEventInputConfig>,
1463}
1464
1465impl common::RequestValue for GoogleCloudRetailV2ImportUserEventsRequest {}
1466
1467/// The public proto to represent the intent classification config. It will be converted to the internal proto in the backend.
1468///
1469/// This type is not used in any activity, and only used as *part* of another schema.
1470///
1471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1472#[serde_with::serde_as]
1473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1474pub struct GoogleCloudRetailV2IntentClassificationConfig {
1475    /// Optional. A list of keywords that will be used to classify the query to the "BLOCKLISTED" intent type. The keywords are case insensitive.
1476    #[serde(rename = "blocklistKeywords")]
1477    pub blocklist_keywords: Option<Vec<String>>,
1478    /// Optional. A list of intent types that will be disabled for this customer. The intent types must match one of the predefined intent types defined at https://cloud.google.com/retail/docs/reference/rpc/google.cloud.retail.v2alpha#querytype
1479    #[serde(rename = "disabledIntentTypes")]
1480    pub disabled_intent_types: Option<Vec<String>>,
1481    /// Optional. A list of examples for intent classification.
1482    pub example: Option<Vec<GoogleCloudRetailV2IntentClassificationConfigExample>>,
1483    /// Optional. Inline source for intent classifications.
1484    #[serde(rename = "inlineSource")]
1485    pub inline_source: Option<GoogleCloudRetailV2IntentClassificationConfigInlineSource>,
1486    /// Optional. Customers can use the preamble to specify any requirements for blocklisting intent classification. This preamble will be added to the blocklisting intent classification model prompt.
1487    #[serde(rename = "modelPreamble")]
1488    pub model_preamble: Option<String>,
1489}
1490
1491impl common::Part for GoogleCloudRetailV2IntentClassificationConfig {}
1492
1493/// An example for intent classification.
1494///
1495/// This type is not used in any activity, and only used as *part* of another schema.
1496///
1497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1498#[serde_with::serde_as]
1499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1500pub struct GoogleCloudRetailV2IntentClassificationConfigExample {
1501    /// Required. Whether the example is classified positively.
1502    #[serde(rename = "classifiedPositive")]
1503    pub classified_positive: Option<bool>,
1504    /// Optional. The intent_type must match one of the predefined intent types defined at https://cloud.google.com/retail/docs/reference/rpc/google.cloud.retail.v2alpha#querytype
1505    #[serde(rename = "intentType")]
1506    pub intent_type: Option<String>,
1507    /// Required. Example query.
1508    pub query: Option<String>,
1509    /// Optional. The reason for the intent classification. This is used to explain the intent classification decision.
1510    pub reason: Option<String>,
1511}
1512
1513impl common::Part for GoogleCloudRetailV2IntentClassificationConfigExample {}
1514
1515/// An inline force intent classification configuration.
1516///
1517/// This type is not used in any activity, and only used as *part* of another schema.
1518///
1519#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1520#[serde_with::serde_as]
1521#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1522pub struct GoogleCloudRetailV2IntentClassificationConfigInlineForceIntent {
1523    /// Optional. The intent_type must match one of the predefined intent types defined at https://cloud.google.com/retail/docs/reference/rpc/google.cloud.retail.v2alpha#querytype
1524    #[serde(rename = "intentType")]
1525    pub intent_type: Option<String>,
1526    /// Optional. The operation to perform for the query.
1527    pub operation: Option<String>,
1528    /// Optional. A example query.
1529    pub query: Option<String>,
1530}
1531
1532impl common::Part for GoogleCloudRetailV2IntentClassificationConfigInlineForceIntent {}
1533
1534/// Inline source for intent classifications.
1535///
1536/// This type is not used in any activity, and only used as *part* of another schema.
1537///
1538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1539#[serde_with::serde_as]
1540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1541pub struct GoogleCloudRetailV2IntentClassificationConfigInlineSource {
1542    /// Optional. A list of inline force intent classifications.
1543    #[serde(rename = "inlineForceIntents")]
1544    pub inline_force_intents:
1545        Option<Vec<GoogleCloudRetailV2IntentClassificationConfigInlineForceIntent>>,
1546}
1547
1548impl common::Part for GoogleCloudRetailV2IntentClassificationConfigInlineSource {}
1549
1550/// A floating point interval.
1551///
1552/// This type is not used in any activity, and only used as *part* of another schema.
1553///
1554#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1555#[serde_with::serde_as]
1556#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1557pub struct GoogleCloudRetailV2Interval {
1558    /// Exclusive upper bound.
1559    #[serde(rename = "exclusiveMaximum")]
1560    pub exclusive_maximum: Option<f64>,
1561    /// Exclusive lower bound.
1562    #[serde(rename = "exclusiveMinimum")]
1563    pub exclusive_minimum: Option<f64>,
1564    /// Inclusive upper bound.
1565    pub maximum: Option<f64>,
1566    /// Inclusive lower bound.
1567    pub minimum: Option<f64>,
1568}
1569
1570impl common::Part for GoogleCloudRetailV2Interval {}
1571
1572/// Response for CatalogService.ListCatalogs method.
1573///
1574/// # Activities
1575///
1576/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1577/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1578///
1579/// * [locations catalogs list projects](ProjectLocationCatalogListCall) (response)
1580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1581#[serde_with::serde_as]
1582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1583pub struct GoogleCloudRetailV2ListCatalogsResponse {
1584    /// All the customer's Catalogs.
1585    pub catalogs: Option<Vec<GoogleCloudRetailV2Catalog>>,
1586    /// A token that can be sent as ListCatalogsRequest.page_token to retrieve the next page. If this field is omitted, there are no subsequent pages.
1587    #[serde(rename = "nextPageToken")]
1588    pub next_page_token: Option<String>,
1589}
1590
1591impl common::ResponseResult for GoogleCloudRetailV2ListCatalogsResponse {}
1592
1593/// Response for ListControls method.
1594///
1595/// # Activities
1596///
1597/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1598/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1599///
1600/// * [locations catalogs controls list projects](ProjectLocationCatalogControlListCall) (response)
1601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1602#[serde_with::serde_as]
1603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1604pub struct GoogleCloudRetailV2ListControlsResponse {
1605    /// All the Controls for a given catalog.
1606    pub controls: Option<Vec<GoogleCloudRetailV2Control>>,
1607    /// Pagination token, if not returned indicates the last page.
1608    #[serde(rename = "nextPageToken")]
1609    pub next_page_token: Option<String>,
1610}
1611
1612impl common::ResponseResult for GoogleCloudRetailV2ListControlsResponse {}
1613
1614/// Response for ListQuestions method.
1615///
1616/// # Activities
1617///
1618/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1619/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1620///
1621/// * [locations catalogs generative questions list projects](ProjectLocationCatalogGenerativeQuestionListCall) (response)
1622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1623#[serde_with::serde_as]
1624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1625pub struct GoogleCloudRetailV2ListGenerativeQuestionConfigsResponse {
1626    /// All the questions for a given catalog.
1627    #[serde(rename = "generativeQuestionConfigs")]
1628    pub generative_question_configs: Option<Vec<GoogleCloudRetailV2GenerativeQuestionConfig>>,
1629}
1630
1631impl common::ResponseResult for GoogleCloudRetailV2ListGenerativeQuestionConfigsResponse {}
1632
1633/// Response to a ListModelRequest.
1634///
1635/// # Activities
1636///
1637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1639///
1640/// * [locations catalogs models list projects](ProjectLocationCatalogModelListCall) (response)
1641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1642#[serde_with::serde_as]
1643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1644pub struct GoogleCloudRetailV2ListModelsResponse {
1645    /// List of Models.
1646    pub models: Option<Vec<GoogleCloudRetailV2Model>>,
1647    /// Pagination token, if not returned indicates the last page.
1648    #[serde(rename = "nextPageToken")]
1649    pub next_page_token: Option<String>,
1650}
1651
1652impl common::ResponseResult for GoogleCloudRetailV2ListModelsResponse {}
1653
1654/// Response message for ProductService.ListProducts method.
1655///
1656/// # Activities
1657///
1658/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1659/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1660///
1661/// * [locations catalogs branches products list projects](ProjectLocationCatalogBranchProductListCall) (response)
1662#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1663#[serde_with::serde_as]
1664#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1665pub struct GoogleCloudRetailV2ListProductsResponse {
1666    /// A token that can be sent as ListProductsRequest.page_token to retrieve the next page. If this field is omitted, there are no subsequent pages.
1667    #[serde(rename = "nextPageToken")]
1668    pub next_page_token: Option<String>,
1669    /// The Products.
1670    pub products: Option<Vec<GoogleCloudRetailV2Product>>,
1671}
1672
1673impl common::ResponseResult for GoogleCloudRetailV2ListProductsResponse {}
1674
1675/// Response for ListServingConfigs method.
1676///
1677/// # Activities
1678///
1679/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1680/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1681///
1682/// * [locations catalogs serving configs list projects](ProjectLocationCatalogServingConfigListCall) (response)
1683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1684#[serde_with::serde_as]
1685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1686pub struct GoogleCloudRetailV2ListServingConfigsResponse {
1687    /// Pagination token, if not returned indicates the last page.
1688    #[serde(rename = "nextPageToken")]
1689    pub next_page_token: Option<String>,
1690    /// All the ServingConfigs for a given catalog.
1691    #[serde(rename = "servingConfigs")]
1692    pub serving_configs: Option<Vec<GoogleCloudRetailV2ServingConfig>>,
1693}
1694
1695impl common::ResponseResult for GoogleCloudRetailV2ListServingConfigsResponse {}
1696
1697/// The inventory information at a place (e.g. a store) identified by a place ID.
1698///
1699/// This type is not used in any activity, and only used as *part* of another schema.
1700///
1701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1702#[serde_with::serde_as]
1703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1704pub struct GoogleCloudRetailV2LocalInventory {
1705    /// Optional. Additional local inventory attributes, for example, store name, promotion tags, etc. This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT error is returned: * At most 30 attributes are allowed. * The key must be a UTF-8 encoded string with a length limit of 32 characters. * The key must match the pattern: `a-zA-Z0-9*`. For example, key0LikeThis or KEY_1_LIKE_THIS. * The attribute values must be of the same type (text or number). * Only 1 value is allowed for each attribute. * For text values, the length limit is 256 UTF-8 characters. * The attribute does not support search. The `searchable` field should be unset or set to false. * The max summed total bytes of custom attribute keys and values per product is 5MiB.
1706    pub attributes: Option<HashMap<String, GoogleCloudRetailV2CustomAttribute>>,
1707    /// Optional. Supported fulfillment types. Valid fulfillment type values include commonly used types (such as pickup in store and same day delivery), and custom types. Customers have to map custom types to their display names before rendering UI. Supported values: * "pickup-in-store" * "ship-to-store" * "same-day-delivery" * "next-day-delivery" * "custom-type-1" * "custom-type-2" * "custom-type-3" * "custom-type-4" * "custom-type-5" If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned. All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is returned.
1708    #[serde(rename = "fulfillmentTypes")]
1709    pub fulfillment_types: Option<Vec<String>>,
1710    /// Optional. The place ID for the current set of inventory information.
1711    #[serde(rename = "placeId")]
1712    pub place_id: Option<String>,
1713    /// Optional. Product price and cost information. Google Merchant Center property [price](https://support.google.com/merchants/answer/6324371).
1714    #[serde(rename = "priceInfo")]
1715    pub price_info: Option<GoogleCloudRetailV2PriceInfo>,
1716}
1717
1718impl common::Part for GoogleCloudRetailV2LocalInventory {}
1719
1720/// Metadata that describes the training and serving parameters of a Model. A Model can be associated with a ServingConfig and then queried through the Predict API.
1721///
1722/// # Activities
1723///
1724/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1725/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1726///
1727/// * [locations catalogs models create projects](ProjectLocationCatalogModelCreateCall) (request)
1728/// * [locations catalogs models get projects](ProjectLocationCatalogModelGetCall) (response)
1729/// * [locations catalogs models patch projects](ProjectLocationCatalogModelPatchCall) (request|response)
1730/// * [locations catalogs models pause projects](ProjectLocationCatalogModelPauseCall) (response)
1731/// * [locations catalogs models resume projects](ProjectLocationCatalogModelResumeCall) (response)
1732#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1733#[serde_with::serde_as]
1734#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1735pub struct GoogleCloudRetailV2Model {
1736    /// Output only. Timestamp the Recommendation Model was created at.
1737    #[serde(rename = "createTime")]
1738    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1739    /// Output only. The state of data requirements for this model: `DATA_OK` and `DATA_ERROR`. Recommendation model cannot be trained if the data is in `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even if serving state is `ACTIVE`: models were trained successfully before, but cannot be refreshed because model no longer has sufficient data for training.
1740    #[serde(rename = "dataState")]
1741    pub data_state: Option<String>,
1742    /// Required. The display name of the model. Should be human readable, used to display Recommendation Models in the Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 characters.
1743    #[serde(rename = "displayName")]
1744    pub display_name: Option<String>,
1745    /// Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering by attributes is enabled for the model.
1746    #[serde(rename = "filteringOption")]
1747    pub filtering_option: Option<String>,
1748    /// Output only. The timestamp when the latest successful tune finished.
1749    #[serde(rename = "lastTuneTime")]
1750    pub last_tune_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1751    /// Optional. Additional model features config.
1752    #[serde(rename = "modelFeaturesConfig")]
1753    pub model_features_config: Option<GoogleCloudRetailV2ModelModelFeaturesConfig>,
1754    /// Required. The fully qualified resource name of the model. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` catalog_id has char limit of 50. recommendation_model_id has char limit of 40.
1755    pub name: Option<String>,
1756    /// Optional. The optimization objective e.g. `cvr`. Currently supported values: `ctr`, `cvr`, `revenue-per-order`. If not specified, we choose default based on model type. Default depends on type of recommendation: `recommended-for-you` => `ctr` `others-you-may-like` => `ctr` `frequently-bought-together` => `revenue_per_order` This field together with optimization_objective describe model metadata to use to control model training and serving. See https://cloud.google.com/retail/docs/models for more details on what the model metadata control and which combination of parameters are valid. For invalid combinations of parameters (e.g. type = `frequently-bought-together` and optimization_objective = `ctr`), you receive an error 400 if you try to create/update a recommendation with this set of knobs.
1757    #[serde(rename = "optimizationObjective")]
1758    pub optimization_objective: Option<String>,
1759    /// Optional. The state of periodic tuning. The period we use is 3 months - to do a one-off tune earlier use the `TuneModel` method. Default value is `PERIODIC_TUNING_ENABLED`.
1760    #[serde(rename = "periodicTuningState")]
1761    pub periodic_tuning_state: Option<String>,
1762    /// Output only. The list of valid serving configs associated with the PageOptimizationConfig.
1763    #[serde(rename = "servingConfigLists")]
1764    pub serving_config_lists: Option<Vec<GoogleCloudRetailV2ModelServingConfigList>>,
1765    /// Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`.
1766    #[serde(rename = "servingState")]
1767    pub serving_state: Option<String>,
1768    /// Optional. The training state that the model is in (e.g. `TRAINING` or `PAUSED`). Since part of the cost of running the service is frequency of training - this can be used to determine when to train model in order to control cost. If not specified: the default value for `CreateModel` method is `TRAINING`. The default value for `UpdateModel` method is to keep the state the same as before.
1769    #[serde(rename = "trainingState")]
1770    pub training_state: Option<String>,
1771    /// Output only. The tune operation associated with the model. Can be used to determine if there is an ongoing tune for this recommendation. Empty field implies no tune is goig on.
1772    #[serde(rename = "tuningOperation")]
1773    pub tuning_operation: Option<String>,
1774    /// Required. The type of model e.g. `home-page`. Currently supported values: `recommended-for-you`, `others-you-may-like`, `frequently-bought-together`, `page-optimization`, `similar-items`, `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). This field together with optimization_objective describe model metadata to use to control model training and serving. See https://cloud.google.com/retail/docs/models for more details on what the model metadata control and which combination of parameters are valid. For invalid combinations of parameters (e.g. type = `frequently-bought-together` and optimization_objective = `ctr`), you receive an error 400 if you try to create/update a recommendation with this set of knobs.
1775    #[serde(rename = "type")]
1776    pub type_: Option<String>,
1777    /// Output only. Timestamp the Recommendation Model was last updated. E.g. if a Recommendation Model was paused - this would be the time the pause was initiated.
1778    #[serde(rename = "updateTime")]
1779    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1780}
1781
1782impl common::RequestValue for GoogleCloudRetailV2Model {}
1783impl common::ResponseResult for GoogleCloudRetailV2Model {}
1784
1785/// Additional configs for the frequently-bought-together model type.
1786///
1787/// This type is not used in any activity, and only used as *part* of another schema.
1788///
1789#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1790#[serde_with::serde_as]
1791#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1792pub struct GoogleCloudRetailV2ModelFrequentlyBoughtTogetherFeaturesConfig {
1793    /// Optional. Specifies the context of the model when it is used in predict requests. Can only be set for the `frequently-bought-together` type. If it isn't specified, it defaults to MULTIPLE_CONTEXT_PRODUCTS.
1794    #[serde(rename = "contextProductsType")]
1795    pub context_products_type: Option<String>,
1796}
1797
1798impl common::Part for GoogleCloudRetailV2ModelFrequentlyBoughtTogetherFeaturesConfig {}
1799
1800/// Additional model features config.
1801///
1802/// This type is not used in any activity, and only used as *part* of another schema.
1803///
1804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1805#[serde_with::serde_as]
1806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1807pub struct GoogleCloudRetailV2ModelModelFeaturesConfig {
1808    /// Additional configs for frequently-bought-together models.
1809    #[serde(rename = "frequentlyBoughtTogetherConfig")]
1810    pub frequently_bought_together_config:
1811        Option<GoogleCloudRetailV2ModelFrequentlyBoughtTogetherFeaturesConfig>,
1812}
1813
1814impl common::Part for GoogleCloudRetailV2ModelModelFeaturesConfig {}
1815
1816/// Represents an ordered combination of valid serving configs, which can be used for `PAGE_OPTIMIZATION` recommendations.
1817///
1818/// This type is not used in any activity, and only used as *part* of another schema.
1819///
1820#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1821#[serde_with::serde_as]
1822#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1823pub struct GoogleCloudRetailV2ModelServingConfigList {
1824    /// Optional. A set of valid serving configs that may be used for `PAGE_OPTIMIZATION`.
1825    #[serde(rename = "servingConfigIds")]
1826    pub serving_config_ids: Option<Vec<String>>,
1827}
1828
1829impl common::Part for GoogleCloudRetailV2ModelServingConfigList {}
1830
1831/// The output configuration setting.
1832///
1833/// This type is not used in any activity, and only used as *part* of another schema.
1834///
1835#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1836#[serde_with::serde_as]
1837#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1838pub struct GoogleCloudRetailV2OutputConfig {
1839    /// The BigQuery location where the output is to be written to.
1840    #[serde(rename = "bigqueryDestination")]
1841    pub bigquery_destination: Option<GoogleCloudRetailV2OutputConfigBigQueryDestination>,
1842    /// The Google Cloud Storage location where the output is to be written to.
1843    #[serde(rename = "gcsDestination")]
1844    pub gcs_destination: Option<GoogleCloudRetailV2OutputConfigGcsDestination>,
1845}
1846
1847impl common::Part for GoogleCloudRetailV2OutputConfig {}
1848
1849/// The BigQuery output destination configuration.
1850///
1851/// This type is not used in any activity, and only used as *part* of another schema.
1852///
1853#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1854#[serde_with::serde_as]
1855#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1856pub struct GoogleCloudRetailV2OutputConfigBigQueryDestination {
1857    /// Required. The ID of a BigQuery Dataset.
1858    #[serde(rename = "datasetId")]
1859    pub dataset_id: Option<String>,
1860    /// Required. The prefix of exported BigQuery tables.
1861    #[serde(rename = "tableIdPrefix")]
1862    pub table_id_prefix: Option<String>,
1863    /// Required. Describes the table type. The following values are supported: * `table`: A BigQuery native table. * `view`: A virtual table defined by a SQL query.
1864    #[serde(rename = "tableType")]
1865    pub table_type: Option<String>,
1866}
1867
1868impl common::Part for GoogleCloudRetailV2OutputConfigBigQueryDestination {}
1869
1870/// The Google Cloud Storage output destination configuration.
1871///
1872/// This type is not used in any activity, and only used as *part* of another schema.
1873///
1874#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1875#[serde_with::serde_as]
1876#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1877pub struct GoogleCloudRetailV2OutputConfigGcsDestination {
1878    /// Required. The output uri prefix for saving output data to json files. Some mapping examples are as follows: output_uri_prefix sample output(assuming the object is foo.json) ======================== ============================================= gs://bucket/ gs://bucket/foo.json gs://bucket/folder/ gs://bucket/folder/foo.json gs://bucket/folder/item_ gs://bucket/folder/item_foo.json
1879    #[serde(rename = "outputUriPrefix")]
1880    pub output_uri_prefix: Option<String>,
1881}
1882
1883impl common::Part for GoogleCloudRetailV2OutputConfigGcsDestination {}
1884
1885/// Detailed panel information associated with a user event.
1886///
1887/// This type is not used in any activity, and only used as *part* of another schema.
1888///
1889#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1890#[serde_with::serde_as]
1891#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1892pub struct GoogleCloudRetailV2PanelInfo {
1893    /// Optional. The attribution token of the panel.
1894    #[serde(rename = "attributionToken")]
1895    pub attribution_token: Option<String>,
1896    /// Optional. The display name of the panel.
1897    #[serde(rename = "displayName")]
1898    pub display_name: Option<String>,
1899    /// Required. The panel ID.
1900    #[serde(rename = "panelId")]
1901    pub panel_id: Option<String>,
1902    /// Optional. The ordered position of the panel, if shown to the user with other panels. If set, then total_panels must also be set.
1903    #[serde(rename = "panelPosition")]
1904    pub panel_position: Option<i32>,
1905    /// Optional. The product details associated with the panel.
1906    #[serde(rename = "productDetails")]
1907    pub product_details: Option<Vec<GoogleCloudRetailV2ProductDetail>>,
1908    /// Optional. The total number of panels, including this one, shown to the user. Must be set if panel_position is set.
1909    #[serde(rename = "totalPanels")]
1910    pub total_panels: Option<i32>,
1911}
1912
1913impl common::Part for GoogleCloudRetailV2PanelInfo {}
1914
1915/// Request for pausing training of a model.
1916///
1917/// # Activities
1918///
1919/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1920/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1921///
1922/// * [locations catalogs models pause projects](ProjectLocationCatalogModelPauseCall) (request)
1923#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1924#[serde_with::serde_as]
1925#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1926pub struct GoogleCloudRetailV2PauseModelRequest {
1927    _never_set: Option<bool>,
1928}
1929
1930impl common::RequestValue for GoogleCloudRetailV2PauseModelRequest {}
1931
1932/// Metadata for pinning to be returned in the response. This is used for distinguishing between applied vs dropped pins.
1933///
1934/// This type is not used in any activity, and only used as *part* of another schema.
1935///
1936#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1937#[serde_with::serde_as]
1938#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1939pub struct GoogleCloudRetailV2PinControlMetadata {
1940    /// Map of all matched pins, keyed by pin position.
1941    #[serde(rename = "allMatchedPins")]
1942    pub all_matched_pins: Option<HashMap<String, GoogleCloudRetailV2PinControlMetadataProductPins>>,
1943    /// Map of pins that were dropped due to overlap with other matching pins, keyed by pin position.
1944    #[serde(rename = "droppedPins")]
1945    pub dropped_pins: Option<HashMap<String, GoogleCloudRetailV2PinControlMetadataProductPins>>,
1946}
1947
1948impl common::Part for GoogleCloudRetailV2PinControlMetadata {}
1949
1950/// List of product ids which have associated pins.
1951///
1952/// This type is not used in any activity, and only used as *part* of another schema.
1953///
1954#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1955#[serde_with::serde_as]
1956#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1957pub struct GoogleCloudRetailV2PinControlMetadataProductPins {
1958    /// List of product ids which have associated pins.
1959    #[serde(rename = "productId")]
1960    pub product_id: Option<Vec<String>>,
1961}
1962
1963impl common::Part for GoogleCloudRetailV2PinControlMetadataProductPins {}
1964
1965/// Request message for Predict method.
1966///
1967/// # Activities
1968///
1969/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1970/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1971///
1972/// * [locations catalogs placements predict projects](ProjectLocationCatalogPlacementPredictCall) (request)
1973/// * [locations catalogs serving configs predict projects](ProjectLocationCatalogServingConfigPredictCall) (request)
1974#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1975#[serde_with::serde_as]
1976#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1977pub struct GoogleCloudRetailV2PredictRequest {
1978    /// Filter for restricting prediction results with a length limit of 5,000 characters. Accepts values for tags and the `filterOutOfStockItems` flag. * Tag expressions. Restricts predictions to products 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,000 characters. Note: "Recently viewed" models don't support tag filtering at the moment. * filterOutOfStockItems. Restricts predictions to products 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, the API will return *no* results. If instead you want empty result sets to return generic (unfiltered) popular products, set `strictFiltering` to False in `PredictRequest.params`. Note that the API will never return items with storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. If `filterSyntaxV2` is set to true under the `params` field, then attribute-based expressions are expected instead of the above described tag-based syntax. Examples: * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) * (availability: ANY("IN_STOCK")) AND (colors: ANY("Red") OR categories: ANY("Phones")) For more information, see [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs).
1979    pub filter: Option<String>,
1980    /// The labels applied to a resource must meet the following requirements: * Each resource can have multiple labels, up to a maximum of 64. * Each label must be a key-value pair. * Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters. * Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. * The key portion of a label must be unique. However, you can use the same key with multiple resources. * Keys must start with a lowercase letter or international character. See [Google Cloud Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) for more details.
1981    pub labels: Option<HashMap<String, String>>,
1982    /// Maximum number of results to return. Set this property to the number of prediction results needed. If zero, the service will choose a reasonable default. The maximum allowed value is 100. Values above 100 will be coerced to 100.
1983    #[serde(rename = "pageSize")]
1984    pub page_size: Option<i32>,
1985    /// This field is not used; leave it unset.
1986    #[serde(rename = "pageToken")]
1987    pub page_token: Option<String>,
1988    /// Additional domain specific parameters for the predictions. Allowed values: * `returnProduct`: Boolean. If set to true, the associated product object will be returned in the `results.metadata` field in the prediction response. * `returnScore`: Boolean. If set to true, the prediction 'score' corresponding to each returned product will be set in the `results.metadata` field in the prediction response. The given 'score' indicates the probability of a product 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 products 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 adjusts 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 adjusts prediction results based on product category. * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` field is interpreteted according to the new, attribute-based syntax.
1989    pub params: Option<HashMap<String, serde_json::Value>>,
1990    /// 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 UserEvent.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 UserEvent.visitor_id to a random unique ID and leave UserInfo.user_id unset.
1991    #[serde(rename = "userEvent")]
1992    pub user_event: Option<GoogleCloudRetailV2UserEvent>,
1993    /// Use validate only mode for this prediction query. If set to true, a dummy model will be used that returns arbitrary products. Note that the validate only mode should only be used for testing the API, or if the model is not ready.
1994    #[serde(rename = "validateOnly")]
1995    pub validate_only: Option<bool>,
1996}
1997
1998impl common::RequestValue for GoogleCloudRetailV2PredictRequest {}
1999
2000/// Response message for predict method.
2001///
2002/// # Activities
2003///
2004/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2005/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2006///
2007/// * [locations catalogs placements predict projects](ProjectLocationCatalogPlacementPredictCall) (response)
2008/// * [locations catalogs serving configs predict projects](ProjectLocationCatalogServingConfigPredictCall) (response)
2009#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2010#[serde_with::serde_as]
2011#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2012pub struct GoogleCloudRetailV2PredictResponse {
2013    /// A unique attribution token. This should be included in the UserEvent logs resulting from this recommendation, which enables accurate attribution of recommendation model performance.
2014    #[serde(rename = "attributionToken")]
2015    pub attribution_token: Option<String>,
2016    /// IDs of products in the request that were missing from the inventory.
2017    #[serde(rename = "missingIds")]
2018    pub missing_ids: Option<Vec<String>>,
2019    /// A list of recommended products. The order represents the ranking (from the most relevant product to the least).
2020    pub results: Option<Vec<GoogleCloudRetailV2PredictResponsePredictionResult>>,
2021    /// True if the validateOnly property was set in the request.
2022    #[serde(rename = "validateOnly")]
2023    pub validate_only: Option<bool>,
2024}
2025
2026impl common::ResponseResult for GoogleCloudRetailV2PredictResponse {}
2027
2028/// PredictionResult represents the recommendation prediction results.
2029///
2030/// This type is not used in any activity, and only used as *part* of another schema.
2031///
2032#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2033#[serde_with::serde_as]
2034#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2035pub struct GoogleCloudRetailV2PredictResponsePredictionResult {
2036    /// ID of the recommended product
2037    pub id: Option<String>,
2038    /// Additional product metadata / annotations. Possible values: * `product`: JSON representation of the product. Is set if `returnProduct` is set to true in `PredictRequest.params`. * `score`: Prediction score in double value. Is set if `returnScore` is set to true in `PredictRequest.params`.
2039    pub metadata: Option<HashMap<String, serde_json::Value>>,
2040}
2041
2042impl common::Part for GoogleCloudRetailV2PredictResponsePredictionResult {}
2043
2044/// The price information of a Product.
2045///
2046/// This type is not used in any activity, and only used as *part* of another schema.
2047///
2048#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2049#[serde_with::serde_as]
2050#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2051pub struct GoogleCloudRetailV2PriceInfo {
2052    /// The costs associated with the sale of a particular product. Used for gross profit reporting. * Profit = price - cost Google Merchant Center property [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895).
2053    pub cost: Option<f32>,
2054    /// The 3-letter currency code defined in [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html). If this field is an unrecognizable currency code, an INVALID_ARGUMENT error is returned. The Product.Type.VARIANT Products with the same Product.primary_product_id must share the same currency_code. Otherwise, a FAILED_PRECONDITION error is returned.
2055    #[serde(rename = "currencyCode")]
2056    pub currency_code: Option<String>,
2057    /// Price of the product without any discount. If zero, by default set to be the price. If set, original_price should be greater than or equal to price, otherwise an INVALID_ARGUMENT error is thrown.
2058    #[serde(rename = "originalPrice")]
2059    pub original_price: Option<f32>,
2060    /// Price of the product. Google Merchant Center property [price](https://support.google.com/merchants/answer/6324371). Schema.org property [Offer.price](https://schema.org/price).
2061    pub price: Option<f32>,
2062    /// The timestamp when the price starts to be effective. This can be set as a future timestamp, and the price is only used for search after price_effective_time. If so, the original_price must be set and original_price is used before price_effective_time. Do not set if price is always effective because it will cause additional latency during search.
2063    #[serde(rename = "priceEffectiveTime")]
2064    pub price_effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2065    /// The timestamp when the price stops to be effective. The price is used for search before price_expire_time. If this field is set, the original_price must be set and original_price is used after price_expire_time. Do not set if price is always effective because it will cause additional latency during search.
2066    #[serde(rename = "priceExpireTime")]
2067    pub price_expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2068    /// Output only. The price range of all the child Product.Type.VARIANT Products grouped together on the Product.Type.PRIMARY Product. Only populated for Product.Type.PRIMARY Products. Note: This field is OUTPUT_ONLY for ProductService.GetProduct. Do not set this field in API requests.
2069    #[serde(rename = "priceRange")]
2070    pub price_range: Option<GoogleCloudRetailV2PriceInfoPriceRange>,
2071}
2072
2073impl common::Part for GoogleCloudRetailV2PriceInfo {}
2074
2075/// The price range of all variant Product having the same Product.primary_product_id.
2076///
2077/// This type is not used in any activity, and only used as *part* of another schema.
2078///
2079#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2080#[serde_with::serde_as]
2081#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2082pub struct GoogleCloudRetailV2PriceInfoPriceRange {
2083    /// The inclusive Product.pricing_info.original_price internal of all variant Product having the same Product.primary_product_id.
2084    #[serde(rename = "originalPrice")]
2085    pub original_price: Option<GoogleCloudRetailV2Interval>,
2086    /// The inclusive Product.pricing_info.price interval of all variant Product having the same Product.primary_product_id.
2087    pub price: Option<GoogleCloudRetailV2Interval>,
2088}
2089
2090impl common::Part for GoogleCloudRetailV2PriceInfoPriceRange {}
2091
2092/// Product captures all metadata information of items to be recommended or searched.
2093///
2094/// # Activities
2095///
2096/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2097/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2098///
2099/// * [locations catalogs branches products create projects](ProjectLocationCatalogBranchProductCreateCall) (request|response)
2100/// * [locations catalogs branches products get projects](ProjectLocationCatalogBranchProductGetCall) (response)
2101/// * [locations catalogs branches products patch projects](ProjectLocationCatalogBranchProductPatchCall) (request|response)
2102#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2103#[serde_with::serde_as]
2104#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2105pub struct GoogleCloudRetailV2Product {
2106    /// Highly encouraged. Extra product attributes to be included. For example, for 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 attributes here. Features that can take on one of a limited number of possible values. Two types of features can be set are: Textual features. some examples would be the brand/maker of a product, or country of a customer. Numerical features. Some examples would be the height/weight of a product, or age of a customer. For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} }`. This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT error is returned: * Max entries count: 200. * The key must be a UTF-8 encoded string with a length limit of 128 characters. * For indexable attribute, the key must match the pattern: `a-zA-Z0-9*`. For example, `key0LikeThis` or `KEY_1_LIKE_THIS`. * For text attributes, at most 400 values are allowed. Empty values are not allowed. Each value must be a non-empty UTF-8 encoded string with a length limit of 256 characters. * For number attributes, at most 400 values are allowed.
2107    pub attributes: Option<HashMap<String, GoogleCloudRetailV2CustomAttribute>>,
2108    /// The target group associated with a given audience (e.g. male, veterans, car owners, musicians, etc.) of the product.
2109    pub audience: Option<GoogleCloudRetailV2Audience>,
2110    /// The online availability of the Product. Default to Availability.IN_STOCK. For primary products with variants set the availability of the primary as Availability.OUT_OF_STOCK and set the true availability at the variant level. This way the primary product will be considered "in stock" as long as it has at least one variant in stock. For primary products with no variants set the true availability at the primary level. Corresponding properties: Google Merchant Center property [availability](https://support.google.com/merchants/answer/6324448). Schema.org property [Offer.availability](https://schema.org/availability).
2111    pub availability: Option<String>,
2112    /// The available quantity of the item.
2113    #[serde(rename = "availableQuantity")]
2114    pub available_quantity: Option<i32>,
2115    /// The timestamp when this Product becomes available for SearchService.Search. Note that this is only applicable to Type.PRIMARY and Type.COLLECTION, and ignored for Type.VARIANT.
2116    #[serde(rename = "availableTime")]
2117    pub available_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2118    /// The brands of the product. A maximum of 30 brands are allowed unless overridden through the Google Cloud console. Each brand must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [brand](https://support.google.com/merchants/answer/6324351). Schema.org property [Product.brand](https://schema.org/brand).
2119    pub brands: Option<Vec<String>>,
2120    /// Product categories. This field is repeated for supporting one product belonging to several parallel categories. Strongly recommended using the full path for better search / recommendation quality. To represent full path of category, use '>' sign to separate different hierarchies. If '>' is part of the category name, replace it with other character(s). For example, if a shoes product belongs to both ["Shoes & Accessories" -> "Shoes"] and ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be represented as: "categories": [ "Shoes & Accessories > Shoes", "Sports & Fitness > Athletic Clothing > Shoes" ] Must be set for Type.PRIMARY Product otherwise an INVALID_ARGUMENT error is returned. At most 250 values are allowed per Product unless overridden through the Google Cloud console. Empty values are not allowed. Each value must be a UTF-8 encoded string with a length limit of 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property google_product_category. Schema.org property [Product.category] (https://schema.org/category). [mc_google_product_category]: https://support.google.com/merchants/answer/6324436
2121    pub categories: Option<Vec<String>>,
2122    /// The id of the collection members when type is Type.COLLECTION. Non-existent product ids are allowed. The type of the members must be either Type.PRIMARY or Type.VARIANT otherwise an INVALID_ARGUMENT error is thrown. Should not set it for other types. A maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is return.
2123    #[serde(rename = "collectionMemberIds")]
2124    pub collection_member_ids: Option<Vec<String>>,
2125    /// The color of the product. Corresponding properties: Google Merchant Center property [color](https://support.google.com/merchants/answer/6324487). Schema.org property [Product.color](https://schema.org/color).
2126    #[serde(rename = "colorInfo")]
2127    pub color_info: Option<GoogleCloudRetailV2ColorInfo>,
2128    /// The condition of the product. Strongly encouraged to use the standard values: "new", "refurbished", "used". A maximum of 1 value is allowed per Product. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [condition](https://support.google.com/merchants/answer/6324469). Schema.org property [Offer.itemCondition](https://schema.org/itemCondition).
2129    pub conditions: Option<Vec<String>>,
2130    /// Product description. This field must be a UTF-8 encoded string with a length limit of 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [description](https://support.google.com/merchants/answer/6324468). Schema.org property [Product.description](https://schema.org/description).
2131    pub description: Option<String>,
2132    /// Note that this field is applied in the following ways: * If the Product is already expired when it is uploaded, this product is not indexed for search. * If the Product is not expired when it is uploaded, only the Type.PRIMARY's and Type.COLLECTION's expireTime is respected, and Type.VARIANT's expireTime is not used. In general, we suggest the users to delete the stale products explicitly, instead of using this field to determine staleness. expire_time must be later than available_time and publish_time, otherwise an INVALID_ARGUMENT error is thrown. Corresponding properties: Google Merchant Center property [expiration_date](https://support.google.com/merchants/answer/6324499).
2133    #[serde(rename = "expireTime")]
2134    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2135    /// Fulfillment information, such as the store IDs for in-store pickup or region IDs for different shipping methods. All the elements must have distinct FulfillmentInfo.type. Otherwise, an INVALID_ARGUMENT error is returned.
2136    #[serde(rename = "fulfillmentInfo")]
2137    pub fulfillment_info: Option<Vec<GoogleCloudRetailV2FulfillmentInfo>>,
2138    /// The Global Trade Item Number (GTIN) of the product. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [gtin](https://support.google.com/merchants/answer/6324461). Schema.org property [Product.isbn](https://schema.org/isbn), [Product.gtin8](https://schema.org/gtin8), [Product.gtin12](https://schema.org/gtin12), [Product.gtin13](https://schema.org/gtin13), or [Product.gtin14](https://schema.org/gtin14). If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned.
2139    pub gtin: Option<String>,
2140    /// Immutable. Product identifier, which is the final component of name. For example, this field is "id_1", if name is `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [id](https://support.google.com/merchants/answer/6324405). Schema.org property [Product.sku](https://schema.org/sku).
2141    pub id: Option<String>,
2142    /// Product images for the product. We highly recommend putting the main image first. A maximum of 300 images are allowed. Corresponding properties: Google Merchant Center property [image_link](https://support.google.com/merchants/answer/6324350). Schema.org property [Product.image](https://schema.org/image).
2143    pub images: Option<Vec<GoogleCloudRetailV2Image>>,
2144    /// Language of the title/description and other string attributes. Use language tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). For product prediction, this field is ignored and the model automatically detects the text language. The Product can include text in different languages, but duplicating Products to provide text in multiple languages can result in degraded model performance. For product search this field is in use. It defaults to "en-US" if unset.
2145    #[serde(rename = "languageCode")]
2146    pub language_code: Option<String>,
2147    /// Output only. A list of local inventories specific to different places. This field can be managed by ProductService.AddLocalInventories and ProductService.RemoveLocalInventories APIs if fine-grained, high-volume updates are necessary.
2148    #[serde(rename = "localInventories")]
2149    pub local_inventories: Option<Vec<GoogleCloudRetailV2LocalInventory>>,
2150    /// The material of the product. For example, "leather", "wooden". A maximum of 20 values are allowed. Each value must be a UTF-8 encoded string with a length limit of 200 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [material](https://support.google.com/merchants/answer/6324410). Schema.org property [Product.material](https://schema.org/material).
2151    pub materials: Option<Vec<String>>,
2152    /// Immutable. Full resource name of the product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`.
2153    pub name: Option<String>,
2154    /// The pattern or graphic print of the product. For example, "striped", "polka dot", "paisley". A maximum of 20 values are allowed per Product. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [pattern](https://support.google.com/merchants/answer/6324483). Schema.org property [Product.pattern](https://schema.org/pattern).
2155    pub patterns: Option<Vec<String>>,
2156    /// Product price and cost information. Corresponding properties: Google Merchant Center property [price](https://support.google.com/merchants/answer/6324371).
2157    #[serde(rename = "priceInfo")]
2158    pub price_info: Option<GoogleCloudRetailV2PriceInfo>,
2159    /// Variant group identifier. Must be an id, with the same parent branch with this product. Otherwise, an error is thrown. For Type.PRIMARY Products, this field can only be empty or set to the same value as id. For VARIANT Products, this field cannot be empty. A maximum of 2,000 products are allowed to share the same Type.PRIMARY Product. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [item_group_id](https://support.google.com/merchants/answer/6324507). Schema.org property [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID).
2160    #[serde(rename = "primaryProductId")]
2161    pub primary_product_id: Option<String>,
2162    /// The promotions applied to the product. A maximum of 10 values are allowed per Product. Only Promotion.promotion_id will be used, other fields will be ignored if set.
2163    pub promotions: Option<Vec<GoogleCloudRetailV2Promotion>>,
2164    /// The timestamp when the product is published by the retailer for the first time, which indicates the freshness of the products. Note that this field is different from available_time, given it purely describes product freshness regardless of when it is available on search and recommendation.
2165    #[serde(rename = "publishTime")]
2166    pub publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2167    /// The rating of this product.
2168    pub rating: Option<GoogleCloudRetailV2Rating>,
2169    /// Indicates which fields in the Products are returned in SearchResponse. Supported fields for all types: * audience * availability * brands * color_info * conditions * gtin * materials * name * patterns * price_info * rating * sizes * title * uri Supported fields only for Type.PRIMARY and Type.COLLECTION: * categories * description * images Supported fields only for Type.VARIANT: * Only the first image in images To mark attributes as retrievable, include paths of the form "attributes.key" where "key" is the key of a custom attribute, as specified in attributes. For Type.PRIMARY and Type.COLLECTION, the following fields are always returned in SearchResponse by default: * name For Type.VARIANT, the following fields are always returned in by default: * name * color_info Note: Returning more fields in SearchResponse can increase response payload size and serving latency. This field is deprecated. Use the retrievable site-wide control instead.
2170    #[serde(rename = "retrievableFields")]
2171    pub retrievable_fields: Option<common::FieldMask>,
2172    /// The size of the product. To represent different size systems or size types, consider using this format: [[[size_system:]size_type:]size_value]. For example, in "US:MENS:M", "US" represents size system; "MENS" represents size type; "M" represents size value. In "GIRLS:27", size system is empty; "GIRLS" represents size type; "27" represents size value. In "32 inches", both size system and size type are empty, while size value is "32 inches". A maximum of 20 values are allowed per Product. Each value must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [size](https://support.google.com/merchants/answer/6324492), [size_type](https://support.google.com/merchants/answer/6324497), and [size_system](https://support.google.com/merchants/answer/6324502). Schema.org property [Product.size](https://schema.org/size).
2173    pub sizes: Option<Vec<String>>,
2174    /// Custom tags associated with the product. At most 250 values are allowed per Product. This value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. This tag can be used for filtering recommendation results by passing the tag as part of the PredictRequest.filter. Corresponding properties: Google Merchant Center property [custom_label_0–4](https://support.google.com/merchants/answer/6324473).
2175    pub tags: Option<Vec<String>>,
2176    /// Required. Product title. This field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [title](https://support.google.com/merchants/answer/6324415). Schema.org property [Product.name](https://schema.org/name).
2177    pub title: Option<String>,
2178    /// Input only. The TTL (time to live) of the product. Note that this is only applicable to Type.PRIMARY and Type.COLLECTION, and ignored for Type.VARIANT. In general, we suggest the users to delete the stale products explicitly, instead of using this field to determine staleness. If it is set, it must be a non-negative value, and expire_time is set as current timestamp plus ttl. The derived expire_time is returned in the output and ttl is left blank when retrieving the Product. If it is set, the product is not available for SearchService.Search after current timestamp plus ttl. However, the product can still be retrieved by ProductService.GetProduct and ProductService.ListProducts.
2179    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2180    pub ttl: Option<chrono::Duration>,
2181    /// Immutable. The type of the product. Default to Catalog.product_level_config.ingestion_product_type if unset.
2182    #[serde(rename = "type")]
2183    pub type_: Option<String>,
2184    /// Canonical URL directly linking to the product detail page. It is strongly recommended to provide a valid uri for the product, otherwise the service performance could be significantly degraded. This field must be a UTF-8 encoded string with a length limit of 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. Corresponding properties: Google Merchant Center property [link](https://support.google.com/merchants/answer/6324416). Schema.org property [Offer.url](https://schema.org/url).
2185    pub uri: Option<String>,
2186    /// Output only. Product variants grouped together on primary product which share similar product attributes. It's automatically grouped by primary_product_id for all the product variants. Only populated for Type.PRIMARY Products. Note: This field is OUTPUT_ONLY for ProductService.GetProduct. Do not set this field in API requests.
2187    pub variants: Option<Vec<GoogleCloudRetailV2Product>>,
2188}
2189
2190impl common::RequestValue for GoogleCloudRetailV2Product {}
2191impl common::ResponseResult for GoogleCloudRetailV2Product {}
2192
2193/// Product attribute name and numeric interval.
2194///
2195/// This type is not used in any activity, and only used as *part* of another schema.
2196///
2197#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2198#[serde_with::serde_as]
2199#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2200pub struct GoogleCloudRetailV2ProductAttributeInterval {
2201    /// The numeric interval (e.g. [10, 20))
2202    pub interval: Option<GoogleCloudRetailV2Interval>,
2203    /// The attribute name (e.g. "length")
2204    pub name: Option<String>,
2205}
2206
2207impl common::Part for GoogleCloudRetailV2ProductAttributeInterval {}
2208
2209/// Product attribute which structured by an attribute name and value. This structure is used in conversational search filters and answers. For example, if we have `name=color` and `value=red`, this means that the color is `red`.
2210///
2211/// This type is not used in any activity, and only used as *part* of another schema.
2212///
2213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2214#[serde_with::serde_as]
2215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2216pub struct GoogleCloudRetailV2ProductAttributeValue {
2217    /// The attribute name.
2218    pub name: Option<String>,
2219    /// The attribute value.
2220    pub value: Option<String>,
2221}
2222
2223impl common::Part for GoogleCloudRetailV2ProductAttributeValue {}
2224
2225/// Detailed product information associated with a user event.
2226///
2227/// This type is not used in any activity, and only used as *part* of another schema.
2228///
2229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2230#[serde_with::serde_as]
2231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2232pub struct GoogleCloudRetailV2ProductDetail {
2233    /// Required. Product information. Required field(s): * Product.id Optional override field(s): * Product.price_info If any supported optional fields are provided, we will treat them as a full override when looking up product information from the catalog. Thus, it is important to ensure that the overriding fields are accurate and complete. All other product fields are ignored and instead populated via catalog lookup after event ingestion.
2234    pub product: Option<GoogleCloudRetailV2Product>,
2235    /// 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 `purchase-complete` event. Required for `add-to-cart` and `purchase-complete` event types.
2236    pub quantity: Option<i32>,
2237}
2238
2239impl common::Part for GoogleCloudRetailV2ProductDetail {}
2240
2241/// The inline source for the input config for ImportProducts method.
2242///
2243/// This type is not used in any activity, and only used as *part* of another schema.
2244///
2245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2246#[serde_with::serde_as]
2247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2248pub struct GoogleCloudRetailV2ProductInlineSource {
2249    /// Required. A list of products to update/create. Each product must have a valid Product.id. Recommended max of 100 items.
2250    pub products: Option<Vec<GoogleCloudRetailV2Product>>,
2251}
2252
2253impl common::Part for GoogleCloudRetailV2ProductInlineSource {}
2254
2255/// The input config source for products.
2256///
2257/// This type is not used in any activity, and only used as *part* of another schema.
2258///
2259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2260#[serde_with::serde_as]
2261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2262pub struct GoogleCloudRetailV2ProductInputConfig {
2263    /// BigQuery input source.
2264    #[serde(rename = "bigQuerySource")]
2265    pub big_query_source: Option<GoogleCloudRetailV2BigQuerySource>,
2266    /// Google Cloud Storage location for the input content.
2267    #[serde(rename = "gcsSource")]
2268    pub gcs_source: Option<GoogleCloudRetailV2GcsSource>,
2269    /// The Inline source for the input content for products.
2270    #[serde(rename = "productInlineSource")]
2271    pub product_inline_source: Option<GoogleCloudRetailV2ProductInlineSource>,
2272}
2273
2274impl common::Part for GoogleCloudRetailV2ProductInputConfig {}
2275
2276/// Configures what level the product should be uploaded with regards to how users will be send events and how predictions will be made.
2277///
2278/// This type is not used in any activity, and only used as *part* of another schema.
2279///
2280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2281#[serde_with::serde_as]
2282#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2283pub struct GoogleCloudRetailV2ProductLevelConfig {
2284    /// The type of Products allowed to be ingested into the catalog. Acceptable values are: * `primary` (default): You can ingest Products of all types. When ingesting a Product, its type will default to Product.Type.PRIMARY if unset. * `variant` (incompatible with Retail Search): You can only ingest Product.Type.VARIANT Products. This means Product.primary_product_id cannot be empty. If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned. If this field is `variant` and merchant_center_product_id_field is `itemGroupId`, an INVALID_ARGUMENT error is returned. See [Product levels](https://cloud.google.com/retail/docs/catalog#product-levels) for more details.
2285    #[serde(rename = "ingestionProductType")]
2286    pub ingestion_product_type: Option<String>,
2287    /// Which field of [Merchant Center Product](https://cloud.google.com/bigquery-transfer/docs/merchant-center-products-schema) should be imported as Product.id. Acceptable values are: * `offerId` (default): Import `offerId` as the product ID. * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail API will choose one item from the ones with the same `itemGroupId`, and use it to represent the item group. If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned. If this field is `itemGroupId` and ingestion_product_type is `variant`, an INVALID_ARGUMENT error is returned. See [Product levels](https://cloud.google.com/retail/docs/catalog#product-levels) for more details.
2288    #[serde(rename = "merchantCenterProductIdField")]
2289    pub merchant_center_product_id_field: Option<String>,
2290}
2291
2292impl common::Part for GoogleCloudRetailV2ProductLevelConfig {}
2293
2294/// Promotion specification.
2295///
2296/// This type is not used in any activity, and only used as *part* of another schema.
2297///
2298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2299#[serde_with::serde_as]
2300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2301pub struct GoogleCloudRetailV2Promotion {
2302    /// Promotion identifier, which is the final component of name. For example, this field is "free_gift", if name is `projects/*/locations/global/catalogs/default_catalog/promotions/free_gift`. The value must be a UTF-8 encoded string with a length limit of 128 characters, and match the pattern: `a-zA-Z*`. For example, id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is returned. Corresponds to Google Merchant Center property [promotion_id](https://support.google.com/merchants/answer/7050148).
2303    #[serde(rename = "promotionId")]
2304    pub promotion_id: Option<String>,
2305}
2306
2307impl common::Part for GoogleCloudRetailV2Promotion {}
2308
2309/// A transaction represents the entire purchase transaction.
2310///
2311/// This type is not used in any activity, and only used as *part* of another schema.
2312///
2313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2314#[serde_with::serde_as]
2315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2316pub struct GoogleCloudRetailV2PurchaseTransaction {
2317    /// All the costs associated with the products. These can be manufacturing costs, shipping expenses not borne by the end user, or any other costs, such that: * Profit = revenue - tax - cost
2318    pub cost: Option<f32>,
2319    /// Required. Currency code. Use three-character ISO-4217 code.
2320    #[serde(rename = "currencyCode")]
2321    pub currency_code: Option<String>,
2322    /// The transaction ID with a length limit of 128 characters.
2323    pub id: Option<String>,
2324    /// Required. Total non-zero 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.
2325    pub revenue: Option<f32>,
2326    /// All the taxes associated with the transaction.
2327    pub tax: Option<f32>,
2328}
2329
2330impl common::Part for GoogleCloudRetailV2PurchaseTransaction {}
2331
2332/// Request message for PurgeProducts method.
2333///
2334/// # Activities
2335///
2336/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2337/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2338///
2339/// * [locations catalogs branches products purge projects](ProjectLocationCatalogBranchProductPurgeCall) (request)
2340#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2341#[serde_with::serde_as]
2342#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2343pub struct GoogleCloudRetailV2PurgeProductsRequest {
2344    /// Required. The filter string to specify the products to be deleted with a length limit of 5,000 characters. Empty string filter is not allowed. "*" implies delete all items in a branch. The eligible fields for filtering are: * `availability`: Double quoted Product.availability string. * `create_time` : in ISO 8601 "zulu" format. Supported syntax: * Comparators (">", "<", ">=", "<=", "="). Examples: * create_time <= "2015-02-13T17:05:46Z" * availability = "IN_STOCK" * Conjunctions ("AND") Examples: * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" * Disjunctions ("OR") Examples: * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" * Can support nested queries. Examples: * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") * Filter Limits: * Filter should not contain more than 6 conditions. * Max nesting depth should not exceed 2 levels. Examples queries: * Delete back order products created before a timestamp. create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER"
2345    pub filter: Option<String>,
2346    /// Actually perform the purge. If `force` is set to false, the method will return the expected purge count without deleting any products.
2347    pub force: Option<bool>,
2348}
2349
2350impl common::RequestValue for GoogleCloudRetailV2PurgeProductsRequest {}
2351
2352/// Request message for PurgeUserEvents method.
2353///
2354/// # Activities
2355///
2356/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2357/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2358///
2359/// * [locations catalogs user events purge projects](ProjectLocationCatalogUserEventPurgeCall) (request)
2360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2361#[serde_with::serde_as]
2362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2363pub struct GoogleCloudRetailV2PurgeUserEventsRequest {
2364    /// Required. The filter string to specify the events to be deleted with a length limit of 5,000 characters. Empty string filter is not allowed. The eligible fields for filtering are: * `eventType`: Double quoted UserEvent.event_type string. * `eventTime`: in ISO 8601 "zulu" format. * `visitorId`: Double quoted string. Specifying this will delete all events associated with a visitor. * `userId`: Double quoted 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.
2365    pub filter: Option<String>,
2366    /// Actually perform the purge. If `force` is set to false, the method will return the expected purge count without deleting any user events.
2367    pub force: Option<bool>,
2368}
2369
2370impl common::RequestValue for GoogleCloudRetailV2PurgeUserEventsRequest {}
2371
2372/// The rating of a Product.
2373///
2374/// This type is not used in any activity, and only used as *part* of another schema.
2375///
2376#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2377#[serde_with::serde_as]
2378#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2379pub struct GoogleCloudRetailV2Rating {
2380    /// The average rating of the Product. The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is returned.
2381    #[serde(rename = "averageRating")]
2382    pub average_rating: Option<f32>,
2383    /// The total number of ratings. This value is independent of the value of rating_histogram. This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is returned.
2384    #[serde(rename = "ratingCount")]
2385    pub rating_count: Option<i32>,
2386    /// List of rating counts per rating value (index = rating - 1). The list is empty if there is no rating. If the list is non-empty, its size is always 5. Otherwise, an INVALID_ARGUMENT error is returned. For example, [41, 14, 13, 47, 303]. It means that the Product got 41 ratings with 1 star, 14 ratings with 2 star, and so on.
2387    #[serde(rename = "ratingHistogram")]
2388    pub rating_histogram: Option<Vec<i32>>,
2389}
2390
2391impl common::Part for GoogleCloudRetailV2Rating {}
2392
2393/// Request message for RejoinUserEvents method.
2394///
2395/// # Activities
2396///
2397/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2398/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2399///
2400/// * [locations catalogs user events rejoin projects](ProjectLocationCatalogUserEventRejoinCall) (request)
2401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2402#[serde_with::serde_as]
2403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2404pub struct GoogleCloudRetailV2RejoinUserEventsRequest {
2405    /// The type of the user event rejoin to define the scope and range of the user events to be rejoined with the latest product catalog. Defaults to `USER_EVENT_REJOIN_SCOPE_UNSPECIFIED` if this field is not set, or set to an invalid integer value.
2406    #[serde(rename = "userEventRejoinScope")]
2407    pub user_event_rejoin_scope: Option<String>,
2408}
2409
2410impl common::RequestValue for GoogleCloudRetailV2RejoinUserEventsRequest {}
2411
2412/// Request for CatalogService.RemoveCatalogAttribute method.
2413///
2414/// # Activities
2415///
2416/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2417/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2418///
2419/// * [locations catalogs attributes config remove catalog attribute projects](ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall) (request)
2420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2421#[serde_with::serde_as]
2422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2423pub struct GoogleCloudRetailV2RemoveCatalogAttributeRequest {
2424    /// Required. The attribute name key of the CatalogAttribute to remove.
2425    pub key: Option<String>,
2426}
2427
2428impl common::RequestValue for GoogleCloudRetailV2RemoveCatalogAttributeRequest {}
2429
2430/// Request for RemoveControl method.
2431///
2432/// # Activities
2433///
2434/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2435/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2436///
2437/// * [locations catalogs serving configs remove control projects](ProjectLocationCatalogServingConfigRemoveControlCall) (request)
2438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2439#[serde_with::serde_as]
2440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2441pub struct GoogleCloudRetailV2RemoveControlRequest {
2442    /// Required. The id of the control to apply. Assumed to be in the same catalog as the serving config.
2443    #[serde(rename = "controlId")]
2444    pub control_id: Option<String>,
2445}
2446
2447impl common::RequestValue for GoogleCloudRetailV2RemoveControlRequest {}
2448
2449/// Request message for ProductService.RemoveFulfillmentPlaces method.
2450///
2451/// # Activities
2452///
2453/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2454/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2455///
2456/// * [locations catalogs branches products remove fulfillment places projects](ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall) (request)
2457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2458#[serde_with::serde_as]
2459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2460pub struct GoogleCloudRetailV2RemoveFulfillmentPlacesRequest {
2461    /// If set to true, and the Product is not found, the fulfillment information will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.
2462    #[serde(rename = "allowMissing")]
2463    pub allow_missing: Option<bool>,
2464    /// Required. The IDs for this type, such as the store IDs for "pickup-in-store" or the region IDs for "same-day-delivery", to be removed for this type. At least 1 value is required, and a maximum of 2000 values are allowed. Each value must be a string with a length limit of 10 characters, matching the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is returned.
2465    #[serde(rename = "placeIds")]
2466    pub place_ids: Option<Vec<String>>,
2467    /// The time when the fulfillment updates are issued, used to prevent out-of-order updates on fulfillment information. If not provided, the internal system time will be used.
2468    #[serde(rename = "removeTime")]
2469    pub remove_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2470    /// Required. The fulfillment type, including commonly used types (such as pickup in store and same day delivery), and custom types. Supported values: * "pickup-in-store" * "ship-to-store" * "same-day-delivery" * "next-day-delivery" * "custom-type-1" * "custom-type-2" * "custom-type-3" * "custom-type-4" * "custom-type-5" If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned. This field directly corresponds to Product.fulfillment_info.type.
2471    #[serde(rename = "type")]
2472    pub type_: Option<String>,
2473}
2474
2475impl common::RequestValue for GoogleCloudRetailV2RemoveFulfillmentPlacesRequest {}
2476
2477/// Request message for ProductService.RemoveLocalInventories method.
2478///
2479/// # Activities
2480///
2481/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2482/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2483///
2484/// * [locations catalogs branches products remove local inventories projects](ProjectLocationCatalogBranchProductRemoveLocalInventoryCall) (request)
2485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2486#[serde_with::serde_as]
2487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2488pub struct GoogleCloudRetailV2RemoveLocalInventoriesRequest {
2489    /// If set to true, and the Product is not found, the local inventory removal request will still be processed and retained for at most 1 day and processed once the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.
2490    #[serde(rename = "allowMissing")]
2491    pub allow_missing: Option<bool>,
2492    /// Required. A list of place IDs to have their inventory deleted. At most 3000 place IDs are allowed per request.
2493    #[serde(rename = "placeIds")]
2494    pub place_ids: Option<Vec<String>>,
2495    /// The time when the inventory deletions are issued. Used to prevent out-of-order updates and deletions on local inventory fields. If not provided, the internal system time will be used.
2496    #[serde(rename = "removeTime")]
2497    pub remove_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2498}
2499
2500impl common::RequestValue for GoogleCloudRetailV2RemoveLocalInventoriesRequest {}
2501
2502/// Request for CatalogService.ReplaceCatalogAttribute method.
2503///
2504/// # Activities
2505///
2506/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2507/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2508///
2509/// * [locations catalogs attributes config replace catalog attribute projects](ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall) (request)
2510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2511#[serde_with::serde_as]
2512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2513pub struct GoogleCloudRetailV2ReplaceCatalogAttributeRequest {
2514    /// Required. The updated CatalogAttribute.
2515    #[serde(rename = "catalogAttribute")]
2516    pub catalog_attribute: Option<GoogleCloudRetailV2CatalogAttribute>,
2517    /// Indicates which fields in the provided CatalogAttribute to update. The following are NOT supported: * CatalogAttribute.key If not set, all supported fields are updated.
2518    #[serde(rename = "updateMask")]
2519    pub update_mask: Option<common::FieldMask>,
2520}
2521
2522impl common::RequestValue for GoogleCloudRetailV2ReplaceCatalogAttributeRequest {}
2523
2524/// Request for resuming training of a model.
2525///
2526/// # Activities
2527///
2528/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2529/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2530///
2531/// * [locations catalogs models resume projects](ProjectLocationCatalogModelResumeCall) (request)
2532#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2533#[serde_with::serde_as]
2534#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2535pub struct GoogleCloudRetailV2ResumeModelRequest {
2536    _never_set: Option<bool>,
2537}
2538
2539impl common::RequestValue for GoogleCloudRetailV2ResumeModelRequest {}
2540
2541/// A rule is a condition-action pair * A condition defines when a rule is to be triggered. * An action specifies what occurs on that trigger. Currently rules only work for controls with SOLUTION_TYPE_SEARCH.
2542///
2543/// This type is not used in any activity, and only used as *part* of another schema.
2544///
2545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2546#[serde_with::serde_as]
2547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2548pub struct GoogleCloudRetailV2Rule {
2549    /// A boost action.
2550    #[serde(rename = "boostAction")]
2551    pub boost_action: Option<GoogleCloudRetailV2RuleBoostAction>,
2552    /// Required. The condition that triggers the rule. If the condition is empty, the rule will always apply.
2553    pub condition: Option<GoogleCloudRetailV2Condition>,
2554    /// Prevents term from being associated with other terms.
2555    #[serde(rename = "doNotAssociateAction")]
2556    pub do_not_associate_action: Option<GoogleCloudRetailV2RuleDoNotAssociateAction>,
2557    /// Filters results.
2558    #[serde(rename = "filterAction")]
2559    pub filter_action: Option<GoogleCloudRetailV2RuleFilterAction>,
2560    /// Force returns an attribute as a facet in the request.
2561    #[serde(rename = "forceReturnFacetAction")]
2562    pub force_return_facet_action: Option<GoogleCloudRetailV2RuleForceReturnFacetAction>,
2563    /// Ignores specific terms from query during search.
2564    #[serde(rename = "ignoreAction")]
2565    pub ignore_action: Option<GoogleCloudRetailV2RuleIgnoreAction>,
2566    /// Treats specific term as a synonym with a group of terms. Group of terms will not be treated as synonyms with the specific term.
2567    #[serde(rename = "onewaySynonymsAction")]
2568    pub oneway_synonyms_action: Option<GoogleCloudRetailV2RuleOnewaySynonymsAction>,
2569    /// Pins one or more specified products to a specific position in the results.
2570    #[serde(rename = "pinAction")]
2571    pub pin_action: Option<GoogleCloudRetailV2RulePinAction>,
2572    /// Redirects a shopper to a specific page.
2573    #[serde(rename = "redirectAction")]
2574    pub redirect_action: Option<GoogleCloudRetailV2RuleRedirectAction>,
2575    /// Remove an attribute as a facet in the request (if present).
2576    #[serde(rename = "removeFacetAction")]
2577    pub remove_facet_action: Option<GoogleCloudRetailV2RuleRemoveFacetAction>,
2578    /// Replaces specific terms in the query.
2579    #[serde(rename = "replacementAction")]
2580    pub replacement_action: Option<GoogleCloudRetailV2RuleReplacementAction>,
2581    /// Treats a set of terms as synonyms of one another.
2582    #[serde(rename = "twowaySynonymsAction")]
2583    pub twoway_synonyms_action: Option<GoogleCloudRetailV2RuleTwowaySynonymsAction>,
2584}
2585
2586impl common::Part for GoogleCloudRetailV2Rule {}
2587
2588/// A boost action to apply to results matching condition specified above.
2589///
2590/// This type is not used in any activity, and only used as *part* of another schema.
2591///
2592#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2593#[serde_with::serde_as]
2594#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2595pub struct GoogleCloudRetailV2RuleBoostAction {
2596    /// Strength of the condition boost, which must be in [-1, 1]. Negative boost means demotion. Default is 0.0. Setting to 1.0 gives the item a big promotion. However, it does not necessarily mean that the boosted item will be the top result at all times, nor that other items will be excluded. Results could still be shown even when none of them matches the condition. And results that are significantly more relevant to the search query can still trump your heavily favored but irrelevant items. Setting to -1.0 gives the item a big demotion. However, results that are deeply relevant might still be shown. The item will have an upstream battle to get a fairly high ranking, but it is not blocked out completely. Setting to 0.0 means no boost applied. The boosting condition is ignored.
2597    pub boost: Option<f32>,
2598    /// The filter can have a max size of 5000 characters. An expression which specifies which products to apply an action to. The syntax and supported fields are the same as a filter expression. See SearchRequest.filter for detail syntax and limitations. Examples: * To boost products with product ID "product_1" or "product_2", and color "Red" or "Blue": *(id: ANY("product_1", "product_2")) * *AND * *(colorFamilies: ANY("Red", "Blue")) *
2599    #[serde(rename = "productsFilter")]
2600    pub products_filter: Option<String>,
2601}
2602
2603impl common::Part for GoogleCloudRetailV2RuleBoostAction {}
2604
2605/// Prevents `query_term` from being associated with specified terms during search. Example: Don't associate "gShoe" and "cheap".
2606///
2607/// This type is not used in any activity, and only used as *part* of another schema.
2608///
2609#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2610#[serde_with::serde_as]
2611#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2612pub struct GoogleCloudRetailV2RuleDoNotAssociateAction {
2613    /// Cannot contain duplicates or the query term. Can specify up to 100 terms.
2614    #[serde(rename = "doNotAssociateTerms")]
2615    pub do_not_associate_terms: Option<Vec<String>>,
2616    /// Terms from the search query. Will not consider do_not_associate_terms for search if in search query. Can specify up to 100 terms.
2617    #[serde(rename = "queryTerms")]
2618    pub query_terms: Option<Vec<String>>,
2619    /// Will be [deprecated = true] post migration;
2620    pub terms: Option<Vec<String>>,
2621}
2622
2623impl common::Part for GoogleCloudRetailV2RuleDoNotAssociateAction {}
2624
2625/// * Rule Condition: - No Condition.query_terms provided is a global match. - 1 or more Condition.query_terms provided are combined with OR operator. * Action Input: The request query and filter that are applied to the retrieved products, in addition to any filters already provided with the SearchRequest. The AND operator is used to combine the query's existing filters with the filter rule(s). NOTE: May result in 0 results when filters conflict. * Action Result: Filters the returned objects to be ONLY those that passed the filter.
2626///
2627/// This type is not used in any activity, and only used as *part* of another schema.
2628///
2629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2630#[serde_with::serde_as]
2631#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2632pub struct GoogleCloudRetailV2RuleFilterAction {
2633    /// A filter to apply on the matching condition results. Supported features: * filter must be set. * Filter syntax is identical to SearchRequest.filter. For more information, see [Filter](https://cloud.google.com/retail/docs/filter-and-order#filter). * To filter products with product ID “product_1” or “product_2”, and color “Red” or “Blue”: \*(id: ANY(“product_1”, “product_2”)) * \*AND * \*(colorFamilies: ANY(“Red”, “Blue”)) *
2634    pub filter: Option<String>,
2635}
2636
2637impl common::Part for GoogleCloudRetailV2RuleFilterAction {}
2638
2639/// Force returns an attribute/facet in the request around a certain position or above. * Rule Condition: Must specify non-empty Condition.query_terms (for search only) or Condition.page_categories (for browse only), but can't specify both. * Action Inputs: attribute name, position * Action Result: Will force return a facet key around a certain position or above if the condition is satisfied. Example: Suppose the query is "shoes", the Condition.query_terms is "shoes", the ForceReturnFacetAction.FacetPositionAdjustment.attribute_name is "size" and the ForceReturnFacetAction.FacetPositionAdjustment.position is 8. Two cases: a) The facet key "size" is not already in the top 8 slots, then the facet "size" will appear at a position close to 8. b) The facet key "size" in among the top 8 positions in the request, then it will stay at its current rank.
2640///
2641/// This type is not used in any activity, and only used as *part* of another schema.
2642///
2643#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2644#[serde_with::serde_as]
2645#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2646pub struct GoogleCloudRetailV2RuleForceReturnFacetAction {
2647    /// Each instance corresponds to a force return attribute for the given condition. There can't be more 15 instances here.
2648    #[serde(rename = "facetPositionAdjustments")]
2649    pub facet_position_adjustments:
2650        Option<Vec<GoogleCloudRetailV2RuleForceReturnFacetActionFacetPositionAdjustment>>,
2651}
2652
2653impl common::Part for GoogleCloudRetailV2RuleForceReturnFacetAction {}
2654
2655/// Each facet position adjustment consists of a single attribute name (i.e. facet key) along with a specified position.
2656///
2657/// This type is not used in any activity, and only used as *part* of another schema.
2658///
2659#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2660#[serde_with::serde_as]
2661#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2662pub struct GoogleCloudRetailV2RuleForceReturnFacetActionFacetPositionAdjustment {
2663    /// The attribute name to force return as a facet. Each attribute name should be a valid attribute name, be non-empty and contain at most 80 characters long.
2664    #[serde(rename = "attributeName")]
2665    pub attribute_name: Option<String>,
2666    /// This is the position in the request as explained above. It should be strictly positive be at most 100.
2667    pub position: Option<i32>,
2668}
2669
2670impl common::Part for GoogleCloudRetailV2RuleForceReturnFacetActionFacetPositionAdjustment {}
2671
2672/// Prevents a term in the query from being used in search. Example: Don't search for "shoddy".
2673///
2674/// This type is not used in any activity, and only used as *part* of another schema.
2675///
2676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2677#[serde_with::serde_as]
2678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2679pub struct GoogleCloudRetailV2RuleIgnoreAction {
2680    /// Terms to ignore in the search query.
2681    #[serde(rename = "ignoreTerms")]
2682    pub ignore_terms: Option<Vec<String>>,
2683}
2684
2685impl common::Part for GoogleCloudRetailV2RuleIgnoreAction {}
2686
2687/// Maps a set of terms to a set of synonyms. Set of synonyms will be treated as synonyms of each query term only. `query_terms` will not be treated as synonyms of each other. Example: "sneakers" will use a synonym of "shoes". "shoes" will not use a synonym of "sneakers".
2688///
2689/// This type is not used in any activity, and only used as *part* of another schema.
2690///
2691#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2692#[serde_with::serde_as]
2693#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2694pub struct GoogleCloudRetailV2RuleOnewaySynonymsAction {
2695    /// Will be [deprecated = true] post migration;
2696    #[serde(rename = "onewayTerms")]
2697    pub oneway_terms: Option<Vec<String>>,
2698    /// Terms from the search query. Will treat synonyms as their synonyms. Not themselves synonyms of the synonyms. Can specify up to 100 terms.
2699    #[serde(rename = "queryTerms")]
2700    pub query_terms: Option<Vec<String>>,
2701    /// Defines a set of synonyms. Cannot contain duplicates. Can specify up to 100 synonyms.
2702    pub synonyms: Option<Vec<String>>,
2703}
2704
2705impl common::Part for GoogleCloudRetailV2RuleOnewaySynonymsAction {}
2706
2707/// Pins one or more specified products to a specific position in the results. * Rule Condition: Must specify non-empty Condition.query_terms (for search only) or Condition.page_categories (for browse only), but can't specify both. * Action Input: mapping of `[pin_position, product_id]` pairs (pin position uses 1-based indexing). * Action Result: Will pin products with matching ids to the position specified in the final result order. Example: Suppose the query is `shoes`, the Condition.query_terms is `shoes` and the pin_map has `{1, "pid1"}`, then product with `pid1` will be pinned to the top position in the final results. If multiple PinActions are matched to a single request the actions will be processed from most to least recently updated. Pins to positions larger than the max allowed page size of 120 are not allowed.
2708///
2709/// This type is not used in any activity, and only used as *part* of another schema.
2710///
2711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2712#[serde_with::serde_as]
2713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2714pub struct GoogleCloudRetailV2RulePinAction {
2715    /// Required. A map of positions to product_ids. Partial matches per action are allowed, if a certain position in the map is already filled that `[position, product_id]` pair will be ignored but the rest may still be applied. This case will only occur if multiple pin actions are matched to a single request, as the map guarantees that pin positions are unique within the same action. Duplicate product_ids are not permitted within a single pin map. The max size of this map is 120, equivalent to the max [request page size](https://cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/search#request-body).
2716    #[serde(rename = "pinMap")]
2717    pub pin_map: Option<HashMap<String, String>>,
2718}
2719
2720impl common::Part for GoogleCloudRetailV2RulePinAction {}
2721
2722/// Redirects a shopper to a specific page. * Rule Condition: Must specify Condition.query_terms. * Action Input: Request Query * Action Result: Redirects shopper to provided uri.
2723///
2724/// This type is not used in any activity, and only used as *part* of another schema.
2725///
2726#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2727#[serde_with::serde_as]
2728#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2729pub struct GoogleCloudRetailV2RuleRedirectAction {
2730    /// URL must have length equal or less than 2000 characters.
2731    #[serde(rename = "redirectUri")]
2732    pub redirect_uri: Option<String>,
2733}
2734
2735impl common::Part for GoogleCloudRetailV2RuleRedirectAction {}
2736
2737/// Removes an attribute/facet in the request if is present. * Rule Condition: Must specify non-empty Condition.query_terms (for search only) or Condition.page_categories (for browse only), but can't specify both. * Action Input: attribute name * Action Result: Will remove the attribute (as a facet) from the request if it is present. Example: Suppose the query is "shoes", the Condition.query_terms is "shoes" and the attribute name "size", then facet key "size" will be removed from the request (if it is present).
2738///
2739/// This type is not used in any activity, and only used as *part* of another schema.
2740///
2741#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2742#[serde_with::serde_as]
2743#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2744pub struct GoogleCloudRetailV2RuleRemoveFacetAction {
2745    /// The attribute names (i.e. facet keys) to remove from the dynamic facets (if present in the request). There can't be more 3 attribute names. Each attribute name should be a valid attribute name, be non-empty and contain at most 80 characters.
2746    #[serde(rename = "attributeNames")]
2747    pub attribute_names: Option<Vec<String>>,
2748}
2749
2750impl common::Part for GoogleCloudRetailV2RuleRemoveFacetAction {}
2751
2752/// Replaces a term in the query. Multiple replacement candidates can be specified. All `query_terms` will be replaced with the replacement term. Example: Replace "gShoe" with "google shoe".
2753///
2754/// This type is not used in any activity, and only used as *part* of another schema.
2755///
2756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2757#[serde_with::serde_as]
2758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2759pub struct GoogleCloudRetailV2RuleReplacementAction {
2760    /// Terms from the search query. Will be replaced by replacement term. Can specify up to 100 terms.
2761    #[serde(rename = "queryTerms")]
2762    pub query_terms: Option<Vec<String>>,
2763    /// Term that will be used for replacement.
2764    #[serde(rename = "replacementTerm")]
2765    pub replacement_term: Option<String>,
2766    /// Will be [deprecated = true] post migration;
2767    pub term: Option<String>,
2768}
2769
2770impl common::Part for GoogleCloudRetailV2RuleReplacementAction {}
2771
2772/// Creates a set of terms that will be treated as synonyms of each other. Example: synonyms of "sneakers" and "shoes": * "sneakers" will use a synonym of "shoes". * "shoes" will use a synonym of "sneakers".
2773///
2774/// This type is not used in any activity, and only used as *part* of another schema.
2775///
2776#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2777#[serde_with::serde_as]
2778#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2779pub struct GoogleCloudRetailV2RuleTwowaySynonymsAction {
2780    /// Defines a set of synonyms. Can specify up to 100 synonyms. Must specify at least 2 synonyms.
2781    pub synonyms: Option<Vec<String>>,
2782}
2783
2784impl common::Part for GoogleCloudRetailV2RuleTwowaySynonymsAction {}
2785
2786/// Safety settings.
2787///
2788/// This type is not used in any activity, and only used as *part* of another schema.
2789///
2790#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2791#[serde_with::serde_as]
2792#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2793pub struct GoogleCloudRetailV2SafetySetting {
2794    /// Harm category.
2795    pub category: Option<String>,
2796    /// Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score.
2797    pub method: Option<String>,
2798    /// The harm block threshold.
2799    pub threshold: Option<String>,
2800}
2801
2802impl common::Part for GoogleCloudRetailV2SafetySetting {}
2803
2804/// Request message for SearchService.Search method.
2805///
2806/// # Activities
2807///
2808/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2809/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2810///
2811/// * [locations catalogs placements search projects](ProjectLocationCatalogPlacementSearchCall) (request)
2812/// * [locations catalogs serving configs search projects](ProjectLocationCatalogServingConfigSearchCall) (request)
2813#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2814#[serde_with::serde_as]
2815#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2816pub struct GoogleCloudRetailV2SearchRequest {
2817    /// Boost specification to boost certain products. For more information, see [Boost results](https://cloud.google.com/retail/docs/boosting). Notice that if both ServingConfig.boost_control_ids and SearchRequest.boost_spec are set, the boost conditions from both places are evaluated. If a search request matches multiple boost conditions, the final boost score is equal to the sum of the boost scores from all matched boost conditions.
2818    #[serde(rename = "boostSpec")]
2819    pub boost_spec: Option<GoogleCloudRetailV2SearchRequestBoostSpec>,
2820    /// The branch resource name, such as `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use "default_branch" as the branch ID or leave this field empty, to search products under the default branch.
2821    pub branch: Option<String>,
2822    /// The default filter that is applied when a user performs a search without checking any filters on the search page. The filter applied to every search request when quality improvement such as query expansion is needed. In the case a query does not have a sufficient amount of results this filter will be used to determine whether or not to enable the query expansion flow. The original filter will still be used for the query expanded search. This field is strongly recommended to achieve high search quality. For more information about filter syntax, see SearchRequest.filter.
2823    #[serde(rename = "canonicalFilter")]
2824    pub canonical_filter: Option<String>,
2825    /// Optional. This field specifies all conversational related parameters addition to traditional retail search.
2826    #[serde(rename = "conversationalSearchSpec")]
2827    pub conversational_search_spec:
2828        Option<GoogleCloudRetailV2SearchRequestConversationalSearchSpec>,
2829    /// Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic to enable dynamic facets. Do not set this field. The specification for dynamically generated facets. Notice that only textual facets can be dynamically generated.
2830    #[serde(rename = "dynamicFacetSpec")]
2831    pub dynamic_facet_spec: Option<GoogleCloudRetailV2SearchRequestDynamicFacetSpec>,
2832    /// The entity for customers that may run multiple different entities, domains, sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, `google.com`, `youtube.com`, etc. If this is set, it should be exactly matched with UserEvent.entity to get search results boosted by entity.
2833    pub entity: Option<String>,
2834    /// Facet specifications for faceted search. If empty, no facets are returned. A maximum of 200 values are allowed. Otherwise, an INVALID_ARGUMENT error is returned.
2835    #[serde(rename = "facetSpecs")]
2836    pub facet_specs: Option<Vec<GoogleCloudRetailV2SearchRequestFacetSpec>>,
2837    /// The filter syntax consists of an expression language for constructing a predicate from one or more fields of the products being filtered. Filter expression is case-sensitive. For more information, see [Filter](https://cloud.google.com/retail/docs/filter-and-order#filter). If this field is unrecognizable, an INVALID_ARGUMENT is returned.
2838    pub filter: Option<String>,
2839    /// The labels applied to a resource must meet the following requirements: * Each resource can have multiple labels, up to a maximum of 64. * Each label must be a key-value pair. * Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters. * Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. * The key portion of a label must be unique. However, you can use the same key with multiple resources. * Keys must start with a lowercase letter or international character. For more information, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) in the Resource Manager documentation.
2840    pub labels: Option<HashMap<String, String>>,
2841    /// Optional. The BCP-47 language code, such as "en-US" or "sr-Latn" [list](https://www.unicode.org/cldr/charts/46/summary/root.html). For more information, see [Standardized codes](https://google.aip.dev/143). This field helps to better interpret the query. If a value isn't specified, the query language code is automatically detected, which may not be accurate.
2842    #[serde(rename = "languageCode")]
2843    pub language_code: Option<String>,
2844    /// A 0-indexed integer that specifies the current offset (that is, starting result location, amongst the Products deemed by the API as relevant) in search results. This field is only considered if page_token is unset. If this field is negative, an INVALID_ARGUMENT is returned.
2845    pub offset: Option<i32>,
2846    /// The order in which products are returned. Products can be ordered by a field in an Product object. Leave it unset if ordered by relevance. OrderBy expression is case-sensitive. For more information, see [Order](https://cloud.google.com/retail/docs/filter-and-order#order). If this field is unrecognizable, an INVALID_ARGUMENT is returned.
2847    #[serde(rename = "orderBy")]
2848    pub order_by: Option<String>,
2849    /// The categories associated with a category page. Must be set for category navigation queries to achieve good search quality. The format should be the same as UserEvent.page_categories; To represent full path of category, use '>' sign to separate different hierarchies. If '>' is part of the category name, replace it with other character(s). Category pages include special pages such as sales or promotions. For instance, a special sale page may have the category hierarchy: "pageCategories" : ["Sales > 2017 Black Friday Deals"].
2850    #[serde(rename = "pageCategories")]
2851    pub page_categories: Option<Vec<String>>,
2852    /// Maximum number of Products to return. If unspecified, defaults to a reasonable value. The maximum allowed value is 120. Values above 120 will be coerced to 120. If this field is negative, an INVALID_ARGUMENT is returned.
2853    #[serde(rename = "pageSize")]
2854    pub page_size: Option<i32>,
2855    /// A page token SearchResponse.next_page_token, received from a previous SearchService.Search call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to SearchService.Search must match the call that provided the page token. Otherwise, an INVALID_ARGUMENT error is returned.
2856    #[serde(rename = "pageToken")]
2857    pub page_token: Option<String>,
2858    /// The specification for personalization. Notice that if both ServingConfig.personalization_spec and SearchRequest.personalization_spec are set. SearchRequest.personalization_spec will override ServingConfig.personalization_spec.
2859    #[serde(rename = "personalizationSpec")]
2860    pub personalization_spec: Option<GoogleCloudRetailV2SearchRequestPersonalizationSpec>,
2861    /// Optional. An id corresponding to a place, such as a store id or region id. When specified, we use the price from the local inventory with the matching product's LocalInventory.place_id for revenue optimization.
2862    #[serde(rename = "placeId")]
2863    pub place_id: Option<String>,
2864    /// Raw search query. If this field is empty, the request is considered a category browsing request and returned results are based on filter and page_categories.
2865    pub query: Option<String>,
2866    /// The query expansion specification that specifies the conditions under which query expansion occurs. For more information, see [Query expansion](https://cloud.google.com/retail/docs/result-size#query_expansion).
2867    #[serde(rename = "queryExpansionSpec")]
2868    pub query_expansion_spec: Option<GoogleCloudRetailV2SearchRequestQueryExpansionSpec>,
2869    /// Optional. The Unicode country/region code (CLDR) of a location, such as "US" and "419" [list](https://www.unicode.org/cldr/charts/46/supplemental/territory_information.html). For more information, see [Standardized codes](https://google.aip.dev/143). If set, then results will be boosted based on the region_code provided.
2870    #[serde(rename = "regionCode")]
2871    pub region_code: Option<String>,
2872    /// The search mode of the search request. If not specified, a single search request triggers both product search and faceted search.
2873    #[serde(rename = "searchMode")]
2874    pub search_mode: Option<String>,
2875    /// The spell correction specification that specifies the mode under which spell correction will take effect.
2876    #[serde(rename = "spellCorrectionSpec")]
2877    pub spell_correction_spec: Option<GoogleCloudRetailV2SearchRequestSpellCorrectionSpec>,
2878    /// Optional. This field specifies tile navigation related parameters.
2879    #[serde(rename = "tileNavigationSpec")]
2880    pub tile_navigation_spec: Option<GoogleCloudRetailV2SearchRequestTileNavigationSpec>,
2881    /// Optional. The user attributes that could be used for personalization of search results. * Populate at most 100 key-value pairs per query. * Only supports string keys and repeated string values. * Duplicate keys are not allowed within a single query. Example: user_attributes: [ { key: "pets" value { values: "dog" values: "cat" } }, { key: "state" value { values: "CA" } } ]
2882    #[serde(rename = "userAttributes")]
2883    pub user_attributes: Option<HashMap<String, GoogleCloudRetailV2StringList>>,
2884    /// User information.
2885    #[serde(rename = "userInfo")]
2886    pub user_info: Option<GoogleCloudRetailV2UserInfo>,
2887    /// The keys to fetch and rollup the matching variant Products attributes, FulfillmentInfo or LocalInventorys attributes. The attributes from all the matching variant Products or LocalInventorys are merged and de-duplicated. Notice that rollup attributes will lead to extra query latency. Maximum number of keys is 30. For FulfillmentInfo, a fulfillment type and a fulfillment ID must be provided in the format of "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", "pickupInStore" is fulfillment type and "store123" is the store ID. Supported keys are: * colorFamilies * price * originalPrice * discount * variantId * inventory(place_id,price) * inventory(place_id,original_price) * inventory(place_id,attributes.key), where key is any key in the Product.local_inventories.attributes map. * attributes.key, where key is any key in the Product.attributes map. * pickupInStore.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "pickup-in-store". * shipToStore.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "ship-to-store". * sameDayDelivery.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "same-day-delivery". * nextDayDelivery.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "next-day-delivery". * customFulfillment1.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "custom-type-1". * customFulfillment2.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "custom-type-2". * customFulfillment3.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "custom-type-3". * customFulfillment4.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "custom-type-4". * customFulfillment5.id, where id is any FulfillmentInfo.place_ids for FulfillmentInfo.type "custom-type-5". If this field is set to an invalid value other than these, an INVALID_ARGUMENT error is returned.
2888    #[serde(rename = "variantRollupKeys")]
2889    pub variant_rollup_keys: Option<Vec<String>>,
2890    /// Required. A unique identifier for tracking visitors. 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. This should be the same identifier as UserEvent.visitor_id. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
2891    #[serde(rename = "visitorId")]
2892    pub visitor_id: Option<String>,
2893}
2894
2895impl common::RequestValue for GoogleCloudRetailV2SearchRequest {}
2896
2897/// Boost specification to boost certain items.
2898///
2899/// This type is not used in any activity, and only used as *part* of another schema.
2900///
2901#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2902#[serde_with::serde_as]
2903#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2904pub struct GoogleCloudRetailV2SearchRequestBoostSpec {
2905    /// Condition boost specifications. If a product matches multiple conditions in the specifications, boost scores from these specifications are all applied and combined in a non-linear way. Maximum number of specifications is 20.
2906    #[serde(rename = "conditionBoostSpecs")]
2907    pub condition_boost_specs:
2908        Option<Vec<GoogleCloudRetailV2SearchRequestBoostSpecConditionBoostSpec>>,
2909    /// Whether to skip boostspec validation. If this field is set to true, invalid BoostSpec.condition_boost_specs will be ignored and valid BoostSpec.condition_boost_specs will still be applied.
2910    #[serde(rename = "skipBoostSpecValidation")]
2911    pub skip_boost_spec_validation: Option<bool>,
2912}
2913
2914impl common::Part for GoogleCloudRetailV2SearchRequestBoostSpec {}
2915
2916/// Boost applies to products which match a condition.
2917///
2918/// This type is not used in any activity, and only used as *part* of another schema.
2919///
2920#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2921#[serde_with::serde_as]
2922#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2923pub struct GoogleCloudRetailV2SearchRequestBoostSpecConditionBoostSpec {
2924    /// Strength of the condition boost, which should be in [-1, 1]. Negative boost means demotion. Default is 0.0. Setting to 1.0 gives the item a big promotion. However, it does not necessarily mean that the boosted item will be the top result at all times, nor that other items will be excluded. Results could still be shown even when none of them matches the condition. And results that are significantly more relevant to the search query can still trump your heavily favored but irrelevant items. Setting to -1.0 gives the item a big demotion. However, results that are deeply relevant might still be shown. The item will have an upstream battle to get a fairly high ranking, but it is not blocked out completely. Setting to 0.0 means no boost applied. The boosting condition is ignored.
2925    pub boost: Option<f32>,
2926    /// An expression which specifies a boost condition. The syntax and supported fields are the same as a filter expression. See SearchRequest.filter for detail syntax and limitations. Examples: * To boost products with product ID "product_1" or "product_2", and color "Red" or "Blue": * (id: ANY("product_1", "product_2")) AND (colorFamilies: ANY("Red","Blue"))
2927    pub condition: Option<String>,
2928}
2929
2930impl common::Part for GoogleCloudRetailV2SearchRequestBoostSpecConditionBoostSpec {}
2931
2932/// This field specifies all conversational related parameters addition to traditional retail search.
2933///
2934/// This type is not used in any activity, and only used as *part* of another schema.
2935///
2936#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2937#[serde_with::serde_as]
2938#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2939pub struct GoogleCloudRetailV2SearchRequestConversationalSearchSpec {
2940    /// This field specifies the conversation id, which maintains the state of the conversation between client side and server side. Use the value from the previous ConversationalSearchResult.conversation_id. For the initial request, this should be empty.
2941    #[serde(rename = "conversationId")]
2942    pub conversation_id: Option<String>,
2943    /// This field specifies whether the customer would like to do conversational search. If this field is set to true, conversational related extra information will be returned from server side, including follow-up question, answer options, etc.
2944    #[serde(rename = "followupConversationRequested")]
2945    pub followup_conversation_requested: Option<bool>,
2946    /// This field specifies the current user answer during the conversational search. This can be either user selected from suggested answers or user input plain text.
2947    #[serde(rename = "userAnswer")]
2948    pub user_answer: Option<GoogleCloudRetailV2SearchRequestConversationalSearchSpecUserAnswer>,
2949}
2950
2951impl common::Part for GoogleCloudRetailV2SearchRequestConversationalSearchSpec {}
2952
2953/// This field specifies the current user answer during the conversational search. This can be either user selected from suggested answers or user input plain text.
2954///
2955/// This type is not used in any activity, and only used as *part* of another schema.
2956///
2957#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2958#[serde_with::serde_as]
2959#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2960pub struct GoogleCloudRetailV2SearchRequestConversationalSearchSpecUserAnswer {
2961    /// This field specifies the selected attributes during the conversational search. This should be a subset of ConversationalSearchResult.suggested_answers.
2962    #[serde(rename = "selectedAnswer")]
2963    pub selected_answer:
2964        Option<GoogleCloudRetailV2SearchRequestConversationalSearchSpecUserAnswerSelectedAnswer>,
2965    /// This field specifies the incremental input text from the user during the conversational search.
2966    #[serde(rename = "textAnswer")]
2967    pub text_answer: Option<String>,
2968}
2969
2970impl common::Part for GoogleCloudRetailV2SearchRequestConversationalSearchSpecUserAnswer {}
2971
2972/// This field specifies the selected answers during the conversational search.
2973///
2974/// This type is not used in any activity, and only used as *part* of another schema.
2975///
2976#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2977#[serde_with::serde_as]
2978#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2979pub struct GoogleCloudRetailV2SearchRequestConversationalSearchSpecUserAnswerSelectedAnswer {
2980    /// This field specifies the selected answer which is a attribute key-value.
2981    #[serde(rename = "productAttributeValue")]
2982    pub product_attribute_value: Option<GoogleCloudRetailV2ProductAttributeValue>,
2983    /// This field is deprecated and should not be set.
2984    #[serde(rename = "productAttributeValues")]
2985    pub product_attribute_values: Option<Vec<GoogleCloudRetailV2ProductAttributeValue>>,
2986}
2987
2988impl common::Part
2989    for GoogleCloudRetailV2SearchRequestConversationalSearchSpecUserAnswerSelectedAnswer
2990{
2991}
2992
2993/// The specifications of dynamically generated facets.
2994///
2995/// This type is not used in any activity, and only used as *part* of another schema.
2996///
2997#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2998#[serde_with::serde_as]
2999#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3000pub struct GoogleCloudRetailV2SearchRequestDynamicFacetSpec {
3001    /// Mode of the DynamicFacet feature. Defaults to Mode.DISABLED if it's unset.
3002    pub mode: Option<String>,
3003}
3004
3005impl common::Part for GoogleCloudRetailV2SearchRequestDynamicFacetSpec {}
3006
3007/// A facet specification to perform faceted search.
3008///
3009/// This type is not used in any activity, and only used as *part* of another schema.
3010///
3011#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3012#[serde_with::serde_as]
3013#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3014pub struct GoogleCloudRetailV2SearchRequestFacetSpec {
3015    /// Enables dynamic position for this facet. If set to true, the position of this facet among all facets in the response is determined by Google Retail Search. It is ordered together with dynamic facets if dynamic facets is enabled. If set to false, the position of this facet in the response is the same as in the request, and it is ranked before the facets with dynamic position enable and all dynamic facets. For example, you may always want to have rating facet returned in the response, but it's not necessarily to always display the rating facet at the top. In that case, you can set enable_dynamic_position to true so that the position of rating facet in response is determined by Google Retail Search. Another example, assuming you have the following facets in the request: * "rating", enable_dynamic_position = true * "price", enable_dynamic_position = false * "brands", enable_dynamic_position = false And also you have a dynamic facets enable, which generates a facet "gender". Then, the final order of the facets in the response can be ("price", "brands", "rating", "gender") or ("price", "brands", "gender", "rating") depends on how Google Retail Search orders "gender" and "rating" facets. However, notice that "price" and "brands" are always ranked at first and second position because their enable_dynamic_position values are false.
3016    #[serde(rename = "enableDynamicPosition")]
3017    pub enable_dynamic_position: Option<bool>,
3018    /// List of keys to exclude when faceting. By default, FacetKey.key is not excluded from the filter unless it is listed in this field. Listing a facet key in this field allows its values to appear as facet results, even when they are filtered out of search results. Using this field does not affect what search results are returned. For example, suppose there are 100 products with the color facet "Red" and 200 products with the color facet "Blue". A query containing the filter "colorFamilies:ANY("Red")" and having "colorFamilies" as FacetKey.key would by default return only "Red" products in the search results, and also return "Red" with count 100 as the only color facet. Although there are also blue products available, "Blue" would not be shown as an available facet value. If "colorFamilies" is listed in "excludedFilterKeys", then the query returns the facet values "Red" with count 100 and "Blue" with count 200, because the "colorFamilies" key is now excluded from the filter. Because this field doesn't affect search results, the search results are still correctly filtered to return only "Red" products. A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error is returned.
3019    #[serde(rename = "excludedFilterKeys")]
3020    pub excluded_filter_keys: Option<Vec<String>>,
3021    /// Required. The facet key specification.
3022    #[serde(rename = "facetKey")]
3023    pub facet_key: Option<GoogleCloudRetailV2SearchRequestFacetSpecFacetKey>,
3024    /// Maximum of facet values that should be returned for this facet. If unspecified, defaults to 50. The maximum allowed value is 300. Values above 300 will be coerced to 300. If this field is negative, an INVALID_ARGUMENT is returned.
3025    pub limit: Option<i32>,
3026}
3027
3028impl common::Part for GoogleCloudRetailV2SearchRequestFacetSpec {}
3029
3030/// Specifies how a facet is computed.
3031///
3032/// This type is not used in any activity, and only used as *part* of another schema.
3033///
3034#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3035#[serde_with::serde_as]
3036#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3037pub struct GoogleCloudRetailV2SearchRequestFacetSpecFacetKey {
3038    /// True to make facet keys case insensitive when getting faceting values with prefixes or contains; false otherwise.
3039    #[serde(rename = "caseInsensitive")]
3040    pub case_insensitive: Option<bool>,
3041    /// Only get facet values that contains the given strings. For example, suppose "categories" has three values "Women > Shoe", "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the "categories" facet gives only "Women > Shoe" and "Men > Shoe". Only supported on textual fields. Maximum is 10.
3042    pub contains: Option<Vec<String>>,
3043    /// Set only if values should be bucketized into intervals. Must be set for facets with numerical values. Must not be set for facet with text values. Maximum number of intervals is 40. For all numerical facet keys that appear in the list of products from the catalog, the percentiles 0, 10, 30, 50, 70, 90, and 100 are computed from their distribution weekly. If the model assigns a high score to a numerical facet key and its intervals are not specified in the search request, these percentiles become the bounds for its intervals and are returned in the response. If the facet key intervals are specified in the request, then the specified intervals are returned instead.
3044    pub intervals: Option<Vec<GoogleCloudRetailV2Interval>>,
3045    /// Required. Supported textual and numerical facet keys in Product object, over which the facet values are computed. Facet key is case-sensitive. Allowed facet keys when FacetKey.query is not specified: * textual_field = * "brands" * "categories" * "genders" * "ageGroups" * "availability" * "colorFamilies" * "colors" * "sizes" * "materials" * "patterns" * "conditions" * "attributes.key" * "pickupInStore" * "shipToStore" * "sameDayDelivery" * "nextDayDelivery" * "customFulfillment1" * "customFulfillment2" * "customFulfillment3" * "customFulfillment4" * "customFulfillment5" * "inventory(place_id,attributes.key)" * numerical_field = * "price" * "discount" * "rating" * "ratingCount" * "attributes.key" * "inventory(place_id,price)" * "inventory(place_id,original_price)" * "inventory(place_id,attributes.key)"
3046    pub key: Option<String>,
3047    /// The order in which SearchResponse.Facet.values are returned. Allowed values are: * "count desc", which means order by SearchResponse.Facet.values.count descending. * "value desc", which means order by SearchResponse.Facet.values.value descending. Only applies to textual facets. If not set, textual values are sorted in [natural order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical intervals are sorted in the order given by FacetSpec.FacetKey.intervals; FulfillmentInfo.place_ids are sorted in the order given by FacetSpec.FacetKey.restricted_values.
3048    #[serde(rename = "orderBy")]
3049    pub order_by: Option<String>,
3050    /// Only get facet values that start with the given string prefix. For example, suppose "categories" has three values "Women > Shoe", "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the "categories" facet gives only "Women > Shoe" and "Women > Dress". Only supported on textual fields. Maximum is 10.
3051    pub prefixes: Option<Vec<String>>,
3052    /// The query that is used to compute facet for the given facet key. When provided, it overrides the default behavior of facet computation. The query syntax is the same as a filter expression. See SearchRequest.filter for detail syntax and limitations. Notice that there is no limitation on FacetKey.key when query is specified. In the response, SearchResponse.Facet.values.value is always "1" and SearchResponse.Facet.values.count is the number of results that match the query. For example, you can set a customized facet for "shipToStore", where FacetKey.key is "customizedShipToStore", and FacetKey.query is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". Then the facet counts the products that are both in stock and ship to store "123".
3053    pub query: Option<String>,
3054    /// Only get facet for the given restricted values. For example, when using "pickupInStore" as key and set restricted values to ["store123", "store456"], only facets for "store123" and "store456" are returned. Only supported on predefined textual fields, custom textual attributes and fulfillments. Maximum is 20. Must be set for the fulfillment facet keys: * pickupInStore * shipToStore * sameDayDelivery * nextDayDelivery * customFulfillment1 * customFulfillment2 * customFulfillment3 * customFulfillment4 * customFulfillment5
3055    #[serde(rename = "restrictedValues")]
3056    pub restricted_values: Option<Vec<String>>,
3057    /// Returns the min and max value for each numerical facet intervals. Ignored for textual facets.
3058    #[serde(rename = "returnMinMax")]
3059    pub return_min_max: Option<bool>,
3060}
3061
3062impl common::Part for GoogleCloudRetailV2SearchRequestFacetSpecFacetKey {}
3063
3064/// The specification for personalization.
3065///
3066/// This type is not used in any activity, and only used as *part* of another schema.
3067///
3068#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3069#[serde_with::serde_as]
3070#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3071pub struct GoogleCloudRetailV2SearchRequestPersonalizationSpec {
3072    /// Defaults to Mode.AUTO.
3073    pub mode: Option<String>,
3074}
3075
3076impl common::Part for GoogleCloudRetailV2SearchRequestPersonalizationSpec {}
3077
3078/// Specification to determine under which conditions query expansion should occur.
3079///
3080/// This type is not used in any activity, and only used as *part* of another schema.
3081///
3082#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3083#[serde_with::serde_as]
3084#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3085pub struct GoogleCloudRetailV2SearchRequestQueryExpansionSpec {
3086    /// The condition under which query expansion should occur. Default to Condition.DISABLED.
3087    pub condition: Option<String>,
3088    /// Whether to pin unexpanded results. The default value is false. If this field is set to true, unexpanded products are always at the top of the search results, followed by the expanded results.
3089    #[serde(rename = "pinUnexpandedResults")]
3090    pub pin_unexpanded_results: Option<bool>,
3091}
3092
3093impl common::Part for GoogleCloudRetailV2SearchRequestQueryExpansionSpec {}
3094
3095/// The specification for query spell correction.
3096///
3097/// This type is not used in any activity, and only used as *part* of another schema.
3098///
3099#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3100#[serde_with::serde_as]
3101#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3102pub struct GoogleCloudRetailV2SearchRequestSpellCorrectionSpec {
3103    /// The mode under which spell correction should take effect to replace the original search query. Default to Mode.AUTO.
3104    pub mode: Option<String>,
3105}
3106
3107impl common::Part for GoogleCloudRetailV2SearchRequestSpellCorrectionSpec {}
3108
3109/// This field specifies tile navigation related parameters.
3110///
3111/// This type is not used in any activity, and only used as *part* of another schema.
3112///
3113#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3114#[serde_with::serde_as]
3115#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3116pub struct GoogleCloudRetailV2SearchRequestTileNavigationSpec {
3117    /// This optional field specifies the tiles which are already clicked in client side. While the feature works without this field set, particularly for an initial query, it is highly recommended to set this field because it can improve the quality of the search response and removes possible duplicate tiles. NOTE: This field is not being used for filtering search products. Client side should also put all the applied tiles in SearchRequest.filter.
3118    #[serde(rename = "appliedTiles")]
3119    pub applied_tiles: Option<Vec<GoogleCloudRetailV2Tile>>,
3120    /// This field specifies whether the customer would like to request tile navigation.
3121    #[serde(rename = "tileNavigationRequested")]
3122    pub tile_navigation_requested: Option<bool>,
3123}
3124
3125impl common::Part for GoogleCloudRetailV2SearchRequestTileNavigationSpec {}
3126
3127/// Response message for SearchService.Search method.
3128///
3129/// # Activities
3130///
3131/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3132/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3133///
3134/// * [locations catalogs placements search projects](ProjectLocationCatalogPlacementSearchCall) (response)
3135/// * [locations catalogs serving configs search projects](ProjectLocationCatalogServingConfigSearchCall) (response)
3136#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3137#[serde_with::serde_as]
3138#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3139pub struct GoogleCloudRetailV2SearchResponse {
3140    /// The fully qualified resource name of applied [controls](https://cloud.google.com/retail/docs/serving-control-rules).
3141    #[serde(rename = "appliedControls")]
3142    pub applied_controls: Option<Vec<String>>,
3143    /// A unique search token. This should be included in the UserEvent logs resulting from this search, which enables accurate attribution of search model performance.
3144    #[serde(rename = "attributionToken")]
3145    pub attribution_token: Option<String>,
3146    /// This field specifies all related information that is needed on client side for UI rendering of conversational retail search.
3147    #[serde(rename = "conversationalSearchResult")]
3148    pub conversational_search_result:
3149        Option<GoogleCloudRetailV2SearchResponseConversationalSearchResult>,
3150    /// Contains the spell corrected query, if found. If the spell correction type is AUTOMATIC, then the search results are based on corrected_query. Otherwise the original query is used for search.
3151    #[serde(rename = "correctedQuery")]
3152    pub corrected_query: Option<String>,
3153    /// Metadata related to A/B testing experiment associated with this response. Only exists when an experiment is triggered.
3154    #[serde(rename = "experimentInfo")]
3155    pub experiment_info: Option<Vec<GoogleCloudRetailV2ExperimentInfo>>,
3156    /// Results of facets requested by user.
3157    pub facets: Option<Vec<GoogleCloudRetailV2SearchResponseFacet>>,
3158    /// The invalid SearchRequest.BoostSpec.condition_boost_specs that are not applied during serving.
3159    #[serde(rename = "invalidConditionBoostSpecs")]
3160    pub invalid_condition_boost_specs:
3161        Option<Vec<GoogleCloudRetailV2SearchRequestBoostSpecConditionBoostSpec>>,
3162    /// A token that can be sent as SearchRequest.page_token to retrieve the next page. If this field is omitted, there are no subsequent pages.
3163    #[serde(rename = "nextPageToken")]
3164    pub next_page_token: Option<String>,
3165    /// Metadata for pin controls which were applicable to the request. This contains two map fields, one for all matched pins and one for pins which were matched but not applied. The two maps are keyed by pin position, and the values are the product ids which were matched to that pin.
3166    #[serde(rename = "pinControlMetadata")]
3167    pub pin_control_metadata: Option<GoogleCloudRetailV2PinControlMetadata>,
3168    /// Query expansion information for the returned results.
3169    #[serde(rename = "queryExpansionInfo")]
3170    pub query_expansion_info: Option<GoogleCloudRetailV2SearchResponseQueryExpansionInfo>,
3171    /// The URI of a customer-defined redirect page. If redirect action is triggered, no search is performed, and only redirect_uri and attribution_token are set in the response.
3172    #[serde(rename = "redirectUri")]
3173    pub redirect_uri: Option<String>,
3174    /// A list of matched items. The order represents the ranking.
3175    pub results: Option<Vec<GoogleCloudRetailV2SearchResponseSearchResult>>,
3176    /// This field specifies all related information for tile navigation that will be used in client side.
3177    #[serde(rename = "tileNavigationResult")]
3178    pub tile_navigation_result: Option<GoogleCloudRetailV2SearchResponseTileNavigationResult>,
3179    /// The estimated total count of matched items irrespective of pagination. The count of results returned by pagination may be less than the total_size that matches.
3180    #[serde(rename = "totalSize")]
3181    pub total_size: Option<i32>,
3182}
3183
3184impl common::ResponseResult for GoogleCloudRetailV2SearchResponse {}
3185
3186/// This field specifies all related information that is needed on client side for UI rendering of conversational retail search.
3187///
3188/// This type is not used in any activity, and only used as *part* of another schema.
3189///
3190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3191#[serde_with::serde_as]
3192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3193pub struct GoogleCloudRetailV2SearchResponseConversationalSearchResult {
3194    /// This is the incremental additional filters implied from the current user answer. User should add the suggested addition filters to the previous SearchRequest.filter, and use the merged filter in the follow up search request.
3195    #[serde(rename = "additionalFilter")]
3196    pub additional_filter:
3197        Option<GoogleCloudRetailV2SearchResponseConversationalSearchResultAdditionalFilter>,
3198    /// This field is deprecated but will be kept for backward compatibility. There is expected to have only one additional filter and the value will be the same to the same as field `additional_filter`.
3199    #[serde(rename = "additionalFilters")]
3200    pub additional_filters:
3201        Option<Vec<GoogleCloudRetailV2SearchResponseConversationalSearchResultAdditionalFilter>>,
3202    /// Conversation UUID. This field will be stored in client side storage to maintain the conversation session with server and will be used for next search request's SearchRequest.ConversationalSearchSpec.conversation_id to restore conversation state in server.
3203    #[serde(rename = "conversationId")]
3204    pub conversation_id: Option<String>,
3205    /// The follow-up question. e.g., `What is the color?`
3206    #[serde(rename = "followupQuestion")]
3207    pub followup_question: Option<String>,
3208    /// The current refined query for the conversational search. This field will be used in customer UI that the query in the search bar should be replaced with the refined query. For example, if SearchRequest.query is `dress` and next SearchRequest.ConversationalSearchSpec.UserAnswer.text_answer is `red color`, which does not match any product attribute value filters, the refined query will be `dress, red color`.
3209    #[serde(rename = "refinedQuery")]
3210    pub refined_query: Option<String>,
3211    /// The answer options provided to client for the follow-up question.
3212    #[serde(rename = "suggestedAnswers")]
3213    pub suggested_answers:
3214        Option<Vec<GoogleCloudRetailV2SearchResponseConversationalSearchResultSuggestedAnswer>>,
3215}
3216
3217impl common::Part for GoogleCloudRetailV2SearchResponseConversationalSearchResult {}
3218
3219/// Additional filter that client side need to apply.
3220///
3221/// This type is not used in any activity, and only used as *part* of another schema.
3222///
3223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3224#[serde_with::serde_as]
3225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3226pub struct GoogleCloudRetailV2SearchResponseConversationalSearchResultAdditionalFilter {
3227    /// Product attribute value, including an attribute key and an attribute value. Other types can be added here in the future.
3228    #[serde(rename = "productAttributeValue")]
3229    pub product_attribute_value: Option<GoogleCloudRetailV2ProductAttributeValue>,
3230}
3231
3232impl common::Part for GoogleCloudRetailV2SearchResponseConversationalSearchResultAdditionalFilter {}
3233
3234/// Suggested answers to the follow-up question.
3235///
3236/// This type is not used in any activity, and only used as *part* of another schema.
3237///
3238#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3239#[serde_with::serde_as]
3240#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3241pub struct GoogleCloudRetailV2SearchResponseConversationalSearchResultSuggestedAnswer {
3242    /// Product attribute value, including an attribute key and an attribute value. Other types can be added here in the future.
3243    #[serde(rename = "productAttributeValue")]
3244    pub product_attribute_value: Option<GoogleCloudRetailV2ProductAttributeValue>,
3245}
3246
3247impl common::Part for GoogleCloudRetailV2SearchResponseConversationalSearchResultSuggestedAnswer {}
3248
3249/// A facet result.
3250///
3251/// This type is not used in any activity, and only used as *part* of another schema.
3252///
3253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3254#[serde_with::serde_as]
3255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3256pub struct GoogleCloudRetailV2SearchResponseFacet {
3257    /// Whether the facet is dynamically generated.
3258    #[serde(rename = "dynamicFacet")]
3259    pub dynamic_facet: Option<bool>,
3260    /// The key for this facet. E.g., "colorFamilies" or "price" or "attributes.attr1".
3261    pub key: Option<String>,
3262    /// The facet values for this field.
3263    pub values: Option<Vec<GoogleCloudRetailV2SearchResponseFacetFacetValue>>,
3264}
3265
3266impl common::Part for GoogleCloudRetailV2SearchResponseFacet {}
3267
3268/// A facet value which contains value names and their count.
3269///
3270/// This type is not used in any activity, and only used as *part* of another schema.
3271///
3272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3273#[serde_with::serde_as]
3274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3275pub struct GoogleCloudRetailV2SearchResponseFacetFacetValue {
3276    /// Number of items that have this facet value.
3277    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3278    pub count: Option<i64>,
3279    /// Interval value for a facet, such as [10, 20) for facet "price".
3280    pub interval: Option<GoogleCloudRetailV2Interval>,
3281    /// The maximum value in the FacetValue.interval. Only supported on numerical facets and returned if SearchRequest.FacetSpec.FacetKey.return_min_max is true.
3282    #[serde(rename = "maxValue")]
3283    pub max_value: Option<f64>,
3284    /// The minimum value in the FacetValue.interval. Only supported on numerical facets and returned if SearchRequest.FacetSpec.FacetKey.return_min_max is true.
3285    #[serde(rename = "minValue")]
3286    pub min_value: Option<f64>,
3287    /// Text value of a facet, such as "Black" for facet "colorFamilies".
3288    pub value: Option<String>,
3289}
3290
3291impl common::Part for GoogleCloudRetailV2SearchResponseFacetFacetValue {}
3292
3293/// Information describing query expansion including whether expansion has occurred.
3294///
3295/// This type is not used in any activity, and only used as *part* of another schema.
3296///
3297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3298#[serde_with::serde_as]
3299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3300pub struct GoogleCloudRetailV2SearchResponseQueryExpansionInfo {
3301    /// Bool describing whether query expansion has occurred.
3302    #[serde(rename = "expandedQuery")]
3303    pub expanded_query: Option<bool>,
3304    /// Number of pinned results. This field will only be set when expansion happens and SearchRequest.QueryExpansionSpec.pin_unexpanded_results is set to true.
3305    #[serde(rename = "pinnedResultCount")]
3306    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3307    pub pinned_result_count: Option<i64>,
3308}
3309
3310impl common::Part for GoogleCloudRetailV2SearchResponseQueryExpansionInfo {}
3311
3312/// Represents the search results.
3313///
3314/// This type is not used in any activity, and only used as *part* of another schema.
3315///
3316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3317#[serde_with::serde_as]
3318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3319pub struct GoogleCloudRetailV2SearchResponseSearchResult {
3320    /// Product.id of the searched Product.
3321    pub id: Option<String>,
3322    /// The count of matched variant Products.
3323    #[serde(rename = "matchingVariantCount")]
3324    pub matching_variant_count: Option<i32>,
3325    /// If a variant Product matches the search query, this map indicates which Product fields are matched. The key is the Product.name, the value is a field mask of the matched Product fields. If matched attributes cannot be determined, this map will be empty. For example, a key "sku1" with field mask "products.color_info" indicates there is a match between "sku1" ColorInfo and the query.
3326    #[serde(rename = "matchingVariantFields")]
3327    pub matching_variant_fields: Option<HashMap<String, common::FieldMask>>,
3328    /// Google provided available scores.
3329    #[serde(rename = "modelScores")]
3330    pub model_scores: Option<HashMap<String, GoogleCloudRetailV2DoubleList>>,
3331    /// Specifies previous events related to this product for this user based on UserEvent with same SearchRequest.visitor_id or UserInfo.user_id. This is set only when SearchRequest.PersonalizationSpec.mode is SearchRequest.PersonalizationSpec.Mode.AUTO. Possible values: * `purchased`: Indicates that this product has been purchased before.
3332    #[serde(rename = "personalLabels")]
3333    pub personal_labels: Option<Vec<String>>,
3334    /// The product data snippet in the search response. Only Product.name is guaranteed to be populated. Product.variants contains the product variants that match the search query. If there are multiple product variants matching the query, top 5 most relevant product variants are returned and ordered by relevancy. If relevancy can be deternmined, use matching_variant_fields to look up matched product variants fields. If relevancy cannot be determined, e.g. when searching "shoe" all products in a shoe product can be a match, 5 product variants are returned but order is meaningless.
3335    pub product: Option<GoogleCloudRetailV2Product>,
3336    /// The rollup matching variant Product attributes. The key is one of the SearchRequest.variant_rollup_keys. The values are the merged and de-duplicated Product attributes. Notice that the rollup values are respect filter. For example, when filtering by "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is returned. For textual and numerical attributes, the rollup values is a list of string or double values with type google.protobuf.ListValue. For example, if there are two variants with colors "red" and "blue", the rollup values are { key: "colorFamilies" value { list_value { values { string_value: "red" } values { string_value: "blue" } } } } For FulfillmentInfo, the rollup values is a double value with type google.protobuf.Value. For example, `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there are 10 variants in this product are available in the store "store1".
3337    #[serde(rename = "variantRollupValues")]
3338    pub variant_rollup_values: Option<HashMap<String, serde_json::Value>>,
3339}
3340
3341impl common::Part for GoogleCloudRetailV2SearchResponseSearchResult {}
3342
3343/// This field specifies all related information for tile navigation that will be used in client side.
3344///
3345/// This type is not used in any activity, and only used as *part* of another schema.
3346///
3347#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3348#[serde_with::serde_as]
3349#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3350pub struct GoogleCloudRetailV2SearchResponseTileNavigationResult {
3351    /// The current tiles that are used for tile navigation, sorted by engagement.
3352    pub tiles: Option<Vec<GoogleCloudRetailV2Tile>>,
3353}
3354
3355impl common::Part for GoogleCloudRetailV2SearchResponseTileNavigationResult {}
3356
3357/// Configures metadata that is used to generate serving time results (e.g. search results or recommendation predictions).
3358///
3359/// # Activities
3360///
3361/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3362/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3363///
3364/// * [locations catalogs serving configs add control projects](ProjectLocationCatalogServingConfigAddControlCall) (response)
3365/// * [locations catalogs serving configs create projects](ProjectLocationCatalogServingConfigCreateCall) (request|response)
3366/// * [locations catalogs serving configs get projects](ProjectLocationCatalogServingConfigGetCall) (response)
3367/// * [locations catalogs serving configs patch projects](ProjectLocationCatalogServingConfigPatchCall) (request|response)
3368/// * [locations catalogs serving configs remove control projects](ProjectLocationCatalogServingConfigRemoveControlCall) (response)
3369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3370#[serde_with::serde_as]
3371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3372pub struct GoogleCloudRetailV2ServingConfig {
3373    /// Condition boost specifications. If a product matches multiple conditions in the specifications, boost scores from these specifications are all applied and combined in a non-linear way. Maximum number of specifications is 100. Notice that if both ServingConfig.boost_control_ids and SearchRequest.boost_spec are set, the boost conditions from both places are evaluated. If a search request matches multiple boost conditions, the final boost score is equal to the sum of the boost scores from all matched boost conditions. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3374    #[serde(rename = "boostControlIds")]
3375    pub boost_control_ids: Option<Vec<String>>,
3376    /// Required. The human readable serving config display name. Used in Retail UI. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
3377    #[serde(rename = "displayName")]
3378    pub display_name: Option<String>,
3379    /// How much diversity to use in recommendation model results e.g. `medium-diversity` or `high-diversity`. Currently supported values: * `no-diversity` * `low-diversity` * `medium-diversity` * `high-diversity` * `auto-diversity` If not specified, we choose default based on recommendation model type. Default value: `no-diversity`. Can only be set if solution_types is SOLUTION_TYPE_RECOMMENDATION.
3380    #[serde(rename = "diversityLevel")]
3381    pub diversity_level: Option<String>,
3382    /// What kind of diversity to use - data driven or rule based. If unset, the server behavior defaults to RULE_BASED_DIVERSITY.
3383    #[serde(rename = "diversityType")]
3384    pub diversity_type: Option<String>,
3385    /// Condition do not associate specifications. If multiple do not associate conditions match, all matching do not associate controls in the list will execute. - Order does not matter. - Maximum number of specifications is 100. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3386    #[serde(rename = "doNotAssociateControlIds")]
3387    pub do_not_associate_control_ids: Option<Vec<String>>,
3388    /// The specification for dynamically generated facets. Notice that only textual facets can be dynamically generated. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3389    #[serde(rename = "dynamicFacetSpec")]
3390    pub dynamic_facet_spec: Option<GoogleCloudRetailV2SearchRequestDynamicFacetSpec>,
3391    /// Whether to add additional category filters on the `similar-items` model. If not specified, we enable it by default. Allowed values are: * `no-category-match`: No additional filtering of original results from the model and the customer's filters. * `relaxed-category-match`: Only keep results with categories that match at least one item categories in the PredictRequests's context item. * If customer also sends filters in the PredictRequest, then the results will satisfy both conditions (user given and category match). Can only be set if solution_types is SOLUTION_TYPE_RECOMMENDATION.
3392    #[serde(rename = "enableCategoryFilterLevel")]
3393    pub enable_category_filter_level: Option<String>,
3394    /// Facet specifications for faceted search. If empty, no facets are returned. The ids refer to the ids of Control resources with only the Facet control set. These controls are assumed to be in the same Catalog as the ServingConfig. A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error is returned. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3395    #[serde(rename = "facetControlIds")]
3396    pub facet_control_ids: Option<Vec<String>>,
3397    /// Condition filter specifications. If a product matches multiple conditions in the specifications, filters from these specifications are all applied and combined via the AND operator. Maximum number of specifications is 100. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3398    #[serde(rename = "filterControlIds")]
3399    pub filter_control_ids: Option<Vec<String>>,
3400    /// Condition ignore specifications. If multiple ignore conditions match, all matching ignore controls in the list will execute. - Order does not matter. - Maximum number of specifications is 100. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3401    #[serde(rename = "ignoreControlIds")]
3402    pub ignore_control_ids: Option<Vec<String>>,
3403    /// When the flag is enabled, the products in the denylist will not be filtered out in the recommendation filtering results.
3404    #[serde(rename = "ignoreRecsDenylist")]
3405    pub ignore_recs_denylist: Option<bool>,
3406    /// The id of the model in the same Catalog to use at serving time. Currently only RecommendationModels are supported: https://cloud.google.com/retail/recommendations-ai/docs/create-models Can be changed but only to a compatible model (e.g. others-you-may-like CTR to others-you-may-like CVR). Required when solution_types is SOLUTION_TYPE_RECOMMENDATION.
3407    #[serde(rename = "modelId")]
3408    pub model_id: Option<String>,
3409    /// Immutable. Fully qualified name `projects/*/locations/global/catalogs/*/servingConfig/*`
3410    pub name: Option<String>,
3411    /// Condition oneway synonyms specifications. If multiple oneway synonyms conditions match, all matching oneway synonyms controls in the list will execute. Order of controls in the list will not matter. Maximum number of specifications is 100. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3412    #[serde(rename = "onewaySynonymsControlIds")]
3413    pub oneway_synonyms_control_ids: Option<Vec<String>>,
3414    /// The specification for personalization spec. Can only be set if solution_types is SOLUTION_TYPE_SEARCH. Notice that if both ServingConfig.personalization_spec and SearchRequest.personalization_spec are set. SearchRequest.personalization_spec will override ServingConfig.personalization_spec.
3415    #[serde(rename = "personalizationSpec")]
3416    pub personalization_spec: Option<GoogleCloudRetailV2SearchRequestPersonalizationSpec>,
3417    /// How much price ranking we want in serving results. Price reranking causes product items with a similar recommendation probability to be ordered by price, with the highest-priced items first. This setting could result in a decrease in click-through and conversion rates. Allowed values are: * `no-price-reranking` * `low-price-reranking` * `medium-price-reranking` * `high-price-reranking` If not specified, we choose default based on model type. Default value: `no-price-reranking`. Can only be set if solution_types is SOLUTION_TYPE_RECOMMENDATION.
3418    #[serde(rename = "priceRerankingLevel")]
3419    pub price_reranking_level: Option<String>,
3420    /// Condition redirect specifications. Only the first triggered redirect action is applied, even if multiple apply. Maximum number of specifications is 1000. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3421    #[serde(rename = "redirectControlIds")]
3422    pub redirect_control_ids: Option<Vec<String>>,
3423    /// Condition replacement specifications. - Applied according to the order in the list. - A previously replaced term can not be re-replaced. - Maximum number of specifications is 100. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3424    #[serde(rename = "replacementControlIds")]
3425    pub replacement_control_ids: Option<Vec<String>>,
3426    /// Required. Immutable. Specifies the solution types that a serving config can be associated with. Currently we support setting only one type of solution.
3427    #[serde(rename = "solutionTypes")]
3428    pub solution_types: Option<Vec<String>>,
3429    /// Condition synonyms specifications. If multiple syonyms conditions match, all matching synonyms control in the list will execute. Order of controls in the list will not matter. Maximum number of specifications is 100. Can only be set if solution_types is SOLUTION_TYPE_SEARCH.
3430    #[serde(rename = "twowaySynonymsControlIds")]
3431    pub twoway_synonyms_control_ids: Option<Vec<String>>,
3432}
3433
3434impl common::RequestValue for GoogleCloudRetailV2ServingConfig {}
3435impl common::ResponseResult for GoogleCloudRetailV2ServingConfig {}
3436
3437/// Request message to set a specified branch as new default_branch.
3438///
3439/// # Activities
3440///
3441/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3442/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3443///
3444/// * [locations catalogs set default branch projects](ProjectLocationCatalogSetDefaultBranchCall) (request)
3445#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3446#[serde_with::serde_as]
3447#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3448pub struct GoogleCloudRetailV2SetDefaultBranchRequest {
3449    /// The final component of the resource name of a branch. This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT error is returned. If there are no sufficient active products in the targeted branch and force is not set, a FAILED_PRECONDITION error is returned.
3450    #[serde(rename = "branchId")]
3451    pub branch_id: Option<String>,
3452    /// If set to true, it permits switching to a branch with branch_id even if it has no sufficient active products.
3453    pub force: Option<bool>,
3454    /// Some note on this request, this can be retrieved by CatalogService.GetDefaultBranch before next valid default branch set occurs. This field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned.
3455    pub note: Option<String>,
3456}
3457
3458impl common::RequestValue for GoogleCloudRetailV2SetDefaultBranchRequest {}
3459
3460/// Request message for ProductService.SetInventory method.
3461///
3462/// # Activities
3463///
3464/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3465/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3466///
3467/// * [locations catalogs branches products set inventory projects](ProjectLocationCatalogBranchProductSetInventoryCall) (request)
3468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3469#[serde_with::serde_as]
3470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3471pub struct GoogleCloudRetailV2SetInventoryRequest {
3472    /// If set to true, and the Product with name Product.name is not found, the inventory update will still be processed and retained for at most 1 day until the Product is created. If set to false, a NOT_FOUND error is returned if the Product is not found.
3473    #[serde(rename = "allowMissing")]
3474    pub allow_missing: Option<bool>,
3475    /// Required. The inventory information to update. The allowable fields to update are: * Product.price_info * Product.availability * Product.available_quantity * Product.fulfillment_info The updated inventory fields must be specified in SetInventoryRequest.set_mask. If SetInventoryRequest.inventory.name is empty or invalid, an INVALID_ARGUMENT error is returned. If the caller does not have permission to update the Product named in Product.name, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. If the Product to update does not have existing inventory information, the provided inventory information will be inserted. If the Product to update has existing inventory information, the provided inventory information will be merged while respecting the last update time for each inventory field, using the provided or default value for SetInventoryRequest.set_time. The caller can replace place IDs for a subset of fulfillment types in the following ways: * Adds "fulfillment_info" in SetInventoryRequest.set_mask * Specifies only the desired fulfillment types and corresponding place IDs to update in SetInventoryRequest.inventory.fulfillment_info The caller can clear all place IDs from a subset of fulfillment types in the following ways: * Adds "fulfillment_info" in SetInventoryRequest.set_mask * Specifies only the desired fulfillment types to clear in SetInventoryRequest.inventory.fulfillment_info * Checks that only the desired fulfillment info types have empty SetInventoryRequest.inventory.fulfillment_info.place_ids The last update time is recorded for the following inventory fields: * Product.price_info * Product.availability * Product.available_quantity * Product.fulfillment_info If a full overwrite of inventory information while ignoring timestamps is needed, ProductService.UpdateProduct should be invoked instead.
3476    pub inventory: Option<GoogleCloudRetailV2Product>,
3477    /// Indicates which inventory fields in the provided Product to update. At least one field must be provided. If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned and the entire update will be ignored.
3478    #[serde(rename = "setMask")]
3479    pub set_mask: Option<common::FieldMask>,
3480    /// The time when the request is issued, used to prevent out-of-order updates on inventory fields with the last update time recorded. If not provided, the internal system time will be used.
3481    #[serde(rename = "setTime")]
3482    pub set_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3483}
3484
3485impl common::RequestValue for GoogleCloudRetailV2SetInventoryRequest {}
3486
3487/// A list of string values.
3488///
3489/// This type is not used in any activity, and only used as *part* of another schema.
3490///
3491#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3492#[serde_with::serde_as]
3493#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3494pub struct GoogleCloudRetailV2StringList {
3495    /// String values.
3496    pub values: Option<Vec<String>>,
3497}
3498
3499impl common::Part for GoogleCloudRetailV2StringList {}
3500
3501/// This field specifies the tile information including an attribute key, attribute value. More fields will be added in the future, eg: product id or product counts, etc.
3502///
3503/// This type is not used in any activity, and only used as *part* of another schema.
3504///
3505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3506#[serde_with::serde_as]
3507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3508pub struct GoogleCloudRetailV2Tile {
3509    /// The product attribute key-numeric interval.
3510    #[serde(rename = "productAttributeInterval")]
3511    pub product_attribute_interval: Option<GoogleCloudRetailV2ProductAttributeInterval>,
3512    /// The product attribute key-value.
3513    #[serde(rename = "productAttributeValue")]
3514    pub product_attribute_value: Option<GoogleCloudRetailV2ProductAttributeValue>,
3515    /// The representative product id for this tile.
3516    #[serde(rename = "representativeProductId")]
3517    pub representative_product_id: Option<String>,
3518}
3519
3520impl common::Part for GoogleCloudRetailV2Tile {}
3521
3522/// Request to manually start a tuning process now (instead of waiting for the periodically scheduled tuning to happen).
3523///
3524/// # Activities
3525///
3526/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3527/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3528///
3529/// * [locations catalogs models tune projects](ProjectLocationCatalogModelTuneCall) (request)
3530#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3531#[serde_with::serde_as]
3532#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3533pub struct GoogleCloudRetailV2TuneModelRequest {
3534    _never_set: Option<bool>,
3535}
3536
3537impl common::RequestValue for GoogleCloudRetailV2TuneModelRequest {}
3538
3539/// Request for UpdateGenerativeQuestionConfig method.
3540///
3541/// This type is not used in any activity, and only used as *part* of another schema.
3542///
3543#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3544#[serde_with::serde_as]
3545#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3546pub struct GoogleCloudRetailV2UpdateGenerativeQuestionConfigRequest {
3547    /// Required. The question to update.
3548    #[serde(rename = "generativeQuestionConfig")]
3549    pub generative_question_config: Option<GoogleCloudRetailV2GenerativeQuestionConfig>,
3550    /// Optional. Indicates which fields in the provided GenerativeQuestionConfig to update. The following are NOT supported: * GenerativeQuestionConfig.frequency If not set or empty, all supported fields are updated.
3551    #[serde(rename = "updateMask")]
3552    pub update_mask: Option<common::FieldMask>,
3553}
3554
3555impl common::Part for GoogleCloudRetailV2UpdateGenerativeQuestionConfigRequest {}
3556
3557/// UserEvent captures all metadata information Retail API needs to know about how end users interact with customers’ website.
3558///
3559/// # Activities
3560///
3561/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3562/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3563///
3564/// * [locations catalogs user events write projects](ProjectLocationCatalogUserEventWriteCall) (request|response)
3565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3566#[serde_with::serde_as]
3567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3568pub struct GoogleCloudRetailV2UserEvent {
3569    /// Extra user event features to include in the recommendation model. If you provide custom attributes for ingested user events, also include them in the user events that you associate with prediction requests. Custom attribute formatting must be consistent between imported events and events provided with prediction requests. This lets the Retail API use those custom attributes when training models and serving predictions, which helps improve recommendation quality. This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT error is returned: * The key must be a UTF-8 encoded string with a length limit of 5,000 characters. * For text attributes, at most 400 values are allowed. Empty values are not allowed. Each value must be a UTF-8 encoded string with a length limit of 256 characters. * For number attributes, at most 400 values are allowed. For product recommendations, an example of extra user information is traffic_channel, which is how a user arrives at the site. Users can arrive at the site by coming to the site directly, coming through Google search, or in other ways.
3570    pub attributes: Option<HashMap<String, GoogleCloudRetailV2CustomAttribute>>,
3571    /// Highly recommended for user events that are the result of PredictionService.Predict. This field enables accurate attribution of recommendation model performance. The value must be a valid PredictResponse.attribution_token for user events that are the result of PredictionService.Predict. The value must be a valid SearchResponse.attribution_token for user events that are the result of SearchService.Search. This token enables us to accurately attribute page view or purchase back to the event and the particular predict response containing this clicked/purchased product. If user clicks on product K in the recommendation results, pass PredictResponse.attribution_token as a URL parameter to product K's page. When recording events on product K's page, log the PredictResponse.attribution_token to this field.
3572    #[serde(rename = "attributionToken")]
3573    pub attribution_token: Option<String>,
3574    /// 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`, `purchase-complete`, or `shopping-cart-page-view` events.
3575    #[serde(rename = "cartId")]
3576    pub cart_id: Option<String>,
3577    /// The main auto-completion details related to the event. This field should be set for `search` event when autocomplete function is enabled and the user clicks a suggestion for search.
3578    #[serde(rename = "completionDetail")]
3579    pub completion_detail: Option<GoogleCloudRetailV2CompletionDetail>,
3580    /// The entity for customers that may run multiple different entities, domains, sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, `google.com`, `youtube.com`, etc. We recommend that you set this field to get better per-entity search, completion, and prediction results.
3581    pub entity: Option<String>,
3582    /// Only required for UserEventService.ImportUserEvents method. Timestamp of when the user event happened.
3583    #[serde(rename = "eventTime")]
3584    pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3585    /// Required. User event type. Allowed values are: * `add-to-cart`: Products being added to cart. * `remove-from-cart`: Products being removed from cart. * `category-page-view`: Special pages such as sale or promotion pages viewed. * `detail-page-view`: Products detail page viewed. * `home-page-view`: Homepage viewed. * `purchase-complete`: User finishing a purchase. * `search`: Product search. * `shopping-cart-page-view`: User viewing a shopping cart.
3586    #[serde(rename = "eventType")]
3587    pub event_type: Option<String>,
3588    /// 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 Retail API, using different recommendation models).
3589    #[serde(rename = "experimentIds")]
3590    pub experiment_ids: Option<Vec<String>>,
3591    /// The filter syntax consists of an expression language for constructing a predicate from one or more fields of the products being filtered. See SearchRequest.filter for definition and syntax. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned.
3592    pub filter: Option<String>,
3593    /// An integer that specifies the current offset for pagination (the 0-indexed starting location, amongst the products deemed by the API as relevant). See SearchRequest.offset for definition. If this field is negative, an INVALID_ARGUMENT is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an INVALID_ARGUMENT error is returned.
3594    pub offset: Option<i32>,
3595    /// The order in which products are returned. See SearchRequest.order_by for definition and syntax. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an INVALID_ARGUMENT error is returned.
3596    #[serde(rename = "orderBy")]
3597    pub order_by: Option<String>,
3598    /// The categories associated with a category page. To represent full path of category, use '>' sign to separate different hierarchies. If '>' is part of the category name, replace it with other character(s). Category pages include special pages such as sales or promotions. For instance, a special sale page may have the category hierarchy: "pageCategories" : ["Sales > 2017 Black Friday Deals"]. 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. Otherwise, an INVALID_ARGUMENT error is returned.
3599    #[serde(rename = "pageCategories")]
3600    pub page_categories: Option<Vec<String>>,
3601    /// 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. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically.
3602    #[serde(rename = "pageViewId")]
3603    pub page_view_id: Option<String>,
3604    /// Optional. List of panels associated with this event. Used for panel-level impression data.
3605    pub panels: Option<Vec<GoogleCloudRetailV2PanelInfo>>,
3606    /// The main product details related to the event. This field is optional except for the following event types: * `add-to-cart` * `detail-page-view` * `purchase-complete` 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 browsing 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 browsing the whole page yet.
3607    #[serde(rename = "productDetails")]
3608    pub product_details: Option<Vec<GoogleCloudRetailV2ProductDetail>>,
3609    /// A transaction represents the entire purchase transaction. Required for `purchase-complete` events. Other event types should not set this field. Otherwise, an INVALID_ARGUMENT error is returned.
3610    #[serde(rename = "purchaseTransaction")]
3611    pub purchase_transaction: Option<GoogleCloudRetailV2PurchaseTransaction>,
3612    /// The referrer URL of the current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically.
3613    #[serde(rename = "referrerUri")]
3614    pub referrer_uri: Option<String>,
3615    /// The user's search query. See SearchRequest.query for definition. The value must be a UTF-8 encoded string with a length limit of 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. At least one of search_query or page_categories is required for `search` events. Other event types should not set this field. Otherwise, an INVALID_ARGUMENT error is returned.
3616    #[serde(rename = "searchQuery")]
3617    pub search_query: Option<String>,
3618    /// A unique identifier for tracking a visitor session with a length limit of 128 bytes. A session is an aggregation of an end user behavior in a time span. A general guideline to populate the session_id: 1. If user has no activity for 30 min, a new session_id should be assigned. 2. The session_id should be unique across users, suggest use uuid or add visitor_id as prefix.
3619    #[serde(rename = "sessionId")]
3620    pub session_id: Option<String>,
3621    /// Complete URL (window.location.href) of the user's current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically. Maximum length 5,000 characters.
3622    pub uri: Option<String>,
3623    /// User information.
3624    #[serde(rename = "userInfo")]
3625    pub user_info: Option<GoogleCloudRetailV2UserInfo>,
3626    /// Required. A unique identifier for tracking visitors. 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 log in/out of the website. 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. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. The field should not contain PII or user-data. We recommend to use Google Analytics [Client ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) for this field.
3627    #[serde(rename = "visitorId")]
3628    pub visitor_id: Option<String>,
3629}
3630
3631impl common::RequestValue for GoogleCloudRetailV2UserEvent {}
3632impl common::ResponseResult for GoogleCloudRetailV2UserEvent {}
3633
3634/// The inline source for the input config for ImportUserEvents method.
3635///
3636/// This type is not used in any activity, and only used as *part* of another schema.
3637///
3638#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3639#[serde_with::serde_as]
3640#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3641pub struct GoogleCloudRetailV2UserEventInlineSource {
3642    /// Required. A list of user events to import. Recommended max of 10k items.
3643    #[serde(rename = "userEvents")]
3644    pub user_events: Option<Vec<GoogleCloudRetailV2UserEvent>>,
3645}
3646
3647impl common::Part for GoogleCloudRetailV2UserEventInlineSource {}
3648
3649/// The input config source for user events.
3650///
3651/// This type is not used in any activity, and only used as *part* of another schema.
3652///
3653#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3654#[serde_with::serde_as]
3655#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3656pub struct GoogleCloudRetailV2UserEventInputConfig {
3657    /// Required. BigQuery input source.
3658    #[serde(rename = "bigQuerySource")]
3659    pub big_query_source: Option<GoogleCloudRetailV2BigQuerySource>,
3660    /// Required. Google Cloud Storage location for the input content.
3661    #[serde(rename = "gcsSource")]
3662    pub gcs_source: Option<GoogleCloudRetailV2GcsSource>,
3663    /// Required. The Inline source for the input content for UserEvents.
3664    #[serde(rename = "userEventInlineSource")]
3665    pub user_event_inline_source: Option<GoogleCloudRetailV2UserEventInlineSource>,
3666}
3667
3668impl common::Part for GoogleCloudRetailV2UserEventInputConfig {}
3669
3670/// Information of an end user.
3671///
3672/// This type is not used in any activity, and only used as *part* of another schema.
3673///
3674#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3675#[serde_with::serde_as]
3676#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3677pub struct GoogleCloudRetailV2UserInfo {
3678    /// True if the request is made directly from the end user, in which case the ip_address and user_agent can be populated from the HTTP request. 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). This should not be set when using the JavaScript tag in UserEventService.CollectUserEvent.
3679    #[serde(rename = "directUserRequest")]
3680    pub direct_user_request: Option<bool>,
3681    /// The end user's IP address. This field is used to extract location information for personalization. This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an INVALID_ARGUMENT error is returned. This should not be set when: * setting SearchRequest.user_info. * using the JavaScript tag in UserEventService.CollectUserEvent or if direct_user_request is set.
3682    #[serde(rename = "ipAddress")]
3683    pub ip_address: Option<String>,
3684    /// User agent as included in the HTTP header. The field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. This should not be set when using the client side event reporting with GTM or JavaScript tag in UserEventService.CollectUserEvent or if direct_user_request is set.
3685    #[serde(rename = "userAgent")]
3686    pub user_agent: Option<String>,
3687    /// Highly recommended for logged-in users. Unique identifier for logged-in user, such as a user name. Don't set for anonymous users. Always use a hashed value for this ID. 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. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
3688    #[serde(rename = "userId")]
3689    pub user_id: Option<String>,
3690}
3691
3692impl common::Part for GoogleCloudRetailV2UserInfo {}
3693
3694/// The response message for Operations.ListOperations.
3695///
3696/// # Activities
3697///
3698/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3699/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3700///
3701/// * [locations catalogs operations list projects](ProjectLocationCatalogOperationListCall) (response)
3702/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
3703/// * [operations list projects](ProjectOperationListCall) (response)
3704#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3705#[serde_with::serde_as]
3706#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3707pub struct GoogleLongrunningListOperationsResponse {
3708    /// The standard List next-page token.
3709    #[serde(rename = "nextPageToken")]
3710    pub next_page_token: Option<String>,
3711    /// A list of operations that matches the specified filter in the request.
3712    pub operations: Option<Vec<GoogleLongrunningOperation>>,
3713    /// 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.
3714    pub unreachable: Option<Vec<String>>,
3715}
3716
3717impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
3718
3719/// This resource represents a long-running operation that is the result of a network API call.
3720///
3721/// # Activities
3722///
3723/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3724/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3725///
3726/// * [locations catalogs branches operations get projects](ProjectLocationCatalogBranchOperationGetCall) (response)
3727/// * [locations catalogs branches products add fulfillment places projects](ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall) (response)
3728/// * [locations catalogs branches products add local inventories projects](ProjectLocationCatalogBranchProductAddLocalInventoryCall) (response)
3729/// * [locations catalogs branches products import projects](ProjectLocationCatalogBranchProductImportCall) (response)
3730/// * [locations catalogs branches products purge projects](ProjectLocationCatalogBranchProductPurgeCall) (response)
3731/// * [locations catalogs branches products remove fulfillment places projects](ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall) (response)
3732/// * [locations catalogs branches products remove local inventories projects](ProjectLocationCatalogBranchProductRemoveLocalInventoryCall) (response)
3733/// * [locations catalogs branches products set inventory projects](ProjectLocationCatalogBranchProductSetInventoryCall) (response)
3734/// * [locations catalogs completion data import projects](ProjectLocationCatalogCompletionDataImportCall) (response)
3735/// * [locations catalogs models create projects](ProjectLocationCatalogModelCreateCall) (response)
3736/// * [locations catalogs models tune projects](ProjectLocationCatalogModelTuneCall) (response)
3737/// * [locations catalogs operations get projects](ProjectLocationCatalogOperationGetCall) (response)
3738/// * [locations catalogs user events import projects](ProjectLocationCatalogUserEventImportCall) (response)
3739/// * [locations catalogs user events purge projects](ProjectLocationCatalogUserEventPurgeCall) (response)
3740/// * [locations catalogs user events rejoin projects](ProjectLocationCatalogUserEventRejoinCall) (response)
3741/// * [locations catalogs export analytics metrics projects](ProjectLocationCatalogExportAnalyticsMetricCall) (response)
3742/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
3743/// * [operations get projects](ProjectOperationGetCall) (response)
3744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3745#[serde_with::serde_as]
3746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3747pub struct GoogleLongrunningOperation {
3748    /// 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.
3749    pub done: Option<bool>,
3750    /// The error result of the operation in case of failure or cancellation.
3751    pub error: Option<GoogleRpcStatus>,
3752    /// 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.
3753    pub metadata: Option<HashMap<String, serde_json::Value>>,
3754    /// 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}`.
3755    pub name: Option<String>,
3756    /// 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`.
3757    pub response: Option<HashMap<String, serde_json::Value>>,
3758}
3759
3760impl common::ResponseResult for GoogleLongrunningOperation {}
3761
3762/// 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); }
3763///
3764/// # Activities
3765///
3766/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3767/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3768///
3769/// * [locations catalogs branches products delete projects](ProjectLocationCatalogBranchProductDeleteCall) (response)
3770/// * [locations catalogs controls delete projects](ProjectLocationCatalogControlDeleteCall) (response)
3771/// * [locations catalogs models delete projects](ProjectLocationCatalogModelDeleteCall) (response)
3772/// * [locations catalogs serving configs delete projects](ProjectLocationCatalogServingConfigDeleteCall) (response)
3773/// * [locations catalogs set default branch projects](ProjectLocationCatalogSetDefaultBranchCall) (response)
3774#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3775#[serde_with::serde_as]
3776#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3777pub struct GoogleProtobufEmpty {
3778    _never_set: Option<bool>,
3779}
3780
3781impl common::ResponseResult for GoogleProtobufEmpty {}
3782
3783/// 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).
3784///
3785/// This type is not used in any activity, and only used as *part* of another schema.
3786///
3787#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3788#[serde_with::serde_as]
3789#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3790pub struct GoogleRpcStatus {
3791    /// The status code, which should be an enum value of google.rpc.Code.
3792    pub code: Option<i32>,
3793    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
3794    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
3795    /// 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.
3796    pub message: Option<String>,
3797}
3798
3799impl common::Part for GoogleRpcStatus {}
3800
3801/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
3802///
3803/// This type is not used in any activity, and only used as *part* of another schema.
3804///
3805#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3806#[serde_with::serde_as]
3807#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3808pub struct GoogleTypeDate {
3809    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
3810    pub day: Option<i32>,
3811    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
3812    pub month: Option<i32>,
3813    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
3814    pub year: Option<i32>,
3815}
3816
3817impl common::Part for GoogleTypeDate {}
3818
3819// ###################
3820// MethodBuilders ###
3821// #################
3822
3823/// A builder providing access to all methods supported on *project* resources.
3824/// It is not used directly, but through the [`CloudRetail`] hub.
3825///
3826/// # Example
3827///
3828/// Instantiate a resource builder
3829///
3830/// ```test_harness,no_run
3831/// extern crate hyper;
3832/// extern crate hyper_rustls;
3833/// extern crate google_retail2 as retail2;
3834///
3835/// # async fn dox() {
3836/// use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3837///
3838/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3839/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3840///     .with_native_roots()
3841///     .unwrap()
3842///     .https_only()
3843///     .enable_http2()
3844///     .build();
3845///
3846/// let executor = hyper_util::rt::TokioExecutor::new();
3847/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3848///     secret,
3849///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3850///     yup_oauth2::client::CustomHyperClientBuilder::from(
3851///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3852///     ),
3853/// ).build().await.unwrap();
3854///
3855/// let client = hyper_util::client::legacy::Client::builder(
3856///     hyper_util::rt::TokioExecutor::new()
3857/// )
3858/// .build(
3859///     hyper_rustls::HttpsConnectorBuilder::new()
3860///         .with_native_roots()
3861///         .unwrap()
3862///         .https_or_http()
3863///         .enable_http2()
3864///         .build()
3865/// );
3866/// let mut hub = CloudRetail::new(client, auth);
3867/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3868/// // like `locations_catalogs_attributes_config_add_catalog_attribute(...)`, `locations_catalogs_attributes_config_remove_catalog_attribute(...)`, `locations_catalogs_attributes_config_replace_catalog_attribute(...)`, `locations_catalogs_branches_operations_get(...)`, `locations_catalogs_branches_products_add_fulfillment_places(...)`, `locations_catalogs_branches_products_add_local_inventories(...)`, `locations_catalogs_branches_products_create(...)`, `locations_catalogs_branches_products_delete(...)`, `locations_catalogs_branches_products_get(...)`, `locations_catalogs_branches_products_import(...)`, `locations_catalogs_branches_products_list(...)`, `locations_catalogs_branches_products_patch(...)`, `locations_catalogs_branches_products_purge(...)`, `locations_catalogs_branches_products_remove_fulfillment_places(...)`, `locations_catalogs_branches_products_remove_local_inventories(...)`, `locations_catalogs_branches_products_set_inventory(...)`, `locations_catalogs_complete_query(...)`, `locations_catalogs_completion_data_import(...)`, `locations_catalogs_controls_create(...)`, `locations_catalogs_controls_delete(...)`, `locations_catalogs_controls_get(...)`, `locations_catalogs_controls_list(...)`, `locations_catalogs_controls_patch(...)`, `locations_catalogs_export_analytics_metrics(...)`, `locations_catalogs_generative_question_batch_update(...)`, `locations_catalogs_generative_questions_list(...)`, `locations_catalogs_get_attributes_config(...)`, `locations_catalogs_get_completion_config(...)`, `locations_catalogs_get_conversational_search_customization_config(...)`, `locations_catalogs_get_default_branch(...)`, `locations_catalogs_get_generative_question_feature(...)`, `locations_catalogs_list(...)`, `locations_catalogs_models_create(...)`, `locations_catalogs_models_delete(...)`, `locations_catalogs_models_get(...)`, `locations_catalogs_models_list(...)`, `locations_catalogs_models_patch(...)`, `locations_catalogs_models_pause(...)`, `locations_catalogs_models_resume(...)`, `locations_catalogs_models_tune(...)`, `locations_catalogs_operations_get(...)`, `locations_catalogs_operations_list(...)`, `locations_catalogs_patch(...)`, `locations_catalogs_placements_conversational_search(...)`, `locations_catalogs_placements_predict(...)`, `locations_catalogs_placements_search(...)`, `locations_catalogs_serving_configs_add_control(...)`, `locations_catalogs_serving_configs_conversational_search(...)`, `locations_catalogs_serving_configs_create(...)`, `locations_catalogs_serving_configs_delete(...)`, `locations_catalogs_serving_configs_get(...)`, `locations_catalogs_serving_configs_list(...)`, `locations_catalogs_serving_configs_patch(...)`, `locations_catalogs_serving_configs_predict(...)`, `locations_catalogs_serving_configs_remove_control(...)`, `locations_catalogs_serving_configs_search(...)`, `locations_catalogs_set_default_branch(...)`, `locations_catalogs_update_attributes_config(...)`, `locations_catalogs_update_completion_config(...)`, `locations_catalogs_update_conversational_search_customization_config(...)`, `locations_catalogs_update_generative_question(...)`, `locations_catalogs_update_generative_question_feature(...)`, `locations_catalogs_user_events_collect(...)`, `locations_catalogs_user_events_import(...)`, `locations_catalogs_user_events_purge(...)`, `locations_catalogs_user_events_rejoin(...)`, `locations_catalogs_user_events_write(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `operations_get(...)` and `operations_list(...)`
3869/// // to build up your call.
3870/// let rb = hub.projects();
3871/// # }
3872/// ```
3873pub struct ProjectMethods<'a, C>
3874where
3875    C: 'a,
3876{
3877    hub: &'a CloudRetail<C>,
3878}
3879
3880impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3881
3882impl<'a, C> ProjectMethods<'a, C> {
3883    /// Create a builder to help you perform the following task:
3884    ///
3885    /// Adds the specified CatalogAttribute to the AttributesConfig. If the CatalogAttribute to add already exists, an ALREADY_EXISTS error is returned.
3886    ///
3887    /// # Arguments
3888    ///
3889    /// * `request` - No description provided.
3890    /// * `attributesConfig` - Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
3891    pub fn locations_catalogs_attributes_config_add_catalog_attribute(
3892        &self,
3893        request: GoogleCloudRetailV2AddCatalogAttributeRequest,
3894        attributes_config: &str,
3895    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C> {
3896        ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall {
3897            hub: self.hub,
3898            _request: request,
3899            _attributes_config: attributes_config.to_string(),
3900            _delegate: Default::default(),
3901            _additional_params: Default::default(),
3902            _scopes: Default::default(),
3903        }
3904    }
3905
3906    /// Create a builder to help you perform the following task:
3907    ///
3908    /// Removes the specified CatalogAttribute from the AttributesConfig. If the CatalogAttribute to remove does not exist, a NOT_FOUND error is returned.
3909    ///
3910    /// # Arguments
3911    ///
3912    /// * `request` - No description provided.
3913    /// * `attributesConfig` - Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
3914    pub fn locations_catalogs_attributes_config_remove_catalog_attribute(
3915        &self,
3916        request: GoogleCloudRetailV2RemoveCatalogAttributeRequest,
3917        attributes_config: &str,
3918    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C> {
3919        ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall {
3920            hub: self.hub,
3921            _request: request,
3922            _attributes_config: attributes_config.to_string(),
3923            _delegate: Default::default(),
3924            _additional_params: Default::default(),
3925            _scopes: Default::default(),
3926        }
3927    }
3928
3929    /// Create a builder to help you perform the following task:
3930    ///
3931    /// Replaces the specified CatalogAttribute in the AttributesConfig by updating the catalog attribute with the same CatalogAttribute.key. If the CatalogAttribute to replace does not exist, a NOT_FOUND error is returned.
3932    ///
3933    /// # Arguments
3934    ///
3935    /// * `request` - No description provided.
3936    /// * `attributesConfig` - Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
3937    pub fn locations_catalogs_attributes_config_replace_catalog_attribute(
3938        &self,
3939        request: GoogleCloudRetailV2ReplaceCatalogAttributeRequest,
3940        attributes_config: &str,
3941    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C> {
3942        ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall {
3943            hub: self.hub,
3944            _request: request,
3945            _attributes_config: attributes_config.to_string(),
3946            _delegate: Default::default(),
3947            _additional_params: Default::default(),
3948            _scopes: Default::default(),
3949        }
3950    }
3951
3952    /// Create a builder to help you perform the following task:
3953    ///
3954    /// 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.
3955    ///
3956    /// # Arguments
3957    ///
3958    /// * `name` - The name of the operation resource.
3959    pub fn locations_catalogs_branches_operations_get(
3960        &self,
3961        name: &str,
3962    ) -> ProjectLocationCatalogBranchOperationGetCall<'a, C> {
3963        ProjectLocationCatalogBranchOperationGetCall {
3964            hub: self.hub,
3965            _name: name.to_string(),
3966            _delegate: Default::default(),
3967            _additional_params: Default::default(),
3968            _scopes: Default::default(),
3969        }
3970    }
3971
3972    /// Create a builder to help you perform the following task:
3973    ///
3974    /// We recommend that you use the ProductService.AddLocalInventories method instead of the ProductService.AddFulfillmentPlaces method. ProductService.AddLocalInventories achieves the same results but provides more fine-grained control over ingesting local inventory data. Incrementally adds place IDs to Product.fulfillment_info.place_ids. This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
3975    ///
3976    /// # Arguments
3977    ///
3978    /// * `request` - No description provided.
3979    /// * `product` - Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
3980    pub fn locations_catalogs_branches_products_add_fulfillment_places(
3981        &self,
3982        request: GoogleCloudRetailV2AddFulfillmentPlacesRequest,
3983        product: &str,
3984    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C> {
3985        ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall {
3986            hub: self.hub,
3987            _request: request,
3988            _product: product.to_string(),
3989            _delegate: Default::default(),
3990            _additional_params: Default::default(),
3991            _scopes: Default::default(),
3992        }
3993    }
3994
3995    /// Create a builder to help you perform the following task:
3996    ///
3997    /// Updates local inventory information for a Product at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the Product to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. Local inventory information can only be modified using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
3998    ///
3999    /// # Arguments
4000    ///
4001    /// * `request` - No description provided.
4002    /// * `product` - Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
4003    pub fn locations_catalogs_branches_products_add_local_inventories(
4004        &self,
4005        request: GoogleCloudRetailV2AddLocalInventoriesRequest,
4006        product: &str,
4007    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C> {
4008        ProjectLocationCatalogBranchProductAddLocalInventoryCall {
4009            hub: self.hub,
4010            _request: request,
4011            _product: product.to_string(),
4012            _delegate: Default::default(),
4013            _additional_params: Default::default(),
4014            _scopes: Default::default(),
4015        }
4016    }
4017
4018    /// Create a builder to help you perform the following task:
4019    ///
4020    /// Creates a Product.
4021    ///
4022    /// # Arguments
4023    ///
4024    /// * `request` - No description provided.
4025    /// * `parent` - Required. The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`.
4026    pub fn locations_catalogs_branches_products_create(
4027        &self,
4028        request: GoogleCloudRetailV2Product,
4029        parent: &str,
4030    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C> {
4031        ProjectLocationCatalogBranchProductCreateCall {
4032            hub: self.hub,
4033            _request: request,
4034            _parent: parent.to_string(),
4035            _product_id: Default::default(),
4036            _delegate: Default::default(),
4037            _additional_params: Default::default(),
4038            _scopes: Default::default(),
4039        }
4040    }
4041
4042    /// Create a builder to help you perform the following task:
4043    ///
4044    /// Deletes a Product.
4045    ///
4046    /// # Arguments
4047    ///
4048    /// * `name` - Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to delete the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. If the Product to delete does not exist, a NOT_FOUND error is returned. The Product to delete can neither be a Product.Type.COLLECTION Product member nor a Product.Type.PRIMARY Product with more than one variants. Otherwise, an INVALID_ARGUMENT error is returned. All inventory information for the named Product will be deleted.
4049    pub fn locations_catalogs_branches_products_delete(
4050        &self,
4051        name: &str,
4052    ) -> ProjectLocationCatalogBranchProductDeleteCall<'a, C> {
4053        ProjectLocationCatalogBranchProductDeleteCall {
4054            hub: self.hub,
4055            _name: name.to_string(),
4056            _delegate: Default::default(),
4057            _additional_params: Default::default(),
4058            _scopes: Default::default(),
4059        }
4060    }
4061
4062    /// Create a builder to help you perform the following task:
4063    ///
4064    /// Gets a Product.
4065    ///
4066    /// # Arguments
4067    ///
4068    /// * `name` - Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. If the requested Product does not exist, a NOT_FOUND error is returned.
4069    pub fn locations_catalogs_branches_products_get(
4070        &self,
4071        name: &str,
4072    ) -> ProjectLocationCatalogBranchProductGetCall<'a, C> {
4073        ProjectLocationCatalogBranchProductGetCall {
4074            hub: self.hub,
4075            _name: name.to_string(),
4076            _delegate: Default::default(),
4077            _additional_params: Default::default(),
4078            _scopes: Default::default(),
4079        }
4080    }
4081
4082    /// Create a builder to help you perform the following task:
4083    ///
4084    /// Bulk import of multiple Products. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the Products to be successfully updated.
4085    ///
4086    /// # Arguments
4087    ///
4088    /// * `request` - No description provided.
4089    /// * `parent` - Required. `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` If no updateMask is specified, requires products.create permission. If updateMask is specified, requires products.update permission.
4090    pub fn locations_catalogs_branches_products_import(
4091        &self,
4092        request: GoogleCloudRetailV2ImportProductsRequest,
4093        parent: &str,
4094    ) -> ProjectLocationCatalogBranchProductImportCall<'a, C> {
4095        ProjectLocationCatalogBranchProductImportCall {
4096            hub: self.hub,
4097            _request: request,
4098            _parent: parent.to_string(),
4099            _delegate: Default::default(),
4100            _additional_params: Default::default(),
4101            _scopes: Default::default(),
4102        }
4103    }
4104
4105    /// Create a builder to help you perform the following task:
4106    ///
4107    /// Gets a list of Products.
4108    ///
4109    /// # Arguments
4110    ///
4111    /// * `parent` - Required. The parent branch resource name, such as `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use `default_branch` as the branch ID, to list products under the default branch. If the caller does not have permission to list Products under this branch, regardless of whether or not this branch exists, a PERMISSION_DENIED error is returned.
4112    pub fn locations_catalogs_branches_products_list(
4113        &self,
4114        parent: &str,
4115    ) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
4116        ProjectLocationCatalogBranchProductListCall {
4117            hub: self.hub,
4118            _parent: parent.to_string(),
4119            _read_mask: Default::default(),
4120            _page_token: Default::default(),
4121            _page_size: Default::default(),
4122            _filter: Default::default(),
4123            _delegate: Default::default(),
4124            _additional_params: Default::default(),
4125            _scopes: Default::default(),
4126        }
4127    }
4128
4129    /// Create a builder to help you perform the following task:
4130    ///
4131    /// Updates a Product.
4132    ///
4133    /// # Arguments
4134    ///
4135    /// * `request` - No description provided.
4136    /// * `name` - Immutable. Full resource name of the product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`.
4137    pub fn locations_catalogs_branches_products_patch(
4138        &self,
4139        request: GoogleCloudRetailV2Product,
4140        name: &str,
4141    ) -> ProjectLocationCatalogBranchProductPatchCall<'a, C> {
4142        ProjectLocationCatalogBranchProductPatchCall {
4143            hub: self.hub,
4144            _request: request,
4145            _name: name.to_string(),
4146            _update_mask: Default::default(),
4147            _allow_missing: Default::default(),
4148            _delegate: Default::default(),
4149            _additional_params: Default::default(),
4150            _scopes: Default::default(),
4151        }
4152    }
4153
4154    /// Create a builder to help you perform the following task:
4155    ///
4156    /// Permanently deletes all selected Products under a branch. This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of Products, this operation could take hours to complete. Before the operation completes, some Products may still be returned by ProductService.GetProduct or ProductService.ListProducts. Depending on the number of Products, this operation could take hours to complete. To get a sample of Products that would be deleted, set PurgeProductsRequest.force to false.
4157    ///
4158    /// # Arguments
4159    ///
4160    /// * `request` - No description provided.
4161    /// * `parent` - Required. The resource name of the branch under which the products are created. The format is `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}`
4162    pub fn locations_catalogs_branches_products_purge(
4163        &self,
4164        request: GoogleCloudRetailV2PurgeProductsRequest,
4165        parent: &str,
4166    ) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C> {
4167        ProjectLocationCatalogBranchProductPurgeCall {
4168            hub: self.hub,
4169            _request: request,
4170            _parent: parent.to_string(),
4171            _delegate: Default::default(),
4172            _additional_params: Default::default(),
4173            _scopes: Default::default(),
4174        }
4175    }
4176
4177    /// Create a builder to help you perform the following task:
4178    ///
4179    /// We recommend that you use the ProductService.RemoveLocalInventories method instead of the ProductService.RemoveFulfillmentPlaces method. ProductService.RemoveLocalInventories achieves the same results but provides more fine-grained control over ingesting local inventory data. Incrementally removes place IDs from a Product.fulfillment_info.place_ids. This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
4180    ///
4181    /// # Arguments
4182    ///
4183    /// * `request` - No description provided.
4184    /// * `product` - Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
4185    pub fn locations_catalogs_branches_products_remove_fulfillment_places(
4186        &self,
4187        request: GoogleCloudRetailV2RemoveFulfillmentPlacesRequest,
4188        product: &str,
4189    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C> {
4190        ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall {
4191            hub: self.hub,
4192            _request: request,
4193            _product: product.to_string(),
4194            _delegate: Default::default(),
4195            _additional_params: Default::default(),
4196            _scopes: Default::default(),
4197        }
4198    }
4199
4200    /// Create a builder to help you perform the following task:
4201    ///
4202    /// Remove local inventory information for a Product at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. Local inventory information can only be removed using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
4203    ///
4204    /// # Arguments
4205    ///
4206    /// * `request` - No description provided.
4207    /// * `product` - Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
4208    pub fn locations_catalogs_branches_products_remove_local_inventories(
4209        &self,
4210        request: GoogleCloudRetailV2RemoveLocalInventoriesRequest,
4211        product: &str,
4212    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C> {
4213        ProjectLocationCatalogBranchProductRemoveLocalInventoryCall {
4214            hub: self.hub,
4215            _request: request,
4216            _product: product.to_string(),
4217            _delegate: Default::default(),
4218            _additional_params: Default::default(),
4219            _scopes: Default::default(),
4220        }
4221    }
4222
4223    /// Create a builder to help you perform the following task:
4224    ///
4225    /// Updates inventory information for a Product while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update is enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. When inventory is updated with ProductService.CreateProduct and ProductService.UpdateProduct, the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the ProductService.CreateProduct or ProductService.UpdateProduct request. If no inventory fields are set in CreateProductRequest.product, then any pre-existing inventory information for this product is used. If no inventory fields are set in SetInventoryRequest.set_mask, then any existing inventory information is preserved. Pre-existing inventory information can only be updated with ProductService.SetInventory, ProductService.AddFulfillmentPlaces, and ProductService.RemoveFulfillmentPlaces. The returned Operations is obsolete after one day, and the GetOperation API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the Operations associated with the stale updates are not marked as done until they are obsolete.
4226    ///
4227    /// # Arguments
4228    ///
4229    /// * `request` - No description provided.
4230    /// * `name` - Immutable. Full resource name of the product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`.
4231    pub fn locations_catalogs_branches_products_set_inventory(
4232        &self,
4233        request: GoogleCloudRetailV2SetInventoryRequest,
4234        name: &str,
4235    ) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C> {
4236        ProjectLocationCatalogBranchProductSetInventoryCall {
4237            hub: self.hub,
4238            _request: request,
4239            _name: name.to_string(),
4240            _delegate: Default::default(),
4241            _additional_params: Default::default(),
4242            _scopes: Default::default(),
4243        }
4244    }
4245
4246    /// Create a builder to help you perform the following task:
4247    ///
4248    /// Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
4249    ///
4250    /// # Arguments
4251    ///
4252    /// * `request` - No description provided.
4253    /// * `parent` - Required. The catalog which the suggestions dataset belongs to. Format: `projects/1234/locations/global/catalogs/default_catalog`.
4254    pub fn locations_catalogs_completion_data_import(
4255        &self,
4256        request: GoogleCloudRetailV2ImportCompletionDataRequest,
4257        parent: &str,
4258    ) -> ProjectLocationCatalogCompletionDataImportCall<'a, C> {
4259        ProjectLocationCatalogCompletionDataImportCall {
4260            hub: self.hub,
4261            _request: request,
4262            _parent: parent.to_string(),
4263            _delegate: Default::default(),
4264            _additional_params: Default::default(),
4265            _scopes: Default::default(),
4266        }
4267    }
4268
4269    /// Create a builder to help you perform the following task:
4270    ///
4271    /// Creates a Control. If the Control to create already exists, an ALREADY_EXISTS error is returned.
4272    ///
4273    /// # Arguments
4274    ///
4275    /// * `request` - No description provided.
4276    /// * `parent` - Required. Full resource name of parent catalog. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
4277    pub fn locations_catalogs_controls_create(
4278        &self,
4279        request: GoogleCloudRetailV2Control,
4280        parent: &str,
4281    ) -> ProjectLocationCatalogControlCreateCall<'a, C> {
4282        ProjectLocationCatalogControlCreateCall {
4283            hub: self.hub,
4284            _request: request,
4285            _parent: parent.to_string(),
4286            _control_id: Default::default(),
4287            _delegate: Default::default(),
4288            _additional_params: Default::default(),
4289            _scopes: Default::default(),
4290        }
4291    }
4292
4293    /// Create a builder to help you perform the following task:
4294    ///
4295    /// Deletes a Control. If the Control to delete does not exist, a NOT_FOUND error is returned.
4296    ///
4297    /// # Arguments
4298    ///
4299    /// * `name` - Required. The resource name of the Control to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
4300    pub fn locations_catalogs_controls_delete(
4301        &self,
4302        name: &str,
4303    ) -> ProjectLocationCatalogControlDeleteCall<'a, C> {
4304        ProjectLocationCatalogControlDeleteCall {
4305            hub: self.hub,
4306            _name: name.to_string(),
4307            _delegate: Default::default(),
4308            _additional_params: Default::default(),
4309            _scopes: Default::default(),
4310        }
4311    }
4312
4313    /// Create a builder to help you perform the following task:
4314    ///
4315    /// Gets a Control.
4316    ///
4317    /// # Arguments
4318    ///
4319    /// * `name` - Required. The resource name of the Control to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
4320    pub fn locations_catalogs_controls_get(
4321        &self,
4322        name: &str,
4323    ) -> ProjectLocationCatalogControlGetCall<'a, C> {
4324        ProjectLocationCatalogControlGetCall {
4325            hub: self.hub,
4326            _name: name.to_string(),
4327            _delegate: Default::default(),
4328            _additional_params: Default::default(),
4329            _scopes: Default::default(),
4330        }
4331    }
4332
4333    /// Create a builder to help you perform the following task:
4334    ///
4335    /// Lists all Controls by their parent Catalog.
4336    ///
4337    /// # Arguments
4338    ///
4339    /// * `parent` - Required. The catalog resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
4340    pub fn locations_catalogs_controls_list(
4341        &self,
4342        parent: &str,
4343    ) -> ProjectLocationCatalogControlListCall<'a, C> {
4344        ProjectLocationCatalogControlListCall {
4345            hub: self.hub,
4346            _parent: parent.to_string(),
4347            _page_token: Default::default(),
4348            _page_size: Default::default(),
4349            _filter: Default::default(),
4350            _delegate: Default::default(),
4351            _additional_params: Default::default(),
4352            _scopes: Default::default(),
4353        }
4354    }
4355
4356    /// Create a builder to help you perform the following task:
4357    ///
4358    /// Updates a Control. Control cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the Control to update does not exist, a NOT_FOUND error is returned.
4359    ///
4360    /// # Arguments
4361    ///
4362    /// * `request` - No description provided.
4363    /// * `name` - Immutable. Fully qualified name `projects/*/locations/global/catalogs/*/controls/*`
4364    pub fn locations_catalogs_controls_patch(
4365        &self,
4366        request: GoogleCloudRetailV2Control,
4367        name: &str,
4368    ) -> ProjectLocationCatalogControlPatchCall<'a, C> {
4369        ProjectLocationCatalogControlPatchCall {
4370            hub: self.hub,
4371            _request: request,
4372            _name: name.to_string(),
4373            _update_mask: Default::default(),
4374            _delegate: Default::default(),
4375            _additional_params: Default::default(),
4376            _scopes: Default::default(),
4377        }
4378    }
4379
4380    /// Create a builder to help you perform the following task:
4381    ///
4382    /// Allows management of multiple questions.
4383    ///
4384    /// # Arguments
4385    ///
4386    /// * `request` - No description provided.
4387    /// * `parent` - Optional. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
4388    pub fn locations_catalogs_generative_question_batch_update(
4389        &self,
4390        request: GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsRequest,
4391        parent: &str,
4392    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C> {
4393        ProjectLocationCatalogGenerativeQuestionBatchUpdateCall {
4394            hub: self.hub,
4395            _request: request,
4396            _parent: parent.to_string(),
4397            _delegate: Default::default(),
4398            _additional_params: Default::default(),
4399            _scopes: Default::default(),
4400        }
4401    }
4402
4403    /// Create a builder to help you perform the following task:
4404    ///
4405    /// Returns all questions for a given catalog.
4406    ///
4407    /// # Arguments
4408    ///
4409    /// * `parent` - Required. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
4410    pub fn locations_catalogs_generative_questions_list(
4411        &self,
4412        parent: &str,
4413    ) -> ProjectLocationCatalogGenerativeQuestionListCall<'a, C> {
4414        ProjectLocationCatalogGenerativeQuestionListCall {
4415            hub: self.hub,
4416            _parent: parent.to_string(),
4417            _delegate: Default::default(),
4418            _additional_params: Default::default(),
4419            _scopes: Default::default(),
4420        }
4421    }
4422
4423    /// Create a builder to help you perform the following task:
4424    ///
4425    /// Creates a new model.
4426    ///
4427    /// # Arguments
4428    ///
4429    /// * `request` - No description provided.
4430    /// * `parent` - Required. The parent resource under which to create the model. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
4431    pub fn locations_catalogs_models_create(
4432        &self,
4433        request: GoogleCloudRetailV2Model,
4434        parent: &str,
4435    ) -> ProjectLocationCatalogModelCreateCall<'a, C> {
4436        ProjectLocationCatalogModelCreateCall {
4437            hub: self.hub,
4438            _request: request,
4439            _parent: parent.to_string(),
4440            _dry_run: Default::default(),
4441            _delegate: Default::default(),
4442            _additional_params: Default::default(),
4443            _scopes: Default::default(),
4444        }
4445    }
4446
4447    /// Create a builder to help you perform the following task:
4448    ///
4449    /// Deletes an existing model.
4450    ///
4451    /// # Arguments
4452    ///
4453    /// * `name` - Required. The resource name of the Model to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
4454    pub fn locations_catalogs_models_delete(
4455        &self,
4456        name: &str,
4457    ) -> ProjectLocationCatalogModelDeleteCall<'a, C> {
4458        ProjectLocationCatalogModelDeleteCall {
4459            hub: self.hub,
4460            _name: name.to_string(),
4461            _delegate: Default::default(),
4462            _additional_params: Default::default(),
4463            _scopes: Default::default(),
4464        }
4465    }
4466
4467    /// Create a builder to help you perform the following task:
4468    ///
4469    /// Gets a model.
4470    ///
4471    /// # Arguments
4472    ///
4473    /// * `name` - Required. The resource name of the Model to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}`
4474    pub fn locations_catalogs_models_get(
4475        &self,
4476        name: &str,
4477    ) -> ProjectLocationCatalogModelGetCall<'a, C> {
4478        ProjectLocationCatalogModelGetCall {
4479            hub: self.hub,
4480            _name: name.to_string(),
4481            _delegate: Default::default(),
4482            _additional_params: Default::default(),
4483            _scopes: Default::default(),
4484        }
4485    }
4486
4487    /// Create a builder to help you perform the following task:
4488    ///
4489    /// Lists all the models linked to this event store.
4490    ///
4491    /// # Arguments
4492    ///
4493    /// * `parent` - Required. The parent for which to list models. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
4494    pub fn locations_catalogs_models_list(
4495        &self,
4496        parent: &str,
4497    ) -> ProjectLocationCatalogModelListCall<'a, C> {
4498        ProjectLocationCatalogModelListCall {
4499            hub: self.hub,
4500            _parent: parent.to_string(),
4501            _page_token: Default::default(),
4502            _page_size: Default::default(),
4503            _delegate: Default::default(),
4504            _additional_params: Default::default(),
4505            _scopes: Default::default(),
4506        }
4507    }
4508
4509    /// Create a builder to help you perform the following task:
4510    ///
4511    /// Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.
4512    ///
4513    /// # Arguments
4514    ///
4515    /// * `request` - No description provided.
4516    /// * `name` - Required. The fully qualified resource name of the model. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` catalog_id has char limit of 50. recommendation_model_id has char limit of 40.
4517    pub fn locations_catalogs_models_patch(
4518        &self,
4519        request: GoogleCloudRetailV2Model,
4520        name: &str,
4521    ) -> ProjectLocationCatalogModelPatchCall<'a, C> {
4522        ProjectLocationCatalogModelPatchCall {
4523            hub: self.hub,
4524            _request: request,
4525            _name: name.to_string(),
4526            _update_mask: Default::default(),
4527            _delegate: Default::default(),
4528            _additional_params: Default::default(),
4529            _scopes: Default::default(),
4530        }
4531    }
4532
4533    /// Create a builder to help you perform the following task:
4534    ///
4535    /// Pauses the training of an existing model.
4536    ///
4537    /// # Arguments
4538    ///
4539    /// * `request` - No description provided.
4540    /// * `name` - Required. The name of the model to pause. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
4541    pub fn locations_catalogs_models_pause(
4542        &self,
4543        request: GoogleCloudRetailV2PauseModelRequest,
4544        name: &str,
4545    ) -> ProjectLocationCatalogModelPauseCall<'a, C> {
4546        ProjectLocationCatalogModelPauseCall {
4547            hub: self.hub,
4548            _request: request,
4549            _name: name.to_string(),
4550            _delegate: Default::default(),
4551            _additional_params: Default::default(),
4552            _scopes: Default::default(),
4553        }
4554    }
4555
4556    /// Create a builder to help you perform the following task:
4557    ///
4558    /// Resumes the training of an existing model.
4559    ///
4560    /// # Arguments
4561    ///
4562    /// * `request` - No description provided.
4563    /// * `name` - Required. The name of the model to resume. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
4564    pub fn locations_catalogs_models_resume(
4565        &self,
4566        request: GoogleCloudRetailV2ResumeModelRequest,
4567        name: &str,
4568    ) -> ProjectLocationCatalogModelResumeCall<'a, C> {
4569        ProjectLocationCatalogModelResumeCall {
4570            hub: self.hub,
4571            _request: request,
4572            _name: name.to_string(),
4573            _delegate: Default::default(),
4574            _additional_params: Default::default(),
4575            _scopes: Default::default(),
4576        }
4577    }
4578
4579    /// Create a builder to help you perform the following task:
4580    ///
4581    /// Tunes an existing model.
4582    ///
4583    /// # Arguments
4584    ///
4585    /// * `request` - No description provided.
4586    /// * `name` - Required. The resource name of the model to tune. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
4587    pub fn locations_catalogs_models_tune(
4588        &self,
4589        request: GoogleCloudRetailV2TuneModelRequest,
4590        name: &str,
4591    ) -> ProjectLocationCatalogModelTuneCall<'a, C> {
4592        ProjectLocationCatalogModelTuneCall {
4593            hub: self.hub,
4594            _request: request,
4595            _name: name.to_string(),
4596            _delegate: Default::default(),
4597            _additional_params: Default::default(),
4598            _scopes: Default::default(),
4599        }
4600    }
4601
4602    /// Create a builder to help you perform the following task:
4603    ///
4604    /// 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.
4605    ///
4606    /// # Arguments
4607    ///
4608    /// * `name` - The name of the operation resource.
4609    pub fn locations_catalogs_operations_get(
4610        &self,
4611        name: &str,
4612    ) -> ProjectLocationCatalogOperationGetCall<'a, C> {
4613        ProjectLocationCatalogOperationGetCall {
4614            hub: self.hub,
4615            _name: name.to_string(),
4616            _delegate: Default::default(),
4617            _additional_params: Default::default(),
4618            _scopes: Default::default(),
4619        }
4620    }
4621
4622    /// Create a builder to help you perform the following task:
4623    ///
4624    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4625    ///
4626    /// # Arguments
4627    ///
4628    /// * `name` - The name of the operation's parent resource.
4629    pub fn locations_catalogs_operations_list(
4630        &self,
4631        name: &str,
4632    ) -> ProjectLocationCatalogOperationListCall<'a, C> {
4633        ProjectLocationCatalogOperationListCall {
4634            hub: self.hub,
4635            _name: name.to_string(),
4636            _return_partial_success: Default::default(),
4637            _page_token: Default::default(),
4638            _page_size: Default::default(),
4639            _filter: Default::default(),
4640            _delegate: Default::default(),
4641            _additional_params: Default::default(),
4642            _scopes: Default::default(),
4643        }
4644    }
4645
4646    /// Create a builder to help you perform the following task:
4647    ///
4648    /// Performs a conversational search. This feature is only available for users who have Conversational Search enabled.
4649    ///
4650    /// # Arguments
4651    ///
4652    /// * `request` - No description provided.
4653    /// * `placement` - Required. The resource name of the search engine placement, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search` or `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` This field is used to identify the serving config name and the set of models that will be used to make the search.
4654    pub fn locations_catalogs_placements_conversational_search(
4655        &self,
4656        request: GoogleCloudRetailV2ConversationalSearchRequest,
4657        placement: &str,
4658    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C> {
4659        ProjectLocationCatalogPlacementConversationalSearchCall {
4660            hub: self.hub,
4661            _request: request,
4662            _placement: placement.to_string(),
4663            _delegate: Default::default(),
4664            _additional_params: Default::default(),
4665            _scopes: Default::default(),
4666        }
4667    }
4668
4669    /// Create a builder to help you perform the following task:
4670    ///
4671    /// Makes a recommendation prediction.
4672    ///
4673    /// # Arguments
4674    ///
4675    /// * `request` - No description provided.
4676    /// * `placement` - Required. Full resource name of the format: `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` or `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. We recommend using the `servingConfigs` resource. `placements` is a legacy resource. The ID of the Recommendations AI serving config or placement. Before you can request predictions from your model, you must create at least one serving config or placement for it. For more information, see [Manage serving configs] (https://cloud.google.com/retail/docs/manage-configs). The full list of available serving configs can be seen at https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs
4677    pub fn locations_catalogs_placements_predict(
4678        &self,
4679        request: GoogleCloudRetailV2PredictRequest,
4680        placement: &str,
4681    ) -> ProjectLocationCatalogPlacementPredictCall<'a, C> {
4682        ProjectLocationCatalogPlacementPredictCall {
4683            hub: self.hub,
4684            _request: request,
4685            _placement: placement.to_string(),
4686            _delegate: Default::default(),
4687            _additional_params: Default::default(),
4688            _scopes: Default::default(),
4689        }
4690    }
4691
4692    /// Create a builder to help you perform the following task:
4693    ///
4694    /// Performs a search. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
4695    ///
4696    /// # Arguments
4697    ///
4698    /// * `request` - No description provided.
4699    /// * `placement` - Required. The resource name of the Retail Search serving config, such as `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` or the name of the legacy placement resource, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. This field is used to identify the serving config name and the set of models that are used to make the search.
4700    pub fn locations_catalogs_placements_search(
4701        &self,
4702        request: GoogleCloudRetailV2SearchRequest,
4703        placement: &str,
4704    ) -> ProjectLocationCatalogPlacementSearchCall<'a, C> {
4705        ProjectLocationCatalogPlacementSearchCall {
4706            hub: self.hub,
4707            _request: request,
4708            _placement: placement.to_string(),
4709            _delegate: Default::default(),
4710            _additional_params: Default::default(),
4711            _scopes: Default::default(),
4712        }
4713    }
4714
4715    /// Create a builder to help you perform the following task:
4716    ///
4717    /// Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.
4718    ///
4719    /// # Arguments
4720    ///
4721    /// * `request` - No description provided.
4722    /// * `servingConfig` - Required. The source ServingConfig resource name . Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
4723    pub fn locations_catalogs_serving_configs_add_control(
4724        &self,
4725        request: GoogleCloudRetailV2AddControlRequest,
4726        serving_config: &str,
4727    ) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C> {
4728        ProjectLocationCatalogServingConfigAddControlCall {
4729            hub: self.hub,
4730            _request: request,
4731            _serving_config: serving_config.to_string(),
4732            _delegate: Default::default(),
4733            _additional_params: Default::default(),
4734            _scopes: Default::default(),
4735        }
4736    }
4737
4738    /// Create a builder to help you perform the following task:
4739    ///
4740    /// Performs a conversational search. This feature is only available for users who have Conversational Search enabled.
4741    ///
4742    /// # Arguments
4743    ///
4744    /// * `request` - No description provided.
4745    /// * `placement` - Required. The resource name of the search engine placement, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search` or `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` This field is used to identify the serving config name and the set of models that will be used to make the search.
4746    pub fn locations_catalogs_serving_configs_conversational_search(
4747        &self,
4748        request: GoogleCloudRetailV2ConversationalSearchRequest,
4749        placement: &str,
4750    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C> {
4751        ProjectLocationCatalogServingConfigConversationalSearchCall {
4752            hub: self.hub,
4753            _request: request,
4754            _placement: placement.to_string(),
4755            _delegate: Default::default(),
4756            _additional_params: Default::default(),
4757            _scopes: Default::default(),
4758        }
4759    }
4760
4761    /// Create a builder to help you perform the following task:
4762    ///
4763    /// Creates a ServingConfig. A maximum of 100 ServingConfigs are allowed in a Catalog, otherwise a FAILED_PRECONDITION error is returned.
4764    ///
4765    /// # Arguments
4766    ///
4767    /// * `request` - No description provided.
4768    /// * `parent` - Required. Full resource name of parent. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
4769    pub fn locations_catalogs_serving_configs_create(
4770        &self,
4771        request: GoogleCloudRetailV2ServingConfig,
4772        parent: &str,
4773    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C> {
4774        ProjectLocationCatalogServingConfigCreateCall {
4775            hub: self.hub,
4776            _request: request,
4777            _parent: parent.to_string(),
4778            _serving_config_id: Default::default(),
4779            _delegate: Default::default(),
4780            _additional_params: Default::default(),
4781            _scopes: Default::default(),
4782        }
4783    }
4784
4785    /// Create a builder to help you perform the following task:
4786    ///
4787    /// Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.
4788    ///
4789    /// # Arguments
4790    ///
4791    /// * `name` - Required. The resource name of the ServingConfig to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
4792    pub fn locations_catalogs_serving_configs_delete(
4793        &self,
4794        name: &str,
4795    ) -> ProjectLocationCatalogServingConfigDeleteCall<'a, C> {
4796        ProjectLocationCatalogServingConfigDeleteCall {
4797            hub: self.hub,
4798            _name: name.to_string(),
4799            _delegate: Default::default(),
4800            _additional_params: Default::default(),
4801            _scopes: Default::default(),
4802        }
4803    }
4804
4805    /// Create a builder to help you perform the following task:
4806    ///
4807    /// Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.
4808    ///
4809    /// # Arguments
4810    ///
4811    /// * `name` - Required. The resource name of the ServingConfig to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
4812    pub fn locations_catalogs_serving_configs_get(
4813        &self,
4814        name: &str,
4815    ) -> ProjectLocationCatalogServingConfigGetCall<'a, C> {
4816        ProjectLocationCatalogServingConfigGetCall {
4817            hub: self.hub,
4818            _name: name.to_string(),
4819            _delegate: Default::default(),
4820            _additional_params: Default::default(),
4821            _scopes: Default::default(),
4822        }
4823    }
4824
4825    /// Create a builder to help you perform the following task:
4826    ///
4827    /// Lists all ServingConfigs linked to this catalog.
4828    ///
4829    /// # Arguments
4830    ///
4831    /// * `parent` - Required. The catalog resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
4832    pub fn locations_catalogs_serving_configs_list(
4833        &self,
4834        parent: &str,
4835    ) -> ProjectLocationCatalogServingConfigListCall<'a, C> {
4836        ProjectLocationCatalogServingConfigListCall {
4837            hub: self.hub,
4838            _parent: parent.to_string(),
4839            _page_token: Default::default(),
4840            _page_size: Default::default(),
4841            _delegate: Default::default(),
4842            _additional_params: Default::default(),
4843            _scopes: Default::default(),
4844        }
4845    }
4846
4847    /// Create a builder to help you perform the following task:
4848    ///
4849    /// Updates a ServingConfig.
4850    ///
4851    /// # Arguments
4852    ///
4853    /// * `request` - No description provided.
4854    /// * `name` - Immutable. Fully qualified name `projects/*/locations/global/catalogs/*/servingConfig/*`
4855    pub fn locations_catalogs_serving_configs_patch(
4856        &self,
4857        request: GoogleCloudRetailV2ServingConfig,
4858        name: &str,
4859    ) -> ProjectLocationCatalogServingConfigPatchCall<'a, C> {
4860        ProjectLocationCatalogServingConfigPatchCall {
4861            hub: self.hub,
4862            _request: request,
4863            _name: name.to_string(),
4864            _update_mask: Default::default(),
4865            _delegate: Default::default(),
4866            _additional_params: Default::default(),
4867            _scopes: Default::default(),
4868        }
4869    }
4870
4871    /// Create a builder to help you perform the following task:
4872    ///
4873    /// Makes a recommendation prediction.
4874    ///
4875    /// # Arguments
4876    ///
4877    /// * `request` - No description provided.
4878    /// * `placement` - Required. Full resource name of the format: `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` or `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. We recommend using the `servingConfigs` resource. `placements` is a legacy resource. The ID of the Recommendations AI serving config or placement. Before you can request predictions from your model, you must create at least one serving config or placement for it. For more information, see [Manage serving configs] (https://cloud.google.com/retail/docs/manage-configs). The full list of available serving configs can be seen at https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs
4879    pub fn locations_catalogs_serving_configs_predict(
4880        &self,
4881        request: GoogleCloudRetailV2PredictRequest,
4882        placement: &str,
4883    ) -> ProjectLocationCatalogServingConfigPredictCall<'a, C> {
4884        ProjectLocationCatalogServingConfigPredictCall {
4885            hub: self.hub,
4886            _request: request,
4887            _placement: placement.to_string(),
4888            _delegate: Default::default(),
4889            _additional_params: Default::default(),
4890            _scopes: Default::default(),
4891        }
4892    }
4893
4894    /// Create a builder to help you perform the following task:
4895    ///
4896    /// Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.
4897    ///
4898    /// # Arguments
4899    ///
4900    /// * `request` - No description provided.
4901    /// * `servingConfig` - Required. The source ServingConfig resource name . Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
4902    pub fn locations_catalogs_serving_configs_remove_control(
4903        &self,
4904        request: GoogleCloudRetailV2RemoveControlRequest,
4905        serving_config: &str,
4906    ) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C> {
4907        ProjectLocationCatalogServingConfigRemoveControlCall {
4908            hub: self.hub,
4909            _request: request,
4910            _serving_config: serving_config.to_string(),
4911            _delegate: Default::default(),
4912            _additional_params: Default::default(),
4913            _scopes: Default::default(),
4914        }
4915    }
4916
4917    /// Create a builder to help you perform the following task:
4918    ///
4919    /// Performs a search. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
4920    ///
4921    /// # Arguments
4922    ///
4923    /// * `request` - No description provided.
4924    /// * `placement` - Required. The resource name of the Retail Search serving config, such as `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` or the name of the legacy placement resource, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. This field is used to identify the serving config name and the set of models that are used to make the search.
4925    pub fn locations_catalogs_serving_configs_search(
4926        &self,
4927        request: GoogleCloudRetailV2SearchRequest,
4928        placement: &str,
4929    ) -> ProjectLocationCatalogServingConfigSearchCall<'a, C> {
4930        ProjectLocationCatalogServingConfigSearchCall {
4931            hub: self.hub,
4932            _request: request,
4933            _placement: placement.to_string(),
4934            _delegate: Default::default(),
4935            _additional_params: Default::default(),
4936            _scopes: Default::default(),
4937        }
4938    }
4939
4940    /// Create a builder to help you perform the following task:
4941    ///
4942    /// Writes a single user event from the browser. For larger user event payload over 16 KB, the POST method should be used instead, otherwise a 400 Bad Request error is returned. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.
4943    ///
4944    /// # Arguments
4945    ///
4946    /// * `request` - No description provided.
4947    /// * `parent` - Required. The parent catalog name, such as `projects/1234/locations/global/catalogs/default_catalog`.
4948    pub fn locations_catalogs_user_events_collect(
4949        &self,
4950        request: GoogleCloudRetailV2CollectUserEventRequest,
4951        parent: &str,
4952    ) -> ProjectLocationCatalogUserEventCollectCall<'a, C> {
4953        ProjectLocationCatalogUserEventCollectCall {
4954            hub: self.hub,
4955            _request: request,
4956            _parent: parent.to_string(),
4957            _delegate: Default::default(),
4958            _additional_params: Default::default(),
4959            _scopes: Default::default(),
4960        }
4961    }
4962
4963    /// Create a builder to help you perform the following task:
4964    ///
4965    /// 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`.
4966    ///
4967    /// # Arguments
4968    ///
4969    /// * `request` - No description provided.
4970    /// * `parent` - Required. `projects/1234/locations/global/catalogs/default_catalog`
4971    pub fn locations_catalogs_user_events_import(
4972        &self,
4973        request: GoogleCloudRetailV2ImportUserEventsRequest,
4974        parent: &str,
4975    ) -> ProjectLocationCatalogUserEventImportCall<'a, C> {
4976        ProjectLocationCatalogUserEventImportCall {
4977            hub: self.hub,
4978            _request: request,
4979            _parent: parent.to_string(),
4980            _delegate: Default::default(),
4981            _additional_params: Default::default(),
4982            _scopes: Default::default(),
4983        }
4984    }
4985
4986    /// Create a builder to help you perform the following task:
4987    ///
4988    /// 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.
4989    ///
4990    /// # Arguments
4991    ///
4992    /// * `request` - No description provided.
4993    /// * `parent` - Required. The resource name of the catalog under which the events are created. The format is `projects/${projectId}/locations/global/catalogs/${catalogId}`
4994    pub fn locations_catalogs_user_events_purge(
4995        &self,
4996        request: GoogleCloudRetailV2PurgeUserEventsRequest,
4997        parent: &str,
4998    ) -> ProjectLocationCatalogUserEventPurgeCall<'a, C> {
4999        ProjectLocationCatalogUserEventPurgeCall {
5000            hub: self.hub,
5001            _request: request,
5002            _parent: parent.to_string(),
5003            _delegate: Default::default(),
5004            _additional_params: Default::default(),
5005            _scopes: Default::default(),
5006        }
5007    }
5008
5009    /// Create a builder to help you perform the following task:
5010    ///
5011    /// Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.
5012    ///
5013    /// # Arguments
5014    ///
5015    /// * `request` - No description provided.
5016    /// * `parent` - Required. The parent catalog resource name, such as `projects/1234/locations/global/catalogs/default_catalog`.
5017    pub fn locations_catalogs_user_events_rejoin(
5018        &self,
5019        request: GoogleCloudRetailV2RejoinUserEventsRequest,
5020        parent: &str,
5021    ) -> ProjectLocationCatalogUserEventRejoinCall<'a, C> {
5022        ProjectLocationCatalogUserEventRejoinCall {
5023            hub: self.hub,
5024            _request: request,
5025            _parent: parent.to_string(),
5026            _delegate: Default::default(),
5027            _additional_params: Default::default(),
5028            _scopes: Default::default(),
5029        }
5030    }
5031
5032    /// Create a builder to help you perform the following task:
5033    ///
5034    /// Writes a single user event.
5035    ///
5036    /// # Arguments
5037    ///
5038    /// * `request` - No description provided.
5039    /// * `parent` - Required. The parent catalog resource name, such as `projects/1234/locations/global/catalogs/default_catalog`.
5040    pub fn locations_catalogs_user_events_write(
5041        &self,
5042        request: GoogleCloudRetailV2UserEvent,
5043        parent: &str,
5044    ) -> ProjectLocationCatalogUserEventWriteCall<'a, C> {
5045        ProjectLocationCatalogUserEventWriteCall {
5046            hub: self.hub,
5047            _request: request,
5048            _parent: parent.to_string(),
5049            _write_async: Default::default(),
5050            _delegate: Default::default(),
5051            _additional_params: Default::default(),
5052            _scopes: Default::default(),
5053        }
5054    }
5055
5056    /// Create a builder to help you perform the following task:
5057    ///
5058    /// Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
5059    ///
5060    /// # Arguments
5061    ///
5062    /// * `catalog` - Required. Catalog for which the completion is performed. Full resource name of catalog, such as `projects/*/locations/global/catalogs/default_catalog`.
5063    pub fn locations_catalogs_complete_query(
5064        &self,
5065        catalog: &str,
5066    ) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
5067        ProjectLocationCatalogCompleteQueryCall {
5068            hub: self.hub,
5069            _catalog: catalog.to_string(),
5070            _visitor_id: Default::default(),
5071            _query: Default::default(),
5072            _max_suggestions: Default::default(),
5073            _language_codes: Default::default(),
5074            _entity: Default::default(),
5075            _enable_attribute_suggestions: Default::default(),
5076            _device_type: Default::default(),
5077            _dataset: Default::default(),
5078            _delegate: Default::default(),
5079            _additional_params: Default::default(),
5080            _scopes: Default::default(),
5081        }
5082    }
5083
5084    /// Create a builder to help you perform the following task:
5085    ///
5086    /// Exports analytics metrics. `Operation.response` is of type `ExportAnalyticsMetricsResponse`. `Operation.metadata` is of type `ExportMetadata`.
5087    ///
5088    /// # Arguments
5089    ///
5090    /// * `request` - No description provided.
5091    /// * `catalog` - Required. Full resource name of the parent catalog. Expected format: `projects/*/locations/*/catalogs/*`
5092    pub fn locations_catalogs_export_analytics_metrics(
5093        &self,
5094        request: GoogleCloudRetailV2ExportAnalyticsMetricsRequest,
5095        catalog: &str,
5096    ) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C> {
5097        ProjectLocationCatalogExportAnalyticsMetricCall {
5098            hub: self.hub,
5099            _request: request,
5100            _catalog: catalog.to_string(),
5101            _delegate: Default::default(),
5102            _additional_params: Default::default(),
5103            _scopes: Default::default(),
5104        }
5105    }
5106
5107    /// Create a builder to help you perform the following task:
5108    ///
5109    /// Gets an AttributesConfig.
5110    ///
5111    /// # Arguments
5112    ///
5113    /// * `name` - Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
5114    pub fn locations_catalogs_get_attributes_config(
5115        &self,
5116        name: &str,
5117    ) -> ProjectLocationCatalogGetAttributesConfigCall<'a, C> {
5118        ProjectLocationCatalogGetAttributesConfigCall {
5119            hub: self.hub,
5120            _name: name.to_string(),
5121            _delegate: Default::default(),
5122            _additional_params: Default::default(),
5123            _scopes: Default::default(),
5124        }
5125    }
5126
5127    /// Create a builder to help you perform the following task:
5128    ///
5129    /// Gets a CompletionConfig.
5130    ///
5131    /// # Arguments
5132    ///
5133    /// * `name` - Required. Full CompletionConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig`
5134    pub fn locations_catalogs_get_completion_config(
5135        &self,
5136        name: &str,
5137    ) -> ProjectLocationCatalogGetCompletionConfigCall<'a, C> {
5138        ProjectLocationCatalogGetCompletionConfigCall {
5139            hub: self.hub,
5140            _name: name.to_string(),
5141            _delegate: Default::default(),
5142            _additional_params: Default::default(),
5143            _scopes: Default::default(),
5144        }
5145    }
5146
5147    /// Create a builder to help you perform the following task:
5148    ///
5149    /// Returns the conversational search customization config for a given catalog.
5150    ///
5151    /// # Arguments
5152    ///
5153    /// * `name` - Required. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
5154    pub fn locations_catalogs_get_conversational_search_customization_config(
5155        &self,
5156        name: &str,
5157    ) -> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C> {
5158        ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall {
5159            hub: self.hub,
5160            _name: name.to_string(),
5161            _delegate: Default::default(),
5162            _additional_params: Default::default(),
5163            _scopes: Default::default(),
5164        }
5165    }
5166
5167    /// Create a builder to help you perform the following task:
5168    ///
5169    /// Get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent catalog.
5170    ///
5171    /// # Arguments
5172    ///
5173    /// * `catalog` - The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog`.
5174    pub fn locations_catalogs_get_default_branch(
5175        &self,
5176        catalog: &str,
5177    ) -> ProjectLocationCatalogGetDefaultBranchCall<'a, C> {
5178        ProjectLocationCatalogGetDefaultBranchCall {
5179            hub: self.hub,
5180            _catalog: catalog.to_string(),
5181            _delegate: Default::default(),
5182            _additional_params: Default::default(),
5183            _scopes: Default::default(),
5184        }
5185    }
5186
5187    /// Create a builder to help you perform the following task:
5188    ///
5189    /// Manages overal generative question feature state -- enables toggling feature on and off.
5190    ///
5191    /// # Arguments
5192    ///
5193    /// * `catalog` - Required. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
5194    pub fn locations_catalogs_get_generative_question_feature(
5195        &self,
5196        catalog: &str,
5197    ) -> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C> {
5198        ProjectLocationCatalogGetGenerativeQuestionFeatureCall {
5199            hub: self.hub,
5200            _catalog: catalog.to_string(),
5201            _delegate: Default::default(),
5202            _additional_params: Default::default(),
5203            _scopes: Default::default(),
5204        }
5205    }
5206
5207    /// Create a builder to help you perform the following task:
5208    ///
5209    /// Lists all the Catalogs associated with the project.
5210    ///
5211    /// # Arguments
5212    ///
5213    /// * `parent` - Required. The account resource name with an associated location. If the caller does not have permission to list Catalogs under this location, regardless of whether or not this location exists, a PERMISSION_DENIED error is returned.
5214    pub fn locations_catalogs_list(&self, parent: &str) -> ProjectLocationCatalogListCall<'a, C> {
5215        ProjectLocationCatalogListCall {
5216            hub: self.hub,
5217            _parent: parent.to_string(),
5218            _page_token: Default::default(),
5219            _page_size: Default::default(),
5220            _delegate: Default::default(),
5221            _additional_params: Default::default(),
5222            _scopes: Default::default(),
5223        }
5224    }
5225
5226    /// Create a builder to help you perform the following task:
5227    ///
5228    /// Updates the Catalogs.
5229    ///
5230    /// # Arguments
5231    ///
5232    /// * `request` - No description provided.
5233    /// * `name` - Required. Immutable. The fully qualified resource name of the catalog.
5234    pub fn locations_catalogs_patch(
5235        &self,
5236        request: GoogleCloudRetailV2Catalog,
5237        name: &str,
5238    ) -> ProjectLocationCatalogPatchCall<'a, C> {
5239        ProjectLocationCatalogPatchCall {
5240            hub: self.hub,
5241            _request: request,
5242            _name: name.to_string(),
5243            _update_mask: Default::default(),
5244            _delegate: Default::default(),
5245            _additional_params: Default::default(),
5246            _scopes: Default::default(),
5247        }
5248    }
5249
5250    /// Create a builder to help you perform the following task:
5251    ///
5252    /// Set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting SearchRequest.branch to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting SearchRequest.branch to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as SearchRequest.branch to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.
5253    ///
5254    /// # Arguments
5255    ///
5256    /// * `request` - No description provided.
5257    /// * `catalog` - Full resource name of the catalog, such as `projects/*/locations/global/catalogs/default_catalog`.
5258    pub fn locations_catalogs_set_default_branch(
5259        &self,
5260        request: GoogleCloudRetailV2SetDefaultBranchRequest,
5261        catalog: &str,
5262    ) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C> {
5263        ProjectLocationCatalogSetDefaultBranchCall {
5264            hub: self.hub,
5265            _request: request,
5266            _catalog: catalog.to_string(),
5267            _delegate: Default::default(),
5268            _additional_params: Default::default(),
5269            _scopes: Default::default(),
5270        }
5271    }
5272
5273    /// Create a builder to help you perform the following task:
5274    ///
5275    /// Updates the AttributesConfig. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.
5276    ///
5277    /// # Arguments
5278    ///
5279    /// * `request` - No description provided.
5280    /// * `name` - Required. Immutable. The fully qualified resource name of the attribute config. Format: `projects/*/locations/*/catalogs/*/attributesConfig`
5281    pub fn locations_catalogs_update_attributes_config(
5282        &self,
5283        request: GoogleCloudRetailV2AttributesConfig,
5284        name: &str,
5285    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C> {
5286        ProjectLocationCatalogUpdateAttributesConfigCall {
5287            hub: self.hub,
5288            _request: request,
5289            _name: name.to_string(),
5290            _update_mask: Default::default(),
5291            _delegate: Default::default(),
5292            _additional_params: Default::default(),
5293            _scopes: Default::default(),
5294        }
5295    }
5296
5297    /// Create a builder to help you perform the following task:
5298    ///
5299    /// Updates the CompletionConfigs.
5300    ///
5301    /// # Arguments
5302    ///
5303    /// * `request` - No description provided.
5304    /// * `name` - Required. Immutable. Fully qualified name `projects/*/locations/*/catalogs/*/completionConfig`
5305    pub fn locations_catalogs_update_completion_config(
5306        &self,
5307        request: GoogleCloudRetailV2CompletionConfig,
5308        name: &str,
5309    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C> {
5310        ProjectLocationCatalogUpdateCompletionConfigCall {
5311            hub: self.hub,
5312            _request: request,
5313            _name: name.to_string(),
5314            _update_mask: Default::default(),
5315            _delegate: Default::default(),
5316            _additional_params: Default::default(),
5317            _scopes: Default::default(),
5318        }
5319    }
5320
5321    /// Create a builder to help you perform the following task:
5322    ///
5323    /// Updates the conversational search customization config for a given catalog.
5324    ///
5325    /// # Arguments
5326    ///
5327    /// * `request` - No description provided.
5328    /// * `catalog` - Required. Resource name of the catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
5329    pub fn locations_catalogs_update_conversational_search_customization_config(
5330        &self,
5331        request: GoogleCloudRetailV2ConversationalSearchCustomizationConfig,
5332        catalog: &str,
5333    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C> {
5334        ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall {
5335            hub: self.hub,
5336            _request: request,
5337            _catalog: catalog.to_string(),
5338            _update_mask: Default::default(),
5339            _delegate: Default::default(),
5340            _additional_params: Default::default(),
5341            _scopes: Default::default(),
5342        }
5343    }
5344
5345    /// Create a builder to help you perform the following task:
5346    ///
5347    /// Allows management of individual questions.
5348    ///
5349    /// # Arguments
5350    ///
5351    /// * `request` - No description provided.
5352    /// * `catalog` - Required. Resource name of the catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
5353    pub fn locations_catalogs_update_generative_question(
5354        &self,
5355        request: GoogleCloudRetailV2GenerativeQuestionConfig,
5356        catalog: &str,
5357    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C> {
5358        ProjectLocationCatalogUpdateGenerativeQuestionCall {
5359            hub: self.hub,
5360            _request: request,
5361            _catalog: catalog.to_string(),
5362            _update_mask: Default::default(),
5363            _delegate: Default::default(),
5364            _additional_params: Default::default(),
5365            _scopes: Default::default(),
5366        }
5367    }
5368
5369    /// Create a builder to help you perform the following task:
5370    ///
5371    /// Manages overal generative question feature state -- enables toggling feature on and off.
5372    ///
5373    /// # Arguments
5374    ///
5375    /// * `request` - No description provided.
5376    /// * `catalog` - Required. Resource name of the affected catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
5377    pub fn locations_catalogs_update_generative_question_feature(
5378        &self,
5379        request: GoogleCloudRetailV2GenerativeQuestionsFeatureConfig,
5380        catalog: &str,
5381    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C> {
5382        ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall {
5383            hub: self.hub,
5384            _request: request,
5385            _catalog: catalog.to_string(),
5386            _update_mask: Default::default(),
5387            _delegate: Default::default(),
5388            _additional_params: Default::default(),
5389            _scopes: Default::default(),
5390        }
5391    }
5392
5393    /// Create a builder to help you perform the following task:
5394    ///
5395    /// 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.
5396    ///
5397    /// # Arguments
5398    ///
5399    /// * `name` - The name of the operation resource.
5400    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
5401        ProjectLocationOperationGetCall {
5402            hub: self.hub,
5403            _name: name.to_string(),
5404            _delegate: Default::default(),
5405            _additional_params: Default::default(),
5406            _scopes: Default::default(),
5407        }
5408    }
5409
5410    /// Create a builder to help you perform the following task:
5411    ///
5412    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
5413    ///
5414    /// # Arguments
5415    ///
5416    /// * `name` - The name of the operation's parent resource.
5417    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
5418        ProjectLocationOperationListCall {
5419            hub: self.hub,
5420            _name: name.to_string(),
5421            _return_partial_success: Default::default(),
5422            _page_token: Default::default(),
5423            _page_size: Default::default(),
5424            _filter: Default::default(),
5425            _delegate: Default::default(),
5426            _additional_params: Default::default(),
5427            _scopes: Default::default(),
5428        }
5429    }
5430
5431    /// Create a builder to help you perform the following task:
5432    ///
5433    /// 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.
5434    ///
5435    /// # Arguments
5436    ///
5437    /// * `name` - The name of the operation resource.
5438    pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
5439        ProjectOperationGetCall {
5440            hub: self.hub,
5441            _name: name.to_string(),
5442            _delegate: Default::default(),
5443            _additional_params: Default::default(),
5444            _scopes: Default::default(),
5445        }
5446    }
5447
5448    /// Create a builder to help you perform the following task:
5449    ///
5450    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
5451    ///
5452    /// # Arguments
5453    ///
5454    /// * `name` - The name of the operation's parent resource.
5455    pub fn operations_list(&self, name: &str) -> ProjectOperationListCall<'a, C> {
5456        ProjectOperationListCall {
5457            hub: self.hub,
5458            _name: name.to_string(),
5459            _return_partial_success: Default::default(),
5460            _page_token: Default::default(),
5461            _page_size: Default::default(),
5462            _filter: Default::default(),
5463            _delegate: Default::default(),
5464            _additional_params: Default::default(),
5465            _scopes: Default::default(),
5466        }
5467    }
5468}
5469
5470// ###################
5471// CallBuilders   ###
5472// #################
5473
5474/// Adds the specified CatalogAttribute to the AttributesConfig. If the CatalogAttribute to add already exists, an ALREADY_EXISTS error is returned.
5475///
5476/// A builder for the *locations.catalogs.attributesConfig.addCatalogAttribute* method supported by a *project* resource.
5477/// It is not used directly, but through a [`ProjectMethods`] instance.
5478///
5479/// # Example
5480///
5481/// Instantiate a resource method builder
5482///
5483/// ```test_harness,no_run
5484/// # extern crate hyper;
5485/// # extern crate hyper_rustls;
5486/// # extern crate google_retail2 as retail2;
5487/// use retail2::api::GoogleCloudRetailV2AddCatalogAttributeRequest;
5488/// # async fn dox() {
5489/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5490///
5491/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5492/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5493/// #     .with_native_roots()
5494/// #     .unwrap()
5495/// #     .https_only()
5496/// #     .enable_http2()
5497/// #     .build();
5498///
5499/// # let executor = hyper_util::rt::TokioExecutor::new();
5500/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5501/// #     secret,
5502/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5503/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5504/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5505/// #     ),
5506/// # ).build().await.unwrap();
5507///
5508/// # let client = hyper_util::client::legacy::Client::builder(
5509/// #     hyper_util::rt::TokioExecutor::new()
5510/// # )
5511/// # .build(
5512/// #     hyper_rustls::HttpsConnectorBuilder::new()
5513/// #         .with_native_roots()
5514/// #         .unwrap()
5515/// #         .https_or_http()
5516/// #         .enable_http2()
5517/// #         .build()
5518/// # );
5519/// # let mut hub = CloudRetail::new(client, auth);
5520/// // As the method needs a request, you would usually fill it with the desired information
5521/// // into the respective structure. Some of the parts shown here might not be applicable !
5522/// // Values shown here are possibly random and not representative !
5523/// let mut req = GoogleCloudRetailV2AddCatalogAttributeRequest::default();
5524///
5525/// // You can configure optional parameters by calling the respective setters at will, and
5526/// // execute the final call using `doit()`.
5527/// // Values shown here are possibly random and not representative !
5528/// let result = hub.projects().locations_catalogs_attributes_config_add_catalog_attribute(req, "attributesConfig")
5529///              .doit().await;
5530/// # }
5531/// ```
5532pub struct ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C>
5533where
5534    C: 'a,
5535{
5536    hub: &'a CloudRetail<C>,
5537    _request: GoogleCloudRetailV2AddCatalogAttributeRequest,
5538    _attributes_config: String,
5539    _delegate: Option<&'a mut dyn common::Delegate>,
5540    _additional_params: HashMap<String, String>,
5541    _scopes: BTreeSet<String>,
5542}
5543
5544impl<'a, C> common::CallBuilder
5545    for ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C>
5546{
5547}
5548
5549impl<'a, C> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C>
5550where
5551    C: common::Connector,
5552{
5553    /// Perform the operation you have build so far.
5554    pub async fn doit(
5555        mut self,
5556    ) -> common::Result<(common::Response, GoogleCloudRetailV2AttributesConfig)> {
5557        use std::borrow::Cow;
5558        use std::io::{Read, Seek};
5559
5560        use common::{url::Params, ToParts};
5561        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5562
5563        let mut dd = common::DefaultDelegate;
5564        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5565        dlg.begin(common::MethodInfo {
5566            id: "retail.projects.locations.catalogs.attributesConfig.addCatalogAttribute",
5567            http_method: hyper::Method::POST,
5568        });
5569
5570        for &field in ["alt", "attributesConfig"].iter() {
5571            if self._additional_params.contains_key(field) {
5572                dlg.finished(false);
5573                return Err(common::Error::FieldClash(field));
5574            }
5575        }
5576
5577        let mut params = Params::with_capacity(4 + self._additional_params.len());
5578        params.push("attributesConfig", self._attributes_config);
5579
5580        params.extend(self._additional_params.iter());
5581
5582        params.push("alt", "json");
5583        let mut url = self.hub._base_url.clone() + "v2/{+attributesConfig}:addCatalogAttribute";
5584        if self._scopes.is_empty() {
5585            self._scopes
5586                .insert(Scope::CloudPlatform.as_ref().to_string());
5587        }
5588
5589        #[allow(clippy::single_element_loop)]
5590        for &(find_this, param_name) in [("{+attributesConfig}", "attributesConfig")].iter() {
5591            url = params.uri_replacement(url, param_name, find_this, true);
5592        }
5593        {
5594            let to_remove = ["attributesConfig"];
5595            params.remove_params(&to_remove);
5596        }
5597
5598        let url = params.parse_with_url(&url);
5599
5600        let mut json_mime_type = mime::APPLICATION_JSON;
5601        let mut request_value_reader = {
5602            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5603            common::remove_json_null_values(&mut value);
5604            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5605            serde_json::to_writer(&mut dst, &value).unwrap();
5606            dst
5607        };
5608        let request_size = request_value_reader
5609            .seek(std::io::SeekFrom::End(0))
5610            .unwrap();
5611        request_value_reader
5612            .seek(std::io::SeekFrom::Start(0))
5613            .unwrap();
5614
5615        loop {
5616            let token = match self
5617                .hub
5618                .auth
5619                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5620                .await
5621            {
5622                Ok(token) => token,
5623                Err(e) => match dlg.token(e) {
5624                    Ok(token) => token,
5625                    Err(e) => {
5626                        dlg.finished(false);
5627                        return Err(common::Error::MissingToken(e));
5628                    }
5629                },
5630            };
5631            request_value_reader
5632                .seek(std::io::SeekFrom::Start(0))
5633                .unwrap();
5634            let mut req_result = {
5635                let client = &self.hub.client;
5636                dlg.pre_request();
5637                let mut req_builder = hyper::Request::builder()
5638                    .method(hyper::Method::POST)
5639                    .uri(url.as_str())
5640                    .header(USER_AGENT, self.hub._user_agent.clone());
5641
5642                if let Some(token) = token.as_ref() {
5643                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5644                }
5645
5646                let request = req_builder
5647                    .header(CONTENT_TYPE, json_mime_type.to_string())
5648                    .header(CONTENT_LENGTH, request_size as u64)
5649                    .body(common::to_body(
5650                        request_value_reader.get_ref().clone().into(),
5651                    ));
5652
5653                client.request(request.unwrap()).await
5654            };
5655
5656            match req_result {
5657                Err(err) => {
5658                    if let common::Retry::After(d) = dlg.http_error(&err) {
5659                        sleep(d).await;
5660                        continue;
5661                    }
5662                    dlg.finished(false);
5663                    return Err(common::Error::HttpError(err));
5664                }
5665                Ok(res) => {
5666                    let (mut parts, body) = res.into_parts();
5667                    let mut body = common::Body::new(body);
5668                    if !parts.status.is_success() {
5669                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5670                        let error = serde_json::from_str(&common::to_string(&bytes));
5671                        let response = common::to_response(parts, bytes.into());
5672
5673                        if let common::Retry::After(d) =
5674                            dlg.http_failure(&response, error.as_ref().ok())
5675                        {
5676                            sleep(d).await;
5677                            continue;
5678                        }
5679
5680                        dlg.finished(false);
5681
5682                        return Err(match error {
5683                            Ok(value) => common::Error::BadRequest(value),
5684                            _ => common::Error::Failure(response),
5685                        });
5686                    }
5687                    let response = {
5688                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5689                        let encoded = common::to_string(&bytes);
5690                        match serde_json::from_str(&encoded) {
5691                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5692                            Err(error) => {
5693                                dlg.response_json_decode_error(&encoded, &error);
5694                                return Err(common::Error::JsonDecodeError(
5695                                    encoded.to_string(),
5696                                    error,
5697                                ));
5698                            }
5699                        }
5700                    };
5701
5702                    dlg.finished(true);
5703                    return Ok(response);
5704                }
5705            }
5706        }
5707    }
5708
5709    ///
5710    /// Sets the *request* property to the given value.
5711    ///
5712    /// Even though the property as already been set when instantiating this call,
5713    /// we provide this method for API completeness.
5714    pub fn request(
5715        mut self,
5716        new_value: GoogleCloudRetailV2AddCatalogAttributeRequest,
5717    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C> {
5718        self._request = new_value;
5719        self
5720    }
5721    /// Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
5722    ///
5723    /// Sets the *attributes config* path property to the given value.
5724    ///
5725    /// Even though the property as already been set when instantiating this call,
5726    /// we provide this method for API completeness.
5727    pub fn attributes_config(
5728        mut self,
5729        new_value: &str,
5730    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C> {
5731        self._attributes_config = new_value.to_string();
5732        self
5733    }
5734    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5735    /// while executing the actual API request.
5736    ///
5737    /// ````text
5738    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5739    /// ````
5740    ///
5741    /// Sets the *delegate* property to the given value.
5742    pub fn delegate(
5743        mut self,
5744        new_value: &'a mut dyn common::Delegate,
5745    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C> {
5746        self._delegate = Some(new_value);
5747        self
5748    }
5749
5750    /// Set any additional parameter of the query string used in the request.
5751    /// It should be used to set parameters which are not yet available through their own
5752    /// setters.
5753    ///
5754    /// Please note that this method must not be used to set any of the known parameters
5755    /// which have their own setter method. If done anyway, the request will fail.
5756    ///
5757    /// # Additional Parameters
5758    ///
5759    /// * *$.xgafv* (query-string) - V1 error format.
5760    /// * *access_token* (query-string) - OAuth access token.
5761    /// * *alt* (query-string) - Data format for response.
5762    /// * *callback* (query-string) - JSONP
5763    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5764    /// * *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.
5765    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5766    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5767    /// * *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.
5768    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5769    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5770    pub fn param<T>(
5771        mut self,
5772        name: T,
5773        value: T,
5774    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C>
5775    where
5776        T: AsRef<str>,
5777    {
5778        self._additional_params
5779            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5780        self
5781    }
5782
5783    /// Identifies the authorization scope for the method you are building.
5784    ///
5785    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5786    /// [`Scope::CloudPlatform`].
5787    ///
5788    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5789    /// tokens for more than one scope.
5790    ///
5791    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5792    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5793    /// sufficient, a read-write scope will do as well.
5794    pub fn add_scope<St>(
5795        mut self,
5796        scope: St,
5797    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C>
5798    where
5799        St: AsRef<str>,
5800    {
5801        self._scopes.insert(String::from(scope.as_ref()));
5802        self
5803    }
5804    /// Identifies the authorization scope(s) for the method you are building.
5805    ///
5806    /// See [`Self::add_scope()`] for details.
5807    pub fn add_scopes<I, St>(
5808        mut self,
5809        scopes: I,
5810    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C>
5811    where
5812        I: IntoIterator<Item = St>,
5813        St: AsRef<str>,
5814    {
5815        self._scopes
5816            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5817        self
5818    }
5819
5820    /// Removes all scopes, and no default scope will be used either.
5821    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5822    /// for details).
5823    pub fn clear_scopes(
5824        mut self,
5825    ) -> ProjectLocationCatalogAttributesConfigAddCatalogAttributeCall<'a, C> {
5826        self._scopes.clear();
5827        self
5828    }
5829}
5830
5831/// Removes the specified CatalogAttribute from the AttributesConfig. If the CatalogAttribute to remove does not exist, a NOT_FOUND error is returned.
5832///
5833/// A builder for the *locations.catalogs.attributesConfig.removeCatalogAttribute* method supported by a *project* resource.
5834/// It is not used directly, but through a [`ProjectMethods`] instance.
5835///
5836/// # Example
5837///
5838/// Instantiate a resource method builder
5839///
5840/// ```test_harness,no_run
5841/// # extern crate hyper;
5842/// # extern crate hyper_rustls;
5843/// # extern crate google_retail2 as retail2;
5844/// use retail2::api::GoogleCloudRetailV2RemoveCatalogAttributeRequest;
5845/// # async fn dox() {
5846/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5847///
5848/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5849/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5850/// #     .with_native_roots()
5851/// #     .unwrap()
5852/// #     .https_only()
5853/// #     .enable_http2()
5854/// #     .build();
5855///
5856/// # let executor = hyper_util::rt::TokioExecutor::new();
5857/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5858/// #     secret,
5859/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5860/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5861/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5862/// #     ),
5863/// # ).build().await.unwrap();
5864///
5865/// # let client = hyper_util::client::legacy::Client::builder(
5866/// #     hyper_util::rt::TokioExecutor::new()
5867/// # )
5868/// # .build(
5869/// #     hyper_rustls::HttpsConnectorBuilder::new()
5870/// #         .with_native_roots()
5871/// #         .unwrap()
5872/// #         .https_or_http()
5873/// #         .enable_http2()
5874/// #         .build()
5875/// # );
5876/// # let mut hub = CloudRetail::new(client, auth);
5877/// // As the method needs a request, you would usually fill it with the desired information
5878/// // into the respective structure. Some of the parts shown here might not be applicable !
5879/// // Values shown here are possibly random and not representative !
5880/// let mut req = GoogleCloudRetailV2RemoveCatalogAttributeRequest::default();
5881///
5882/// // You can configure optional parameters by calling the respective setters at will, and
5883/// // execute the final call using `doit()`.
5884/// // Values shown here are possibly random and not representative !
5885/// let result = hub.projects().locations_catalogs_attributes_config_remove_catalog_attribute(req, "attributesConfig")
5886///              .doit().await;
5887/// # }
5888/// ```
5889pub struct ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C>
5890where
5891    C: 'a,
5892{
5893    hub: &'a CloudRetail<C>,
5894    _request: GoogleCloudRetailV2RemoveCatalogAttributeRequest,
5895    _attributes_config: String,
5896    _delegate: Option<&'a mut dyn common::Delegate>,
5897    _additional_params: HashMap<String, String>,
5898    _scopes: BTreeSet<String>,
5899}
5900
5901impl<'a, C> common::CallBuilder
5902    for ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C>
5903{
5904}
5905
5906impl<'a, C> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C>
5907where
5908    C: common::Connector,
5909{
5910    /// Perform the operation you have build so far.
5911    pub async fn doit(
5912        mut self,
5913    ) -> common::Result<(common::Response, GoogleCloudRetailV2AttributesConfig)> {
5914        use std::borrow::Cow;
5915        use std::io::{Read, Seek};
5916
5917        use common::{url::Params, ToParts};
5918        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5919
5920        let mut dd = common::DefaultDelegate;
5921        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5922        dlg.begin(common::MethodInfo {
5923            id: "retail.projects.locations.catalogs.attributesConfig.removeCatalogAttribute",
5924            http_method: hyper::Method::POST,
5925        });
5926
5927        for &field in ["alt", "attributesConfig"].iter() {
5928            if self._additional_params.contains_key(field) {
5929                dlg.finished(false);
5930                return Err(common::Error::FieldClash(field));
5931            }
5932        }
5933
5934        let mut params = Params::with_capacity(4 + self._additional_params.len());
5935        params.push("attributesConfig", self._attributes_config);
5936
5937        params.extend(self._additional_params.iter());
5938
5939        params.push("alt", "json");
5940        let mut url = self.hub._base_url.clone() + "v2/{+attributesConfig}:removeCatalogAttribute";
5941        if self._scopes.is_empty() {
5942            self._scopes
5943                .insert(Scope::CloudPlatform.as_ref().to_string());
5944        }
5945
5946        #[allow(clippy::single_element_loop)]
5947        for &(find_this, param_name) in [("{+attributesConfig}", "attributesConfig")].iter() {
5948            url = params.uri_replacement(url, param_name, find_this, true);
5949        }
5950        {
5951            let to_remove = ["attributesConfig"];
5952            params.remove_params(&to_remove);
5953        }
5954
5955        let url = params.parse_with_url(&url);
5956
5957        let mut json_mime_type = mime::APPLICATION_JSON;
5958        let mut request_value_reader = {
5959            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5960            common::remove_json_null_values(&mut value);
5961            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5962            serde_json::to_writer(&mut dst, &value).unwrap();
5963            dst
5964        };
5965        let request_size = request_value_reader
5966            .seek(std::io::SeekFrom::End(0))
5967            .unwrap();
5968        request_value_reader
5969            .seek(std::io::SeekFrom::Start(0))
5970            .unwrap();
5971
5972        loop {
5973            let token = match self
5974                .hub
5975                .auth
5976                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5977                .await
5978            {
5979                Ok(token) => token,
5980                Err(e) => match dlg.token(e) {
5981                    Ok(token) => token,
5982                    Err(e) => {
5983                        dlg.finished(false);
5984                        return Err(common::Error::MissingToken(e));
5985                    }
5986                },
5987            };
5988            request_value_reader
5989                .seek(std::io::SeekFrom::Start(0))
5990                .unwrap();
5991            let mut req_result = {
5992                let client = &self.hub.client;
5993                dlg.pre_request();
5994                let mut req_builder = hyper::Request::builder()
5995                    .method(hyper::Method::POST)
5996                    .uri(url.as_str())
5997                    .header(USER_AGENT, self.hub._user_agent.clone());
5998
5999                if let Some(token) = token.as_ref() {
6000                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6001                }
6002
6003                let request = req_builder
6004                    .header(CONTENT_TYPE, json_mime_type.to_string())
6005                    .header(CONTENT_LENGTH, request_size as u64)
6006                    .body(common::to_body(
6007                        request_value_reader.get_ref().clone().into(),
6008                    ));
6009
6010                client.request(request.unwrap()).await
6011            };
6012
6013            match req_result {
6014                Err(err) => {
6015                    if let common::Retry::After(d) = dlg.http_error(&err) {
6016                        sleep(d).await;
6017                        continue;
6018                    }
6019                    dlg.finished(false);
6020                    return Err(common::Error::HttpError(err));
6021                }
6022                Ok(res) => {
6023                    let (mut parts, body) = res.into_parts();
6024                    let mut body = common::Body::new(body);
6025                    if !parts.status.is_success() {
6026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6027                        let error = serde_json::from_str(&common::to_string(&bytes));
6028                        let response = common::to_response(parts, bytes.into());
6029
6030                        if let common::Retry::After(d) =
6031                            dlg.http_failure(&response, error.as_ref().ok())
6032                        {
6033                            sleep(d).await;
6034                            continue;
6035                        }
6036
6037                        dlg.finished(false);
6038
6039                        return Err(match error {
6040                            Ok(value) => common::Error::BadRequest(value),
6041                            _ => common::Error::Failure(response),
6042                        });
6043                    }
6044                    let response = {
6045                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6046                        let encoded = common::to_string(&bytes);
6047                        match serde_json::from_str(&encoded) {
6048                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6049                            Err(error) => {
6050                                dlg.response_json_decode_error(&encoded, &error);
6051                                return Err(common::Error::JsonDecodeError(
6052                                    encoded.to_string(),
6053                                    error,
6054                                ));
6055                            }
6056                        }
6057                    };
6058
6059                    dlg.finished(true);
6060                    return Ok(response);
6061                }
6062            }
6063        }
6064    }
6065
6066    ///
6067    /// Sets the *request* property to the given value.
6068    ///
6069    /// Even though the property as already been set when instantiating this call,
6070    /// we provide this method for API completeness.
6071    pub fn request(
6072        mut self,
6073        new_value: GoogleCloudRetailV2RemoveCatalogAttributeRequest,
6074    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C> {
6075        self._request = new_value;
6076        self
6077    }
6078    /// Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
6079    ///
6080    /// Sets the *attributes config* path property to the given value.
6081    ///
6082    /// Even though the property as already been set when instantiating this call,
6083    /// we provide this method for API completeness.
6084    pub fn attributes_config(
6085        mut self,
6086        new_value: &str,
6087    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C> {
6088        self._attributes_config = new_value.to_string();
6089        self
6090    }
6091    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6092    /// while executing the actual API request.
6093    ///
6094    /// ````text
6095    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6096    /// ````
6097    ///
6098    /// Sets the *delegate* property to the given value.
6099    pub fn delegate(
6100        mut self,
6101        new_value: &'a mut dyn common::Delegate,
6102    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C> {
6103        self._delegate = Some(new_value);
6104        self
6105    }
6106
6107    /// Set any additional parameter of the query string used in the request.
6108    /// It should be used to set parameters which are not yet available through their own
6109    /// setters.
6110    ///
6111    /// Please note that this method must not be used to set any of the known parameters
6112    /// which have their own setter method. If done anyway, the request will fail.
6113    ///
6114    /// # Additional Parameters
6115    ///
6116    /// * *$.xgafv* (query-string) - V1 error format.
6117    /// * *access_token* (query-string) - OAuth access token.
6118    /// * *alt* (query-string) - Data format for response.
6119    /// * *callback* (query-string) - JSONP
6120    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6121    /// * *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.
6122    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6123    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6124    /// * *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.
6125    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6126    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6127    pub fn param<T>(
6128        mut self,
6129        name: T,
6130        value: T,
6131    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C>
6132    where
6133        T: AsRef<str>,
6134    {
6135        self._additional_params
6136            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6137        self
6138    }
6139
6140    /// Identifies the authorization scope for the method you are building.
6141    ///
6142    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6143    /// [`Scope::CloudPlatform`].
6144    ///
6145    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6146    /// tokens for more than one scope.
6147    ///
6148    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6149    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6150    /// sufficient, a read-write scope will do as well.
6151    pub fn add_scope<St>(
6152        mut self,
6153        scope: St,
6154    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C>
6155    where
6156        St: AsRef<str>,
6157    {
6158        self._scopes.insert(String::from(scope.as_ref()));
6159        self
6160    }
6161    /// Identifies the authorization scope(s) for the method you are building.
6162    ///
6163    /// See [`Self::add_scope()`] for details.
6164    pub fn add_scopes<I, St>(
6165        mut self,
6166        scopes: I,
6167    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C>
6168    where
6169        I: IntoIterator<Item = St>,
6170        St: AsRef<str>,
6171    {
6172        self._scopes
6173            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6174        self
6175    }
6176
6177    /// Removes all scopes, and no default scope will be used either.
6178    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6179    /// for details).
6180    pub fn clear_scopes(
6181        mut self,
6182    ) -> ProjectLocationCatalogAttributesConfigRemoveCatalogAttributeCall<'a, C> {
6183        self._scopes.clear();
6184        self
6185    }
6186}
6187
6188/// Replaces the specified CatalogAttribute in the AttributesConfig by updating the catalog attribute with the same CatalogAttribute.key. If the CatalogAttribute to replace does not exist, a NOT_FOUND error is returned.
6189///
6190/// A builder for the *locations.catalogs.attributesConfig.replaceCatalogAttribute* method supported by a *project* resource.
6191/// It is not used directly, but through a [`ProjectMethods`] instance.
6192///
6193/// # Example
6194///
6195/// Instantiate a resource method builder
6196///
6197/// ```test_harness,no_run
6198/// # extern crate hyper;
6199/// # extern crate hyper_rustls;
6200/// # extern crate google_retail2 as retail2;
6201/// use retail2::api::GoogleCloudRetailV2ReplaceCatalogAttributeRequest;
6202/// # async fn dox() {
6203/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6204///
6205/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6206/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6207/// #     .with_native_roots()
6208/// #     .unwrap()
6209/// #     .https_only()
6210/// #     .enable_http2()
6211/// #     .build();
6212///
6213/// # let executor = hyper_util::rt::TokioExecutor::new();
6214/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6215/// #     secret,
6216/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6217/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6218/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6219/// #     ),
6220/// # ).build().await.unwrap();
6221///
6222/// # let client = hyper_util::client::legacy::Client::builder(
6223/// #     hyper_util::rt::TokioExecutor::new()
6224/// # )
6225/// # .build(
6226/// #     hyper_rustls::HttpsConnectorBuilder::new()
6227/// #         .with_native_roots()
6228/// #         .unwrap()
6229/// #         .https_or_http()
6230/// #         .enable_http2()
6231/// #         .build()
6232/// # );
6233/// # let mut hub = CloudRetail::new(client, auth);
6234/// // As the method needs a request, you would usually fill it with the desired information
6235/// // into the respective structure. Some of the parts shown here might not be applicable !
6236/// // Values shown here are possibly random and not representative !
6237/// let mut req = GoogleCloudRetailV2ReplaceCatalogAttributeRequest::default();
6238///
6239/// // You can configure optional parameters by calling the respective setters at will, and
6240/// // execute the final call using `doit()`.
6241/// // Values shown here are possibly random and not representative !
6242/// let result = hub.projects().locations_catalogs_attributes_config_replace_catalog_attribute(req, "attributesConfig")
6243///              .doit().await;
6244/// # }
6245/// ```
6246pub struct ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C>
6247where
6248    C: 'a,
6249{
6250    hub: &'a CloudRetail<C>,
6251    _request: GoogleCloudRetailV2ReplaceCatalogAttributeRequest,
6252    _attributes_config: String,
6253    _delegate: Option<&'a mut dyn common::Delegate>,
6254    _additional_params: HashMap<String, String>,
6255    _scopes: BTreeSet<String>,
6256}
6257
6258impl<'a, C> common::CallBuilder
6259    for ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C>
6260{
6261}
6262
6263impl<'a, C> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C>
6264where
6265    C: common::Connector,
6266{
6267    /// Perform the operation you have build so far.
6268    pub async fn doit(
6269        mut self,
6270    ) -> common::Result<(common::Response, GoogleCloudRetailV2AttributesConfig)> {
6271        use std::borrow::Cow;
6272        use std::io::{Read, Seek};
6273
6274        use common::{url::Params, ToParts};
6275        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6276
6277        let mut dd = common::DefaultDelegate;
6278        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6279        dlg.begin(common::MethodInfo {
6280            id: "retail.projects.locations.catalogs.attributesConfig.replaceCatalogAttribute",
6281            http_method: hyper::Method::POST,
6282        });
6283
6284        for &field in ["alt", "attributesConfig"].iter() {
6285            if self._additional_params.contains_key(field) {
6286                dlg.finished(false);
6287                return Err(common::Error::FieldClash(field));
6288            }
6289        }
6290
6291        let mut params = Params::with_capacity(4 + self._additional_params.len());
6292        params.push("attributesConfig", self._attributes_config);
6293
6294        params.extend(self._additional_params.iter());
6295
6296        params.push("alt", "json");
6297        let mut url = self.hub._base_url.clone() + "v2/{+attributesConfig}:replaceCatalogAttribute";
6298        if self._scopes.is_empty() {
6299            self._scopes
6300                .insert(Scope::CloudPlatform.as_ref().to_string());
6301        }
6302
6303        #[allow(clippy::single_element_loop)]
6304        for &(find_this, param_name) in [("{+attributesConfig}", "attributesConfig")].iter() {
6305            url = params.uri_replacement(url, param_name, find_this, true);
6306        }
6307        {
6308            let to_remove = ["attributesConfig"];
6309            params.remove_params(&to_remove);
6310        }
6311
6312        let url = params.parse_with_url(&url);
6313
6314        let mut json_mime_type = mime::APPLICATION_JSON;
6315        let mut request_value_reader = {
6316            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6317            common::remove_json_null_values(&mut value);
6318            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6319            serde_json::to_writer(&mut dst, &value).unwrap();
6320            dst
6321        };
6322        let request_size = request_value_reader
6323            .seek(std::io::SeekFrom::End(0))
6324            .unwrap();
6325        request_value_reader
6326            .seek(std::io::SeekFrom::Start(0))
6327            .unwrap();
6328
6329        loop {
6330            let token = match self
6331                .hub
6332                .auth
6333                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6334                .await
6335            {
6336                Ok(token) => token,
6337                Err(e) => match dlg.token(e) {
6338                    Ok(token) => token,
6339                    Err(e) => {
6340                        dlg.finished(false);
6341                        return Err(common::Error::MissingToken(e));
6342                    }
6343                },
6344            };
6345            request_value_reader
6346                .seek(std::io::SeekFrom::Start(0))
6347                .unwrap();
6348            let mut req_result = {
6349                let client = &self.hub.client;
6350                dlg.pre_request();
6351                let mut req_builder = hyper::Request::builder()
6352                    .method(hyper::Method::POST)
6353                    .uri(url.as_str())
6354                    .header(USER_AGENT, self.hub._user_agent.clone());
6355
6356                if let Some(token) = token.as_ref() {
6357                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6358                }
6359
6360                let request = req_builder
6361                    .header(CONTENT_TYPE, json_mime_type.to_string())
6362                    .header(CONTENT_LENGTH, request_size as u64)
6363                    .body(common::to_body(
6364                        request_value_reader.get_ref().clone().into(),
6365                    ));
6366
6367                client.request(request.unwrap()).await
6368            };
6369
6370            match req_result {
6371                Err(err) => {
6372                    if let common::Retry::After(d) = dlg.http_error(&err) {
6373                        sleep(d).await;
6374                        continue;
6375                    }
6376                    dlg.finished(false);
6377                    return Err(common::Error::HttpError(err));
6378                }
6379                Ok(res) => {
6380                    let (mut parts, body) = res.into_parts();
6381                    let mut body = common::Body::new(body);
6382                    if !parts.status.is_success() {
6383                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6384                        let error = serde_json::from_str(&common::to_string(&bytes));
6385                        let response = common::to_response(parts, bytes.into());
6386
6387                        if let common::Retry::After(d) =
6388                            dlg.http_failure(&response, error.as_ref().ok())
6389                        {
6390                            sleep(d).await;
6391                            continue;
6392                        }
6393
6394                        dlg.finished(false);
6395
6396                        return Err(match error {
6397                            Ok(value) => common::Error::BadRequest(value),
6398                            _ => common::Error::Failure(response),
6399                        });
6400                    }
6401                    let response = {
6402                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6403                        let encoded = common::to_string(&bytes);
6404                        match serde_json::from_str(&encoded) {
6405                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6406                            Err(error) => {
6407                                dlg.response_json_decode_error(&encoded, &error);
6408                                return Err(common::Error::JsonDecodeError(
6409                                    encoded.to_string(),
6410                                    error,
6411                                ));
6412                            }
6413                        }
6414                    };
6415
6416                    dlg.finished(true);
6417                    return Ok(response);
6418                }
6419            }
6420        }
6421    }
6422
6423    ///
6424    /// Sets the *request* property to the given value.
6425    ///
6426    /// Even though the property as already been set when instantiating this call,
6427    /// we provide this method for API completeness.
6428    pub fn request(
6429        mut self,
6430        new_value: GoogleCloudRetailV2ReplaceCatalogAttributeRequest,
6431    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C> {
6432        self._request = new_value;
6433        self
6434    }
6435    /// Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
6436    ///
6437    /// Sets the *attributes config* path property to the given value.
6438    ///
6439    /// Even though the property as already been set when instantiating this call,
6440    /// we provide this method for API completeness.
6441    pub fn attributes_config(
6442        mut self,
6443        new_value: &str,
6444    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C> {
6445        self._attributes_config = new_value.to_string();
6446        self
6447    }
6448    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6449    /// while executing the actual API request.
6450    ///
6451    /// ````text
6452    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6453    /// ````
6454    ///
6455    /// Sets the *delegate* property to the given value.
6456    pub fn delegate(
6457        mut self,
6458        new_value: &'a mut dyn common::Delegate,
6459    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C> {
6460        self._delegate = Some(new_value);
6461        self
6462    }
6463
6464    /// Set any additional parameter of the query string used in the request.
6465    /// It should be used to set parameters which are not yet available through their own
6466    /// setters.
6467    ///
6468    /// Please note that this method must not be used to set any of the known parameters
6469    /// which have their own setter method. If done anyway, the request will fail.
6470    ///
6471    /// # Additional Parameters
6472    ///
6473    /// * *$.xgafv* (query-string) - V1 error format.
6474    /// * *access_token* (query-string) - OAuth access token.
6475    /// * *alt* (query-string) - Data format for response.
6476    /// * *callback* (query-string) - JSONP
6477    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6478    /// * *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.
6479    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6480    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6481    /// * *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.
6482    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6483    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6484    pub fn param<T>(
6485        mut self,
6486        name: T,
6487        value: T,
6488    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C>
6489    where
6490        T: AsRef<str>,
6491    {
6492        self._additional_params
6493            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6494        self
6495    }
6496
6497    /// Identifies the authorization scope for the method you are building.
6498    ///
6499    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6500    /// [`Scope::CloudPlatform`].
6501    ///
6502    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6503    /// tokens for more than one scope.
6504    ///
6505    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6506    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6507    /// sufficient, a read-write scope will do as well.
6508    pub fn add_scope<St>(
6509        mut self,
6510        scope: St,
6511    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C>
6512    where
6513        St: AsRef<str>,
6514    {
6515        self._scopes.insert(String::from(scope.as_ref()));
6516        self
6517    }
6518    /// Identifies the authorization scope(s) for the method you are building.
6519    ///
6520    /// See [`Self::add_scope()`] for details.
6521    pub fn add_scopes<I, St>(
6522        mut self,
6523        scopes: I,
6524    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C>
6525    where
6526        I: IntoIterator<Item = St>,
6527        St: AsRef<str>,
6528    {
6529        self._scopes
6530            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6531        self
6532    }
6533
6534    /// Removes all scopes, and no default scope will be used either.
6535    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6536    /// for details).
6537    pub fn clear_scopes(
6538        mut self,
6539    ) -> ProjectLocationCatalogAttributesConfigReplaceCatalogAttributeCall<'a, C> {
6540        self._scopes.clear();
6541        self
6542    }
6543}
6544
6545/// 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.
6546///
6547/// A builder for the *locations.catalogs.branches.operations.get* method supported by a *project* resource.
6548/// It is not used directly, but through a [`ProjectMethods`] instance.
6549///
6550/// # Example
6551///
6552/// Instantiate a resource method builder
6553///
6554/// ```test_harness,no_run
6555/// # extern crate hyper;
6556/// # extern crate hyper_rustls;
6557/// # extern crate google_retail2 as retail2;
6558/// # async fn dox() {
6559/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6560///
6561/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6562/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6563/// #     .with_native_roots()
6564/// #     .unwrap()
6565/// #     .https_only()
6566/// #     .enable_http2()
6567/// #     .build();
6568///
6569/// # let executor = hyper_util::rt::TokioExecutor::new();
6570/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6571/// #     secret,
6572/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6573/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6574/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6575/// #     ),
6576/// # ).build().await.unwrap();
6577///
6578/// # let client = hyper_util::client::legacy::Client::builder(
6579/// #     hyper_util::rt::TokioExecutor::new()
6580/// # )
6581/// # .build(
6582/// #     hyper_rustls::HttpsConnectorBuilder::new()
6583/// #         .with_native_roots()
6584/// #         .unwrap()
6585/// #         .https_or_http()
6586/// #         .enable_http2()
6587/// #         .build()
6588/// # );
6589/// # let mut hub = CloudRetail::new(client, auth);
6590/// // You can configure optional parameters by calling the respective setters at will, and
6591/// // execute the final call using `doit()`.
6592/// // Values shown here are possibly random and not representative !
6593/// let result = hub.projects().locations_catalogs_branches_operations_get("name")
6594///              .doit().await;
6595/// # }
6596/// ```
6597pub struct ProjectLocationCatalogBranchOperationGetCall<'a, C>
6598where
6599    C: 'a,
6600{
6601    hub: &'a CloudRetail<C>,
6602    _name: String,
6603    _delegate: Option<&'a mut dyn common::Delegate>,
6604    _additional_params: HashMap<String, String>,
6605    _scopes: BTreeSet<String>,
6606}
6607
6608impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchOperationGetCall<'a, C> {}
6609
6610impl<'a, C> ProjectLocationCatalogBranchOperationGetCall<'a, C>
6611where
6612    C: common::Connector,
6613{
6614    /// Perform the operation you have build so far.
6615    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6616        use std::borrow::Cow;
6617        use std::io::{Read, Seek};
6618
6619        use common::{url::Params, ToParts};
6620        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6621
6622        let mut dd = common::DefaultDelegate;
6623        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6624        dlg.begin(common::MethodInfo {
6625            id: "retail.projects.locations.catalogs.branches.operations.get",
6626            http_method: hyper::Method::GET,
6627        });
6628
6629        for &field in ["alt", "name"].iter() {
6630            if self._additional_params.contains_key(field) {
6631                dlg.finished(false);
6632                return Err(common::Error::FieldClash(field));
6633            }
6634        }
6635
6636        let mut params = Params::with_capacity(3 + self._additional_params.len());
6637        params.push("name", self._name);
6638
6639        params.extend(self._additional_params.iter());
6640
6641        params.push("alt", "json");
6642        let mut url = self.hub._base_url.clone() + "v2/{+name}";
6643        if self._scopes.is_empty() {
6644            self._scopes
6645                .insert(Scope::CloudPlatform.as_ref().to_string());
6646        }
6647
6648        #[allow(clippy::single_element_loop)]
6649        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6650            url = params.uri_replacement(url, param_name, find_this, true);
6651        }
6652        {
6653            let to_remove = ["name"];
6654            params.remove_params(&to_remove);
6655        }
6656
6657        let url = params.parse_with_url(&url);
6658
6659        loop {
6660            let token = match self
6661                .hub
6662                .auth
6663                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6664                .await
6665            {
6666                Ok(token) => token,
6667                Err(e) => match dlg.token(e) {
6668                    Ok(token) => token,
6669                    Err(e) => {
6670                        dlg.finished(false);
6671                        return Err(common::Error::MissingToken(e));
6672                    }
6673                },
6674            };
6675            let mut req_result = {
6676                let client = &self.hub.client;
6677                dlg.pre_request();
6678                let mut req_builder = hyper::Request::builder()
6679                    .method(hyper::Method::GET)
6680                    .uri(url.as_str())
6681                    .header(USER_AGENT, self.hub._user_agent.clone());
6682
6683                if let Some(token) = token.as_ref() {
6684                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6685                }
6686
6687                let request = req_builder
6688                    .header(CONTENT_LENGTH, 0_u64)
6689                    .body(common::to_body::<String>(None));
6690
6691                client.request(request.unwrap()).await
6692            };
6693
6694            match req_result {
6695                Err(err) => {
6696                    if let common::Retry::After(d) = dlg.http_error(&err) {
6697                        sleep(d).await;
6698                        continue;
6699                    }
6700                    dlg.finished(false);
6701                    return Err(common::Error::HttpError(err));
6702                }
6703                Ok(res) => {
6704                    let (mut parts, body) = res.into_parts();
6705                    let mut body = common::Body::new(body);
6706                    if !parts.status.is_success() {
6707                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6708                        let error = serde_json::from_str(&common::to_string(&bytes));
6709                        let response = common::to_response(parts, bytes.into());
6710
6711                        if let common::Retry::After(d) =
6712                            dlg.http_failure(&response, error.as_ref().ok())
6713                        {
6714                            sleep(d).await;
6715                            continue;
6716                        }
6717
6718                        dlg.finished(false);
6719
6720                        return Err(match error {
6721                            Ok(value) => common::Error::BadRequest(value),
6722                            _ => common::Error::Failure(response),
6723                        });
6724                    }
6725                    let response = {
6726                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6727                        let encoded = common::to_string(&bytes);
6728                        match serde_json::from_str(&encoded) {
6729                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6730                            Err(error) => {
6731                                dlg.response_json_decode_error(&encoded, &error);
6732                                return Err(common::Error::JsonDecodeError(
6733                                    encoded.to_string(),
6734                                    error,
6735                                ));
6736                            }
6737                        }
6738                    };
6739
6740                    dlg.finished(true);
6741                    return Ok(response);
6742                }
6743            }
6744        }
6745    }
6746
6747    /// The name of the operation resource.
6748    ///
6749    /// Sets the *name* path property to the given value.
6750    ///
6751    /// Even though the property as already been set when instantiating this call,
6752    /// we provide this method for API completeness.
6753    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogBranchOperationGetCall<'a, C> {
6754        self._name = new_value.to_string();
6755        self
6756    }
6757    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6758    /// while executing the actual API request.
6759    ///
6760    /// ````text
6761    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6762    /// ````
6763    ///
6764    /// Sets the *delegate* property to the given value.
6765    pub fn delegate(
6766        mut self,
6767        new_value: &'a mut dyn common::Delegate,
6768    ) -> ProjectLocationCatalogBranchOperationGetCall<'a, C> {
6769        self._delegate = Some(new_value);
6770        self
6771    }
6772
6773    /// Set any additional parameter of the query string used in the request.
6774    /// It should be used to set parameters which are not yet available through their own
6775    /// setters.
6776    ///
6777    /// Please note that this method must not be used to set any of the known parameters
6778    /// which have their own setter method. If done anyway, the request will fail.
6779    ///
6780    /// # Additional Parameters
6781    ///
6782    /// * *$.xgafv* (query-string) - V1 error format.
6783    /// * *access_token* (query-string) - OAuth access token.
6784    /// * *alt* (query-string) - Data format for response.
6785    /// * *callback* (query-string) - JSONP
6786    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6787    /// * *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.
6788    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6789    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6790    /// * *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.
6791    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6792    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6793    pub fn param<T>(
6794        mut self,
6795        name: T,
6796        value: T,
6797    ) -> ProjectLocationCatalogBranchOperationGetCall<'a, C>
6798    where
6799        T: AsRef<str>,
6800    {
6801        self._additional_params
6802            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6803        self
6804    }
6805
6806    /// Identifies the authorization scope for the method you are building.
6807    ///
6808    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6809    /// [`Scope::CloudPlatform`].
6810    ///
6811    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6812    /// tokens for more than one scope.
6813    ///
6814    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6815    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6816    /// sufficient, a read-write scope will do as well.
6817    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogBranchOperationGetCall<'a, C>
6818    where
6819        St: AsRef<str>,
6820    {
6821        self._scopes.insert(String::from(scope.as_ref()));
6822        self
6823    }
6824    /// Identifies the authorization scope(s) for the method you are building.
6825    ///
6826    /// See [`Self::add_scope()`] for details.
6827    pub fn add_scopes<I, St>(
6828        mut self,
6829        scopes: I,
6830    ) -> ProjectLocationCatalogBranchOperationGetCall<'a, C>
6831    where
6832        I: IntoIterator<Item = St>,
6833        St: AsRef<str>,
6834    {
6835        self._scopes
6836            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6837        self
6838    }
6839
6840    /// Removes all scopes, and no default scope will be used either.
6841    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6842    /// for details).
6843    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchOperationGetCall<'a, C> {
6844        self._scopes.clear();
6845        self
6846    }
6847}
6848
6849/// We recommend that you use the ProductService.AddLocalInventories method instead of the ProductService.AddFulfillmentPlaces method. ProductService.AddLocalInventories achieves the same results but provides more fine-grained control over ingesting local inventory data. Incrementally adds place IDs to Product.fulfillment_info.place_ids. This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
6850///
6851/// A builder for the *locations.catalogs.branches.products.addFulfillmentPlaces* method supported by a *project* resource.
6852/// It is not used directly, but through a [`ProjectMethods`] instance.
6853///
6854/// # Example
6855///
6856/// Instantiate a resource method builder
6857///
6858/// ```test_harness,no_run
6859/// # extern crate hyper;
6860/// # extern crate hyper_rustls;
6861/// # extern crate google_retail2 as retail2;
6862/// use retail2::api::GoogleCloudRetailV2AddFulfillmentPlacesRequest;
6863/// # async fn dox() {
6864/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6865///
6866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6867/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6868/// #     .with_native_roots()
6869/// #     .unwrap()
6870/// #     .https_only()
6871/// #     .enable_http2()
6872/// #     .build();
6873///
6874/// # let executor = hyper_util::rt::TokioExecutor::new();
6875/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6876/// #     secret,
6877/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6878/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6879/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6880/// #     ),
6881/// # ).build().await.unwrap();
6882///
6883/// # let client = hyper_util::client::legacy::Client::builder(
6884/// #     hyper_util::rt::TokioExecutor::new()
6885/// # )
6886/// # .build(
6887/// #     hyper_rustls::HttpsConnectorBuilder::new()
6888/// #         .with_native_roots()
6889/// #         .unwrap()
6890/// #         .https_or_http()
6891/// #         .enable_http2()
6892/// #         .build()
6893/// # );
6894/// # let mut hub = CloudRetail::new(client, auth);
6895/// // As the method needs a request, you would usually fill it with the desired information
6896/// // into the respective structure. Some of the parts shown here might not be applicable !
6897/// // Values shown here are possibly random and not representative !
6898/// let mut req = GoogleCloudRetailV2AddFulfillmentPlacesRequest::default();
6899///
6900/// // You can configure optional parameters by calling the respective setters at will, and
6901/// // execute the final call using `doit()`.
6902/// // Values shown here are possibly random and not representative !
6903/// let result = hub.projects().locations_catalogs_branches_products_add_fulfillment_places(req, "product")
6904///              .doit().await;
6905/// # }
6906/// ```
6907pub struct ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C>
6908where
6909    C: 'a,
6910{
6911    hub: &'a CloudRetail<C>,
6912    _request: GoogleCloudRetailV2AddFulfillmentPlacesRequest,
6913    _product: String,
6914    _delegate: Option<&'a mut dyn common::Delegate>,
6915    _additional_params: HashMap<String, String>,
6916    _scopes: BTreeSet<String>,
6917}
6918
6919impl<'a, C> common::CallBuilder
6920    for ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C>
6921{
6922}
6923
6924impl<'a, C> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C>
6925where
6926    C: common::Connector,
6927{
6928    /// Perform the operation you have build so far.
6929    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6930        use std::borrow::Cow;
6931        use std::io::{Read, Seek};
6932
6933        use common::{url::Params, ToParts};
6934        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6935
6936        let mut dd = common::DefaultDelegate;
6937        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6938        dlg.begin(common::MethodInfo {
6939            id: "retail.projects.locations.catalogs.branches.products.addFulfillmentPlaces",
6940            http_method: hyper::Method::POST,
6941        });
6942
6943        for &field in ["alt", "product"].iter() {
6944            if self._additional_params.contains_key(field) {
6945                dlg.finished(false);
6946                return Err(common::Error::FieldClash(field));
6947            }
6948        }
6949
6950        let mut params = Params::with_capacity(4 + self._additional_params.len());
6951        params.push("product", self._product);
6952
6953        params.extend(self._additional_params.iter());
6954
6955        params.push("alt", "json");
6956        let mut url = self.hub._base_url.clone() + "v2/{+product}:addFulfillmentPlaces";
6957        if self._scopes.is_empty() {
6958            self._scopes
6959                .insert(Scope::CloudPlatform.as_ref().to_string());
6960        }
6961
6962        #[allow(clippy::single_element_loop)]
6963        for &(find_this, param_name) in [("{+product}", "product")].iter() {
6964            url = params.uri_replacement(url, param_name, find_this, true);
6965        }
6966        {
6967            let to_remove = ["product"];
6968            params.remove_params(&to_remove);
6969        }
6970
6971        let url = params.parse_with_url(&url);
6972
6973        let mut json_mime_type = mime::APPLICATION_JSON;
6974        let mut request_value_reader = {
6975            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6976            common::remove_json_null_values(&mut value);
6977            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6978            serde_json::to_writer(&mut dst, &value).unwrap();
6979            dst
6980        };
6981        let request_size = request_value_reader
6982            .seek(std::io::SeekFrom::End(0))
6983            .unwrap();
6984        request_value_reader
6985            .seek(std::io::SeekFrom::Start(0))
6986            .unwrap();
6987
6988        loop {
6989            let token = match self
6990                .hub
6991                .auth
6992                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6993                .await
6994            {
6995                Ok(token) => token,
6996                Err(e) => match dlg.token(e) {
6997                    Ok(token) => token,
6998                    Err(e) => {
6999                        dlg.finished(false);
7000                        return Err(common::Error::MissingToken(e));
7001                    }
7002                },
7003            };
7004            request_value_reader
7005                .seek(std::io::SeekFrom::Start(0))
7006                .unwrap();
7007            let mut req_result = {
7008                let client = &self.hub.client;
7009                dlg.pre_request();
7010                let mut req_builder = hyper::Request::builder()
7011                    .method(hyper::Method::POST)
7012                    .uri(url.as_str())
7013                    .header(USER_AGENT, self.hub._user_agent.clone());
7014
7015                if let Some(token) = token.as_ref() {
7016                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7017                }
7018
7019                let request = req_builder
7020                    .header(CONTENT_TYPE, json_mime_type.to_string())
7021                    .header(CONTENT_LENGTH, request_size as u64)
7022                    .body(common::to_body(
7023                        request_value_reader.get_ref().clone().into(),
7024                    ));
7025
7026                client.request(request.unwrap()).await
7027            };
7028
7029            match req_result {
7030                Err(err) => {
7031                    if let common::Retry::After(d) = dlg.http_error(&err) {
7032                        sleep(d).await;
7033                        continue;
7034                    }
7035                    dlg.finished(false);
7036                    return Err(common::Error::HttpError(err));
7037                }
7038                Ok(res) => {
7039                    let (mut parts, body) = res.into_parts();
7040                    let mut body = common::Body::new(body);
7041                    if !parts.status.is_success() {
7042                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7043                        let error = serde_json::from_str(&common::to_string(&bytes));
7044                        let response = common::to_response(parts, bytes.into());
7045
7046                        if let common::Retry::After(d) =
7047                            dlg.http_failure(&response, error.as_ref().ok())
7048                        {
7049                            sleep(d).await;
7050                            continue;
7051                        }
7052
7053                        dlg.finished(false);
7054
7055                        return Err(match error {
7056                            Ok(value) => common::Error::BadRequest(value),
7057                            _ => common::Error::Failure(response),
7058                        });
7059                    }
7060                    let response = {
7061                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7062                        let encoded = common::to_string(&bytes);
7063                        match serde_json::from_str(&encoded) {
7064                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7065                            Err(error) => {
7066                                dlg.response_json_decode_error(&encoded, &error);
7067                                return Err(common::Error::JsonDecodeError(
7068                                    encoded.to_string(),
7069                                    error,
7070                                ));
7071                            }
7072                        }
7073                    };
7074
7075                    dlg.finished(true);
7076                    return Ok(response);
7077                }
7078            }
7079        }
7080    }
7081
7082    ///
7083    /// Sets the *request* property to the given value.
7084    ///
7085    /// Even though the property as already been set when instantiating this call,
7086    /// we provide this method for API completeness.
7087    pub fn request(
7088        mut self,
7089        new_value: GoogleCloudRetailV2AddFulfillmentPlacesRequest,
7090    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C> {
7091        self._request = new_value;
7092        self
7093    }
7094    /// Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
7095    ///
7096    /// Sets the *product* path property to the given value.
7097    ///
7098    /// Even though the property as already been set when instantiating this call,
7099    /// we provide this method for API completeness.
7100    pub fn product(
7101        mut self,
7102        new_value: &str,
7103    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C> {
7104        self._product = new_value.to_string();
7105        self
7106    }
7107    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7108    /// while executing the actual API request.
7109    ///
7110    /// ````text
7111    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7112    /// ````
7113    ///
7114    /// Sets the *delegate* property to the given value.
7115    pub fn delegate(
7116        mut self,
7117        new_value: &'a mut dyn common::Delegate,
7118    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C> {
7119        self._delegate = Some(new_value);
7120        self
7121    }
7122
7123    /// Set any additional parameter of the query string used in the request.
7124    /// It should be used to set parameters which are not yet available through their own
7125    /// setters.
7126    ///
7127    /// Please note that this method must not be used to set any of the known parameters
7128    /// which have their own setter method. If done anyway, the request will fail.
7129    ///
7130    /// # Additional Parameters
7131    ///
7132    /// * *$.xgafv* (query-string) - V1 error format.
7133    /// * *access_token* (query-string) - OAuth access token.
7134    /// * *alt* (query-string) - Data format for response.
7135    /// * *callback* (query-string) - JSONP
7136    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7137    /// * *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.
7138    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7139    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7140    /// * *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.
7141    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7142    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7143    pub fn param<T>(
7144        mut self,
7145        name: T,
7146        value: T,
7147    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C>
7148    where
7149        T: AsRef<str>,
7150    {
7151        self._additional_params
7152            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7153        self
7154    }
7155
7156    /// Identifies the authorization scope for the method you are building.
7157    ///
7158    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7159    /// [`Scope::CloudPlatform`].
7160    ///
7161    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7162    /// tokens for more than one scope.
7163    ///
7164    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7165    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7166    /// sufficient, a read-write scope will do as well.
7167    pub fn add_scope<St>(
7168        mut self,
7169        scope: St,
7170    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C>
7171    where
7172        St: AsRef<str>,
7173    {
7174        self._scopes.insert(String::from(scope.as_ref()));
7175        self
7176    }
7177    /// Identifies the authorization scope(s) for the method you are building.
7178    ///
7179    /// See [`Self::add_scope()`] for details.
7180    pub fn add_scopes<I, St>(
7181        mut self,
7182        scopes: I,
7183    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C>
7184    where
7185        I: IntoIterator<Item = St>,
7186        St: AsRef<str>,
7187    {
7188        self._scopes
7189            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7190        self
7191    }
7192
7193    /// Removes all scopes, and no default scope will be used either.
7194    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7195    /// for details).
7196    pub fn clear_scopes(
7197        mut self,
7198    ) -> ProjectLocationCatalogBranchProductAddFulfillmentPlaceCall<'a, C> {
7199        self._scopes.clear();
7200        self
7201    }
7202}
7203
7204/// Updates local inventory information for a Product at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the Product to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. Local inventory information can only be modified using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
7205///
7206/// A builder for the *locations.catalogs.branches.products.addLocalInventories* method supported by a *project* resource.
7207/// It is not used directly, but through a [`ProjectMethods`] instance.
7208///
7209/// # Example
7210///
7211/// Instantiate a resource method builder
7212///
7213/// ```test_harness,no_run
7214/// # extern crate hyper;
7215/// # extern crate hyper_rustls;
7216/// # extern crate google_retail2 as retail2;
7217/// use retail2::api::GoogleCloudRetailV2AddLocalInventoriesRequest;
7218/// # async fn dox() {
7219/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7220///
7221/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7222/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7223/// #     .with_native_roots()
7224/// #     .unwrap()
7225/// #     .https_only()
7226/// #     .enable_http2()
7227/// #     .build();
7228///
7229/// # let executor = hyper_util::rt::TokioExecutor::new();
7230/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7231/// #     secret,
7232/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7233/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7234/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7235/// #     ),
7236/// # ).build().await.unwrap();
7237///
7238/// # let client = hyper_util::client::legacy::Client::builder(
7239/// #     hyper_util::rt::TokioExecutor::new()
7240/// # )
7241/// # .build(
7242/// #     hyper_rustls::HttpsConnectorBuilder::new()
7243/// #         .with_native_roots()
7244/// #         .unwrap()
7245/// #         .https_or_http()
7246/// #         .enable_http2()
7247/// #         .build()
7248/// # );
7249/// # let mut hub = CloudRetail::new(client, auth);
7250/// // As the method needs a request, you would usually fill it with the desired information
7251/// // into the respective structure. Some of the parts shown here might not be applicable !
7252/// // Values shown here are possibly random and not representative !
7253/// let mut req = GoogleCloudRetailV2AddLocalInventoriesRequest::default();
7254///
7255/// // You can configure optional parameters by calling the respective setters at will, and
7256/// // execute the final call using `doit()`.
7257/// // Values shown here are possibly random and not representative !
7258/// let result = hub.projects().locations_catalogs_branches_products_add_local_inventories(req, "product")
7259///              .doit().await;
7260/// # }
7261/// ```
7262pub struct ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C>
7263where
7264    C: 'a,
7265{
7266    hub: &'a CloudRetail<C>,
7267    _request: GoogleCloudRetailV2AddLocalInventoriesRequest,
7268    _product: String,
7269    _delegate: Option<&'a mut dyn common::Delegate>,
7270    _additional_params: HashMap<String, String>,
7271    _scopes: BTreeSet<String>,
7272}
7273
7274impl<'a, C> common::CallBuilder
7275    for ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C>
7276{
7277}
7278
7279impl<'a, C> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C>
7280where
7281    C: common::Connector,
7282{
7283    /// Perform the operation you have build so far.
7284    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7285        use std::borrow::Cow;
7286        use std::io::{Read, Seek};
7287
7288        use common::{url::Params, ToParts};
7289        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7290
7291        let mut dd = common::DefaultDelegate;
7292        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7293        dlg.begin(common::MethodInfo {
7294            id: "retail.projects.locations.catalogs.branches.products.addLocalInventories",
7295            http_method: hyper::Method::POST,
7296        });
7297
7298        for &field in ["alt", "product"].iter() {
7299            if self._additional_params.contains_key(field) {
7300                dlg.finished(false);
7301                return Err(common::Error::FieldClash(field));
7302            }
7303        }
7304
7305        let mut params = Params::with_capacity(4 + self._additional_params.len());
7306        params.push("product", self._product);
7307
7308        params.extend(self._additional_params.iter());
7309
7310        params.push("alt", "json");
7311        let mut url = self.hub._base_url.clone() + "v2/{+product}:addLocalInventories";
7312        if self._scopes.is_empty() {
7313            self._scopes
7314                .insert(Scope::CloudPlatform.as_ref().to_string());
7315        }
7316
7317        #[allow(clippy::single_element_loop)]
7318        for &(find_this, param_name) in [("{+product}", "product")].iter() {
7319            url = params.uri_replacement(url, param_name, find_this, true);
7320        }
7321        {
7322            let to_remove = ["product"];
7323            params.remove_params(&to_remove);
7324        }
7325
7326        let url = params.parse_with_url(&url);
7327
7328        let mut json_mime_type = mime::APPLICATION_JSON;
7329        let mut request_value_reader = {
7330            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7331            common::remove_json_null_values(&mut value);
7332            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7333            serde_json::to_writer(&mut dst, &value).unwrap();
7334            dst
7335        };
7336        let request_size = request_value_reader
7337            .seek(std::io::SeekFrom::End(0))
7338            .unwrap();
7339        request_value_reader
7340            .seek(std::io::SeekFrom::Start(0))
7341            .unwrap();
7342
7343        loop {
7344            let token = match self
7345                .hub
7346                .auth
7347                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7348                .await
7349            {
7350                Ok(token) => token,
7351                Err(e) => match dlg.token(e) {
7352                    Ok(token) => token,
7353                    Err(e) => {
7354                        dlg.finished(false);
7355                        return Err(common::Error::MissingToken(e));
7356                    }
7357                },
7358            };
7359            request_value_reader
7360                .seek(std::io::SeekFrom::Start(0))
7361                .unwrap();
7362            let mut req_result = {
7363                let client = &self.hub.client;
7364                dlg.pre_request();
7365                let mut req_builder = hyper::Request::builder()
7366                    .method(hyper::Method::POST)
7367                    .uri(url.as_str())
7368                    .header(USER_AGENT, self.hub._user_agent.clone());
7369
7370                if let Some(token) = token.as_ref() {
7371                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7372                }
7373
7374                let request = req_builder
7375                    .header(CONTENT_TYPE, json_mime_type.to_string())
7376                    .header(CONTENT_LENGTH, request_size as u64)
7377                    .body(common::to_body(
7378                        request_value_reader.get_ref().clone().into(),
7379                    ));
7380
7381                client.request(request.unwrap()).await
7382            };
7383
7384            match req_result {
7385                Err(err) => {
7386                    if let common::Retry::After(d) = dlg.http_error(&err) {
7387                        sleep(d).await;
7388                        continue;
7389                    }
7390                    dlg.finished(false);
7391                    return Err(common::Error::HttpError(err));
7392                }
7393                Ok(res) => {
7394                    let (mut parts, body) = res.into_parts();
7395                    let mut body = common::Body::new(body);
7396                    if !parts.status.is_success() {
7397                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7398                        let error = serde_json::from_str(&common::to_string(&bytes));
7399                        let response = common::to_response(parts, bytes.into());
7400
7401                        if let common::Retry::After(d) =
7402                            dlg.http_failure(&response, error.as_ref().ok())
7403                        {
7404                            sleep(d).await;
7405                            continue;
7406                        }
7407
7408                        dlg.finished(false);
7409
7410                        return Err(match error {
7411                            Ok(value) => common::Error::BadRequest(value),
7412                            _ => common::Error::Failure(response),
7413                        });
7414                    }
7415                    let response = {
7416                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7417                        let encoded = common::to_string(&bytes);
7418                        match serde_json::from_str(&encoded) {
7419                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7420                            Err(error) => {
7421                                dlg.response_json_decode_error(&encoded, &error);
7422                                return Err(common::Error::JsonDecodeError(
7423                                    encoded.to_string(),
7424                                    error,
7425                                ));
7426                            }
7427                        }
7428                    };
7429
7430                    dlg.finished(true);
7431                    return Ok(response);
7432                }
7433            }
7434        }
7435    }
7436
7437    ///
7438    /// Sets the *request* property to the given value.
7439    ///
7440    /// Even though the property as already been set when instantiating this call,
7441    /// we provide this method for API completeness.
7442    pub fn request(
7443        mut self,
7444        new_value: GoogleCloudRetailV2AddLocalInventoriesRequest,
7445    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C> {
7446        self._request = new_value;
7447        self
7448    }
7449    /// Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
7450    ///
7451    /// Sets the *product* path property to the given value.
7452    ///
7453    /// Even though the property as already been set when instantiating this call,
7454    /// we provide this method for API completeness.
7455    pub fn product(
7456        mut self,
7457        new_value: &str,
7458    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C> {
7459        self._product = new_value.to_string();
7460        self
7461    }
7462    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7463    /// while executing the actual API request.
7464    ///
7465    /// ````text
7466    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7467    /// ````
7468    ///
7469    /// Sets the *delegate* property to the given value.
7470    pub fn delegate(
7471        mut self,
7472        new_value: &'a mut dyn common::Delegate,
7473    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C> {
7474        self._delegate = Some(new_value);
7475        self
7476    }
7477
7478    /// Set any additional parameter of the query string used in the request.
7479    /// It should be used to set parameters which are not yet available through their own
7480    /// setters.
7481    ///
7482    /// Please note that this method must not be used to set any of the known parameters
7483    /// which have their own setter method. If done anyway, the request will fail.
7484    ///
7485    /// # Additional Parameters
7486    ///
7487    /// * *$.xgafv* (query-string) - V1 error format.
7488    /// * *access_token* (query-string) - OAuth access token.
7489    /// * *alt* (query-string) - Data format for response.
7490    /// * *callback* (query-string) - JSONP
7491    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7492    /// * *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.
7493    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7494    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7495    /// * *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.
7496    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7497    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7498    pub fn param<T>(
7499        mut self,
7500        name: T,
7501        value: T,
7502    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C>
7503    where
7504        T: AsRef<str>,
7505    {
7506        self._additional_params
7507            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7508        self
7509    }
7510
7511    /// Identifies the authorization scope for the method you are building.
7512    ///
7513    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7514    /// [`Scope::CloudPlatform`].
7515    ///
7516    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7517    /// tokens for more than one scope.
7518    ///
7519    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7520    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7521    /// sufficient, a read-write scope will do as well.
7522    pub fn add_scope<St>(
7523        mut self,
7524        scope: St,
7525    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C>
7526    where
7527        St: AsRef<str>,
7528    {
7529        self._scopes.insert(String::from(scope.as_ref()));
7530        self
7531    }
7532    /// Identifies the authorization scope(s) for the method you are building.
7533    ///
7534    /// See [`Self::add_scope()`] for details.
7535    pub fn add_scopes<I, St>(
7536        mut self,
7537        scopes: I,
7538    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C>
7539    where
7540        I: IntoIterator<Item = St>,
7541        St: AsRef<str>,
7542    {
7543        self._scopes
7544            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7545        self
7546    }
7547
7548    /// Removes all scopes, and no default scope will be used either.
7549    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7550    /// for details).
7551    pub fn clear_scopes(
7552        mut self,
7553    ) -> ProjectLocationCatalogBranchProductAddLocalInventoryCall<'a, C> {
7554        self._scopes.clear();
7555        self
7556    }
7557}
7558
7559/// Creates a Product.
7560///
7561/// A builder for the *locations.catalogs.branches.products.create* method supported by a *project* resource.
7562/// It is not used directly, but through a [`ProjectMethods`] instance.
7563///
7564/// # Example
7565///
7566/// Instantiate a resource method builder
7567///
7568/// ```test_harness,no_run
7569/// # extern crate hyper;
7570/// # extern crate hyper_rustls;
7571/// # extern crate google_retail2 as retail2;
7572/// use retail2::api::GoogleCloudRetailV2Product;
7573/// # async fn dox() {
7574/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7575///
7576/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7577/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7578/// #     .with_native_roots()
7579/// #     .unwrap()
7580/// #     .https_only()
7581/// #     .enable_http2()
7582/// #     .build();
7583///
7584/// # let executor = hyper_util::rt::TokioExecutor::new();
7585/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7586/// #     secret,
7587/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7588/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7589/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7590/// #     ),
7591/// # ).build().await.unwrap();
7592///
7593/// # let client = hyper_util::client::legacy::Client::builder(
7594/// #     hyper_util::rt::TokioExecutor::new()
7595/// # )
7596/// # .build(
7597/// #     hyper_rustls::HttpsConnectorBuilder::new()
7598/// #         .with_native_roots()
7599/// #         .unwrap()
7600/// #         .https_or_http()
7601/// #         .enable_http2()
7602/// #         .build()
7603/// # );
7604/// # let mut hub = CloudRetail::new(client, auth);
7605/// // As the method needs a request, you would usually fill it with the desired information
7606/// // into the respective structure. Some of the parts shown here might not be applicable !
7607/// // Values shown here are possibly random and not representative !
7608/// let mut req = GoogleCloudRetailV2Product::default();
7609///
7610/// // You can configure optional parameters by calling the respective setters at will, and
7611/// // execute the final call using `doit()`.
7612/// // Values shown here are possibly random and not representative !
7613/// let result = hub.projects().locations_catalogs_branches_products_create(req, "parent")
7614///              .product_id("dolor")
7615///              .doit().await;
7616/// # }
7617/// ```
7618pub struct ProjectLocationCatalogBranchProductCreateCall<'a, C>
7619where
7620    C: 'a,
7621{
7622    hub: &'a CloudRetail<C>,
7623    _request: GoogleCloudRetailV2Product,
7624    _parent: String,
7625    _product_id: Option<String>,
7626    _delegate: Option<&'a mut dyn common::Delegate>,
7627    _additional_params: HashMap<String, String>,
7628    _scopes: BTreeSet<String>,
7629}
7630
7631impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductCreateCall<'a, C> {}
7632
7633impl<'a, C> ProjectLocationCatalogBranchProductCreateCall<'a, C>
7634where
7635    C: common::Connector,
7636{
7637    /// Perform the operation you have build so far.
7638    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Product)> {
7639        use std::borrow::Cow;
7640        use std::io::{Read, Seek};
7641
7642        use common::{url::Params, ToParts};
7643        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7644
7645        let mut dd = common::DefaultDelegate;
7646        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7647        dlg.begin(common::MethodInfo {
7648            id: "retail.projects.locations.catalogs.branches.products.create",
7649            http_method: hyper::Method::POST,
7650        });
7651
7652        for &field in ["alt", "parent", "productId"].iter() {
7653            if self._additional_params.contains_key(field) {
7654                dlg.finished(false);
7655                return Err(common::Error::FieldClash(field));
7656            }
7657        }
7658
7659        let mut params = Params::with_capacity(5 + self._additional_params.len());
7660        params.push("parent", self._parent);
7661        if let Some(value) = self._product_id.as_ref() {
7662            params.push("productId", value);
7663        }
7664
7665        params.extend(self._additional_params.iter());
7666
7667        params.push("alt", "json");
7668        let mut url = self.hub._base_url.clone() + "v2/{+parent}/products";
7669        if self._scopes.is_empty() {
7670            self._scopes
7671                .insert(Scope::CloudPlatform.as_ref().to_string());
7672        }
7673
7674        #[allow(clippy::single_element_loop)]
7675        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7676            url = params.uri_replacement(url, param_name, find_this, true);
7677        }
7678        {
7679            let to_remove = ["parent"];
7680            params.remove_params(&to_remove);
7681        }
7682
7683        let url = params.parse_with_url(&url);
7684
7685        let mut json_mime_type = mime::APPLICATION_JSON;
7686        let mut request_value_reader = {
7687            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7688            common::remove_json_null_values(&mut value);
7689            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7690            serde_json::to_writer(&mut dst, &value).unwrap();
7691            dst
7692        };
7693        let request_size = request_value_reader
7694            .seek(std::io::SeekFrom::End(0))
7695            .unwrap();
7696        request_value_reader
7697            .seek(std::io::SeekFrom::Start(0))
7698            .unwrap();
7699
7700        loop {
7701            let token = match self
7702                .hub
7703                .auth
7704                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7705                .await
7706            {
7707                Ok(token) => token,
7708                Err(e) => match dlg.token(e) {
7709                    Ok(token) => token,
7710                    Err(e) => {
7711                        dlg.finished(false);
7712                        return Err(common::Error::MissingToken(e));
7713                    }
7714                },
7715            };
7716            request_value_reader
7717                .seek(std::io::SeekFrom::Start(0))
7718                .unwrap();
7719            let mut req_result = {
7720                let client = &self.hub.client;
7721                dlg.pre_request();
7722                let mut req_builder = hyper::Request::builder()
7723                    .method(hyper::Method::POST)
7724                    .uri(url.as_str())
7725                    .header(USER_AGENT, self.hub._user_agent.clone());
7726
7727                if let Some(token) = token.as_ref() {
7728                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7729                }
7730
7731                let request = req_builder
7732                    .header(CONTENT_TYPE, json_mime_type.to_string())
7733                    .header(CONTENT_LENGTH, request_size as u64)
7734                    .body(common::to_body(
7735                        request_value_reader.get_ref().clone().into(),
7736                    ));
7737
7738                client.request(request.unwrap()).await
7739            };
7740
7741            match req_result {
7742                Err(err) => {
7743                    if let common::Retry::After(d) = dlg.http_error(&err) {
7744                        sleep(d).await;
7745                        continue;
7746                    }
7747                    dlg.finished(false);
7748                    return Err(common::Error::HttpError(err));
7749                }
7750                Ok(res) => {
7751                    let (mut parts, body) = res.into_parts();
7752                    let mut body = common::Body::new(body);
7753                    if !parts.status.is_success() {
7754                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7755                        let error = serde_json::from_str(&common::to_string(&bytes));
7756                        let response = common::to_response(parts, bytes.into());
7757
7758                        if let common::Retry::After(d) =
7759                            dlg.http_failure(&response, error.as_ref().ok())
7760                        {
7761                            sleep(d).await;
7762                            continue;
7763                        }
7764
7765                        dlg.finished(false);
7766
7767                        return Err(match error {
7768                            Ok(value) => common::Error::BadRequest(value),
7769                            _ => common::Error::Failure(response),
7770                        });
7771                    }
7772                    let response = {
7773                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7774                        let encoded = common::to_string(&bytes);
7775                        match serde_json::from_str(&encoded) {
7776                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7777                            Err(error) => {
7778                                dlg.response_json_decode_error(&encoded, &error);
7779                                return Err(common::Error::JsonDecodeError(
7780                                    encoded.to_string(),
7781                                    error,
7782                                ));
7783                            }
7784                        }
7785                    };
7786
7787                    dlg.finished(true);
7788                    return Ok(response);
7789                }
7790            }
7791        }
7792    }
7793
7794    ///
7795    /// Sets the *request* property to the given value.
7796    ///
7797    /// Even though the property as already been set when instantiating this call,
7798    /// we provide this method for API completeness.
7799    pub fn request(
7800        mut self,
7801        new_value: GoogleCloudRetailV2Product,
7802    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C> {
7803        self._request = new_value;
7804        self
7805    }
7806    /// Required. The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`.
7807    ///
7808    /// Sets the *parent* path property to the given value.
7809    ///
7810    /// Even though the property as already been set when instantiating this call,
7811    /// we provide this method for API completeness.
7812    pub fn parent(
7813        mut self,
7814        new_value: &str,
7815    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C> {
7816        self._parent = new_value.to_string();
7817        self
7818    }
7819    /// Required. The ID to use for the Product, which will become the final component of the Product.name. If the caller does not have permission to create the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. This field must be unique among all Products with the same parent. Otherwise, an ALREADY_EXISTS error is returned. This field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
7820    ///
7821    /// Sets the *product id* query property to the given value.
7822    pub fn product_id(
7823        mut self,
7824        new_value: &str,
7825    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C> {
7826        self._product_id = Some(new_value.to_string());
7827        self
7828    }
7829    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7830    /// while executing the actual API request.
7831    ///
7832    /// ````text
7833    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7834    /// ````
7835    ///
7836    /// Sets the *delegate* property to the given value.
7837    pub fn delegate(
7838        mut self,
7839        new_value: &'a mut dyn common::Delegate,
7840    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C> {
7841        self._delegate = Some(new_value);
7842        self
7843    }
7844
7845    /// Set any additional parameter of the query string used in the request.
7846    /// It should be used to set parameters which are not yet available through their own
7847    /// setters.
7848    ///
7849    /// Please note that this method must not be used to set any of the known parameters
7850    /// which have their own setter method. If done anyway, the request will fail.
7851    ///
7852    /// # Additional Parameters
7853    ///
7854    /// * *$.xgafv* (query-string) - V1 error format.
7855    /// * *access_token* (query-string) - OAuth access token.
7856    /// * *alt* (query-string) - Data format for response.
7857    /// * *callback* (query-string) - JSONP
7858    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7859    /// * *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.
7860    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7861    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7862    /// * *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.
7863    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7864    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7865    pub fn param<T>(
7866        mut self,
7867        name: T,
7868        value: T,
7869    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C>
7870    where
7871        T: AsRef<str>,
7872    {
7873        self._additional_params
7874            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7875        self
7876    }
7877
7878    /// Identifies the authorization scope for the method you are building.
7879    ///
7880    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7881    /// [`Scope::CloudPlatform`].
7882    ///
7883    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7884    /// tokens for more than one scope.
7885    ///
7886    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7887    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7888    /// sufficient, a read-write scope will do as well.
7889    pub fn add_scope<St>(
7890        mut self,
7891        scope: St,
7892    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C>
7893    where
7894        St: AsRef<str>,
7895    {
7896        self._scopes.insert(String::from(scope.as_ref()));
7897        self
7898    }
7899    /// Identifies the authorization scope(s) for the method you are building.
7900    ///
7901    /// See [`Self::add_scope()`] for details.
7902    pub fn add_scopes<I, St>(
7903        mut self,
7904        scopes: I,
7905    ) -> ProjectLocationCatalogBranchProductCreateCall<'a, C>
7906    where
7907        I: IntoIterator<Item = St>,
7908        St: AsRef<str>,
7909    {
7910        self._scopes
7911            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7912        self
7913    }
7914
7915    /// Removes all scopes, and no default scope will be used either.
7916    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7917    /// for details).
7918    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductCreateCall<'a, C> {
7919        self._scopes.clear();
7920        self
7921    }
7922}
7923
7924/// Deletes a Product.
7925///
7926/// A builder for the *locations.catalogs.branches.products.delete* method supported by a *project* resource.
7927/// It is not used directly, but through a [`ProjectMethods`] instance.
7928///
7929/// # Example
7930///
7931/// Instantiate a resource method builder
7932///
7933/// ```test_harness,no_run
7934/// # extern crate hyper;
7935/// # extern crate hyper_rustls;
7936/// # extern crate google_retail2 as retail2;
7937/// # async fn dox() {
7938/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7939///
7940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7941/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7942/// #     .with_native_roots()
7943/// #     .unwrap()
7944/// #     .https_only()
7945/// #     .enable_http2()
7946/// #     .build();
7947///
7948/// # let executor = hyper_util::rt::TokioExecutor::new();
7949/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7950/// #     secret,
7951/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7952/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7953/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7954/// #     ),
7955/// # ).build().await.unwrap();
7956///
7957/// # let client = hyper_util::client::legacy::Client::builder(
7958/// #     hyper_util::rt::TokioExecutor::new()
7959/// # )
7960/// # .build(
7961/// #     hyper_rustls::HttpsConnectorBuilder::new()
7962/// #         .with_native_roots()
7963/// #         .unwrap()
7964/// #         .https_or_http()
7965/// #         .enable_http2()
7966/// #         .build()
7967/// # );
7968/// # let mut hub = CloudRetail::new(client, auth);
7969/// // You can configure optional parameters by calling the respective setters at will, and
7970/// // execute the final call using `doit()`.
7971/// // Values shown here are possibly random and not representative !
7972/// let result = hub.projects().locations_catalogs_branches_products_delete("name")
7973///              .doit().await;
7974/// # }
7975/// ```
7976pub struct ProjectLocationCatalogBranchProductDeleteCall<'a, C>
7977where
7978    C: 'a,
7979{
7980    hub: &'a CloudRetail<C>,
7981    _name: String,
7982    _delegate: Option<&'a mut dyn common::Delegate>,
7983    _additional_params: HashMap<String, String>,
7984    _scopes: BTreeSet<String>,
7985}
7986
7987impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductDeleteCall<'a, C> {}
7988
7989impl<'a, C> ProjectLocationCatalogBranchProductDeleteCall<'a, C>
7990where
7991    C: common::Connector,
7992{
7993    /// Perform the operation you have build so far.
7994    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
7995        use std::borrow::Cow;
7996        use std::io::{Read, Seek};
7997
7998        use common::{url::Params, ToParts};
7999        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8000
8001        let mut dd = common::DefaultDelegate;
8002        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8003        dlg.begin(common::MethodInfo {
8004            id: "retail.projects.locations.catalogs.branches.products.delete",
8005            http_method: hyper::Method::DELETE,
8006        });
8007
8008        for &field in ["alt", "name"].iter() {
8009            if self._additional_params.contains_key(field) {
8010                dlg.finished(false);
8011                return Err(common::Error::FieldClash(field));
8012            }
8013        }
8014
8015        let mut params = Params::with_capacity(3 + self._additional_params.len());
8016        params.push("name", self._name);
8017
8018        params.extend(self._additional_params.iter());
8019
8020        params.push("alt", "json");
8021        let mut url = self.hub._base_url.clone() + "v2/{+name}";
8022        if self._scopes.is_empty() {
8023            self._scopes
8024                .insert(Scope::CloudPlatform.as_ref().to_string());
8025        }
8026
8027        #[allow(clippy::single_element_loop)]
8028        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8029            url = params.uri_replacement(url, param_name, find_this, true);
8030        }
8031        {
8032            let to_remove = ["name"];
8033            params.remove_params(&to_remove);
8034        }
8035
8036        let url = params.parse_with_url(&url);
8037
8038        loop {
8039            let token = match self
8040                .hub
8041                .auth
8042                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8043                .await
8044            {
8045                Ok(token) => token,
8046                Err(e) => match dlg.token(e) {
8047                    Ok(token) => token,
8048                    Err(e) => {
8049                        dlg.finished(false);
8050                        return Err(common::Error::MissingToken(e));
8051                    }
8052                },
8053            };
8054            let mut req_result = {
8055                let client = &self.hub.client;
8056                dlg.pre_request();
8057                let mut req_builder = hyper::Request::builder()
8058                    .method(hyper::Method::DELETE)
8059                    .uri(url.as_str())
8060                    .header(USER_AGENT, self.hub._user_agent.clone());
8061
8062                if let Some(token) = token.as_ref() {
8063                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8064                }
8065
8066                let request = req_builder
8067                    .header(CONTENT_LENGTH, 0_u64)
8068                    .body(common::to_body::<String>(None));
8069
8070                client.request(request.unwrap()).await
8071            };
8072
8073            match req_result {
8074                Err(err) => {
8075                    if let common::Retry::After(d) = dlg.http_error(&err) {
8076                        sleep(d).await;
8077                        continue;
8078                    }
8079                    dlg.finished(false);
8080                    return Err(common::Error::HttpError(err));
8081                }
8082                Ok(res) => {
8083                    let (mut parts, body) = res.into_parts();
8084                    let mut body = common::Body::new(body);
8085                    if !parts.status.is_success() {
8086                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8087                        let error = serde_json::from_str(&common::to_string(&bytes));
8088                        let response = common::to_response(parts, bytes.into());
8089
8090                        if let common::Retry::After(d) =
8091                            dlg.http_failure(&response, error.as_ref().ok())
8092                        {
8093                            sleep(d).await;
8094                            continue;
8095                        }
8096
8097                        dlg.finished(false);
8098
8099                        return Err(match error {
8100                            Ok(value) => common::Error::BadRequest(value),
8101                            _ => common::Error::Failure(response),
8102                        });
8103                    }
8104                    let response = {
8105                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8106                        let encoded = common::to_string(&bytes);
8107                        match serde_json::from_str(&encoded) {
8108                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8109                            Err(error) => {
8110                                dlg.response_json_decode_error(&encoded, &error);
8111                                return Err(common::Error::JsonDecodeError(
8112                                    encoded.to_string(),
8113                                    error,
8114                                ));
8115                            }
8116                        }
8117                    };
8118
8119                    dlg.finished(true);
8120                    return Ok(response);
8121                }
8122            }
8123        }
8124    }
8125
8126    /// Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to delete the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. If the Product to delete does not exist, a NOT_FOUND error is returned. The Product to delete can neither be a Product.Type.COLLECTION Product member nor a Product.Type.PRIMARY Product with more than one variants. Otherwise, an INVALID_ARGUMENT error is returned. All inventory information for the named Product will be deleted.
8127    ///
8128    /// Sets the *name* path property to the given value.
8129    ///
8130    /// Even though the property as already been set when instantiating this call,
8131    /// we provide this method for API completeness.
8132    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogBranchProductDeleteCall<'a, C> {
8133        self._name = new_value.to_string();
8134        self
8135    }
8136    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8137    /// while executing the actual API request.
8138    ///
8139    /// ````text
8140    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8141    /// ````
8142    ///
8143    /// Sets the *delegate* property to the given value.
8144    pub fn delegate(
8145        mut self,
8146        new_value: &'a mut dyn common::Delegate,
8147    ) -> ProjectLocationCatalogBranchProductDeleteCall<'a, C> {
8148        self._delegate = Some(new_value);
8149        self
8150    }
8151
8152    /// Set any additional parameter of the query string used in the request.
8153    /// It should be used to set parameters which are not yet available through their own
8154    /// setters.
8155    ///
8156    /// Please note that this method must not be used to set any of the known parameters
8157    /// which have their own setter method. If done anyway, the request will fail.
8158    ///
8159    /// # Additional Parameters
8160    ///
8161    /// * *$.xgafv* (query-string) - V1 error format.
8162    /// * *access_token* (query-string) - OAuth access token.
8163    /// * *alt* (query-string) - Data format for response.
8164    /// * *callback* (query-string) - JSONP
8165    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8166    /// * *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.
8167    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8168    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8169    /// * *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.
8170    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8171    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8172    pub fn param<T>(
8173        mut self,
8174        name: T,
8175        value: T,
8176    ) -> ProjectLocationCatalogBranchProductDeleteCall<'a, C>
8177    where
8178        T: AsRef<str>,
8179    {
8180        self._additional_params
8181            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8182        self
8183    }
8184
8185    /// Identifies the authorization scope for the method you are building.
8186    ///
8187    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8188    /// [`Scope::CloudPlatform`].
8189    ///
8190    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8191    /// tokens for more than one scope.
8192    ///
8193    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8194    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8195    /// sufficient, a read-write scope will do as well.
8196    pub fn add_scope<St>(
8197        mut self,
8198        scope: St,
8199    ) -> ProjectLocationCatalogBranchProductDeleteCall<'a, C>
8200    where
8201        St: AsRef<str>,
8202    {
8203        self._scopes.insert(String::from(scope.as_ref()));
8204        self
8205    }
8206    /// Identifies the authorization scope(s) for the method you are building.
8207    ///
8208    /// See [`Self::add_scope()`] for details.
8209    pub fn add_scopes<I, St>(
8210        mut self,
8211        scopes: I,
8212    ) -> ProjectLocationCatalogBranchProductDeleteCall<'a, C>
8213    where
8214        I: IntoIterator<Item = St>,
8215        St: AsRef<str>,
8216    {
8217        self._scopes
8218            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8219        self
8220    }
8221
8222    /// Removes all scopes, and no default scope will be used either.
8223    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8224    /// for details).
8225    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductDeleteCall<'a, C> {
8226        self._scopes.clear();
8227        self
8228    }
8229}
8230
8231/// Gets a Product.
8232///
8233/// A builder for the *locations.catalogs.branches.products.get* method supported by a *project* resource.
8234/// It is not used directly, but through a [`ProjectMethods`] instance.
8235///
8236/// # Example
8237///
8238/// Instantiate a resource method builder
8239///
8240/// ```test_harness,no_run
8241/// # extern crate hyper;
8242/// # extern crate hyper_rustls;
8243/// # extern crate google_retail2 as retail2;
8244/// # async fn dox() {
8245/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8246///
8247/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8248/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8249/// #     .with_native_roots()
8250/// #     .unwrap()
8251/// #     .https_only()
8252/// #     .enable_http2()
8253/// #     .build();
8254///
8255/// # let executor = hyper_util::rt::TokioExecutor::new();
8256/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8257/// #     secret,
8258/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8259/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8260/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8261/// #     ),
8262/// # ).build().await.unwrap();
8263///
8264/// # let client = hyper_util::client::legacy::Client::builder(
8265/// #     hyper_util::rt::TokioExecutor::new()
8266/// # )
8267/// # .build(
8268/// #     hyper_rustls::HttpsConnectorBuilder::new()
8269/// #         .with_native_roots()
8270/// #         .unwrap()
8271/// #         .https_or_http()
8272/// #         .enable_http2()
8273/// #         .build()
8274/// # );
8275/// # let mut hub = CloudRetail::new(client, auth);
8276/// // You can configure optional parameters by calling the respective setters at will, and
8277/// // execute the final call using `doit()`.
8278/// // Values shown here are possibly random and not representative !
8279/// let result = hub.projects().locations_catalogs_branches_products_get("name")
8280///              .doit().await;
8281/// # }
8282/// ```
8283pub struct ProjectLocationCatalogBranchProductGetCall<'a, C>
8284where
8285    C: 'a,
8286{
8287    hub: &'a CloudRetail<C>,
8288    _name: String,
8289    _delegate: Option<&'a mut dyn common::Delegate>,
8290    _additional_params: HashMap<String, String>,
8291    _scopes: BTreeSet<String>,
8292}
8293
8294impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductGetCall<'a, C> {}
8295
8296impl<'a, C> ProjectLocationCatalogBranchProductGetCall<'a, C>
8297where
8298    C: common::Connector,
8299{
8300    /// Perform the operation you have build so far.
8301    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Product)> {
8302        use std::borrow::Cow;
8303        use std::io::{Read, Seek};
8304
8305        use common::{url::Params, ToParts};
8306        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8307
8308        let mut dd = common::DefaultDelegate;
8309        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8310        dlg.begin(common::MethodInfo {
8311            id: "retail.projects.locations.catalogs.branches.products.get",
8312            http_method: hyper::Method::GET,
8313        });
8314
8315        for &field in ["alt", "name"].iter() {
8316            if self._additional_params.contains_key(field) {
8317                dlg.finished(false);
8318                return Err(common::Error::FieldClash(field));
8319            }
8320        }
8321
8322        let mut params = Params::with_capacity(3 + self._additional_params.len());
8323        params.push("name", self._name);
8324
8325        params.extend(self._additional_params.iter());
8326
8327        params.push("alt", "json");
8328        let mut url = self.hub._base_url.clone() + "v2/{+name}";
8329        if self._scopes.is_empty() {
8330            self._scopes
8331                .insert(Scope::CloudPlatform.as_ref().to_string());
8332        }
8333
8334        #[allow(clippy::single_element_loop)]
8335        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8336            url = params.uri_replacement(url, param_name, find_this, true);
8337        }
8338        {
8339            let to_remove = ["name"];
8340            params.remove_params(&to_remove);
8341        }
8342
8343        let url = params.parse_with_url(&url);
8344
8345        loop {
8346            let token = match self
8347                .hub
8348                .auth
8349                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8350                .await
8351            {
8352                Ok(token) => token,
8353                Err(e) => match dlg.token(e) {
8354                    Ok(token) => token,
8355                    Err(e) => {
8356                        dlg.finished(false);
8357                        return Err(common::Error::MissingToken(e));
8358                    }
8359                },
8360            };
8361            let mut req_result = {
8362                let client = &self.hub.client;
8363                dlg.pre_request();
8364                let mut req_builder = hyper::Request::builder()
8365                    .method(hyper::Method::GET)
8366                    .uri(url.as_str())
8367                    .header(USER_AGENT, self.hub._user_agent.clone());
8368
8369                if let Some(token) = token.as_ref() {
8370                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8371                }
8372
8373                let request = req_builder
8374                    .header(CONTENT_LENGTH, 0_u64)
8375                    .body(common::to_body::<String>(None));
8376
8377                client.request(request.unwrap()).await
8378            };
8379
8380            match req_result {
8381                Err(err) => {
8382                    if let common::Retry::After(d) = dlg.http_error(&err) {
8383                        sleep(d).await;
8384                        continue;
8385                    }
8386                    dlg.finished(false);
8387                    return Err(common::Error::HttpError(err));
8388                }
8389                Ok(res) => {
8390                    let (mut parts, body) = res.into_parts();
8391                    let mut body = common::Body::new(body);
8392                    if !parts.status.is_success() {
8393                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8394                        let error = serde_json::from_str(&common::to_string(&bytes));
8395                        let response = common::to_response(parts, bytes.into());
8396
8397                        if let common::Retry::After(d) =
8398                            dlg.http_failure(&response, error.as_ref().ok())
8399                        {
8400                            sleep(d).await;
8401                            continue;
8402                        }
8403
8404                        dlg.finished(false);
8405
8406                        return Err(match error {
8407                            Ok(value) => common::Error::BadRequest(value),
8408                            _ => common::Error::Failure(response),
8409                        });
8410                    }
8411                    let response = {
8412                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8413                        let encoded = common::to_string(&bytes);
8414                        match serde_json::from_str(&encoded) {
8415                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8416                            Err(error) => {
8417                                dlg.response_json_decode_error(&encoded, &error);
8418                                return Err(common::Error::JsonDecodeError(
8419                                    encoded.to_string(),
8420                                    error,
8421                                ));
8422                            }
8423                        }
8424                    };
8425
8426                    dlg.finished(true);
8427                    return Ok(response);
8428                }
8429            }
8430        }
8431    }
8432
8433    /// Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned. If the requested Product does not exist, a NOT_FOUND error is returned.
8434    ///
8435    /// Sets the *name* path property to the given value.
8436    ///
8437    /// Even though the property as already been set when instantiating this call,
8438    /// we provide this method for API completeness.
8439    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogBranchProductGetCall<'a, C> {
8440        self._name = new_value.to_string();
8441        self
8442    }
8443    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8444    /// while executing the actual API request.
8445    ///
8446    /// ````text
8447    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8448    /// ````
8449    ///
8450    /// Sets the *delegate* property to the given value.
8451    pub fn delegate(
8452        mut self,
8453        new_value: &'a mut dyn common::Delegate,
8454    ) -> ProjectLocationCatalogBranchProductGetCall<'a, C> {
8455        self._delegate = Some(new_value);
8456        self
8457    }
8458
8459    /// Set any additional parameter of the query string used in the request.
8460    /// It should be used to set parameters which are not yet available through their own
8461    /// setters.
8462    ///
8463    /// Please note that this method must not be used to set any of the known parameters
8464    /// which have their own setter method. If done anyway, the request will fail.
8465    ///
8466    /// # Additional Parameters
8467    ///
8468    /// * *$.xgafv* (query-string) - V1 error format.
8469    /// * *access_token* (query-string) - OAuth access token.
8470    /// * *alt* (query-string) - Data format for response.
8471    /// * *callback* (query-string) - JSONP
8472    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8473    /// * *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.
8474    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8475    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8476    /// * *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.
8477    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8478    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8479    pub fn param<T>(
8480        mut self,
8481        name: T,
8482        value: T,
8483    ) -> ProjectLocationCatalogBranchProductGetCall<'a, C>
8484    where
8485        T: AsRef<str>,
8486    {
8487        self._additional_params
8488            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8489        self
8490    }
8491
8492    /// Identifies the authorization scope for the method you are building.
8493    ///
8494    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8495    /// [`Scope::CloudPlatform`].
8496    ///
8497    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8498    /// tokens for more than one scope.
8499    ///
8500    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8501    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8502    /// sufficient, a read-write scope will do as well.
8503    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogBranchProductGetCall<'a, C>
8504    where
8505        St: AsRef<str>,
8506    {
8507        self._scopes.insert(String::from(scope.as_ref()));
8508        self
8509    }
8510    /// Identifies the authorization scope(s) for the method you are building.
8511    ///
8512    /// See [`Self::add_scope()`] for details.
8513    pub fn add_scopes<I, St>(
8514        mut self,
8515        scopes: I,
8516    ) -> ProjectLocationCatalogBranchProductGetCall<'a, C>
8517    where
8518        I: IntoIterator<Item = St>,
8519        St: AsRef<str>,
8520    {
8521        self._scopes
8522            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8523        self
8524    }
8525
8526    /// Removes all scopes, and no default scope will be used either.
8527    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8528    /// for details).
8529    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductGetCall<'a, C> {
8530        self._scopes.clear();
8531        self
8532    }
8533}
8534
8535/// Bulk import of multiple Products. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the Products to be successfully updated.
8536///
8537/// A builder for the *locations.catalogs.branches.products.import* method supported by a *project* resource.
8538/// It is not used directly, but through a [`ProjectMethods`] instance.
8539///
8540/// # Example
8541///
8542/// Instantiate a resource method builder
8543///
8544/// ```test_harness,no_run
8545/// # extern crate hyper;
8546/// # extern crate hyper_rustls;
8547/// # extern crate google_retail2 as retail2;
8548/// use retail2::api::GoogleCloudRetailV2ImportProductsRequest;
8549/// # async fn dox() {
8550/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8551///
8552/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8553/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8554/// #     .with_native_roots()
8555/// #     .unwrap()
8556/// #     .https_only()
8557/// #     .enable_http2()
8558/// #     .build();
8559///
8560/// # let executor = hyper_util::rt::TokioExecutor::new();
8561/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8562/// #     secret,
8563/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8564/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8565/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8566/// #     ),
8567/// # ).build().await.unwrap();
8568///
8569/// # let client = hyper_util::client::legacy::Client::builder(
8570/// #     hyper_util::rt::TokioExecutor::new()
8571/// # )
8572/// # .build(
8573/// #     hyper_rustls::HttpsConnectorBuilder::new()
8574/// #         .with_native_roots()
8575/// #         .unwrap()
8576/// #         .https_or_http()
8577/// #         .enable_http2()
8578/// #         .build()
8579/// # );
8580/// # let mut hub = CloudRetail::new(client, auth);
8581/// // As the method needs a request, you would usually fill it with the desired information
8582/// // into the respective structure. Some of the parts shown here might not be applicable !
8583/// // Values shown here are possibly random and not representative !
8584/// let mut req = GoogleCloudRetailV2ImportProductsRequest::default();
8585///
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_branches_products_import(req, "parent")
8590///              .doit().await;
8591/// # }
8592/// ```
8593pub struct ProjectLocationCatalogBranchProductImportCall<'a, C>
8594where
8595    C: 'a,
8596{
8597    hub: &'a CloudRetail<C>,
8598    _request: GoogleCloudRetailV2ImportProductsRequest,
8599    _parent: String,
8600    _delegate: Option<&'a mut dyn common::Delegate>,
8601    _additional_params: HashMap<String, String>,
8602    _scopes: BTreeSet<String>,
8603}
8604
8605impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductImportCall<'a, C> {}
8606
8607impl<'a, C> ProjectLocationCatalogBranchProductImportCall<'a, C>
8608where
8609    C: common::Connector,
8610{
8611    /// Perform the operation you have build so far.
8612    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
8613        use std::borrow::Cow;
8614        use std::io::{Read, Seek};
8615
8616        use common::{url::Params, ToParts};
8617        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8618
8619        let mut dd = common::DefaultDelegate;
8620        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8621        dlg.begin(common::MethodInfo {
8622            id: "retail.projects.locations.catalogs.branches.products.import",
8623            http_method: hyper::Method::POST,
8624        });
8625
8626        for &field in ["alt", "parent"].iter() {
8627            if self._additional_params.contains_key(field) {
8628                dlg.finished(false);
8629                return Err(common::Error::FieldClash(field));
8630            }
8631        }
8632
8633        let mut params = Params::with_capacity(4 + self._additional_params.len());
8634        params.push("parent", self._parent);
8635
8636        params.extend(self._additional_params.iter());
8637
8638        params.push("alt", "json");
8639        let mut url = self.hub._base_url.clone() + "v2/{+parent}/products:import";
8640        if self._scopes.is_empty() {
8641            self._scopes
8642                .insert(Scope::CloudPlatform.as_ref().to_string());
8643        }
8644
8645        #[allow(clippy::single_element_loop)]
8646        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8647            url = params.uri_replacement(url, param_name, find_this, true);
8648        }
8649        {
8650            let to_remove = ["parent"];
8651            params.remove_params(&to_remove);
8652        }
8653
8654        let url = params.parse_with_url(&url);
8655
8656        let mut json_mime_type = mime::APPLICATION_JSON;
8657        let mut request_value_reader = {
8658            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8659            common::remove_json_null_values(&mut value);
8660            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8661            serde_json::to_writer(&mut dst, &value).unwrap();
8662            dst
8663        };
8664        let request_size = request_value_reader
8665            .seek(std::io::SeekFrom::End(0))
8666            .unwrap();
8667        request_value_reader
8668            .seek(std::io::SeekFrom::Start(0))
8669            .unwrap();
8670
8671        loop {
8672            let token = match self
8673                .hub
8674                .auth
8675                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8676                .await
8677            {
8678                Ok(token) => token,
8679                Err(e) => match dlg.token(e) {
8680                    Ok(token) => token,
8681                    Err(e) => {
8682                        dlg.finished(false);
8683                        return Err(common::Error::MissingToken(e));
8684                    }
8685                },
8686            };
8687            request_value_reader
8688                .seek(std::io::SeekFrom::Start(0))
8689                .unwrap();
8690            let mut req_result = {
8691                let client = &self.hub.client;
8692                dlg.pre_request();
8693                let mut req_builder = hyper::Request::builder()
8694                    .method(hyper::Method::POST)
8695                    .uri(url.as_str())
8696                    .header(USER_AGENT, self.hub._user_agent.clone());
8697
8698                if let Some(token) = token.as_ref() {
8699                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8700                }
8701
8702                let request = req_builder
8703                    .header(CONTENT_TYPE, json_mime_type.to_string())
8704                    .header(CONTENT_LENGTH, request_size as u64)
8705                    .body(common::to_body(
8706                        request_value_reader.get_ref().clone().into(),
8707                    ));
8708
8709                client.request(request.unwrap()).await
8710            };
8711
8712            match req_result {
8713                Err(err) => {
8714                    if let common::Retry::After(d) = dlg.http_error(&err) {
8715                        sleep(d).await;
8716                        continue;
8717                    }
8718                    dlg.finished(false);
8719                    return Err(common::Error::HttpError(err));
8720                }
8721                Ok(res) => {
8722                    let (mut parts, body) = res.into_parts();
8723                    let mut body = common::Body::new(body);
8724                    if !parts.status.is_success() {
8725                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8726                        let error = serde_json::from_str(&common::to_string(&bytes));
8727                        let response = common::to_response(parts, bytes.into());
8728
8729                        if let common::Retry::After(d) =
8730                            dlg.http_failure(&response, error.as_ref().ok())
8731                        {
8732                            sleep(d).await;
8733                            continue;
8734                        }
8735
8736                        dlg.finished(false);
8737
8738                        return Err(match error {
8739                            Ok(value) => common::Error::BadRequest(value),
8740                            _ => common::Error::Failure(response),
8741                        });
8742                    }
8743                    let response = {
8744                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8745                        let encoded = common::to_string(&bytes);
8746                        match serde_json::from_str(&encoded) {
8747                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8748                            Err(error) => {
8749                                dlg.response_json_decode_error(&encoded, &error);
8750                                return Err(common::Error::JsonDecodeError(
8751                                    encoded.to_string(),
8752                                    error,
8753                                ));
8754                            }
8755                        }
8756                    };
8757
8758                    dlg.finished(true);
8759                    return Ok(response);
8760                }
8761            }
8762        }
8763    }
8764
8765    ///
8766    /// Sets the *request* property to the given value.
8767    ///
8768    /// Even though the property as already been set when instantiating this call,
8769    /// we provide this method for API completeness.
8770    pub fn request(
8771        mut self,
8772        new_value: GoogleCloudRetailV2ImportProductsRequest,
8773    ) -> ProjectLocationCatalogBranchProductImportCall<'a, C> {
8774        self._request = new_value;
8775        self
8776    }
8777    /// Required. `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` If no updateMask is specified, requires products.create permission. If updateMask is specified, requires products.update permission.
8778    ///
8779    /// Sets the *parent* path property to the given value.
8780    ///
8781    /// Even though the property as already been set when instantiating this call,
8782    /// we provide this method for API completeness.
8783    pub fn parent(
8784        mut self,
8785        new_value: &str,
8786    ) -> ProjectLocationCatalogBranchProductImportCall<'a, C> {
8787        self._parent = new_value.to_string();
8788        self
8789    }
8790    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8791    /// while executing the actual API request.
8792    ///
8793    /// ````text
8794    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8795    /// ````
8796    ///
8797    /// Sets the *delegate* property to the given value.
8798    pub fn delegate(
8799        mut self,
8800        new_value: &'a mut dyn common::Delegate,
8801    ) -> ProjectLocationCatalogBranchProductImportCall<'a, C> {
8802        self._delegate = Some(new_value);
8803        self
8804    }
8805
8806    /// Set any additional parameter of the query string used in the request.
8807    /// It should be used to set parameters which are not yet available through their own
8808    /// setters.
8809    ///
8810    /// Please note that this method must not be used to set any of the known parameters
8811    /// which have their own setter method. If done anyway, the request will fail.
8812    ///
8813    /// # Additional Parameters
8814    ///
8815    /// * *$.xgafv* (query-string) - V1 error format.
8816    /// * *access_token* (query-string) - OAuth access token.
8817    /// * *alt* (query-string) - Data format for response.
8818    /// * *callback* (query-string) - JSONP
8819    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8820    /// * *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.
8821    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8822    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8823    /// * *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.
8824    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8825    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8826    pub fn param<T>(
8827        mut self,
8828        name: T,
8829        value: T,
8830    ) -> ProjectLocationCatalogBranchProductImportCall<'a, C>
8831    where
8832        T: AsRef<str>,
8833    {
8834        self._additional_params
8835            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8836        self
8837    }
8838
8839    /// Identifies the authorization scope for the method you are building.
8840    ///
8841    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8842    /// [`Scope::CloudPlatform`].
8843    ///
8844    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8845    /// tokens for more than one scope.
8846    ///
8847    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8848    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8849    /// sufficient, a read-write scope will do as well.
8850    pub fn add_scope<St>(
8851        mut self,
8852        scope: St,
8853    ) -> ProjectLocationCatalogBranchProductImportCall<'a, C>
8854    where
8855        St: AsRef<str>,
8856    {
8857        self._scopes.insert(String::from(scope.as_ref()));
8858        self
8859    }
8860    /// Identifies the authorization scope(s) for the method you are building.
8861    ///
8862    /// See [`Self::add_scope()`] for details.
8863    pub fn add_scopes<I, St>(
8864        mut self,
8865        scopes: I,
8866    ) -> ProjectLocationCatalogBranchProductImportCall<'a, C>
8867    where
8868        I: IntoIterator<Item = St>,
8869        St: AsRef<str>,
8870    {
8871        self._scopes
8872            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8873        self
8874    }
8875
8876    /// Removes all scopes, and no default scope will be used either.
8877    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8878    /// for details).
8879    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductImportCall<'a, C> {
8880        self._scopes.clear();
8881        self
8882    }
8883}
8884
8885/// Gets a list of Products.
8886///
8887/// A builder for the *locations.catalogs.branches.products.list* method supported by a *project* resource.
8888/// It is not used directly, but through a [`ProjectMethods`] instance.
8889///
8890/// # Example
8891///
8892/// Instantiate a resource method builder
8893///
8894/// ```test_harness,no_run
8895/// # extern crate hyper;
8896/// # extern crate hyper_rustls;
8897/// # extern crate google_retail2 as retail2;
8898/// # async fn dox() {
8899/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8900///
8901/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8902/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8903/// #     .with_native_roots()
8904/// #     .unwrap()
8905/// #     .https_only()
8906/// #     .enable_http2()
8907/// #     .build();
8908///
8909/// # let executor = hyper_util::rt::TokioExecutor::new();
8910/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8911/// #     secret,
8912/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8913/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8914/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8915/// #     ),
8916/// # ).build().await.unwrap();
8917///
8918/// # let client = hyper_util::client::legacy::Client::builder(
8919/// #     hyper_util::rt::TokioExecutor::new()
8920/// # )
8921/// # .build(
8922/// #     hyper_rustls::HttpsConnectorBuilder::new()
8923/// #         .with_native_roots()
8924/// #         .unwrap()
8925/// #         .https_or_http()
8926/// #         .enable_http2()
8927/// #         .build()
8928/// # );
8929/// # let mut hub = CloudRetail::new(client, auth);
8930/// // You can configure optional parameters by calling the respective setters at will, and
8931/// // execute the final call using `doit()`.
8932/// // Values shown here are possibly random and not representative !
8933/// let result = hub.projects().locations_catalogs_branches_products_list("parent")
8934///              .read_mask(FieldMask::new::<&str>(&[]))
8935///              .page_token("duo")
8936///              .page_size(-50)
8937///              .filter("sed")
8938///              .doit().await;
8939/// # }
8940/// ```
8941pub struct ProjectLocationCatalogBranchProductListCall<'a, C>
8942where
8943    C: 'a,
8944{
8945    hub: &'a CloudRetail<C>,
8946    _parent: String,
8947    _read_mask: Option<common::FieldMask>,
8948    _page_token: Option<String>,
8949    _page_size: Option<i32>,
8950    _filter: Option<String>,
8951    _delegate: Option<&'a mut dyn common::Delegate>,
8952    _additional_params: HashMap<String, String>,
8953    _scopes: BTreeSet<String>,
8954}
8955
8956impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductListCall<'a, C> {}
8957
8958impl<'a, C> ProjectLocationCatalogBranchProductListCall<'a, C>
8959where
8960    C: common::Connector,
8961{
8962    /// Perform the operation you have build so far.
8963    pub async fn doit(
8964        mut self,
8965    ) -> common::Result<(common::Response, GoogleCloudRetailV2ListProductsResponse)> {
8966        use std::borrow::Cow;
8967        use std::io::{Read, Seek};
8968
8969        use common::{url::Params, ToParts};
8970        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8971
8972        let mut dd = common::DefaultDelegate;
8973        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8974        dlg.begin(common::MethodInfo {
8975            id: "retail.projects.locations.catalogs.branches.products.list",
8976            http_method: hyper::Method::GET,
8977        });
8978
8979        for &field in [
8980            "alt",
8981            "parent",
8982            "readMask",
8983            "pageToken",
8984            "pageSize",
8985            "filter",
8986        ]
8987        .iter()
8988        {
8989            if self._additional_params.contains_key(field) {
8990                dlg.finished(false);
8991                return Err(common::Error::FieldClash(field));
8992            }
8993        }
8994
8995        let mut params = Params::with_capacity(7 + self._additional_params.len());
8996        params.push("parent", self._parent);
8997        if let Some(value) = self._read_mask.as_ref() {
8998            params.push("readMask", value.to_string());
8999        }
9000        if let Some(value) = self._page_token.as_ref() {
9001            params.push("pageToken", value);
9002        }
9003        if let Some(value) = self._page_size.as_ref() {
9004            params.push("pageSize", value.to_string());
9005        }
9006        if let Some(value) = self._filter.as_ref() {
9007            params.push("filter", value);
9008        }
9009
9010        params.extend(self._additional_params.iter());
9011
9012        params.push("alt", "json");
9013        let mut url = self.hub._base_url.clone() + "v2/{+parent}/products";
9014        if self._scopes.is_empty() {
9015            self._scopes
9016                .insert(Scope::CloudPlatform.as_ref().to_string());
9017        }
9018
9019        #[allow(clippy::single_element_loop)]
9020        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9021            url = params.uri_replacement(url, param_name, find_this, true);
9022        }
9023        {
9024            let to_remove = ["parent"];
9025            params.remove_params(&to_remove);
9026        }
9027
9028        let url = params.parse_with_url(&url);
9029
9030        loop {
9031            let token = match self
9032                .hub
9033                .auth
9034                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9035                .await
9036            {
9037                Ok(token) => token,
9038                Err(e) => match dlg.token(e) {
9039                    Ok(token) => token,
9040                    Err(e) => {
9041                        dlg.finished(false);
9042                        return Err(common::Error::MissingToken(e));
9043                    }
9044                },
9045            };
9046            let mut req_result = {
9047                let client = &self.hub.client;
9048                dlg.pre_request();
9049                let mut req_builder = hyper::Request::builder()
9050                    .method(hyper::Method::GET)
9051                    .uri(url.as_str())
9052                    .header(USER_AGENT, self.hub._user_agent.clone());
9053
9054                if let Some(token) = token.as_ref() {
9055                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9056                }
9057
9058                let request = req_builder
9059                    .header(CONTENT_LENGTH, 0_u64)
9060                    .body(common::to_body::<String>(None));
9061
9062                client.request(request.unwrap()).await
9063            };
9064
9065            match req_result {
9066                Err(err) => {
9067                    if let common::Retry::After(d) = dlg.http_error(&err) {
9068                        sleep(d).await;
9069                        continue;
9070                    }
9071                    dlg.finished(false);
9072                    return Err(common::Error::HttpError(err));
9073                }
9074                Ok(res) => {
9075                    let (mut parts, body) = res.into_parts();
9076                    let mut body = common::Body::new(body);
9077                    if !parts.status.is_success() {
9078                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9079                        let error = serde_json::from_str(&common::to_string(&bytes));
9080                        let response = common::to_response(parts, bytes.into());
9081
9082                        if let common::Retry::After(d) =
9083                            dlg.http_failure(&response, error.as_ref().ok())
9084                        {
9085                            sleep(d).await;
9086                            continue;
9087                        }
9088
9089                        dlg.finished(false);
9090
9091                        return Err(match error {
9092                            Ok(value) => common::Error::BadRequest(value),
9093                            _ => common::Error::Failure(response),
9094                        });
9095                    }
9096                    let response = {
9097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9098                        let encoded = common::to_string(&bytes);
9099                        match serde_json::from_str(&encoded) {
9100                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9101                            Err(error) => {
9102                                dlg.response_json_decode_error(&encoded, &error);
9103                                return Err(common::Error::JsonDecodeError(
9104                                    encoded.to_string(),
9105                                    error,
9106                                ));
9107                            }
9108                        }
9109                    };
9110
9111                    dlg.finished(true);
9112                    return Ok(response);
9113                }
9114            }
9115        }
9116    }
9117
9118    /// Required. The parent branch resource name, such as `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use `default_branch` as the branch ID, to list products under the default branch. If the caller does not have permission to list Products under this branch, regardless of whether or not this branch exists, a PERMISSION_DENIED error is returned.
9119    ///
9120    /// Sets the *parent* path property to the given value.
9121    ///
9122    /// Even though the property as already been set when instantiating this call,
9123    /// we provide this method for API completeness.
9124    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
9125        self._parent = new_value.to_string();
9126        self
9127    }
9128    /// The fields of Product to return in the responses. If not set or empty, the following fields are returned: * Product.name * Product.id * Product.title * Product.uri * Product.images * Product.price_info * Product.brands If "*" is provided, all fields are returned. Product.name is always returned no matter what mask is set. If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned.
9129    ///
9130    /// Sets the *read mask* query property to the given value.
9131    pub fn read_mask(
9132        mut self,
9133        new_value: common::FieldMask,
9134    ) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
9135        self._read_mask = Some(new_value);
9136        self
9137    }
9138    /// A page token ListProductsResponse.next_page_token, received from a previous ProductService.ListProducts call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to ProductService.ListProducts must match the call that provided the page token. Otherwise, an INVALID_ARGUMENT error is returned.
9139    ///
9140    /// Sets the *page token* query property to the given value.
9141    pub fn page_token(
9142        mut self,
9143        new_value: &str,
9144    ) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
9145        self._page_token = Some(new_value.to_string());
9146        self
9147    }
9148    /// Maximum number of Products to return. If unspecified, defaults to 100. The maximum allowed value is 1000. Values above 1000 will be coerced to 1000. If this field is negative, an INVALID_ARGUMENT error is returned.
9149    ///
9150    /// Sets the *page size* query property to the given value.
9151    pub fn page_size(
9152        mut self,
9153        new_value: i32,
9154    ) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
9155        self._page_size = Some(new_value);
9156        self
9157    }
9158    /// A filter to apply on the list results. Supported features: * List all the products under the parent branch if filter is unset. * List Product.Type.VARIANT Products sharing the same Product.Type.PRIMARY Product. For example: `primary_product_id = "some_product_id"` * List Products bundled in a Product.Type.COLLECTION Product. For example: `collection_product_id = "some_product_id"` * List Products with a partibular type. For example: `type = "PRIMARY"` `type = "VARIANT"` `type = "COLLECTION"` If the field is unrecognizable, an INVALID_ARGUMENT error is returned. If the specified Product.Type.PRIMARY Product or Product.Type.COLLECTION Product does not exist, a NOT_FOUND error is returned.
9159    ///
9160    /// Sets the *filter* query property to the given value.
9161    pub fn filter(mut self, new_value: &str) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
9162        self._filter = Some(new_value.to_string());
9163        self
9164    }
9165    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9166    /// while executing the actual API request.
9167    ///
9168    /// ````text
9169    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9170    /// ````
9171    ///
9172    /// Sets the *delegate* property to the given value.
9173    pub fn delegate(
9174        mut self,
9175        new_value: &'a mut dyn common::Delegate,
9176    ) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
9177        self._delegate = Some(new_value);
9178        self
9179    }
9180
9181    /// Set any additional parameter of the query string used in the request.
9182    /// It should be used to set parameters which are not yet available through their own
9183    /// setters.
9184    ///
9185    /// Please note that this method must not be used to set any of the known parameters
9186    /// which have their own setter method. If done anyway, the request will fail.
9187    ///
9188    /// # Additional Parameters
9189    ///
9190    /// * *$.xgafv* (query-string) - V1 error format.
9191    /// * *access_token* (query-string) - OAuth access token.
9192    /// * *alt* (query-string) - Data format for response.
9193    /// * *callback* (query-string) - JSONP
9194    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9195    /// * *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.
9196    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9197    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9198    /// * *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.
9199    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9200    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9201    pub fn param<T>(
9202        mut self,
9203        name: T,
9204        value: T,
9205    ) -> ProjectLocationCatalogBranchProductListCall<'a, C>
9206    where
9207        T: AsRef<str>,
9208    {
9209        self._additional_params
9210            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9211        self
9212    }
9213
9214    /// Identifies the authorization scope for the method you are building.
9215    ///
9216    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9217    /// [`Scope::CloudPlatform`].
9218    ///
9219    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9220    /// tokens for more than one scope.
9221    ///
9222    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9223    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9224    /// sufficient, a read-write scope will do as well.
9225    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogBranchProductListCall<'a, C>
9226    where
9227        St: AsRef<str>,
9228    {
9229        self._scopes.insert(String::from(scope.as_ref()));
9230        self
9231    }
9232    /// Identifies the authorization scope(s) for the method you are building.
9233    ///
9234    /// See [`Self::add_scope()`] for details.
9235    pub fn add_scopes<I, St>(
9236        mut self,
9237        scopes: I,
9238    ) -> ProjectLocationCatalogBranchProductListCall<'a, C>
9239    where
9240        I: IntoIterator<Item = St>,
9241        St: AsRef<str>,
9242    {
9243        self._scopes
9244            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9245        self
9246    }
9247
9248    /// Removes all scopes, and no default scope will be used either.
9249    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9250    /// for details).
9251    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductListCall<'a, C> {
9252        self._scopes.clear();
9253        self
9254    }
9255}
9256
9257/// Updates a Product.
9258///
9259/// A builder for the *locations.catalogs.branches.products.patch* method supported by a *project* resource.
9260/// It is not used directly, but through a [`ProjectMethods`] instance.
9261///
9262/// # Example
9263///
9264/// Instantiate a resource method builder
9265///
9266/// ```test_harness,no_run
9267/// # extern crate hyper;
9268/// # extern crate hyper_rustls;
9269/// # extern crate google_retail2 as retail2;
9270/// use retail2::api::GoogleCloudRetailV2Product;
9271/// # async fn dox() {
9272/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9273///
9274/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9275/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9276/// #     .with_native_roots()
9277/// #     .unwrap()
9278/// #     .https_only()
9279/// #     .enable_http2()
9280/// #     .build();
9281///
9282/// # let executor = hyper_util::rt::TokioExecutor::new();
9283/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9284/// #     secret,
9285/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9286/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9287/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9288/// #     ),
9289/// # ).build().await.unwrap();
9290///
9291/// # let client = hyper_util::client::legacy::Client::builder(
9292/// #     hyper_util::rt::TokioExecutor::new()
9293/// # )
9294/// # .build(
9295/// #     hyper_rustls::HttpsConnectorBuilder::new()
9296/// #         .with_native_roots()
9297/// #         .unwrap()
9298/// #         .https_or_http()
9299/// #         .enable_http2()
9300/// #         .build()
9301/// # );
9302/// # let mut hub = CloudRetail::new(client, auth);
9303/// // As the method needs a request, you would usually fill it with the desired information
9304/// // into the respective structure. Some of the parts shown here might not be applicable !
9305/// // Values shown here are possibly random and not representative !
9306/// let mut req = GoogleCloudRetailV2Product::default();
9307///
9308/// // You can configure optional parameters by calling the respective setters at will, and
9309/// // execute the final call using `doit()`.
9310/// // Values shown here are possibly random and not representative !
9311/// let result = hub.projects().locations_catalogs_branches_products_patch(req, "name")
9312///              .update_mask(FieldMask::new::<&str>(&[]))
9313///              .allow_missing(true)
9314///              .doit().await;
9315/// # }
9316/// ```
9317pub struct ProjectLocationCatalogBranchProductPatchCall<'a, C>
9318where
9319    C: 'a,
9320{
9321    hub: &'a CloudRetail<C>,
9322    _request: GoogleCloudRetailV2Product,
9323    _name: String,
9324    _update_mask: Option<common::FieldMask>,
9325    _allow_missing: Option<bool>,
9326    _delegate: Option<&'a mut dyn common::Delegate>,
9327    _additional_params: HashMap<String, String>,
9328    _scopes: BTreeSet<String>,
9329}
9330
9331impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductPatchCall<'a, C> {}
9332
9333impl<'a, C> ProjectLocationCatalogBranchProductPatchCall<'a, C>
9334where
9335    C: common::Connector,
9336{
9337    /// Perform the operation you have build so far.
9338    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Product)> {
9339        use std::borrow::Cow;
9340        use std::io::{Read, Seek};
9341
9342        use common::{url::Params, ToParts};
9343        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9344
9345        let mut dd = common::DefaultDelegate;
9346        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9347        dlg.begin(common::MethodInfo {
9348            id: "retail.projects.locations.catalogs.branches.products.patch",
9349            http_method: hyper::Method::PATCH,
9350        });
9351
9352        for &field in ["alt", "name", "updateMask", "allowMissing"].iter() {
9353            if self._additional_params.contains_key(field) {
9354                dlg.finished(false);
9355                return Err(common::Error::FieldClash(field));
9356            }
9357        }
9358
9359        let mut params = Params::with_capacity(6 + self._additional_params.len());
9360        params.push("name", self._name);
9361        if let Some(value) = self._update_mask.as_ref() {
9362            params.push("updateMask", value.to_string());
9363        }
9364        if let Some(value) = self._allow_missing.as_ref() {
9365            params.push("allowMissing", value.to_string());
9366        }
9367
9368        params.extend(self._additional_params.iter());
9369
9370        params.push("alt", "json");
9371        let mut url = self.hub._base_url.clone() + "v2/{+name}";
9372        if self._scopes.is_empty() {
9373            self._scopes
9374                .insert(Scope::CloudPlatform.as_ref().to_string());
9375        }
9376
9377        #[allow(clippy::single_element_loop)]
9378        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9379            url = params.uri_replacement(url, param_name, find_this, true);
9380        }
9381        {
9382            let to_remove = ["name"];
9383            params.remove_params(&to_remove);
9384        }
9385
9386        let url = params.parse_with_url(&url);
9387
9388        let mut json_mime_type = mime::APPLICATION_JSON;
9389        let mut request_value_reader = {
9390            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9391            common::remove_json_null_values(&mut value);
9392            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9393            serde_json::to_writer(&mut dst, &value).unwrap();
9394            dst
9395        };
9396        let request_size = request_value_reader
9397            .seek(std::io::SeekFrom::End(0))
9398            .unwrap();
9399        request_value_reader
9400            .seek(std::io::SeekFrom::Start(0))
9401            .unwrap();
9402
9403        loop {
9404            let token = match self
9405                .hub
9406                .auth
9407                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9408                .await
9409            {
9410                Ok(token) => token,
9411                Err(e) => match dlg.token(e) {
9412                    Ok(token) => token,
9413                    Err(e) => {
9414                        dlg.finished(false);
9415                        return Err(common::Error::MissingToken(e));
9416                    }
9417                },
9418            };
9419            request_value_reader
9420                .seek(std::io::SeekFrom::Start(0))
9421                .unwrap();
9422            let mut req_result = {
9423                let client = &self.hub.client;
9424                dlg.pre_request();
9425                let mut req_builder = hyper::Request::builder()
9426                    .method(hyper::Method::PATCH)
9427                    .uri(url.as_str())
9428                    .header(USER_AGENT, self.hub._user_agent.clone());
9429
9430                if let Some(token) = token.as_ref() {
9431                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9432                }
9433
9434                let request = req_builder
9435                    .header(CONTENT_TYPE, json_mime_type.to_string())
9436                    .header(CONTENT_LENGTH, request_size as u64)
9437                    .body(common::to_body(
9438                        request_value_reader.get_ref().clone().into(),
9439                    ));
9440
9441                client.request(request.unwrap()).await
9442            };
9443
9444            match req_result {
9445                Err(err) => {
9446                    if let common::Retry::After(d) = dlg.http_error(&err) {
9447                        sleep(d).await;
9448                        continue;
9449                    }
9450                    dlg.finished(false);
9451                    return Err(common::Error::HttpError(err));
9452                }
9453                Ok(res) => {
9454                    let (mut parts, body) = res.into_parts();
9455                    let mut body = common::Body::new(body);
9456                    if !parts.status.is_success() {
9457                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9458                        let error = serde_json::from_str(&common::to_string(&bytes));
9459                        let response = common::to_response(parts, bytes.into());
9460
9461                        if let common::Retry::After(d) =
9462                            dlg.http_failure(&response, error.as_ref().ok())
9463                        {
9464                            sleep(d).await;
9465                            continue;
9466                        }
9467
9468                        dlg.finished(false);
9469
9470                        return Err(match error {
9471                            Ok(value) => common::Error::BadRequest(value),
9472                            _ => common::Error::Failure(response),
9473                        });
9474                    }
9475                    let response = {
9476                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9477                        let encoded = common::to_string(&bytes);
9478                        match serde_json::from_str(&encoded) {
9479                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9480                            Err(error) => {
9481                                dlg.response_json_decode_error(&encoded, &error);
9482                                return Err(common::Error::JsonDecodeError(
9483                                    encoded.to_string(),
9484                                    error,
9485                                ));
9486                            }
9487                        }
9488                    };
9489
9490                    dlg.finished(true);
9491                    return Ok(response);
9492                }
9493            }
9494        }
9495    }
9496
9497    ///
9498    /// Sets the *request* property to the given value.
9499    ///
9500    /// Even though the property as already been set when instantiating this call,
9501    /// we provide this method for API completeness.
9502    pub fn request(
9503        mut self,
9504        new_value: GoogleCloudRetailV2Product,
9505    ) -> ProjectLocationCatalogBranchProductPatchCall<'a, C> {
9506        self._request = new_value;
9507        self
9508    }
9509    /// Immutable. Full resource name of the product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`.
9510    ///
9511    /// Sets the *name* path property to the given value.
9512    ///
9513    /// Even though the property as already been set when instantiating this call,
9514    /// we provide this method for API completeness.
9515    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogBranchProductPatchCall<'a, C> {
9516        self._name = new_value.to_string();
9517        self
9518    }
9519    /// Indicates which fields in the provided Product to update. The immutable and output only fields are NOT supported. If not set, all supported fields (the fields that are neither immutable nor output only) are updated. If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned. The attribute key can be updated by setting the mask path as "attributes.${key_name}". If a key name is present in the mask but not in the patching product from the request, this key will be deleted after the update.
9520    ///
9521    /// Sets the *update mask* query property to the given value.
9522    pub fn update_mask(
9523        mut self,
9524        new_value: common::FieldMask,
9525    ) -> ProjectLocationCatalogBranchProductPatchCall<'a, C> {
9526        self._update_mask = Some(new_value);
9527        self
9528    }
9529    /// If set to true, and the Product is not found, a new Product will be created. In this situation, `update_mask` is ignored.
9530    ///
9531    /// Sets the *allow missing* query property to the given value.
9532    pub fn allow_missing(
9533        mut self,
9534        new_value: bool,
9535    ) -> ProjectLocationCatalogBranchProductPatchCall<'a, C> {
9536        self._allow_missing = Some(new_value);
9537        self
9538    }
9539    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9540    /// while executing the actual API request.
9541    ///
9542    /// ````text
9543    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9544    /// ````
9545    ///
9546    /// Sets the *delegate* property to the given value.
9547    pub fn delegate(
9548        mut self,
9549        new_value: &'a mut dyn common::Delegate,
9550    ) -> ProjectLocationCatalogBranchProductPatchCall<'a, C> {
9551        self._delegate = Some(new_value);
9552        self
9553    }
9554
9555    /// Set any additional parameter of the query string used in the request.
9556    /// It should be used to set parameters which are not yet available through their own
9557    /// setters.
9558    ///
9559    /// Please note that this method must not be used to set any of the known parameters
9560    /// which have their own setter method. If done anyway, the request will fail.
9561    ///
9562    /// # Additional Parameters
9563    ///
9564    /// * *$.xgafv* (query-string) - V1 error format.
9565    /// * *access_token* (query-string) - OAuth access token.
9566    /// * *alt* (query-string) - Data format for response.
9567    /// * *callback* (query-string) - JSONP
9568    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9569    /// * *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.
9570    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9571    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9572    /// * *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.
9573    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9574    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9575    pub fn param<T>(
9576        mut self,
9577        name: T,
9578        value: T,
9579    ) -> ProjectLocationCatalogBranchProductPatchCall<'a, C>
9580    where
9581        T: AsRef<str>,
9582    {
9583        self._additional_params
9584            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9585        self
9586    }
9587
9588    /// Identifies the authorization scope for the method you are building.
9589    ///
9590    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9591    /// [`Scope::CloudPlatform`].
9592    ///
9593    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9594    /// tokens for more than one scope.
9595    ///
9596    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9597    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9598    /// sufficient, a read-write scope will do as well.
9599    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogBranchProductPatchCall<'a, C>
9600    where
9601        St: AsRef<str>,
9602    {
9603        self._scopes.insert(String::from(scope.as_ref()));
9604        self
9605    }
9606    /// Identifies the authorization scope(s) for the method you are building.
9607    ///
9608    /// See [`Self::add_scope()`] for details.
9609    pub fn add_scopes<I, St>(
9610        mut self,
9611        scopes: I,
9612    ) -> ProjectLocationCatalogBranchProductPatchCall<'a, C>
9613    where
9614        I: IntoIterator<Item = St>,
9615        St: AsRef<str>,
9616    {
9617        self._scopes
9618            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9619        self
9620    }
9621
9622    /// Removes all scopes, and no default scope will be used either.
9623    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9624    /// for details).
9625    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductPatchCall<'a, C> {
9626        self._scopes.clear();
9627        self
9628    }
9629}
9630
9631/// Permanently deletes all selected Products under a branch. This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of Products, this operation could take hours to complete. Before the operation completes, some Products may still be returned by ProductService.GetProduct or ProductService.ListProducts. Depending on the number of Products, this operation could take hours to complete. To get a sample of Products that would be deleted, set PurgeProductsRequest.force to false.
9632///
9633/// A builder for the *locations.catalogs.branches.products.purge* method supported by a *project* resource.
9634/// It is not used directly, but through a [`ProjectMethods`] instance.
9635///
9636/// # Example
9637///
9638/// Instantiate a resource method builder
9639///
9640/// ```test_harness,no_run
9641/// # extern crate hyper;
9642/// # extern crate hyper_rustls;
9643/// # extern crate google_retail2 as retail2;
9644/// use retail2::api::GoogleCloudRetailV2PurgeProductsRequest;
9645/// # async fn dox() {
9646/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9647///
9648/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9649/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9650/// #     .with_native_roots()
9651/// #     .unwrap()
9652/// #     .https_only()
9653/// #     .enable_http2()
9654/// #     .build();
9655///
9656/// # let executor = hyper_util::rt::TokioExecutor::new();
9657/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9658/// #     secret,
9659/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9660/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9661/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9662/// #     ),
9663/// # ).build().await.unwrap();
9664///
9665/// # let client = hyper_util::client::legacy::Client::builder(
9666/// #     hyper_util::rt::TokioExecutor::new()
9667/// # )
9668/// # .build(
9669/// #     hyper_rustls::HttpsConnectorBuilder::new()
9670/// #         .with_native_roots()
9671/// #         .unwrap()
9672/// #         .https_or_http()
9673/// #         .enable_http2()
9674/// #         .build()
9675/// # );
9676/// # let mut hub = CloudRetail::new(client, auth);
9677/// // As the method needs a request, you would usually fill it with the desired information
9678/// // into the respective structure. Some of the parts shown here might not be applicable !
9679/// // Values shown here are possibly random and not representative !
9680/// let mut req = GoogleCloudRetailV2PurgeProductsRequest::default();
9681///
9682/// // You can configure optional parameters by calling the respective setters at will, and
9683/// // execute the final call using `doit()`.
9684/// // Values shown here are possibly random and not representative !
9685/// let result = hub.projects().locations_catalogs_branches_products_purge(req, "parent")
9686///              .doit().await;
9687/// # }
9688/// ```
9689pub struct ProjectLocationCatalogBranchProductPurgeCall<'a, C>
9690where
9691    C: 'a,
9692{
9693    hub: &'a CloudRetail<C>,
9694    _request: GoogleCloudRetailV2PurgeProductsRequest,
9695    _parent: String,
9696    _delegate: Option<&'a mut dyn common::Delegate>,
9697    _additional_params: HashMap<String, String>,
9698    _scopes: BTreeSet<String>,
9699}
9700
9701impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductPurgeCall<'a, C> {}
9702
9703impl<'a, C> ProjectLocationCatalogBranchProductPurgeCall<'a, C>
9704where
9705    C: common::Connector,
9706{
9707    /// Perform the operation you have build so far.
9708    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
9709        use std::borrow::Cow;
9710        use std::io::{Read, Seek};
9711
9712        use common::{url::Params, ToParts};
9713        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9714
9715        let mut dd = common::DefaultDelegate;
9716        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9717        dlg.begin(common::MethodInfo {
9718            id: "retail.projects.locations.catalogs.branches.products.purge",
9719            http_method: hyper::Method::POST,
9720        });
9721
9722        for &field in ["alt", "parent"].iter() {
9723            if self._additional_params.contains_key(field) {
9724                dlg.finished(false);
9725                return Err(common::Error::FieldClash(field));
9726            }
9727        }
9728
9729        let mut params = Params::with_capacity(4 + self._additional_params.len());
9730        params.push("parent", self._parent);
9731
9732        params.extend(self._additional_params.iter());
9733
9734        params.push("alt", "json");
9735        let mut url = self.hub._base_url.clone() + "v2/{+parent}/products:purge";
9736        if self._scopes.is_empty() {
9737            self._scopes
9738                .insert(Scope::CloudPlatform.as_ref().to_string());
9739        }
9740
9741        #[allow(clippy::single_element_loop)]
9742        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9743            url = params.uri_replacement(url, param_name, find_this, true);
9744        }
9745        {
9746            let to_remove = ["parent"];
9747            params.remove_params(&to_remove);
9748        }
9749
9750        let url = params.parse_with_url(&url);
9751
9752        let mut json_mime_type = mime::APPLICATION_JSON;
9753        let mut request_value_reader = {
9754            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9755            common::remove_json_null_values(&mut value);
9756            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9757            serde_json::to_writer(&mut dst, &value).unwrap();
9758            dst
9759        };
9760        let request_size = request_value_reader
9761            .seek(std::io::SeekFrom::End(0))
9762            .unwrap();
9763        request_value_reader
9764            .seek(std::io::SeekFrom::Start(0))
9765            .unwrap();
9766
9767        loop {
9768            let token = match self
9769                .hub
9770                .auth
9771                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9772                .await
9773            {
9774                Ok(token) => token,
9775                Err(e) => match dlg.token(e) {
9776                    Ok(token) => token,
9777                    Err(e) => {
9778                        dlg.finished(false);
9779                        return Err(common::Error::MissingToken(e));
9780                    }
9781                },
9782            };
9783            request_value_reader
9784                .seek(std::io::SeekFrom::Start(0))
9785                .unwrap();
9786            let mut req_result = {
9787                let client = &self.hub.client;
9788                dlg.pre_request();
9789                let mut req_builder = hyper::Request::builder()
9790                    .method(hyper::Method::POST)
9791                    .uri(url.as_str())
9792                    .header(USER_AGENT, self.hub._user_agent.clone());
9793
9794                if let Some(token) = token.as_ref() {
9795                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9796                }
9797
9798                let request = req_builder
9799                    .header(CONTENT_TYPE, json_mime_type.to_string())
9800                    .header(CONTENT_LENGTH, request_size as u64)
9801                    .body(common::to_body(
9802                        request_value_reader.get_ref().clone().into(),
9803                    ));
9804
9805                client.request(request.unwrap()).await
9806            };
9807
9808            match req_result {
9809                Err(err) => {
9810                    if let common::Retry::After(d) = dlg.http_error(&err) {
9811                        sleep(d).await;
9812                        continue;
9813                    }
9814                    dlg.finished(false);
9815                    return Err(common::Error::HttpError(err));
9816                }
9817                Ok(res) => {
9818                    let (mut parts, body) = res.into_parts();
9819                    let mut body = common::Body::new(body);
9820                    if !parts.status.is_success() {
9821                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9822                        let error = serde_json::from_str(&common::to_string(&bytes));
9823                        let response = common::to_response(parts, bytes.into());
9824
9825                        if let common::Retry::After(d) =
9826                            dlg.http_failure(&response, error.as_ref().ok())
9827                        {
9828                            sleep(d).await;
9829                            continue;
9830                        }
9831
9832                        dlg.finished(false);
9833
9834                        return Err(match error {
9835                            Ok(value) => common::Error::BadRequest(value),
9836                            _ => common::Error::Failure(response),
9837                        });
9838                    }
9839                    let response = {
9840                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9841                        let encoded = common::to_string(&bytes);
9842                        match serde_json::from_str(&encoded) {
9843                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9844                            Err(error) => {
9845                                dlg.response_json_decode_error(&encoded, &error);
9846                                return Err(common::Error::JsonDecodeError(
9847                                    encoded.to_string(),
9848                                    error,
9849                                ));
9850                            }
9851                        }
9852                    };
9853
9854                    dlg.finished(true);
9855                    return Ok(response);
9856                }
9857            }
9858        }
9859    }
9860
9861    ///
9862    /// Sets the *request* property to the given value.
9863    ///
9864    /// Even though the property as already been set when instantiating this call,
9865    /// we provide this method for API completeness.
9866    pub fn request(
9867        mut self,
9868        new_value: GoogleCloudRetailV2PurgeProductsRequest,
9869    ) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C> {
9870        self._request = new_value;
9871        self
9872    }
9873    /// Required. The resource name of the branch under which the products are created. The format is `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}`
9874    ///
9875    /// Sets the *parent* path property to the given value.
9876    ///
9877    /// Even though the property as already been set when instantiating this call,
9878    /// we provide this method for API completeness.
9879    pub fn parent(
9880        mut self,
9881        new_value: &str,
9882    ) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C> {
9883        self._parent = new_value.to_string();
9884        self
9885    }
9886    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9887    /// while executing the actual API request.
9888    ///
9889    /// ````text
9890    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9891    /// ````
9892    ///
9893    /// Sets the *delegate* property to the given value.
9894    pub fn delegate(
9895        mut self,
9896        new_value: &'a mut dyn common::Delegate,
9897    ) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C> {
9898        self._delegate = Some(new_value);
9899        self
9900    }
9901
9902    /// Set any additional parameter of the query string used in the request.
9903    /// It should be used to set parameters which are not yet available through their own
9904    /// setters.
9905    ///
9906    /// Please note that this method must not be used to set any of the known parameters
9907    /// which have their own setter method. If done anyway, the request will fail.
9908    ///
9909    /// # Additional Parameters
9910    ///
9911    /// * *$.xgafv* (query-string) - V1 error format.
9912    /// * *access_token* (query-string) - OAuth access token.
9913    /// * *alt* (query-string) - Data format for response.
9914    /// * *callback* (query-string) - JSONP
9915    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9916    /// * *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.
9917    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9918    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9919    /// * *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.
9920    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9921    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9922    pub fn param<T>(
9923        mut self,
9924        name: T,
9925        value: T,
9926    ) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C>
9927    where
9928        T: AsRef<str>,
9929    {
9930        self._additional_params
9931            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9932        self
9933    }
9934
9935    /// Identifies the authorization scope for the method you are building.
9936    ///
9937    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9938    /// [`Scope::CloudPlatform`].
9939    ///
9940    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9941    /// tokens for more than one scope.
9942    ///
9943    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9944    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9945    /// sufficient, a read-write scope will do as well.
9946    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C>
9947    where
9948        St: AsRef<str>,
9949    {
9950        self._scopes.insert(String::from(scope.as_ref()));
9951        self
9952    }
9953    /// Identifies the authorization scope(s) for the method you are building.
9954    ///
9955    /// See [`Self::add_scope()`] for details.
9956    pub fn add_scopes<I, St>(
9957        mut self,
9958        scopes: I,
9959    ) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C>
9960    where
9961        I: IntoIterator<Item = St>,
9962        St: AsRef<str>,
9963    {
9964        self._scopes
9965            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9966        self
9967    }
9968
9969    /// Removes all scopes, and no default scope will be used either.
9970    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9971    /// for details).
9972    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductPurgeCall<'a, C> {
9973        self._scopes.clear();
9974        self
9975    }
9976}
9977
9978/// We recommend that you use the ProductService.RemoveLocalInventories method instead of the ProductService.RemoveFulfillmentPlaces method. ProductService.RemoveLocalInventories achieves the same results but provides more fine-grained control over ingesting local inventory data. Incrementally removes place IDs from a Product.fulfillment_info.place_ids. This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
9979///
9980/// A builder for the *locations.catalogs.branches.products.removeFulfillmentPlaces* method supported by a *project* resource.
9981/// It is not used directly, but through a [`ProjectMethods`] instance.
9982///
9983/// # Example
9984///
9985/// Instantiate a resource method builder
9986///
9987/// ```test_harness,no_run
9988/// # extern crate hyper;
9989/// # extern crate hyper_rustls;
9990/// # extern crate google_retail2 as retail2;
9991/// use retail2::api::GoogleCloudRetailV2RemoveFulfillmentPlacesRequest;
9992/// # async fn dox() {
9993/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9994///
9995/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9996/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9997/// #     .with_native_roots()
9998/// #     .unwrap()
9999/// #     .https_only()
10000/// #     .enable_http2()
10001/// #     .build();
10002///
10003/// # let executor = hyper_util::rt::TokioExecutor::new();
10004/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10005/// #     secret,
10006/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10007/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10008/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10009/// #     ),
10010/// # ).build().await.unwrap();
10011///
10012/// # let client = hyper_util::client::legacy::Client::builder(
10013/// #     hyper_util::rt::TokioExecutor::new()
10014/// # )
10015/// # .build(
10016/// #     hyper_rustls::HttpsConnectorBuilder::new()
10017/// #         .with_native_roots()
10018/// #         .unwrap()
10019/// #         .https_or_http()
10020/// #         .enable_http2()
10021/// #         .build()
10022/// # );
10023/// # let mut hub = CloudRetail::new(client, auth);
10024/// // As the method needs a request, you would usually fill it with the desired information
10025/// // into the respective structure. Some of the parts shown here might not be applicable !
10026/// // Values shown here are possibly random and not representative !
10027/// let mut req = GoogleCloudRetailV2RemoveFulfillmentPlacesRequest::default();
10028///
10029/// // You can configure optional parameters by calling the respective setters at will, and
10030/// // execute the final call using `doit()`.
10031/// // Values shown here are possibly random and not representative !
10032/// let result = hub.projects().locations_catalogs_branches_products_remove_fulfillment_places(req, "product")
10033///              .doit().await;
10034/// # }
10035/// ```
10036pub struct ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C>
10037where
10038    C: 'a,
10039{
10040    hub: &'a CloudRetail<C>,
10041    _request: GoogleCloudRetailV2RemoveFulfillmentPlacesRequest,
10042    _product: String,
10043    _delegate: Option<&'a mut dyn common::Delegate>,
10044    _additional_params: HashMap<String, String>,
10045    _scopes: BTreeSet<String>,
10046}
10047
10048impl<'a, C> common::CallBuilder
10049    for ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C>
10050{
10051}
10052
10053impl<'a, C> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C>
10054where
10055    C: common::Connector,
10056{
10057    /// Perform the operation you have build so far.
10058    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10059        use std::borrow::Cow;
10060        use std::io::{Read, Seek};
10061
10062        use common::{url::Params, ToParts};
10063        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10064
10065        let mut dd = common::DefaultDelegate;
10066        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10067        dlg.begin(common::MethodInfo {
10068            id: "retail.projects.locations.catalogs.branches.products.removeFulfillmentPlaces",
10069            http_method: hyper::Method::POST,
10070        });
10071
10072        for &field in ["alt", "product"].iter() {
10073            if self._additional_params.contains_key(field) {
10074                dlg.finished(false);
10075                return Err(common::Error::FieldClash(field));
10076            }
10077        }
10078
10079        let mut params = Params::with_capacity(4 + self._additional_params.len());
10080        params.push("product", self._product);
10081
10082        params.extend(self._additional_params.iter());
10083
10084        params.push("alt", "json");
10085        let mut url = self.hub._base_url.clone() + "v2/{+product}:removeFulfillmentPlaces";
10086        if self._scopes.is_empty() {
10087            self._scopes
10088                .insert(Scope::CloudPlatform.as_ref().to_string());
10089        }
10090
10091        #[allow(clippy::single_element_loop)]
10092        for &(find_this, param_name) in [("{+product}", "product")].iter() {
10093            url = params.uri_replacement(url, param_name, find_this, true);
10094        }
10095        {
10096            let to_remove = ["product"];
10097            params.remove_params(&to_remove);
10098        }
10099
10100        let url = params.parse_with_url(&url);
10101
10102        let mut json_mime_type = mime::APPLICATION_JSON;
10103        let mut request_value_reader = {
10104            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10105            common::remove_json_null_values(&mut value);
10106            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10107            serde_json::to_writer(&mut dst, &value).unwrap();
10108            dst
10109        };
10110        let request_size = request_value_reader
10111            .seek(std::io::SeekFrom::End(0))
10112            .unwrap();
10113        request_value_reader
10114            .seek(std::io::SeekFrom::Start(0))
10115            .unwrap();
10116
10117        loop {
10118            let token = match self
10119                .hub
10120                .auth
10121                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10122                .await
10123            {
10124                Ok(token) => token,
10125                Err(e) => match dlg.token(e) {
10126                    Ok(token) => token,
10127                    Err(e) => {
10128                        dlg.finished(false);
10129                        return Err(common::Error::MissingToken(e));
10130                    }
10131                },
10132            };
10133            request_value_reader
10134                .seek(std::io::SeekFrom::Start(0))
10135                .unwrap();
10136            let mut req_result = {
10137                let client = &self.hub.client;
10138                dlg.pre_request();
10139                let mut req_builder = hyper::Request::builder()
10140                    .method(hyper::Method::POST)
10141                    .uri(url.as_str())
10142                    .header(USER_AGENT, self.hub._user_agent.clone());
10143
10144                if let Some(token) = token.as_ref() {
10145                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10146                }
10147
10148                let request = req_builder
10149                    .header(CONTENT_TYPE, json_mime_type.to_string())
10150                    .header(CONTENT_LENGTH, request_size as u64)
10151                    .body(common::to_body(
10152                        request_value_reader.get_ref().clone().into(),
10153                    ));
10154
10155                client.request(request.unwrap()).await
10156            };
10157
10158            match req_result {
10159                Err(err) => {
10160                    if let common::Retry::After(d) = dlg.http_error(&err) {
10161                        sleep(d).await;
10162                        continue;
10163                    }
10164                    dlg.finished(false);
10165                    return Err(common::Error::HttpError(err));
10166                }
10167                Ok(res) => {
10168                    let (mut parts, body) = res.into_parts();
10169                    let mut body = common::Body::new(body);
10170                    if !parts.status.is_success() {
10171                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10172                        let error = serde_json::from_str(&common::to_string(&bytes));
10173                        let response = common::to_response(parts, bytes.into());
10174
10175                        if let common::Retry::After(d) =
10176                            dlg.http_failure(&response, error.as_ref().ok())
10177                        {
10178                            sleep(d).await;
10179                            continue;
10180                        }
10181
10182                        dlg.finished(false);
10183
10184                        return Err(match error {
10185                            Ok(value) => common::Error::BadRequest(value),
10186                            _ => common::Error::Failure(response),
10187                        });
10188                    }
10189                    let response = {
10190                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10191                        let encoded = common::to_string(&bytes);
10192                        match serde_json::from_str(&encoded) {
10193                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10194                            Err(error) => {
10195                                dlg.response_json_decode_error(&encoded, &error);
10196                                return Err(common::Error::JsonDecodeError(
10197                                    encoded.to_string(),
10198                                    error,
10199                                ));
10200                            }
10201                        }
10202                    };
10203
10204                    dlg.finished(true);
10205                    return Ok(response);
10206                }
10207            }
10208        }
10209    }
10210
10211    ///
10212    /// Sets the *request* property to the given value.
10213    ///
10214    /// Even though the property as already been set when instantiating this call,
10215    /// we provide this method for API completeness.
10216    pub fn request(
10217        mut self,
10218        new_value: GoogleCloudRetailV2RemoveFulfillmentPlacesRequest,
10219    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C> {
10220        self._request = new_value;
10221        self
10222    }
10223    /// Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
10224    ///
10225    /// Sets the *product* path property to the given value.
10226    ///
10227    /// Even though the property as already been set when instantiating this call,
10228    /// we provide this method for API completeness.
10229    pub fn product(
10230        mut self,
10231        new_value: &str,
10232    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C> {
10233        self._product = new_value.to_string();
10234        self
10235    }
10236    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10237    /// while executing the actual API request.
10238    ///
10239    /// ````text
10240    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10241    /// ````
10242    ///
10243    /// Sets the *delegate* property to the given value.
10244    pub fn delegate(
10245        mut self,
10246        new_value: &'a mut dyn common::Delegate,
10247    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C> {
10248        self._delegate = Some(new_value);
10249        self
10250    }
10251
10252    /// Set any additional parameter of the query string used in the request.
10253    /// It should be used to set parameters which are not yet available through their own
10254    /// setters.
10255    ///
10256    /// Please note that this method must not be used to set any of the known parameters
10257    /// which have their own setter method. If done anyway, the request will fail.
10258    ///
10259    /// # Additional Parameters
10260    ///
10261    /// * *$.xgafv* (query-string) - V1 error format.
10262    /// * *access_token* (query-string) - OAuth access token.
10263    /// * *alt* (query-string) - Data format for response.
10264    /// * *callback* (query-string) - JSONP
10265    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10266    /// * *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.
10267    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10268    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10269    /// * *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.
10270    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10271    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10272    pub fn param<T>(
10273        mut self,
10274        name: T,
10275        value: T,
10276    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C>
10277    where
10278        T: AsRef<str>,
10279    {
10280        self._additional_params
10281            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10282        self
10283    }
10284
10285    /// Identifies the authorization scope for the method you are building.
10286    ///
10287    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10288    /// [`Scope::CloudPlatform`].
10289    ///
10290    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10291    /// tokens for more than one scope.
10292    ///
10293    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10294    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10295    /// sufficient, a read-write scope will do as well.
10296    pub fn add_scope<St>(
10297        mut self,
10298        scope: St,
10299    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C>
10300    where
10301        St: AsRef<str>,
10302    {
10303        self._scopes.insert(String::from(scope.as_ref()));
10304        self
10305    }
10306    /// Identifies the authorization scope(s) for the method you are building.
10307    ///
10308    /// See [`Self::add_scope()`] for details.
10309    pub fn add_scopes<I, St>(
10310        mut self,
10311        scopes: I,
10312    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C>
10313    where
10314        I: IntoIterator<Item = St>,
10315        St: AsRef<str>,
10316    {
10317        self._scopes
10318            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10319        self
10320    }
10321
10322    /// Removes all scopes, and no default scope will be used either.
10323    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10324    /// for details).
10325    pub fn clear_scopes(
10326        mut self,
10327    ) -> ProjectLocationCatalogBranchProductRemoveFulfillmentPlaceCall<'a, C> {
10328        self._scopes.clear();
10329        self
10330    }
10331}
10332
10333/// Remove local inventory information for a Product at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. Local inventory information can only be removed using this method. ProductService.CreateProduct and ProductService.UpdateProduct has no effect on local inventories. The returned Operations will be obsolete after 1 day, and GetOperation API will return NOT_FOUND afterwards. If conflicting updates are issued, the Operations associated with the stale updates will not be marked as done until being obsolete.
10334///
10335/// A builder for the *locations.catalogs.branches.products.removeLocalInventories* method supported by a *project* resource.
10336/// It is not used directly, but through a [`ProjectMethods`] instance.
10337///
10338/// # Example
10339///
10340/// Instantiate a resource method builder
10341///
10342/// ```test_harness,no_run
10343/// # extern crate hyper;
10344/// # extern crate hyper_rustls;
10345/// # extern crate google_retail2 as retail2;
10346/// use retail2::api::GoogleCloudRetailV2RemoveLocalInventoriesRequest;
10347/// # async fn dox() {
10348/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10349///
10350/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10351/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10352/// #     .with_native_roots()
10353/// #     .unwrap()
10354/// #     .https_only()
10355/// #     .enable_http2()
10356/// #     .build();
10357///
10358/// # let executor = hyper_util::rt::TokioExecutor::new();
10359/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10360/// #     secret,
10361/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10362/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10363/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10364/// #     ),
10365/// # ).build().await.unwrap();
10366///
10367/// # let client = hyper_util::client::legacy::Client::builder(
10368/// #     hyper_util::rt::TokioExecutor::new()
10369/// # )
10370/// # .build(
10371/// #     hyper_rustls::HttpsConnectorBuilder::new()
10372/// #         .with_native_roots()
10373/// #         .unwrap()
10374/// #         .https_or_http()
10375/// #         .enable_http2()
10376/// #         .build()
10377/// # );
10378/// # let mut hub = CloudRetail::new(client, auth);
10379/// // As the method needs a request, you would usually fill it with the desired information
10380/// // into the respective structure. Some of the parts shown here might not be applicable !
10381/// // Values shown here are possibly random and not representative !
10382/// let mut req = GoogleCloudRetailV2RemoveLocalInventoriesRequest::default();
10383///
10384/// // You can configure optional parameters by calling the respective setters at will, and
10385/// // execute the final call using `doit()`.
10386/// // Values shown here are possibly random and not representative !
10387/// let result = hub.projects().locations_catalogs_branches_products_remove_local_inventories(req, "product")
10388///              .doit().await;
10389/// # }
10390/// ```
10391pub struct ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C>
10392where
10393    C: 'a,
10394{
10395    hub: &'a CloudRetail<C>,
10396    _request: GoogleCloudRetailV2RemoveLocalInventoriesRequest,
10397    _product: String,
10398    _delegate: Option<&'a mut dyn common::Delegate>,
10399    _additional_params: HashMap<String, String>,
10400    _scopes: BTreeSet<String>,
10401}
10402
10403impl<'a, C> common::CallBuilder
10404    for ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C>
10405{
10406}
10407
10408impl<'a, C> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C>
10409where
10410    C: common::Connector,
10411{
10412    /// Perform the operation you have build so far.
10413    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10414        use std::borrow::Cow;
10415        use std::io::{Read, Seek};
10416
10417        use common::{url::Params, ToParts};
10418        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10419
10420        let mut dd = common::DefaultDelegate;
10421        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10422        dlg.begin(common::MethodInfo {
10423            id: "retail.projects.locations.catalogs.branches.products.removeLocalInventories",
10424            http_method: hyper::Method::POST,
10425        });
10426
10427        for &field in ["alt", "product"].iter() {
10428            if self._additional_params.contains_key(field) {
10429                dlg.finished(false);
10430                return Err(common::Error::FieldClash(field));
10431            }
10432        }
10433
10434        let mut params = Params::with_capacity(4 + self._additional_params.len());
10435        params.push("product", self._product);
10436
10437        params.extend(self._additional_params.iter());
10438
10439        params.push("alt", "json");
10440        let mut url = self.hub._base_url.clone() + "v2/{+product}:removeLocalInventories";
10441        if self._scopes.is_empty() {
10442            self._scopes
10443                .insert(Scope::CloudPlatform.as_ref().to_string());
10444        }
10445
10446        #[allow(clippy::single_element_loop)]
10447        for &(find_this, param_name) in [("{+product}", "product")].iter() {
10448            url = params.uri_replacement(url, param_name, find_this, true);
10449        }
10450        {
10451            let to_remove = ["product"];
10452            params.remove_params(&to_remove);
10453        }
10454
10455        let url = params.parse_with_url(&url);
10456
10457        let mut json_mime_type = mime::APPLICATION_JSON;
10458        let mut request_value_reader = {
10459            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10460            common::remove_json_null_values(&mut value);
10461            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10462            serde_json::to_writer(&mut dst, &value).unwrap();
10463            dst
10464        };
10465        let request_size = request_value_reader
10466            .seek(std::io::SeekFrom::End(0))
10467            .unwrap();
10468        request_value_reader
10469            .seek(std::io::SeekFrom::Start(0))
10470            .unwrap();
10471
10472        loop {
10473            let token = match self
10474                .hub
10475                .auth
10476                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10477                .await
10478            {
10479                Ok(token) => token,
10480                Err(e) => match dlg.token(e) {
10481                    Ok(token) => token,
10482                    Err(e) => {
10483                        dlg.finished(false);
10484                        return Err(common::Error::MissingToken(e));
10485                    }
10486                },
10487            };
10488            request_value_reader
10489                .seek(std::io::SeekFrom::Start(0))
10490                .unwrap();
10491            let mut req_result = {
10492                let client = &self.hub.client;
10493                dlg.pre_request();
10494                let mut req_builder = hyper::Request::builder()
10495                    .method(hyper::Method::POST)
10496                    .uri(url.as_str())
10497                    .header(USER_AGENT, self.hub._user_agent.clone());
10498
10499                if let Some(token) = token.as_ref() {
10500                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10501                }
10502
10503                let request = req_builder
10504                    .header(CONTENT_TYPE, json_mime_type.to_string())
10505                    .header(CONTENT_LENGTH, request_size as u64)
10506                    .body(common::to_body(
10507                        request_value_reader.get_ref().clone().into(),
10508                    ));
10509
10510                client.request(request.unwrap()).await
10511            };
10512
10513            match req_result {
10514                Err(err) => {
10515                    if let common::Retry::After(d) = dlg.http_error(&err) {
10516                        sleep(d).await;
10517                        continue;
10518                    }
10519                    dlg.finished(false);
10520                    return Err(common::Error::HttpError(err));
10521                }
10522                Ok(res) => {
10523                    let (mut parts, body) = res.into_parts();
10524                    let mut body = common::Body::new(body);
10525                    if !parts.status.is_success() {
10526                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10527                        let error = serde_json::from_str(&common::to_string(&bytes));
10528                        let response = common::to_response(parts, bytes.into());
10529
10530                        if let common::Retry::After(d) =
10531                            dlg.http_failure(&response, error.as_ref().ok())
10532                        {
10533                            sleep(d).await;
10534                            continue;
10535                        }
10536
10537                        dlg.finished(false);
10538
10539                        return Err(match error {
10540                            Ok(value) => common::Error::BadRequest(value),
10541                            _ => common::Error::Failure(response),
10542                        });
10543                    }
10544                    let response = {
10545                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10546                        let encoded = common::to_string(&bytes);
10547                        match serde_json::from_str(&encoded) {
10548                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10549                            Err(error) => {
10550                                dlg.response_json_decode_error(&encoded, &error);
10551                                return Err(common::Error::JsonDecodeError(
10552                                    encoded.to_string(),
10553                                    error,
10554                                ));
10555                            }
10556                        }
10557                    };
10558
10559                    dlg.finished(true);
10560                    return Ok(response);
10561                }
10562            }
10563        }
10564    }
10565
10566    ///
10567    /// Sets the *request* property to the given value.
10568    ///
10569    /// Even though the property as already been set when instantiating this call,
10570    /// we provide this method for API completeness.
10571    pub fn request(
10572        mut self,
10573        new_value: GoogleCloudRetailV2RemoveLocalInventoriesRequest,
10574    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C> {
10575        self._request = new_value;
10576        self
10577    }
10578    /// Required. Full resource name of Product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. If the caller does not have permission to access the Product, regardless of whether or not it exists, a PERMISSION_DENIED error is returned.
10579    ///
10580    /// Sets the *product* path property to the given value.
10581    ///
10582    /// Even though the property as already been set when instantiating this call,
10583    /// we provide this method for API completeness.
10584    pub fn product(
10585        mut self,
10586        new_value: &str,
10587    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C> {
10588        self._product = new_value.to_string();
10589        self
10590    }
10591    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10592    /// while executing the actual API request.
10593    ///
10594    /// ````text
10595    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10596    /// ````
10597    ///
10598    /// Sets the *delegate* property to the given value.
10599    pub fn delegate(
10600        mut self,
10601        new_value: &'a mut dyn common::Delegate,
10602    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C> {
10603        self._delegate = Some(new_value);
10604        self
10605    }
10606
10607    /// Set any additional parameter of the query string used in the request.
10608    /// It should be used to set parameters which are not yet available through their own
10609    /// setters.
10610    ///
10611    /// Please note that this method must not be used to set any of the known parameters
10612    /// which have their own setter method. If done anyway, the request will fail.
10613    ///
10614    /// # Additional Parameters
10615    ///
10616    /// * *$.xgafv* (query-string) - V1 error format.
10617    /// * *access_token* (query-string) - OAuth access token.
10618    /// * *alt* (query-string) - Data format for response.
10619    /// * *callback* (query-string) - JSONP
10620    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10621    /// * *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.
10622    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10623    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10624    /// * *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.
10625    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10626    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10627    pub fn param<T>(
10628        mut self,
10629        name: T,
10630        value: T,
10631    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C>
10632    where
10633        T: AsRef<str>,
10634    {
10635        self._additional_params
10636            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10637        self
10638    }
10639
10640    /// Identifies the authorization scope for the method you are building.
10641    ///
10642    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10643    /// [`Scope::CloudPlatform`].
10644    ///
10645    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10646    /// tokens for more than one scope.
10647    ///
10648    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10649    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10650    /// sufficient, a read-write scope will do as well.
10651    pub fn add_scope<St>(
10652        mut self,
10653        scope: St,
10654    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C>
10655    where
10656        St: AsRef<str>,
10657    {
10658        self._scopes.insert(String::from(scope.as_ref()));
10659        self
10660    }
10661    /// Identifies the authorization scope(s) for the method you are building.
10662    ///
10663    /// See [`Self::add_scope()`] for details.
10664    pub fn add_scopes<I, St>(
10665        mut self,
10666        scopes: I,
10667    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C>
10668    where
10669        I: IntoIterator<Item = St>,
10670        St: AsRef<str>,
10671    {
10672        self._scopes
10673            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10674        self
10675    }
10676
10677    /// Removes all scopes, and no default scope will be used either.
10678    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10679    /// for details).
10680    pub fn clear_scopes(
10681        mut self,
10682    ) -> ProjectLocationCatalogBranchProductRemoveLocalInventoryCall<'a, C> {
10683        self._scopes.clear();
10684        self
10685    }
10686}
10687
10688/// Updates inventory information for a Product while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the Product to exist before updating fulfillment information. If the request is valid, the update is enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the Product queried by ProductService.GetProduct or ProductService.ListProducts. When inventory is updated with ProductService.CreateProduct and ProductService.UpdateProduct, the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the ProductService.CreateProduct or ProductService.UpdateProduct request. If no inventory fields are set in CreateProductRequest.product, then any pre-existing inventory information for this product is used. If no inventory fields are set in SetInventoryRequest.set_mask, then any existing inventory information is preserved. Pre-existing inventory information can only be updated with ProductService.SetInventory, ProductService.AddFulfillmentPlaces, and ProductService.RemoveFulfillmentPlaces. The returned Operations is obsolete after one day, and the GetOperation API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the Operations associated with the stale updates are not marked as done until they are obsolete.
10689///
10690/// A builder for the *locations.catalogs.branches.products.setInventory* method supported by a *project* resource.
10691/// It is not used directly, but through a [`ProjectMethods`] instance.
10692///
10693/// # Example
10694///
10695/// Instantiate a resource method builder
10696///
10697/// ```test_harness,no_run
10698/// # extern crate hyper;
10699/// # extern crate hyper_rustls;
10700/// # extern crate google_retail2 as retail2;
10701/// use retail2::api::GoogleCloudRetailV2SetInventoryRequest;
10702/// # async fn dox() {
10703/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10704///
10705/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10706/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10707/// #     .with_native_roots()
10708/// #     .unwrap()
10709/// #     .https_only()
10710/// #     .enable_http2()
10711/// #     .build();
10712///
10713/// # let executor = hyper_util::rt::TokioExecutor::new();
10714/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10715/// #     secret,
10716/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10717/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10718/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10719/// #     ),
10720/// # ).build().await.unwrap();
10721///
10722/// # let client = hyper_util::client::legacy::Client::builder(
10723/// #     hyper_util::rt::TokioExecutor::new()
10724/// # )
10725/// # .build(
10726/// #     hyper_rustls::HttpsConnectorBuilder::new()
10727/// #         .with_native_roots()
10728/// #         .unwrap()
10729/// #         .https_or_http()
10730/// #         .enable_http2()
10731/// #         .build()
10732/// # );
10733/// # let mut hub = CloudRetail::new(client, auth);
10734/// // As the method needs a request, you would usually fill it with the desired information
10735/// // into the respective structure. Some of the parts shown here might not be applicable !
10736/// // Values shown here are possibly random and not representative !
10737/// let mut req = GoogleCloudRetailV2SetInventoryRequest::default();
10738///
10739/// // You can configure optional parameters by calling the respective setters at will, and
10740/// // execute the final call using `doit()`.
10741/// // Values shown here are possibly random and not representative !
10742/// let result = hub.projects().locations_catalogs_branches_products_set_inventory(req, "name")
10743///              .doit().await;
10744/// # }
10745/// ```
10746pub struct ProjectLocationCatalogBranchProductSetInventoryCall<'a, C>
10747where
10748    C: 'a,
10749{
10750    hub: &'a CloudRetail<C>,
10751    _request: GoogleCloudRetailV2SetInventoryRequest,
10752    _name: String,
10753    _delegate: Option<&'a mut dyn common::Delegate>,
10754    _additional_params: HashMap<String, String>,
10755    _scopes: BTreeSet<String>,
10756}
10757
10758impl<'a, C> common::CallBuilder for ProjectLocationCatalogBranchProductSetInventoryCall<'a, C> {}
10759
10760impl<'a, C> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C>
10761where
10762    C: common::Connector,
10763{
10764    /// Perform the operation you have build so far.
10765    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10766        use std::borrow::Cow;
10767        use std::io::{Read, Seek};
10768
10769        use common::{url::Params, ToParts};
10770        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10771
10772        let mut dd = common::DefaultDelegate;
10773        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10774        dlg.begin(common::MethodInfo {
10775            id: "retail.projects.locations.catalogs.branches.products.setInventory",
10776            http_method: hyper::Method::POST,
10777        });
10778
10779        for &field in ["alt", "name"].iter() {
10780            if self._additional_params.contains_key(field) {
10781                dlg.finished(false);
10782                return Err(common::Error::FieldClash(field));
10783            }
10784        }
10785
10786        let mut params = Params::with_capacity(4 + self._additional_params.len());
10787        params.push("name", self._name);
10788
10789        params.extend(self._additional_params.iter());
10790
10791        params.push("alt", "json");
10792        let mut url = self.hub._base_url.clone() + "v2/{+name}:setInventory";
10793        if self._scopes.is_empty() {
10794            self._scopes
10795                .insert(Scope::CloudPlatform.as_ref().to_string());
10796        }
10797
10798        #[allow(clippy::single_element_loop)]
10799        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10800            url = params.uri_replacement(url, param_name, find_this, true);
10801        }
10802        {
10803            let to_remove = ["name"];
10804            params.remove_params(&to_remove);
10805        }
10806
10807        let url = params.parse_with_url(&url);
10808
10809        let mut json_mime_type = mime::APPLICATION_JSON;
10810        let mut request_value_reader = {
10811            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10812            common::remove_json_null_values(&mut value);
10813            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10814            serde_json::to_writer(&mut dst, &value).unwrap();
10815            dst
10816        };
10817        let request_size = request_value_reader
10818            .seek(std::io::SeekFrom::End(0))
10819            .unwrap();
10820        request_value_reader
10821            .seek(std::io::SeekFrom::Start(0))
10822            .unwrap();
10823
10824        loop {
10825            let token = match self
10826                .hub
10827                .auth
10828                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10829                .await
10830            {
10831                Ok(token) => token,
10832                Err(e) => match dlg.token(e) {
10833                    Ok(token) => token,
10834                    Err(e) => {
10835                        dlg.finished(false);
10836                        return Err(common::Error::MissingToken(e));
10837                    }
10838                },
10839            };
10840            request_value_reader
10841                .seek(std::io::SeekFrom::Start(0))
10842                .unwrap();
10843            let mut req_result = {
10844                let client = &self.hub.client;
10845                dlg.pre_request();
10846                let mut req_builder = hyper::Request::builder()
10847                    .method(hyper::Method::POST)
10848                    .uri(url.as_str())
10849                    .header(USER_AGENT, self.hub._user_agent.clone());
10850
10851                if let Some(token) = token.as_ref() {
10852                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10853                }
10854
10855                let request = req_builder
10856                    .header(CONTENT_TYPE, json_mime_type.to_string())
10857                    .header(CONTENT_LENGTH, request_size as u64)
10858                    .body(common::to_body(
10859                        request_value_reader.get_ref().clone().into(),
10860                    ));
10861
10862                client.request(request.unwrap()).await
10863            };
10864
10865            match req_result {
10866                Err(err) => {
10867                    if let common::Retry::After(d) = dlg.http_error(&err) {
10868                        sleep(d).await;
10869                        continue;
10870                    }
10871                    dlg.finished(false);
10872                    return Err(common::Error::HttpError(err));
10873                }
10874                Ok(res) => {
10875                    let (mut parts, body) = res.into_parts();
10876                    let mut body = common::Body::new(body);
10877                    if !parts.status.is_success() {
10878                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10879                        let error = serde_json::from_str(&common::to_string(&bytes));
10880                        let response = common::to_response(parts, bytes.into());
10881
10882                        if let common::Retry::After(d) =
10883                            dlg.http_failure(&response, error.as_ref().ok())
10884                        {
10885                            sleep(d).await;
10886                            continue;
10887                        }
10888
10889                        dlg.finished(false);
10890
10891                        return Err(match error {
10892                            Ok(value) => common::Error::BadRequest(value),
10893                            _ => common::Error::Failure(response),
10894                        });
10895                    }
10896                    let response = {
10897                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10898                        let encoded = common::to_string(&bytes);
10899                        match serde_json::from_str(&encoded) {
10900                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10901                            Err(error) => {
10902                                dlg.response_json_decode_error(&encoded, &error);
10903                                return Err(common::Error::JsonDecodeError(
10904                                    encoded.to_string(),
10905                                    error,
10906                                ));
10907                            }
10908                        }
10909                    };
10910
10911                    dlg.finished(true);
10912                    return Ok(response);
10913                }
10914            }
10915        }
10916    }
10917
10918    ///
10919    /// Sets the *request* property to the given value.
10920    ///
10921    /// Even though the property as already been set when instantiating this call,
10922    /// we provide this method for API completeness.
10923    pub fn request(
10924        mut self,
10925        new_value: GoogleCloudRetailV2SetInventoryRequest,
10926    ) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C> {
10927        self._request = new_value;
10928        self
10929    }
10930    /// Immutable. Full resource name of the product, such as `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`.
10931    ///
10932    /// Sets the *name* path property to the given value.
10933    ///
10934    /// Even though the property as already been set when instantiating this call,
10935    /// we provide this method for API completeness.
10936    pub fn name(
10937        mut self,
10938        new_value: &str,
10939    ) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C> {
10940        self._name = new_value.to_string();
10941        self
10942    }
10943    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10944    /// while executing the actual API request.
10945    ///
10946    /// ````text
10947    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10948    /// ````
10949    ///
10950    /// Sets the *delegate* property to the given value.
10951    pub fn delegate(
10952        mut self,
10953        new_value: &'a mut dyn common::Delegate,
10954    ) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C> {
10955        self._delegate = Some(new_value);
10956        self
10957    }
10958
10959    /// Set any additional parameter of the query string used in the request.
10960    /// It should be used to set parameters which are not yet available through their own
10961    /// setters.
10962    ///
10963    /// Please note that this method must not be used to set any of the known parameters
10964    /// which have their own setter method. If done anyway, the request will fail.
10965    ///
10966    /// # Additional Parameters
10967    ///
10968    /// * *$.xgafv* (query-string) - V1 error format.
10969    /// * *access_token* (query-string) - OAuth access token.
10970    /// * *alt* (query-string) - Data format for response.
10971    /// * *callback* (query-string) - JSONP
10972    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10973    /// * *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.
10974    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10975    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10976    /// * *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.
10977    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10978    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10979    pub fn param<T>(
10980        mut self,
10981        name: T,
10982        value: T,
10983    ) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C>
10984    where
10985        T: AsRef<str>,
10986    {
10987        self._additional_params
10988            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10989        self
10990    }
10991
10992    /// Identifies the authorization scope for the method you are building.
10993    ///
10994    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10995    /// [`Scope::CloudPlatform`].
10996    ///
10997    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10998    /// tokens for more than one scope.
10999    ///
11000    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11001    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11002    /// sufficient, a read-write scope will do as well.
11003    pub fn add_scope<St>(
11004        mut self,
11005        scope: St,
11006    ) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C>
11007    where
11008        St: AsRef<str>,
11009    {
11010        self._scopes.insert(String::from(scope.as_ref()));
11011        self
11012    }
11013    /// Identifies the authorization scope(s) for the method you are building.
11014    ///
11015    /// See [`Self::add_scope()`] for details.
11016    pub fn add_scopes<I, St>(
11017        mut self,
11018        scopes: I,
11019    ) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C>
11020    where
11021        I: IntoIterator<Item = St>,
11022        St: AsRef<str>,
11023    {
11024        self._scopes
11025            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11026        self
11027    }
11028
11029    /// Removes all scopes, and no default scope will be used either.
11030    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11031    /// for details).
11032    pub fn clear_scopes(mut self) -> ProjectLocationCatalogBranchProductSetInventoryCall<'a, C> {
11033        self._scopes.clear();
11034        self
11035    }
11036}
11037
11038/// Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
11039///
11040/// A builder for the *locations.catalogs.completionData.import* method supported by a *project* resource.
11041/// It is not used directly, but through a [`ProjectMethods`] instance.
11042///
11043/// # Example
11044///
11045/// Instantiate a resource method builder
11046///
11047/// ```test_harness,no_run
11048/// # extern crate hyper;
11049/// # extern crate hyper_rustls;
11050/// # extern crate google_retail2 as retail2;
11051/// use retail2::api::GoogleCloudRetailV2ImportCompletionDataRequest;
11052/// # async fn dox() {
11053/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11054///
11055/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11056/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11057/// #     .with_native_roots()
11058/// #     .unwrap()
11059/// #     .https_only()
11060/// #     .enable_http2()
11061/// #     .build();
11062///
11063/// # let executor = hyper_util::rt::TokioExecutor::new();
11064/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11065/// #     secret,
11066/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11067/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11068/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11069/// #     ),
11070/// # ).build().await.unwrap();
11071///
11072/// # let client = hyper_util::client::legacy::Client::builder(
11073/// #     hyper_util::rt::TokioExecutor::new()
11074/// # )
11075/// # .build(
11076/// #     hyper_rustls::HttpsConnectorBuilder::new()
11077/// #         .with_native_roots()
11078/// #         .unwrap()
11079/// #         .https_or_http()
11080/// #         .enable_http2()
11081/// #         .build()
11082/// # );
11083/// # let mut hub = CloudRetail::new(client, auth);
11084/// // As the method needs a request, you would usually fill it with the desired information
11085/// // into the respective structure. Some of the parts shown here might not be applicable !
11086/// // Values shown here are possibly random and not representative !
11087/// let mut req = GoogleCloudRetailV2ImportCompletionDataRequest::default();
11088///
11089/// // You can configure optional parameters by calling the respective setters at will, and
11090/// // execute the final call using `doit()`.
11091/// // Values shown here are possibly random and not representative !
11092/// let result = hub.projects().locations_catalogs_completion_data_import(req, "parent")
11093///              .doit().await;
11094/// # }
11095/// ```
11096pub struct ProjectLocationCatalogCompletionDataImportCall<'a, C>
11097where
11098    C: 'a,
11099{
11100    hub: &'a CloudRetail<C>,
11101    _request: GoogleCloudRetailV2ImportCompletionDataRequest,
11102    _parent: String,
11103    _delegate: Option<&'a mut dyn common::Delegate>,
11104    _additional_params: HashMap<String, String>,
11105    _scopes: BTreeSet<String>,
11106}
11107
11108impl<'a, C> common::CallBuilder for ProjectLocationCatalogCompletionDataImportCall<'a, C> {}
11109
11110impl<'a, C> ProjectLocationCatalogCompletionDataImportCall<'a, C>
11111where
11112    C: common::Connector,
11113{
11114    /// Perform the operation you have build so far.
11115    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
11116        use std::borrow::Cow;
11117        use std::io::{Read, Seek};
11118
11119        use common::{url::Params, ToParts};
11120        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11121
11122        let mut dd = common::DefaultDelegate;
11123        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11124        dlg.begin(common::MethodInfo {
11125            id: "retail.projects.locations.catalogs.completionData.import",
11126            http_method: hyper::Method::POST,
11127        });
11128
11129        for &field in ["alt", "parent"].iter() {
11130            if self._additional_params.contains_key(field) {
11131                dlg.finished(false);
11132                return Err(common::Error::FieldClash(field));
11133            }
11134        }
11135
11136        let mut params = Params::with_capacity(4 + self._additional_params.len());
11137        params.push("parent", self._parent);
11138
11139        params.extend(self._additional_params.iter());
11140
11141        params.push("alt", "json");
11142        let mut url = self.hub._base_url.clone() + "v2/{+parent}/completionData:import";
11143        if self._scopes.is_empty() {
11144            self._scopes
11145                .insert(Scope::CloudPlatform.as_ref().to_string());
11146        }
11147
11148        #[allow(clippy::single_element_loop)]
11149        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11150            url = params.uri_replacement(url, param_name, find_this, true);
11151        }
11152        {
11153            let to_remove = ["parent"];
11154            params.remove_params(&to_remove);
11155        }
11156
11157        let url = params.parse_with_url(&url);
11158
11159        let mut json_mime_type = mime::APPLICATION_JSON;
11160        let mut request_value_reader = {
11161            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11162            common::remove_json_null_values(&mut value);
11163            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11164            serde_json::to_writer(&mut dst, &value).unwrap();
11165            dst
11166        };
11167        let request_size = request_value_reader
11168            .seek(std::io::SeekFrom::End(0))
11169            .unwrap();
11170        request_value_reader
11171            .seek(std::io::SeekFrom::Start(0))
11172            .unwrap();
11173
11174        loop {
11175            let token = match self
11176                .hub
11177                .auth
11178                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11179                .await
11180            {
11181                Ok(token) => token,
11182                Err(e) => match dlg.token(e) {
11183                    Ok(token) => token,
11184                    Err(e) => {
11185                        dlg.finished(false);
11186                        return Err(common::Error::MissingToken(e));
11187                    }
11188                },
11189            };
11190            request_value_reader
11191                .seek(std::io::SeekFrom::Start(0))
11192                .unwrap();
11193            let mut req_result = {
11194                let client = &self.hub.client;
11195                dlg.pre_request();
11196                let mut req_builder = hyper::Request::builder()
11197                    .method(hyper::Method::POST)
11198                    .uri(url.as_str())
11199                    .header(USER_AGENT, self.hub._user_agent.clone());
11200
11201                if let Some(token) = token.as_ref() {
11202                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11203                }
11204
11205                let request = req_builder
11206                    .header(CONTENT_TYPE, json_mime_type.to_string())
11207                    .header(CONTENT_LENGTH, request_size as u64)
11208                    .body(common::to_body(
11209                        request_value_reader.get_ref().clone().into(),
11210                    ));
11211
11212                client.request(request.unwrap()).await
11213            };
11214
11215            match req_result {
11216                Err(err) => {
11217                    if let common::Retry::After(d) = dlg.http_error(&err) {
11218                        sleep(d).await;
11219                        continue;
11220                    }
11221                    dlg.finished(false);
11222                    return Err(common::Error::HttpError(err));
11223                }
11224                Ok(res) => {
11225                    let (mut parts, body) = res.into_parts();
11226                    let mut body = common::Body::new(body);
11227                    if !parts.status.is_success() {
11228                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11229                        let error = serde_json::from_str(&common::to_string(&bytes));
11230                        let response = common::to_response(parts, bytes.into());
11231
11232                        if let common::Retry::After(d) =
11233                            dlg.http_failure(&response, error.as_ref().ok())
11234                        {
11235                            sleep(d).await;
11236                            continue;
11237                        }
11238
11239                        dlg.finished(false);
11240
11241                        return Err(match error {
11242                            Ok(value) => common::Error::BadRequest(value),
11243                            _ => common::Error::Failure(response),
11244                        });
11245                    }
11246                    let response = {
11247                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11248                        let encoded = common::to_string(&bytes);
11249                        match serde_json::from_str(&encoded) {
11250                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11251                            Err(error) => {
11252                                dlg.response_json_decode_error(&encoded, &error);
11253                                return Err(common::Error::JsonDecodeError(
11254                                    encoded.to_string(),
11255                                    error,
11256                                ));
11257                            }
11258                        }
11259                    };
11260
11261                    dlg.finished(true);
11262                    return Ok(response);
11263                }
11264            }
11265        }
11266    }
11267
11268    ///
11269    /// Sets the *request* property to the given value.
11270    ///
11271    /// Even though the property as already been set when instantiating this call,
11272    /// we provide this method for API completeness.
11273    pub fn request(
11274        mut self,
11275        new_value: GoogleCloudRetailV2ImportCompletionDataRequest,
11276    ) -> ProjectLocationCatalogCompletionDataImportCall<'a, C> {
11277        self._request = new_value;
11278        self
11279    }
11280    /// Required. The catalog which the suggestions dataset belongs to. Format: `projects/1234/locations/global/catalogs/default_catalog`.
11281    ///
11282    /// Sets the *parent* path property to the given value.
11283    ///
11284    /// Even though the property as already been set when instantiating this call,
11285    /// we provide this method for API completeness.
11286    pub fn parent(
11287        mut self,
11288        new_value: &str,
11289    ) -> ProjectLocationCatalogCompletionDataImportCall<'a, C> {
11290        self._parent = new_value.to_string();
11291        self
11292    }
11293    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11294    /// while executing the actual API request.
11295    ///
11296    /// ````text
11297    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11298    /// ````
11299    ///
11300    /// Sets the *delegate* property to the given value.
11301    pub fn delegate(
11302        mut self,
11303        new_value: &'a mut dyn common::Delegate,
11304    ) -> ProjectLocationCatalogCompletionDataImportCall<'a, C> {
11305        self._delegate = Some(new_value);
11306        self
11307    }
11308
11309    /// Set any additional parameter of the query string used in the request.
11310    /// It should be used to set parameters which are not yet available through their own
11311    /// setters.
11312    ///
11313    /// Please note that this method must not be used to set any of the known parameters
11314    /// which have their own setter method. If done anyway, the request will fail.
11315    ///
11316    /// # Additional Parameters
11317    ///
11318    /// * *$.xgafv* (query-string) - V1 error format.
11319    /// * *access_token* (query-string) - OAuth access token.
11320    /// * *alt* (query-string) - Data format for response.
11321    /// * *callback* (query-string) - JSONP
11322    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11323    /// * *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.
11324    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11325    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11326    /// * *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.
11327    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11328    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11329    pub fn param<T>(
11330        mut self,
11331        name: T,
11332        value: T,
11333    ) -> ProjectLocationCatalogCompletionDataImportCall<'a, C>
11334    where
11335        T: AsRef<str>,
11336    {
11337        self._additional_params
11338            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11339        self
11340    }
11341
11342    /// Identifies the authorization scope for the method you are building.
11343    ///
11344    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11345    /// [`Scope::CloudPlatform`].
11346    ///
11347    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11348    /// tokens for more than one scope.
11349    ///
11350    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11351    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11352    /// sufficient, a read-write scope will do as well.
11353    pub fn add_scope<St>(
11354        mut self,
11355        scope: St,
11356    ) -> ProjectLocationCatalogCompletionDataImportCall<'a, C>
11357    where
11358        St: AsRef<str>,
11359    {
11360        self._scopes.insert(String::from(scope.as_ref()));
11361        self
11362    }
11363    /// Identifies the authorization scope(s) for the method you are building.
11364    ///
11365    /// See [`Self::add_scope()`] for details.
11366    pub fn add_scopes<I, St>(
11367        mut self,
11368        scopes: I,
11369    ) -> ProjectLocationCatalogCompletionDataImportCall<'a, C>
11370    where
11371        I: IntoIterator<Item = St>,
11372        St: AsRef<str>,
11373    {
11374        self._scopes
11375            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11376        self
11377    }
11378
11379    /// Removes all scopes, and no default scope will be used either.
11380    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11381    /// for details).
11382    pub fn clear_scopes(mut self) -> ProjectLocationCatalogCompletionDataImportCall<'a, C> {
11383        self._scopes.clear();
11384        self
11385    }
11386}
11387
11388/// Creates a Control. If the Control to create already exists, an ALREADY_EXISTS error is returned.
11389///
11390/// A builder for the *locations.catalogs.controls.create* method supported by a *project* resource.
11391/// It is not used directly, but through a [`ProjectMethods`] instance.
11392///
11393/// # Example
11394///
11395/// Instantiate a resource method builder
11396///
11397/// ```test_harness,no_run
11398/// # extern crate hyper;
11399/// # extern crate hyper_rustls;
11400/// # extern crate google_retail2 as retail2;
11401/// use retail2::api::GoogleCloudRetailV2Control;
11402/// # async fn dox() {
11403/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11404///
11405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11406/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11407/// #     .with_native_roots()
11408/// #     .unwrap()
11409/// #     .https_only()
11410/// #     .enable_http2()
11411/// #     .build();
11412///
11413/// # let executor = hyper_util::rt::TokioExecutor::new();
11414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11415/// #     secret,
11416/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11417/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11418/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11419/// #     ),
11420/// # ).build().await.unwrap();
11421///
11422/// # let client = hyper_util::client::legacy::Client::builder(
11423/// #     hyper_util::rt::TokioExecutor::new()
11424/// # )
11425/// # .build(
11426/// #     hyper_rustls::HttpsConnectorBuilder::new()
11427/// #         .with_native_roots()
11428/// #         .unwrap()
11429/// #         .https_or_http()
11430/// #         .enable_http2()
11431/// #         .build()
11432/// # );
11433/// # let mut hub = CloudRetail::new(client, auth);
11434/// // As the method needs a request, you would usually fill it with the desired information
11435/// // into the respective structure. Some of the parts shown here might not be applicable !
11436/// // Values shown here are possibly random and not representative !
11437/// let mut req = GoogleCloudRetailV2Control::default();
11438///
11439/// // You can configure optional parameters by calling the respective setters at will, and
11440/// // execute the final call using `doit()`.
11441/// // Values shown here are possibly random and not representative !
11442/// let result = hub.projects().locations_catalogs_controls_create(req, "parent")
11443///              .control_id("Lorem")
11444///              .doit().await;
11445/// # }
11446/// ```
11447pub struct ProjectLocationCatalogControlCreateCall<'a, C>
11448where
11449    C: 'a,
11450{
11451    hub: &'a CloudRetail<C>,
11452    _request: GoogleCloudRetailV2Control,
11453    _parent: String,
11454    _control_id: Option<String>,
11455    _delegate: Option<&'a mut dyn common::Delegate>,
11456    _additional_params: HashMap<String, String>,
11457    _scopes: BTreeSet<String>,
11458}
11459
11460impl<'a, C> common::CallBuilder for ProjectLocationCatalogControlCreateCall<'a, C> {}
11461
11462impl<'a, C> ProjectLocationCatalogControlCreateCall<'a, C>
11463where
11464    C: common::Connector,
11465{
11466    /// Perform the operation you have build so far.
11467    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Control)> {
11468        use std::borrow::Cow;
11469        use std::io::{Read, Seek};
11470
11471        use common::{url::Params, ToParts};
11472        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11473
11474        let mut dd = common::DefaultDelegate;
11475        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11476        dlg.begin(common::MethodInfo {
11477            id: "retail.projects.locations.catalogs.controls.create",
11478            http_method: hyper::Method::POST,
11479        });
11480
11481        for &field in ["alt", "parent", "controlId"].iter() {
11482            if self._additional_params.contains_key(field) {
11483                dlg.finished(false);
11484                return Err(common::Error::FieldClash(field));
11485            }
11486        }
11487
11488        let mut params = Params::with_capacity(5 + self._additional_params.len());
11489        params.push("parent", self._parent);
11490        if let Some(value) = self._control_id.as_ref() {
11491            params.push("controlId", value);
11492        }
11493
11494        params.extend(self._additional_params.iter());
11495
11496        params.push("alt", "json");
11497        let mut url = self.hub._base_url.clone() + "v2/{+parent}/controls";
11498        if self._scopes.is_empty() {
11499            self._scopes
11500                .insert(Scope::CloudPlatform.as_ref().to_string());
11501        }
11502
11503        #[allow(clippy::single_element_loop)]
11504        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11505            url = params.uri_replacement(url, param_name, find_this, true);
11506        }
11507        {
11508            let to_remove = ["parent"];
11509            params.remove_params(&to_remove);
11510        }
11511
11512        let url = params.parse_with_url(&url);
11513
11514        let mut json_mime_type = mime::APPLICATION_JSON;
11515        let mut request_value_reader = {
11516            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11517            common::remove_json_null_values(&mut value);
11518            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11519            serde_json::to_writer(&mut dst, &value).unwrap();
11520            dst
11521        };
11522        let request_size = request_value_reader
11523            .seek(std::io::SeekFrom::End(0))
11524            .unwrap();
11525        request_value_reader
11526            .seek(std::io::SeekFrom::Start(0))
11527            .unwrap();
11528
11529        loop {
11530            let token = match self
11531                .hub
11532                .auth
11533                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11534                .await
11535            {
11536                Ok(token) => token,
11537                Err(e) => match dlg.token(e) {
11538                    Ok(token) => token,
11539                    Err(e) => {
11540                        dlg.finished(false);
11541                        return Err(common::Error::MissingToken(e));
11542                    }
11543                },
11544            };
11545            request_value_reader
11546                .seek(std::io::SeekFrom::Start(0))
11547                .unwrap();
11548            let mut req_result = {
11549                let client = &self.hub.client;
11550                dlg.pre_request();
11551                let mut req_builder = hyper::Request::builder()
11552                    .method(hyper::Method::POST)
11553                    .uri(url.as_str())
11554                    .header(USER_AGENT, self.hub._user_agent.clone());
11555
11556                if let Some(token) = token.as_ref() {
11557                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11558                }
11559
11560                let request = req_builder
11561                    .header(CONTENT_TYPE, json_mime_type.to_string())
11562                    .header(CONTENT_LENGTH, request_size as u64)
11563                    .body(common::to_body(
11564                        request_value_reader.get_ref().clone().into(),
11565                    ));
11566
11567                client.request(request.unwrap()).await
11568            };
11569
11570            match req_result {
11571                Err(err) => {
11572                    if let common::Retry::After(d) = dlg.http_error(&err) {
11573                        sleep(d).await;
11574                        continue;
11575                    }
11576                    dlg.finished(false);
11577                    return Err(common::Error::HttpError(err));
11578                }
11579                Ok(res) => {
11580                    let (mut parts, body) = res.into_parts();
11581                    let mut body = common::Body::new(body);
11582                    if !parts.status.is_success() {
11583                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11584                        let error = serde_json::from_str(&common::to_string(&bytes));
11585                        let response = common::to_response(parts, bytes.into());
11586
11587                        if let common::Retry::After(d) =
11588                            dlg.http_failure(&response, error.as_ref().ok())
11589                        {
11590                            sleep(d).await;
11591                            continue;
11592                        }
11593
11594                        dlg.finished(false);
11595
11596                        return Err(match error {
11597                            Ok(value) => common::Error::BadRequest(value),
11598                            _ => common::Error::Failure(response),
11599                        });
11600                    }
11601                    let response = {
11602                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11603                        let encoded = common::to_string(&bytes);
11604                        match serde_json::from_str(&encoded) {
11605                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11606                            Err(error) => {
11607                                dlg.response_json_decode_error(&encoded, &error);
11608                                return Err(common::Error::JsonDecodeError(
11609                                    encoded.to_string(),
11610                                    error,
11611                                ));
11612                            }
11613                        }
11614                    };
11615
11616                    dlg.finished(true);
11617                    return Ok(response);
11618                }
11619            }
11620        }
11621    }
11622
11623    ///
11624    /// Sets the *request* property to the given value.
11625    ///
11626    /// Even though the property as already been set when instantiating this call,
11627    /// we provide this method for API completeness.
11628    pub fn request(
11629        mut self,
11630        new_value: GoogleCloudRetailV2Control,
11631    ) -> ProjectLocationCatalogControlCreateCall<'a, C> {
11632        self._request = new_value;
11633        self
11634    }
11635    /// Required. Full resource name of parent catalog. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
11636    ///
11637    /// Sets the *parent* path property to the given value.
11638    ///
11639    /// Even though the property as already been set when instantiating this call,
11640    /// we provide this method for API completeness.
11641    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogControlCreateCall<'a, C> {
11642        self._parent = new_value.to_string();
11643        self
11644    }
11645    /// Required. The ID to use for the Control, which will become the final component of the Control's resource name. This value should be 4-63 characters, and valid characters are /a-z-_/.
11646    ///
11647    /// Sets the *control id* query property to the given value.
11648    pub fn control_id(mut self, new_value: &str) -> ProjectLocationCatalogControlCreateCall<'a, C> {
11649        self._control_id = Some(new_value.to_string());
11650        self
11651    }
11652    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11653    /// while executing the actual API request.
11654    ///
11655    /// ````text
11656    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11657    /// ````
11658    ///
11659    /// Sets the *delegate* property to the given value.
11660    pub fn delegate(
11661        mut self,
11662        new_value: &'a mut dyn common::Delegate,
11663    ) -> ProjectLocationCatalogControlCreateCall<'a, C> {
11664        self._delegate = Some(new_value);
11665        self
11666    }
11667
11668    /// Set any additional parameter of the query string used in the request.
11669    /// It should be used to set parameters which are not yet available through their own
11670    /// setters.
11671    ///
11672    /// Please note that this method must not be used to set any of the known parameters
11673    /// which have their own setter method. If done anyway, the request will fail.
11674    ///
11675    /// # Additional Parameters
11676    ///
11677    /// * *$.xgafv* (query-string) - V1 error format.
11678    /// * *access_token* (query-string) - OAuth access token.
11679    /// * *alt* (query-string) - Data format for response.
11680    /// * *callback* (query-string) - JSONP
11681    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11682    /// * *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.
11683    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11684    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11685    /// * *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.
11686    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11687    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11688    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogControlCreateCall<'a, C>
11689    where
11690        T: AsRef<str>,
11691    {
11692        self._additional_params
11693            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11694        self
11695    }
11696
11697    /// Identifies the authorization scope for the method you are building.
11698    ///
11699    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11700    /// [`Scope::CloudPlatform`].
11701    ///
11702    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11703    /// tokens for more than one scope.
11704    ///
11705    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11706    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11707    /// sufficient, a read-write scope will do as well.
11708    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogControlCreateCall<'a, C>
11709    where
11710        St: AsRef<str>,
11711    {
11712        self._scopes.insert(String::from(scope.as_ref()));
11713        self
11714    }
11715    /// Identifies the authorization scope(s) for the method you are building.
11716    ///
11717    /// See [`Self::add_scope()`] for details.
11718    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogControlCreateCall<'a, C>
11719    where
11720        I: IntoIterator<Item = St>,
11721        St: AsRef<str>,
11722    {
11723        self._scopes
11724            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11725        self
11726    }
11727
11728    /// Removes all scopes, and no default scope will be used either.
11729    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11730    /// for details).
11731    pub fn clear_scopes(mut self) -> ProjectLocationCatalogControlCreateCall<'a, C> {
11732        self._scopes.clear();
11733        self
11734    }
11735}
11736
11737/// Deletes a Control. If the Control to delete does not exist, a NOT_FOUND error is returned.
11738///
11739/// A builder for the *locations.catalogs.controls.delete* method supported by a *project* resource.
11740/// It is not used directly, but through a [`ProjectMethods`] instance.
11741///
11742/// # Example
11743///
11744/// Instantiate a resource method builder
11745///
11746/// ```test_harness,no_run
11747/// # extern crate hyper;
11748/// # extern crate hyper_rustls;
11749/// # extern crate google_retail2 as retail2;
11750/// # async fn dox() {
11751/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11752///
11753/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11754/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11755/// #     .with_native_roots()
11756/// #     .unwrap()
11757/// #     .https_only()
11758/// #     .enable_http2()
11759/// #     .build();
11760///
11761/// # let executor = hyper_util::rt::TokioExecutor::new();
11762/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11763/// #     secret,
11764/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11765/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11766/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11767/// #     ),
11768/// # ).build().await.unwrap();
11769///
11770/// # let client = hyper_util::client::legacy::Client::builder(
11771/// #     hyper_util::rt::TokioExecutor::new()
11772/// # )
11773/// # .build(
11774/// #     hyper_rustls::HttpsConnectorBuilder::new()
11775/// #         .with_native_roots()
11776/// #         .unwrap()
11777/// #         .https_or_http()
11778/// #         .enable_http2()
11779/// #         .build()
11780/// # );
11781/// # let mut hub = CloudRetail::new(client, auth);
11782/// // You can configure optional parameters by calling the respective setters at will, and
11783/// // execute the final call using `doit()`.
11784/// // Values shown here are possibly random and not representative !
11785/// let result = hub.projects().locations_catalogs_controls_delete("name")
11786///              .doit().await;
11787/// # }
11788/// ```
11789pub struct ProjectLocationCatalogControlDeleteCall<'a, C>
11790where
11791    C: 'a,
11792{
11793    hub: &'a CloudRetail<C>,
11794    _name: String,
11795    _delegate: Option<&'a mut dyn common::Delegate>,
11796    _additional_params: HashMap<String, String>,
11797    _scopes: BTreeSet<String>,
11798}
11799
11800impl<'a, C> common::CallBuilder for ProjectLocationCatalogControlDeleteCall<'a, C> {}
11801
11802impl<'a, C> ProjectLocationCatalogControlDeleteCall<'a, C>
11803where
11804    C: common::Connector,
11805{
11806    /// Perform the operation you have build so far.
11807    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
11808        use std::borrow::Cow;
11809        use std::io::{Read, Seek};
11810
11811        use common::{url::Params, ToParts};
11812        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11813
11814        let mut dd = common::DefaultDelegate;
11815        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11816        dlg.begin(common::MethodInfo {
11817            id: "retail.projects.locations.catalogs.controls.delete",
11818            http_method: hyper::Method::DELETE,
11819        });
11820
11821        for &field in ["alt", "name"].iter() {
11822            if self._additional_params.contains_key(field) {
11823                dlg.finished(false);
11824                return Err(common::Error::FieldClash(field));
11825            }
11826        }
11827
11828        let mut params = Params::with_capacity(3 + self._additional_params.len());
11829        params.push("name", self._name);
11830
11831        params.extend(self._additional_params.iter());
11832
11833        params.push("alt", "json");
11834        let mut url = self.hub._base_url.clone() + "v2/{+name}";
11835        if self._scopes.is_empty() {
11836            self._scopes
11837                .insert(Scope::CloudPlatform.as_ref().to_string());
11838        }
11839
11840        #[allow(clippy::single_element_loop)]
11841        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11842            url = params.uri_replacement(url, param_name, find_this, true);
11843        }
11844        {
11845            let to_remove = ["name"];
11846            params.remove_params(&to_remove);
11847        }
11848
11849        let url = params.parse_with_url(&url);
11850
11851        loop {
11852            let token = match self
11853                .hub
11854                .auth
11855                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11856                .await
11857            {
11858                Ok(token) => token,
11859                Err(e) => match dlg.token(e) {
11860                    Ok(token) => token,
11861                    Err(e) => {
11862                        dlg.finished(false);
11863                        return Err(common::Error::MissingToken(e));
11864                    }
11865                },
11866            };
11867            let mut req_result = {
11868                let client = &self.hub.client;
11869                dlg.pre_request();
11870                let mut req_builder = hyper::Request::builder()
11871                    .method(hyper::Method::DELETE)
11872                    .uri(url.as_str())
11873                    .header(USER_AGENT, self.hub._user_agent.clone());
11874
11875                if let Some(token) = token.as_ref() {
11876                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11877                }
11878
11879                let request = req_builder
11880                    .header(CONTENT_LENGTH, 0_u64)
11881                    .body(common::to_body::<String>(None));
11882
11883                client.request(request.unwrap()).await
11884            };
11885
11886            match req_result {
11887                Err(err) => {
11888                    if let common::Retry::After(d) = dlg.http_error(&err) {
11889                        sleep(d).await;
11890                        continue;
11891                    }
11892                    dlg.finished(false);
11893                    return Err(common::Error::HttpError(err));
11894                }
11895                Ok(res) => {
11896                    let (mut parts, body) = res.into_parts();
11897                    let mut body = common::Body::new(body);
11898                    if !parts.status.is_success() {
11899                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11900                        let error = serde_json::from_str(&common::to_string(&bytes));
11901                        let response = common::to_response(parts, bytes.into());
11902
11903                        if let common::Retry::After(d) =
11904                            dlg.http_failure(&response, error.as_ref().ok())
11905                        {
11906                            sleep(d).await;
11907                            continue;
11908                        }
11909
11910                        dlg.finished(false);
11911
11912                        return Err(match error {
11913                            Ok(value) => common::Error::BadRequest(value),
11914                            _ => common::Error::Failure(response),
11915                        });
11916                    }
11917                    let response = {
11918                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11919                        let encoded = common::to_string(&bytes);
11920                        match serde_json::from_str(&encoded) {
11921                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11922                            Err(error) => {
11923                                dlg.response_json_decode_error(&encoded, &error);
11924                                return Err(common::Error::JsonDecodeError(
11925                                    encoded.to_string(),
11926                                    error,
11927                                ));
11928                            }
11929                        }
11930                    };
11931
11932                    dlg.finished(true);
11933                    return Ok(response);
11934                }
11935            }
11936        }
11937    }
11938
11939    /// Required. The resource name of the Control to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
11940    ///
11941    /// Sets the *name* path property to the given value.
11942    ///
11943    /// Even though the property as already been set when instantiating this call,
11944    /// we provide this method for API completeness.
11945    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogControlDeleteCall<'a, C> {
11946        self._name = new_value.to_string();
11947        self
11948    }
11949    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11950    /// while executing the actual API request.
11951    ///
11952    /// ````text
11953    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11954    /// ````
11955    ///
11956    /// Sets the *delegate* property to the given value.
11957    pub fn delegate(
11958        mut self,
11959        new_value: &'a mut dyn common::Delegate,
11960    ) -> ProjectLocationCatalogControlDeleteCall<'a, C> {
11961        self._delegate = Some(new_value);
11962        self
11963    }
11964
11965    /// Set any additional parameter of the query string used in the request.
11966    /// It should be used to set parameters which are not yet available through their own
11967    /// setters.
11968    ///
11969    /// Please note that this method must not be used to set any of the known parameters
11970    /// which have their own setter method. If done anyway, the request will fail.
11971    ///
11972    /// # Additional Parameters
11973    ///
11974    /// * *$.xgafv* (query-string) - V1 error format.
11975    /// * *access_token* (query-string) - OAuth access token.
11976    /// * *alt* (query-string) - Data format for response.
11977    /// * *callback* (query-string) - JSONP
11978    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11979    /// * *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.
11980    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11981    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11982    /// * *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.
11983    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11984    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11985    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogControlDeleteCall<'a, C>
11986    where
11987        T: AsRef<str>,
11988    {
11989        self._additional_params
11990            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11991        self
11992    }
11993
11994    /// Identifies the authorization scope for the method you are building.
11995    ///
11996    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11997    /// [`Scope::CloudPlatform`].
11998    ///
11999    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12000    /// tokens for more than one scope.
12001    ///
12002    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12003    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12004    /// sufficient, a read-write scope will do as well.
12005    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogControlDeleteCall<'a, C>
12006    where
12007        St: AsRef<str>,
12008    {
12009        self._scopes.insert(String::from(scope.as_ref()));
12010        self
12011    }
12012    /// Identifies the authorization scope(s) for the method you are building.
12013    ///
12014    /// See [`Self::add_scope()`] for details.
12015    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogControlDeleteCall<'a, C>
12016    where
12017        I: IntoIterator<Item = St>,
12018        St: AsRef<str>,
12019    {
12020        self._scopes
12021            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12022        self
12023    }
12024
12025    /// Removes all scopes, and no default scope will be used either.
12026    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12027    /// for details).
12028    pub fn clear_scopes(mut self) -> ProjectLocationCatalogControlDeleteCall<'a, C> {
12029        self._scopes.clear();
12030        self
12031    }
12032}
12033
12034/// Gets a Control.
12035///
12036/// A builder for the *locations.catalogs.controls.get* method supported by a *project* resource.
12037/// It is not used directly, but through a [`ProjectMethods`] instance.
12038///
12039/// # Example
12040///
12041/// Instantiate a resource method builder
12042///
12043/// ```test_harness,no_run
12044/// # extern crate hyper;
12045/// # extern crate hyper_rustls;
12046/// # extern crate google_retail2 as retail2;
12047/// # async fn dox() {
12048/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12049///
12050/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12051/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12052/// #     .with_native_roots()
12053/// #     .unwrap()
12054/// #     .https_only()
12055/// #     .enable_http2()
12056/// #     .build();
12057///
12058/// # let executor = hyper_util::rt::TokioExecutor::new();
12059/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12060/// #     secret,
12061/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12062/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12063/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12064/// #     ),
12065/// # ).build().await.unwrap();
12066///
12067/// # let client = hyper_util::client::legacy::Client::builder(
12068/// #     hyper_util::rt::TokioExecutor::new()
12069/// # )
12070/// # .build(
12071/// #     hyper_rustls::HttpsConnectorBuilder::new()
12072/// #         .with_native_roots()
12073/// #         .unwrap()
12074/// #         .https_or_http()
12075/// #         .enable_http2()
12076/// #         .build()
12077/// # );
12078/// # let mut hub = CloudRetail::new(client, auth);
12079/// // You can configure optional parameters by calling the respective setters at will, and
12080/// // execute the final call using `doit()`.
12081/// // Values shown here are possibly random and not representative !
12082/// let result = hub.projects().locations_catalogs_controls_get("name")
12083///              .doit().await;
12084/// # }
12085/// ```
12086pub struct ProjectLocationCatalogControlGetCall<'a, C>
12087where
12088    C: 'a,
12089{
12090    hub: &'a CloudRetail<C>,
12091    _name: String,
12092    _delegate: Option<&'a mut dyn common::Delegate>,
12093    _additional_params: HashMap<String, String>,
12094    _scopes: BTreeSet<String>,
12095}
12096
12097impl<'a, C> common::CallBuilder for ProjectLocationCatalogControlGetCall<'a, C> {}
12098
12099impl<'a, C> ProjectLocationCatalogControlGetCall<'a, C>
12100where
12101    C: common::Connector,
12102{
12103    /// Perform the operation you have build so far.
12104    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Control)> {
12105        use std::borrow::Cow;
12106        use std::io::{Read, Seek};
12107
12108        use common::{url::Params, ToParts};
12109        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12110
12111        let mut dd = common::DefaultDelegate;
12112        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12113        dlg.begin(common::MethodInfo {
12114            id: "retail.projects.locations.catalogs.controls.get",
12115            http_method: hyper::Method::GET,
12116        });
12117
12118        for &field in ["alt", "name"].iter() {
12119            if self._additional_params.contains_key(field) {
12120                dlg.finished(false);
12121                return Err(common::Error::FieldClash(field));
12122            }
12123        }
12124
12125        let mut params = Params::with_capacity(3 + self._additional_params.len());
12126        params.push("name", self._name);
12127
12128        params.extend(self._additional_params.iter());
12129
12130        params.push("alt", "json");
12131        let mut url = self.hub._base_url.clone() + "v2/{+name}";
12132        if self._scopes.is_empty() {
12133            self._scopes
12134                .insert(Scope::CloudPlatform.as_ref().to_string());
12135        }
12136
12137        #[allow(clippy::single_element_loop)]
12138        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12139            url = params.uri_replacement(url, param_name, find_this, true);
12140        }
12141        {
12142            let to_remove = ["name"];
12143            params.remove_params(&to_remove);
12144        }
12145
12146        let url = params.parse_with_url(&url);
12147
12148        loop {
12149            let token = match self
12150                .hub
12151                .auth
12152                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12153                .await
12154            {
12155                Ok(token) => token,
12156                Err(e) => match dlg.token(e) {
12157                    Ok(token) => token,
12158                    Err(e) => {
12159                        dlg.finished(false);
12160                        return Err(common::Error::MissingToken(e));
12161                    }
12162                },
12163            };
12164            let mut req_result = {
12165                let client = &self.hub.client;
12166                dlg.pre_request();
12167                let mut req_builder = hyper::Request::builder()
12168                    .method(hyper::Method::GET)
12169                    .uri(url.as_str())
12170                    .header(USER_AGENT, self.hub._user_agent.clone());
12171
12172                if let Some(token) = token.as_ref() {
12173                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12174                }
12175
12176                let request = req_builder
12177                    .header(CONTENT_LENGTH, 0_u64)
12178                    .body(common::to_body::<String>(None));
12179
12180                client.request(request.unwrap()).await
12181            };
12182
12183            match req_result {
12184                Err(err) => {
12185                    if let common::Retry::After(d) = dlg.http_error(&err) {
12186                        sleep(d).await;
12187                        continue;
12188                    }
12189                    dlg.finished(false);
12190                    return Err(common::Error::HttpError(err));
12191                }
12192                Ok(res) => {
12193                    let (mut parts, body) = res.into_parts();
12194                    let mut body = common::Body::new(body);
12195                    if !parts.status.is_success() {
12196                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12197                        let error = serde_json::from_str(&common::to_string(&bytes));
12198                        let response = common::to_response(parts, bytes.into());
12199
12200                        if let common::Retry::After(d) =
12201                            dlg.http_failure(&response, error.as_ref().ok())
12202                        {
12203                            sleep(d).await;
12204                            continue;
12205                        }
12206
12207                        dlg.finished(false);
12208
12209                        return Err(match error {
12210                            Ok(value) => common::Error::BadRequest(value),
12211                            _ => common::Error::Failure(response),
12212                        });
12213                    }
12214                    let response = {
12215                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12216                        let encoded = common::to_string(&bytes);
12217                        match serde_json::from_str(&encoded) {
12218                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12219                            Err(error) => {
12220                                dlg.response_json_decode_error(&encoded, &error);
12221                                return Err(common::Error::JsonDecodeError(
12222                                    encoded.to_string(),
12223                                    error,
12224                                ));
12225                            }
12226                        }
12227                    };
12228
12229                    dlg.finished(true);
12230                    return Ok(response);
12231                }
12232            }
12233        }
12234    }
12235
12236    /// Required. The resource name of the Control to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
12237    ///
12238    /// Sets the *name* path property to the given value.
12239    ///
12240    /// Even though the property as already been set when instantiating this call,
12241    /// we provide this method for API completeness.
12242    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogControlGetCall<'a, C> {
12243        self._name = new_value.to_string();
12244        self
12245    }
12246    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12247    /// while executing the actual API request.
12248    ///
12249    /// ````text
12250    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12251    /// ````
12252    ///
12253    /// Sets the *delegate* property to the given value.
12254    pub fn delegate(
12255        mut self,
12256        new_value: &'a mut dyn common::Delegate,
12257    ) -> ProjectLocationCatalogControlGetCall<'a, C> {
12258        self._delegate = Some(new_value);
12259        self
12260    }
12261
12262    /// Set any additional parameter of the query string used in the request.
12263    /// It should be used to set parameters which are not yet available through their own
12264    /// setters.
12265    ///
12266    /// Please note that this method must not be used to set any of the known parameters
12267    /// which have their own setter method. If done anyway, the request will fail.
12268    ///
12269    /// # Additional Parameters
12270    ///
12271    /// * *$.xgafv* (query-string) - V1 error format.
12272    /// * *access_token* (query-string) - OAuth access token.
12273    /// * *alt* (query-string) - Data format for response.
12274    /// * *callback* (query-string) - JSONP
12275    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12276    /// * *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.
12277    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12278    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12279    /// * *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.
12280    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12281    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12282    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogControlGetCall<'a, C>
12283    where
12284        T: AsRef<str>,
12285    {
12286        self._additional_params
12287            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12288        self
12289    }
12290
12291    /// Identifies the authorization scope for the method you are building.
12292    ///
12293    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12294    /// [`Scope::CloudPlatform`].
12295    ///
12296    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12297    /// tokens for more than one scope.
12298    ///
12299    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12300    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12301    /// sufficient, a read-write scope will do as well.
12302    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogControlGetCall<'a, C>
12303    where
12304        St: AsRef<str>,
12305    {
12306        self._scopes.insert(String::from(scope.as_ref()));
12307        self
12308    }
12309    /// Identifies the authorization scope(s) for the method you are building.
12310    ///
12311    /// See [`Self::add_scope()`] for details.
12312    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogControlGetCall<'a, C>
12313    where
12314        I: IntoIterator<Item = St>,
12315        St: AsRef<str>,
12316    {
12317        self._scopes
12318            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12319        self
12320    }
12321
12322    /// Removes all scopes, and no default scope will be used either.
12323    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12324    /// for details).
12325    pub fn clear_scopes(mut self) -> ProjectLocationCatalogControlGetCall<'a, C> {
12326        self._scopes.clear();
12327        self
12328    }
12329}
12330
12331/// Lists all Controls by their parent Catalog.
12332///
12333/// A builder for the *locations.catalogs.controls.list* method supported by a *project* resource.
12334/// It is not used directly, but through a [`ProjectMethods`] instance.
12335///
12336/// # Example
12337///
12338/// Instantiate a resource method builder
12339///
12340/// ```test_harness,no_run
12341/// # extern crate hyper;
12342/// # extern crate hyper_rustls;
12343/// # extern crate google_retail2 as retail2;
12344/// # async fn dox() {
12345/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12346///
12347/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12348/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12349/// #     .with_native_roots()
12350/// #     .unwrap()
12351/// #     .https_only()
12352/// #     .enable_http2()
12353/// #     .build();
12354///
12355/// # let executor = hyper_util::rt::TokioExecutor::new();
12356/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12357/// #     secret,
12358/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12359/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12360/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12361/// #     ),
12362/// # ).build().await.unwrap();
12363///
12364/// # let client = hyper_util::client::legacy::Client::builder(
12365/// #     hyper_util::rt::TokioExecutor::new()
12366/// # )
12367/// # .build(
12368/// #     hyper_rustls::HttpsConnectorBuilder::new()
12369/// #         .with_native_roots()
12370/// #         .unwrap()
12371/// #         .https_or_http()
12372/// #         .enable_http2()
12373/// #         .build()
12374/// # );
12375/// # let mut hub = CloudRetail::new(client, auth);
12376/// // You can configure optional parameters by calling the respective setters at will, and
12377/// // execute the final call using `doit()`.
12378/// // Values shown here are possibly random and not representative !
12379/// let result = hub.projects().locations_catalogs_controls_list("parent")
12380///              .page_token("duo")
12381///              .page_size(-80)
12382///              .filter("no")
12383///              .doit().await;
12384/// # }
12385/// ```
12386pub struct ProjectLocationCatalogControlListCall<'a, C>
12387where
12388    C: 'a,
12389{
12390    hub: &'a CloudRetail<C>,
12391    _parent: String,
12392    _page_token: Option<String>,
12393    _page_size: Option<i32>,
12394    _filter: Option<String>,
12395    _delegate: Option<&'a mut dyn common::Delegate>,
12396    _additional_params: HashMap<String, String>,
12397    _scopes: BTreeSet<String>,
12398}
12399
12400impl<'a, C> common::CallBuilder for ProjectLocationCatalogControlListCall<'a, C> {}
12401
12402impl<'a, C> ProjectLocationCatalogControlListCall<'a, C>
12403where
12404    C: common::Connector,
12405{
12406    /// Perform the operation you have build so far.
12407    pub async fn doit(
12408        mut self,
12409    ) -> common::Result<(common::Response, GoogleCloudRetailV2ListControlsResponse)> {
12410        use std::borrow::Cow;
12411        use std::io::{Read, Seek};
12412
12413        use common::{url::Params, ToParts};
12414        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12415
12416        let mut dd = common::DefaultDelegate;
12417        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12418        dlg.begin(common::MethodInfo {
12419            id: "retail.projects.locations.catalogs.controls.list",
12420            http_method: hyper::Method::GET,
12421        });
12422
12423        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
12424            if self._additional_params.contains_key(field) {
12425                dlg.finished(false);
12426                return Err(common::Error::FieldClash(field));
12427            }
12428        }
12429
12430        let mut params = Params::with_capacity(6 + self._additional_params.len());
12431        params.push("parent", self._parent);
12432        if let Some(value) = self._page_token.as_ref() {
12433            params.push("pageToken", value);
12434        }
12435        if let Some(value) = self._page_size.as_ref() {
12436            params.push("pageSize", value.to_string());
12437        }
12438        if let Some(value) = self._filter.as_ref() {
12439            params.push("filter", value);
12440        }
12441
12442        params.extend(self._additional_params.iter());
12443
12444        params.push("alt", "json");
12445        let mut url = self.hub._base_url.clone() + "v2/{+parent}/controls";
12446        if self._scopes.is_empty() {
12447            self._scopes
12448                .insert(Scope::CloudPlatform.as_ref().to_string());
12449        }
12450
12451        #[allow(clippy::single_element_loop)]
12452        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12453            url = params.uri_replacement(url, param_name, find_this, true);
12454        }
12455        {
12456            let to_remove = ["parent"];
12457            params.remove_params(&to_remove);
12458        }
12459
12460        let url = params.parse_with_url(&url);
12461
12462        loop {
12463            let token = match self
12464                .hub
12465                .auth
12466                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12467                .await
12468            {
12469                Ok(token) => token,
12470                Err(e) => match dlg.token(e) {
12471                    Ok(token) => token,
12472                    Err(e) => {
12473                        dlg.finished(false);
12474                        return Err(common::Error::MissingToken(e));
12475                    }
12476                },
12477            };
12478            let mut req_result = {
12479                let client = &self.hub.client;
12480                dlg.pre_request();
12481                let mut req_builder = hyper::Request::builder()
12482                    .method(hyper::Method::GET)
12483                    .uri(url.as_str())
12484                    .header(USER_AGENT, self.hub._user_agent.clone());
12485
12486                if let Some(token) = token.as_ref() {
12487                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12488                }
12489
12490                let request = req_builder
12491                    .header(CONTENT_LENGTH, 0_u64)
12492                    .body(common::to_body::<String>(None));
12493
12494                client.request(request.unwrap()).await
12495            };
12496
12497            match req_result {
12498                Err(err) => {
12499                    if let common::Retry::After(d) = dlg.http_error(&err) {
12500                        sleep(d).await;
12501                        continue;
12502                    }
12503                    dlg.finished(false);
12504                    return Err(common::Error::HttpError(err));
12505                }
12506                Ok(res) => {
12507                    let (mut parts, body) = res.into_parts();
12508                    let mut body = common::Body::new(body);
12509                    if !parts.status.is_success() {
12510                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12511                        let error = serde_json::from_str(&common::to_string(&bytes));
12512                        let response = common::to_response(parts, bytes.into());
12513
12514                        if let common::Retry::After(d) =
12515                            dlg.http_failure(&response, error.as_ref().ok())
12516                        {
12517                            sleep(d).await;
12518                            continue;
12519                        }
12520
12521                        dlg.finished(false);
12522
12523                        return Err(match error {
12524                            Ok(value) => common::Error::BadRequest(value),
12525                            _ => common::Error::Failure(response),
12526                        });
12527                    }
12528                    let response = {
12529                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12530                        let encoded = common::to_string(&bytes);
12531                        match serde_json::from_str(&encoded) {
12532                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12533                            Err(error) => {
12534                                dlg.response_json_decode_error(&encoded, &error);
12535                                return Err(common::Error::JsonDecodeError(
12536                                    encoded.to_string(),
12537                                    error,
12538                                ));
12539                            }
12540                        }
12541                    };
12542
12543                    dlg.finished(true);
12544                    return Ok(response);
12545                }
12546            }
12547        }
12548    }
12549
12550    /// Required. The catalog resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
12551    ///
12552    /// Sets the *parent* path property to the given value.
12553    ///
12554    /// Even though the property as already been set when instantiating this call,
12555    /// we provide this method for API completeness.
12556    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogControlListCall<'a, C> {
12557        self._parent = new_value.to_string();
12558        self
12559    }
12560    /// Optional. A page token, received from a previous `ListControls` call. Provide this to retrieve the subsequent page.
12561    ///
12562    /// Sets the *page token* query property to the given value.
12563    pub fn page_token(mut self, new_value: &str) -> ProjectLocationCatalogControlListCall<'a, C> {
12564        self._page_token = Some(new_value.to_string());
12565        self
12566    }
12567    /// Optional. Maximum number of results to return. If unspecified, defaults to 50. Max allowed value is 1000.
12568    ///
12569    /// Sets the *page size* query property to the given value.
12570    pub fn page_size(mut self, new_value: i32) -> ProjectLocationCatalogControlListCall<'a, C> {
12571        self._page_size = Some(new_value);
12572        self
12573    }
12574    /// Optional. A filter to apply on the list results. Supported features: * List all the products under the parent branch if filter is unset. * List controls that are used in a single ServingConfig: 'serving_config = "boosted_home_page_cvr"'
12575    ///
12576    /// Sets the *filter* query property to the given value.
12577    pub fn filter(mut self, new_value: &str) -> ProjectLocationCatalogControlListCall<'a, C> {
12578        self._filter = Some(new_value.to_string());
12579        self
12580    }
12581    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12582    /// while executing the actual API request.
12583    ///
12584    /// ````text
12585    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12586    /// ````
12587    ///
12588    /// Sets the *delegate* property to the given value.
12589    pub fn delegate(
12590        mut self,
12591        new_value: &'a mut dyn common::Delegate,
12592    ) -> ProjectLocationCatalogControlListCall<'a, C> {
12593        self._delegate = Some(new_value);
12594        self
12595    }
12596
12597    /// Set any additional parameter of the query string used in the request.
12598    /// It should be used to set parameters which are not yet available through their own
12599    /// setters.
12600    ///
12601    /// Please note that this method must not be used to set any of the known parameters
12602    /// which have their own setter method. If done anyway, the request will fail.
12603    ///
12604    /// # Additional Parameters
12605    ///
12606    /// * *$.xgafv* (query-string) - V1 error format.
12607    /// * *access_token* (query-string) - OAuth access token.
12608    /// * *alt* (query-string) - Data format for response.
12609    /// * *callback* (query-string) - JSONP
12610    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12611    /// * *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.
12612    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12613    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12614    /// * *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.
12615    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12616    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12617    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogControlListCall<'a, C>
12618    where
12619        T: AsRef<str>,
12620    {
12621        self._additional_params
12622            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12623        self
12624    }
12625
12626    /// Identifies the authorization scope for the method you are building.
12627    ///
12628    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12629    /// [`Scope::CloudPlatform`].
12630    ///
12631    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12632    /// tokens for more than one scope.
12633    ///
12634    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12635    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12636    /// sufficient, a read-write scope will do as well.
12637    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogControlListCall<'a, C>
12638    where
12639        St: AsRef<str>,
12640    {
12641        self._scopes.insert(String::from(scope.as_ref()));
12642        self
12643    }
12644    /// Identifies the authorization scope(s) for the method you are building.
12645    ///
12646    /// See [`Self::add_scope()`] for details.
12647    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogControlListCall<'a, C>
12648    where
12649        I: IntoIterator<Item = St>,
12650        St: AsRef<str>,
12651    {
12652        self._scopes
12653            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12654        self
12655    }
12656
12657    /// Removes all scopes, and no default scope will be used either.
12658    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12659    /// for details).
12660    pub fn clear_scopes(mut self) -> ProjectLocationCatalogControlListCall<'a, C> {
12661        self._scopes.clear();
12662        self
12663    }
12664}
12665
12666/// Updates a Control. Control cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the Control to update does not exist, a NOT_FOUND error is returned.
12667///
12668/// A builder for the *locations.catalogs.controls.patch* method supported by a *project* resource.
12669/// It is not used directly, but through a [`ProjectMethods`] instance.
12670///
12671/// # Example
12672///
12673/// Instantiate a resource method builder
12674///
12675/// ```test_harness,no_run
12676/// # extern crate hyper;
12677/// # extern crate hyper_rustls;
12678/// # extern crate google_retail2 as retail2;
12679/// use retail2::api::GoogleCloudRetailV2Control;
12680/// # async fn dox() {
12681/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12682///
12683/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12684/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12685/// #     .with_native_roots()
12686/// #     .unwrap()
12687/// #     .https_only()
12688/// #     .enable_http2()
12689/// #     .build();
12690///
12691/// # let executor = hyper_util::rt::TokioExecutor::new();
12692/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12693/// #     secret,
12694/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12695/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12696/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12697/// #     ),
12698/// # ).build().await.unwrap();
12699///
12700/// # let client = hyper_util::client::legacy::Client::builder(
12701/// #     hyper_util::rt::TokioExecutor::new()
12702/// # )
12703/// # .build(
12704/// #     hyper_rustls::HttpsConnectorBuilder::new()
12705/// #         .with_native_roots()
12706/// #         .unwrap()
12707/// #         .https_or_http()
12708/// #         .enable_http2()
12709/// #         .build()
12710/// # );
12711/// # let mut hub = CloudRetail::new(client, auth);
12712/// // As the method needs a request, you would usually fill it with the desired information
12713/// // into the respective structure. Some of the parts shown here might not be applicable !
12714/// // Values shown here are possibly random and not representative !
12715/// let mut req = GoogleCloudRetailV2Control::default();
12716///
12717/// // You can configure optional parameters by calling the respective setters at will, and
12718/// // execute the final call using `doit()`.
12719/// // Values shown here are possibly random and not representative !
12720/// let result = hub.projects().locations_catalogs_controls_patch(req, "name")
12721///              .update_mask(FieldMask::new::<&str>(&[]))
12722///              .doit().await;
12723/// # }
12724/// ```
12725pub struct ProjectLocationCatalogControlPatchCall<'a, C>
12726where
12727    C: 'a,
12728{
12729    hub: &'a CloudRetail<C>,
12730    _request: GoogleCloudRetailV2Control,
12731    _name: String,
12732    _update_mask: Option<common::FieldMask>,
12733    _delegate: Option<&'a mut dyn common::Delegate>,
12734    _additional_params: HashMap<String, String>,
12735    _scopes: BTreeSet<String>,
12736}
12737
12738impl<'a, C> common::CallBuilder for ProjectLocationCatalogControlPatchCall<'a, C> {}
12739
12740impl<'a, C> ProjectLocationCatalogControlPatchCall<'a, C>
12741where
12742    C: common::Connector,
12743{
12744    /// Perform the operation you have build so far.
12745    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Control)> {
12746        use std::borrow::Cow;
12747        use std::io::{Read, Seek};
12748
12749        use common::{url::Params, ToParts};
12750        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12751
12752        let mut dd = common::DefaultDelegate;
12753        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12754        dlg.begin(common::MethodInfo {
12755            id: "retail.projects.locations.catalogs.controls.patch",
12756            http_method: hyper::Method::PATCH,
12757        });
12758
12759        for &field in ["alt", "name", "updateMask"].iter() {
12760            if self._additional_params.contains_key(field) {
12761                dlg.finished(false);
12762                return Err(common::Error::FieldClash(field));
12763            }
12764        }
12765
12766        let mut params = Params::with_capacity(5 + self._additional_params.len());
12767        params.push("name", self._name);
12768        if let Some(value) = self._update_mask.as_ref() {
12769            params.push("updateMask", value.to_string());
12770        }
12771
12772        params.extend(self._additional_params.iter());
12773
12774        params.push("alt", "json");
12775        let mut url = self.hub._base_url.clone() + "v2/{+name}";
12776        if self._scopes.is_empty() {
12777            self._scopes
12778                .insert(Scope::CloudPlatform.as_ref().to_string());
12779        }
12780
12781        #[allow(clippy::single_element_loop)]
12782        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12783            url = params.uri_replacement(url, param_name, find_this, true);
12784        }
12785        {
12786            let to_remove = ["name"];
12787            params.remove_params(&to_remove);
12788        }
12789
12790        let url = params.parse_with_url(&url);
12791
12792        let mut json_mime_type = mime::APPLICATION_JSON;
12793        let mut request_value_reader = {
12794            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12795            common::remove_json_null_values(&mut value);
12796            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12797            serde_json::to_writer(&mut dst, &value).unwrap();
12798            dst
12799        };
12800        let request_size = request_value_reader
12801            .seek(std::io::SeekFrom::End(0))
12802            .unwrap();
12803        request_value_reader
12804            .seek(std::io::SeekFrom::Start(0))
12805            .unwrap();
12806
12807        loop {
12808            let token = match self
12809                .hub
12810                .auth
12811                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12812                .await
12813            {
12814                Ok(token) => token,
12815                Err(e) => match dlg.token(e) {
12816                    Ok(token) => token,
12817                    Err(e) => {
12818                        dlg.finished(false);
12819                        return Err(common::Error::MissingToken(e));
12820                    }
12821                },
12822            };
12823            request_value_reader
12824                .seek(std::io::SeekFrom::Start(0))
12825                .unwrap();
12826            let mut req_result = {
12827                let client = &self.hub.client;
12828                dlg.pre_request();
12829                let mut req_builder = hyper::Request::builder()
12830                    .method(hyper::Method::PATCH)
12831                    .uri(url.as_str())
12832                    .header(USER_AGENT, self.hub._user_agent.clone());
12833
12834                if let Some(token) = token.as_ref() {
12835                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12836                }
12837
12838                let request = req_builder
12839                    .header(CONTENT_TYPE, json_mime_type.to_string())
12840                    .header(CONTENT_LENGTH, request_size as u64)
12841                    .body(common::to_body(
12842                        request_value_reader.get_ref().clone().into(),
12843                    ));
12844
12845                client.request(request.unwrap()).await
12846            };
12847
12848            match req_result {
12849                Err(err) => {
12850                    if let common::Retry::After(d) = dlg.http_error(&err) {
12851                        sleep(d).await;
12852                        continue;
12853                    }
12854                    dlg.finished(false);
12855                    return Err(common::Error::HttpError(err));
12856                }
12857                Ok(res) => {
12858                    let (mut parts, body) = res.into_parts();
12859                    let mut body = common::Body::new(body);
12860                    if !parts.status.is_success() {
12861                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12862                        let error = serde_json::from_str(&common::to_string(&bytes));
12863                        let response = common::to_response(parts, bytes.into());
12864
12865                        if let common::Retry::After(d) =
12866                            dlg.http_failure(&response, error.as_ref().ok())
12867                        {
12868                            sleep(d).await;
12869                            continue;
12870                        }
12871
12872                        dlg.finished(false);
12873
12874                        return Err(match error {
12875                            Ok(value) => common::Error::BadRequest(value),
12876                            _ => common::Error::Failure(response),
12877                        });
12878                    }
12879                    let response = {
12880                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12881                        let encoded = common::to_string(&bytes);
12882                        match serde_json::from_str(&encoded) {
12883                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12884                            Err(error) => {
12885                                dlg.response_json_decode_error(&encoded, &error);
12886                                return Err(common::Error::JsonDecodeError(
12887                                    encoded.to_string(),
12888                                    error,
12889                                ));
12890                            }
12891                        }
12892                    };
12893
12894                    dlg.finished(true);
12895                    return Ok(response);
12896                }
12897            }
12898        }
12899    }
12900
12901    ///
12902    /// Sets the *request* property to the given value.
12903    ///
12904    /// Even though the property as already been set when instantiating this call,
12905    /// we provide this method for API completeness.
12906    pub fn request(
12907        mut self,
12908        new_value: GoogleCloudRetailV2Control,
12909    ) -> ProjectLocationCatalogControlPatchCall<'a, C> {
12910        self._request = new_value;
12911        self
12912    }
12913    /// Immutable. Fully qualified name `projects/*/locations/global/catalogs/*/controls/*`
12914    ///
12915    /// Sets the *name* path property to the given value.
12916    ///
12917    /// Even though the property as already been set when instantiating this call,
12918    /// we provide this method for API completeness.
12919    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogControlPatchCall<'a, C> {
12920        self._name = new_value.to_string();
12921        self
12922    }
12923    /// Indicates which fields in the provided Control to update. The following are NOT supported: * Control.name If not set or empty, all supported fields are updated.
12924    ///
12925    /// Sets the *update mask* query property to the given value.
12926    pub fn update_mask(
12927        mut self,
12928        new_value: common::FieldMask,
12929    ) -> ProjectLocationCatalogControlPatchCall<'a, C> {
12930        self._update_mask = Some(new_value);
12931        self
12932    }
12933    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12934    /// while executing the actual API request.
12935    ///
12936    /// ````text
12937    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12938    /// ````
12939    ///
12940    /// Sets the *delegate* property to the given value.
12941    pub fn delegate(
12942        mut self,
12943        new_value: &'a mut dyn common::Delegate,
12944    ) -> ProjectLocationCatalogControlPatchCall<'a, C> {
12945        self._delegate = Some(new_value);
12946        self
12947    }
12948
12949    /// Set any additional parameter of the query string used in the request.
12950    /// It should be used to set parameters which are not yet available through their own
12951    /// setters.
12952    ///
12953    /// Please note that this method must not be used to set any of the known parameters
12954    /// which have their own setter method. If done anyway, the request will fail.
12955    ///
12956    /// # Additional Parameters
12957    ///
12958    /// * *$.xgafv* (query-string) - V1 error format.
12959    /// * *access_token* (query-string) - OAuth access token.
12960    /// * *alt* (query-string) - Data format for response.
12961    /// * *callback* (query-string) - JSONP
12962    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12963    /// * *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.
12964    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12965    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12966    /// * *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.
12967    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12968    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12969    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogControlPatchCall<'a, C>
12970    where
12971        T: AsRef<str>,
12972    {
12973        self._additional_params
12974            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12975        self
12976    }
12977
12978    /// Identifies the authorization scope for the method you are building.
12979    ///
12980    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12981    /// [`Scope::CloudPlatform`].
12982    ///
12983    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12984    /// tokens for more than one scope.
12985    ///
12986    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12987    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12988    /// sufficient, a read-write scope will do as well.
12989    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogControlPatchCall<'a, C>
12990    where
12991        St: AsRef<str>,
12992    {
12993        self._scopes.insert(String::from(scope.as_ref()));
12994        self
12995    }
12996    /// Identifies the authorization scope(s) for the method you are building.
12997    ///
12998    /// See [`Self::add_scope()`] for details.
12999    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogControlPatchCall<'a, C>
13000    where
13001        I: IntoIterator<Item = St>,
13002        St: AsRef<str>,
13003    {
13004        self._scopes
13005            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13006        self
13007    }
13008
13009    /// Removes all scopes, and no default scope will be used either.
13010    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13011    /// for details).
13012    pub fn clear_scopes(mut self) -> ProjectLocationCatalogControlPatchCall<'a, C> {
13013        self._scopes.clear();
13014        self
13015    }
13016}
13017
13018/// Allows management of multiple questions.
13019///
13020/// A builder for the *locations.catalogs.generativeQuestion.batchUpdate* method supported by a *project* resource.
13021/// It is not used directly, but through a [`ProjectMethods`] instance.
13022///
13023/// # Example
13024///
13025/// Instantiate a resource method builder
13026///
13027/// ```test_harness,no_run
13028/// # extern crate hyper;
13029/// # extern crate hyper_rustls;
13030/// # extern crate google_retail2 as retail2;
13031/// use retail2::api::GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsRequest;
13032/// # async fn dox() {
13033/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13034///
13035/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13036/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13037/// #     .with_native_roots()
13038/// #     .unwrap()
13039/// #     .https_only()
13040/// #     .enable_http2()
13041/// #     .build();
13042///
13043/// # let executor = hyper_util::rt::TokioExecutor::new();
13044/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13045/// #     secret,
13046/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13047/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13048/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13049/// #     ),
13050/// # ).build().await.unwrap();
13051///
13052/// # let client = hyper_util::client::legacy::Client::builder(
13053/// #     hyper_util::rt::TokioExecutor::new()
13054/// # )
13055/// # .build(
13056/// #     hyper_rustls::HttpsConnectorBuilder::new()
13057/// #         .with_native_roots()
13058/// #         .unwrap()
13059/// #         .https_or_http()
13060/// #         .enable_http2()
13061/// #         .build()
13062/// # );
13063/// # let mut hub = CloudRetail::new(client, auth);
13064/// // As the method needs a request, you would usually fill it with the desired information
13065/// // into the respective structure. Some of the parts shown here might not be applicable !
13066/// // Values shown here are possibly random and not representative !
13067/// let mut req = GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsRequest::default();
13068///
13069/// // You can configure optional parameters by calling the respective setters at will, and
13070/// // execute the final call using `doit()`.
13071/// // Values shown here are possibly random and not representative !
13072/// let result = hub.projects().locations_catalogs_generative_question_batch_update(req, "parent")
13073///              .doit().await;
13074/// # }
13075/// ```
13076pub struct ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C>
13077where
13078    C: 'a,
13079{
13080    hub: &'a CloudRetail<C>,
13081    _request: GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsRequest,
13082    _parent: String,
13083    _delegate: Option<&'a mut dyn common::Delegate>,
13084    _additional_params: HashMap<String, String>,
13085    _scopes: BTreeSet<String>,
13086}
13087
13088impl<'a, C> common::CallBuilder for ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C> {}
13089
13090impl<'a, C> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C>
13091where
13092    C: common::Connector,
13093{
13094    /// Perform the operation you have build so far.
13095    pub async fn doit(
13096        mut self,
13097    ) -> common::Result<(
13098        common::Response,
13099        GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsResponse,
13100    )> {
13101        use std::borrow::Cow;
13102        use std::io::{Read, Seek};
13103
13104        use common::{url::Params, ToParts};
13105        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13106
13107        let mut dd = common::DefaultDelegate;
13108        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13109        dlg.begin(common::MethodInfo {
13110            id: "retail.projects.locations.catalogs.generativeQuestion.batchUpdate",
13111            http_method: hyper::Method::POST,
13112        });
13113
13114        for &field in ["alt", "parent"].iter() {
13115            if self._additional_params.contains_key(field) {
13116                dlg.finished(false);
13117                return Err(common::Error::FieldClash(field));
13118            }
13119        }
13120
13121        let mut params = Params::with_capacity(4 + self._additional_params.len());
13122        params.push("parent", self._parent);
13123
13124        params.extend(self._additional_params.iter());
13125
13126        params.push("alt", "json");
13127        let mut url = self.hub._base_url.clone() + "v2/{+parent}/generativeQuestion:batchUpdate";
13128        if self._scopes.is_empty() {
13129            self._scopes
13130                .insert(Scope::CloudPlatform.as_ref().to_string());
13131        }
13132
13133        #[allow(clippy::single_element_loop)]
13134        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13135            url = params.uri_replacement(url, param_name, find_this, true);
13136        }
13137        {
13138            let to_remove = ["parent"];
13139            params.remove_params(&to_remove);
13140        }
13141
13142        let url = params.parse_with_url(&url);
13143
13144        let mut json_mime_type = mime::APPLICATION_JSON;
13145        let mut request_value_reader = {
13146            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13147            common::remove_json_null_values(&mut value);
13148            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13149            serde_json::to_writer(&mut dst, &value).unwrap();
13150            dst
13151        };
13152        let request_size = request_value_reader
13153            .seek(std::io::SeekFrom::End(0))
13154            .unwrap();
13155        request_value_reader
13156            .seek(std::io::SeekFrom::Start(0))
13157            .unwrap();
13158
13159        loop {
13160            let token = match self
13161                .hub
13162                .auth
13163                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13164                .await
13165            {
13166                Ok(token) => token,
13167                Err(e) => match dlg.token(e) {
13168                    Ok(token) => token,
13169                    Err(e) => {
13170                        dlg.finished(false);
13171                        return Err(common::Error::MissingToken(e));
13172                    }
13173                },
13174            };
13175            request_value_reader
13176                .seek(std::io::SeekFrom::Start(0))
13177                .unwrap();
13178            let mut req_result = {
13179                let client = &self.hub.client;
13180                dlg.pre_request();
13181                let mut req_builder = hyper::Request::builder()
13182                    .method(hyper::Method::POST)
13183                    .uri(url.as_str())
13184                    .header(USER_AGENT, self.hub._user_agent.clone());
13185
13186                if let Some(token) = token.as_ref() {
13187                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13188                }
13189
13190                let request = req_builder
13191                    .header(CONTENT_TYPE, json_mime_type.to_string())
13192                    .header(CONTENT_LENGTH, request_size as u64)
13193                    .body(common::to_body(
13194                        request_value_reader.get_ref().clone().into(),
13195                    ));
13196
13197                client.request(request.unwrap()).await
13198            };
13199
13200            match req_result {
13201                Err(err) => {
13202                    if let common::Retry::After(d) = dlg.http_error(&err) {
13203                        sleep(d).await;
13204                        continue;
13205                    }
13206                    dlg.finished(false);
13207                    return Err(common::Error::HttpError(err));
13208                }
13209                Ok(res) => {
13210                    let (mut parts, body) = res.into_parts();
13211                    let mut body = common::Body::new(body);
13212                    if !parts.status.is_success() {
13213                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13214                        let error = serde_json::from_str(&common::to_string(&bytes));
13215                        let response = common::to_response(parts, bytes.into());
13216
13217                        if let common::Retry::After(d) =
13218                            dlg.http_failure(&response, error.as_ref().ok())
13219                        {
13220                            sleep(d).await;
13221                            continue;
13222                        }
13223
13224                        dlg.finished(false);
13225
13226                        return Err(match error {
13227                            Ok(value) => common::Error::BadRequest(value),
13228                            _ => common::Error::Failure(response),
13229                        });
13230                    }
13231                    let response = {
13232                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13233                        let encoded = common::to_string(&bytes);
13234                        match serde_json::from_str(&encoded) {
13235                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13236                            Err(error) => {
13237                                dlg.response_json_decode_error(&encoded, &error);
13238                                return Err(common::Error::JsonDecodeError(
13239                                    encoded.to_string(),
13240                                    error,
13241                                ));
13242                            }
13243                        }
13244                    };
13245
13246                    dlg.finished(true);
13247                    return Ok(response);
13248                }
13249            }
13250        }
13251    }
13252
13253    ///
13254    /// Sets the *request* property to the given value.
13255    ///
13256    /// Even though the property as already been set when instantiating this call,
13257    /// we provide this method for API completeness.
13258    pub fn request(
13259        mut self,
13260        new_value: GoogleCloudRetailV2BatchUpdateGenerativeQuestionConfigsRequest,
13261    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C> {
13262        self._request = new_value;
13263        self
13264    }
13265    /// Optional. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
13266    ///
13267    /// Sets the *parent* path property to the given value.
13268    ///
13269    /// Even though the property as already been set when instantiating this call,
13270    /// we provide this method for API completeness.
13271    pub fn parent(
13272        mut self,
13273        new_value: &str,
13274    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C> {
13275        self._parent = new_value.to_string();
13276        self
13277    }
13278    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13279    /// while executing the actual API request.
13280    ///
13281    /// ````text
13282    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13283    /// ````
13284    ///
13285    /// Sets the *delegate* property to the given value.
13286    pub fn delegate(
13287        mut self,
13288        new_value: &'a mut dyn common::Delegate,
13289    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C> {
13290        self._delegate = Some(new_value);
13291        self
13292    }
13293
13294    /// Set any additional parameter of the query string used in the request.
13295    /// It should be used to set parameters which are not yet available through their own
13296    /// setters.
13297    ///
13298    /// Please note that this method must not be used to set any of the known parameters
13299    /// which have their own setter method. If done anyway, the request will fail.
13300    ///
13301    /// # Additional Parameters
13302    ///
13303    /// * *$.xgafv* (query-string) - V1 error format.
13304    /// * *access_token* (query-string) - OAuth access token.
13305    /// * *alt* (query-string) - Data format for response.
13306    /// * *callback* (query-string) - JSONP
13307    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13308    /// * *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.
13309    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13310    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13311    /// * *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.
13312    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13313    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13314    pub fn param<T>(
13315        mut self,
13316        name: T,
13317        value: T,
13318    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C>
13319    where
13320        T: AsRef<str>,
13321    {
13322        self._additional_params
13323            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13324        self
13325    }
13326
13327    /// Identifies the authorization scope for the method you are building.
13328    ///
13329    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13330    /// [`Scope::CloudPlatform`].
13331    ///
13332    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13333    /// tokens for more than one scope.
13334    ///
13335    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13336    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13337    /// sufficient, a read-write scope will do as well.
13338    pub fn add_scope<St>(
13339        mut self,
13340        scope: St,
13341    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C>
13342    where
13343        St: AsRef<str>,
13344    {
13345        self._scopes.insert(String::from(scope.as_ref()));
13346        self
13347    }
13348    /// Identifies the authorization scope(s) for the method you are building.
13349    ///
13350    /// See [`Self::add_scope()`] for details.
13351    pub fn add_scopes<I, St>(
13352        mut self,
13353        scopes: I,
13354    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C>
13355    where
13356        I: IntoIterator<Item = St>,
13357        St: AsRef<str>,
13358    {
13359        self._scopes
13360            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13361        self
13362    }
13363
13364    /// Removes all scopes, and no default scope will be used either.
13365    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13366    /// for details).
13367    pub fn clear_scopes(
13368        mut self,
13369    ) -> ProjectLocationCatalogGenerativeQuestionBatchUpdateCall<'a, C> {
13370        self._scopes.clear();
13371        self
13372    }
13373}
13374
13375/// Returns all questions for a given catalog.
13376///
13377/// A builder for the *locations.catalogs.generativeQuestions.list* method supported by a *project* resource.
13378/// It is not used directly, but through a [`ProjectMethods`] instance.
13379///
13380/// # Example
13381///
13382/// Instantiate a resource method builder
13383///
13384/// ```test_harness,no_run
13385/// # extern crate hyper;
13386/// # extern crate hyper_rustls;
13387/// # extern crate google_retail2 as retail2;
13388/// # async fn dox() {
13389/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13390///
13391/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13392/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13393/// #     .with_native_roots()
13394/// #     .unwrap()
13395/// #     .https_only()
13396/// #     .enable_http2()
13397/// #     .build();
13398///
13399/// # let executor = hyper_util::rt::TokioExecutor::new();
13400/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13401/// #     secret,
13402/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13403/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13404/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13405/// #     ),
13406/// # ).build().await.unwrap();
13407///
13408/// # let client = hyper_util::client::legacy::Client::builder(
13409/// #     hyper_util::rt::TokioExecutor::new()
13410/// # )
13411/// # .build(
13412/// #     hyper_rustls::HttpsConnectorBuilder::new()
13413/// #         .with_native_roots()
13414/// #         .unwrap()
13415/// #         .https_or_http()
13416/// #         .enable_http2()
13417/// #         .build()
13418/// # );
13419/// # let mut hub = CloudRetail::new(client, auth);
13420/// // You can configure optional parameters by calling the respective setters at will, and
13421/// // execute the final call using `doit()`.
13422/// // Values shown here are possibly random and not representative !
13423/// let result = hub.projects().locations_catalogs_generative_questions_list("parent")
13424///              .doit().await;
13425/// # }
13426/// ```
13427pub struct ProjectLocationCatalogGenerativeQuestionListCall<'a, C>
13428where
13429    C: 'a,
13430{
13431    hub: &'a CloudRetail<C>,
13432    _parent: String,
13433    _delegate: Option<&'a mut dyn common::Delegate>,
13434    _additional_params: HashMap<String, String>,
13435    _scopes: BTreeSet<String>,
13436}
13437
13438impl<'a, C> common::CallBuilder for ProjectLocationCatalogGenerativeQuestionListCall<'a, C> {}
13439
13440impl<'a, C> ProjectLocationCatalogGenerativeQuestionListCall<'a, C>
13441where
13442    C: common::Connector,
13443{
13444    /// Perform the operation you have build so far.
13445    pub async fn doit(
13446        mut self,
13447    ) -> common::Result<(
13448        common::Response,
13449        GoogleCloudRetailV2ListGenerativeQuestionConfigsResponse,
13450    )> {
13451        use std::borrow::Cow;
13452        use std::io::{Read, Seek};
13453
13454        use common::{url::Params, ToParts};
13455        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13456
13457        let mut dd = common::DefaultDelegate;
13458        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13459        dlg.begin(common::MethodInfo {
13460            id: "retail.projects.locations.catalogs.generativeQuestions.list",
13461            http_method: hyper::Method::GET,
13462        });
13463
13464        for &field in ["alt", "parent"].iter() {
13465            if self._additional_params.contains_key(field) {
13466                dlg.finished(false);
13467                return Err(common::Error::FieldClash(field));
13468            }
13469        }
13470
13471        let mut params = Params::with_capacity(3 + self._additional_params.len());
13472        params.push("parent", self._parent);
13473
13474        params.extend(self._additional_params.iter());
13475
13476        params.push("alt", "json");
13477        let mut url = self.hub._base_url.clone() + "v2/{+parent}/generativeQuestions";
13478        if self._scopes.is_empty() {
13479            self._scopes
13480                .insert(Scope::CloudPlatform.as_ref().to_string());
13481        }
13482
13483        #[allow(clippy::single_element_loop)]
13484        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13485            url = params.uri_replacement(url, param_name, find_this, true);
13486        }
13487        {
13488            let to_remove = ["parent"];
13489            params.remove_params(&to_remove);
13490        }
13491
13492        let url = params.parse_with_url(&url);
13493
13494        loop {
13495            let token = match self
13496                .hub
13497                .auth
13498                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13499                .await
13500            {
13501                Ok(token) => token,
13502                Err(e) => match dlg.token(e) {
13503                    Ok(token) => token,
13504                    Err(e) => {
13505                        dlg.finished(false);
13506                        return Err(common::Error::MissingToken(e));
13507                    }
13508                },
13509            };
13510            let mut req_result = {
13511                let client = &self.hub.client;
13512                dlg.pre_request();
13513                let mut req_builder = hyper::Request::builder()
13514                    .method(hyper::Method::GET)
13515                    .uri(url.as_str())
13516                    .header(USER_AGENT, self.hub._user_agent.clone());
13517
13518                if let Some(token) = token.as_ref() {
13519                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13520                }
13521
13522                let request = req_builder
13523                    .header(CONTENT_LENGTH, 0_u64)
13524                    .body(common::to_body::<String>(None));
13525
13526                client.request(request.unwrap()).await
13527            };
13528
13529            match req_result {
13530                Err(err) => {
13531                    if let common::Retry::After(d) = dlg.http_error(&err) {
13532                        sleep(d).await;
13533                        continue;
13534                    }
13535                    dlg.finished(false);
13536                    return Err(common::Error::HttpError(err));
13537                }
13538                Ok(res) => {
13539                    let (mut parts, body) = res.into_parts();
13540                    let mut body = common::Body::new(body);
13541                    if !parts.status.is_success() {
13542                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13543                        let error = serde_json::from_str(&common::to_string(&bytes));
13544                        let response = common::to_response(parts, bytes.into());
13545
13546                        if let common::Retry::After(d) =
13547                            dlg.http_failure(&response, error.as_ref().ok())
13548                        {
13549                            sleep(d).await;
13550                            continue;
13551                        }
13552
13553                        dlg.finished(false);
13554
13555                        return Err(match error {
13556                            Ok(value) => common::Error::BadRequest(value),
13557                            _ => common::Error::Failure(response),
13558                        });
13559                    }
13560                    let response = {
13561                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13562                        let encoded = common::to_string(&bytes);
13563                        match serde_json::from_str(&encoded) {
13564                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13565                            Err(error) => {
13566                                dlg.response_json_decode_error(&encoded, &error);
13567                                return Err(common::Error::JsonDecodeError(
13568                                    encoded.to_string(),
13569                                    error,
13570                                ));
13571                            }
13572                        }
13573                    };
13574
13575                    dlg.finished(true);
13576                    return Ok(response);
13577                }
13578            }
13579        }
13580    }
13581
13582    /// Required. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
13583    ///
13584    /// Sets the *parent* path property to the given value.
13585    ///
13586    /// Even though the property as already been set when instantiating this call,
13587    /// we provide this method for API completeness.
13588    pub fn parent(
13589        mut self,
13590        new_value: &str,
13591    ) -> ProjectLocationCatalogGenerativeQuestionListCall<'a, C> {
13592        self._parent = new_value.to_string();
13593        self
13594    }
13595    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13596    /// while executing the actual API request.
13597    ///
13598    /// ````text
13599    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13600    /// ````
13601    ///
13602    /// Sets the *delegate* property to the given value.
13603    pub fn delegate(
13604        mut self,
13605        new_value: &'a mut dyn common::Delegate,
13606    ) -> ProjectLocationCatalogGenerativeQuestionListCall<'a, C> {
13607        self._delegate = Some(new_value);
13608        self
13609    }
13610
13611    /// Set any additional parameter of the query string used in the request.
13612    /// It should be used to set parameters which are not yet available through their own
13613    /// setters.
13614    ///
13615    /// Please note that this method must not be used to set any of the known parameters
13616    /// which have their own setter method. If done anyway, the request will fail.
13617    ///
13618    /// # Additional Parameters
13619    ///
13620    /// * *$.xgafv* (query-string) - V1 error format.
13621    /// * *access_token* (query-string) - OAuth access token.
13622    /// * *alt* (query-string) - Data format for response.
13623    /// * *callback* (query-string) - JSONP
13624    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13625    /// * *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.
13626    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13627    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13628    /// * *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.
13629    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13630    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13631    pub fn param<T>(
13632        mut self,
13633        name: T,
13634        value: T,
13635    ) -> ProjectLocationCatalogGenerativeQuestionListCall<'a, C>
13636    where
13637        T: AsRef<str>,
13638    {
13639        self._additional_params
13640            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13641        self
13642    }
13643
13644    /// Identifies the authorization scope for the method you are building.
13645    ///
13646    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13647    /// [`Scope::CloudPlatform`].
13648    ///
13649    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13650    /// tokens for more than one scope.
13651    ///
13652    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13653    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13654    /// sufficient, a read-write scope will do as well.
13655    pub fn add_scope<St>(
13656        mut self,
13657        scope: St,
13658    ) -> ProjectLocationCatalogGenerativeQuestionListCall<'a, C>
13659    where
13660        St: AsRef<str>,
13661    {
13662        self._scopes.insert(String::from(scope.as_ref()));
13663        self
13664    }
13665    /// Identifies the authorization scope(s) for the method you are building.
13666    ///
13667    /// See [`Self::add_scope()`] for details.
13668    pub fn add_scopes<I, St>(
13669        mut self,
13670        scopes: I,
13671    ) -> ProjectLocationCatalogGenerativeQuestionListCall<'a, C>
13672    where
13673        I: IntoIterator<Item = St>,
13674        St: AsRef<str>,
13675    {
13676        self._scopes
13677            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13678        self
13679    }
13680
13681    /// Removes all scopes, and no default scope will be used either.
13682    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13683    /// for details).
13684    pub fn clear_scopes(mut self) -> ProjectLocationCatalogGenerativeQuestionListCall<'a, C> {
13685        self._scopes.clear();
13686        self
13687    }
13688}
13689
13690/// Creates a new model.
13691///
13692/// A builder for the *locations.catalogs.models.create* method supported by a *project* resource.
13693/// It is not used directly, but through a [`ProjectMethods`] instance.
13694///
13695/// # Example
13696///
13697/// Instantiate a resource method builder
13698///
13699/// ```test_harness,no_run
13700/// # extern crate hyper;
13701/// # extern crate hyper_rustls;
13702/// # extern crate google_retail2 as retail2;
13703/// use retail2::api::GoogleCloudRetailV2Model;
13704/// # async fn dox() {
13705/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13706///
13707/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13708/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13709/// #     .with_native_roots()
13710/// #     .unwrap()
13711/// #     .https_only()
13712/// #     .enable_http2()
13713/// #     .build();
13714///
13715/// # let executor = hyper_util::rt::TokioExecutor::new();
13716/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13717/// #     secret,
13718/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13719/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13720/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13721/// #     ),
13722/// # ).build().await.unwrap();
13723///
13724/// # let client = hyper_util::client::legacy::Client::builder(
13725/// #     hyper_util::rt::TokioExecutor::new()
13726/// # )
13727/// # .build(
13728/// #     hyper_rustls::HttpsConnectorBuilder::new()
13729/// #         .with_native_roots()
13730/// #         .unwrap()
13731/// #         .https_or_http()
13732/// #         .enable_http2()
13733/// #         .build()
13734/// # );
13735/// # let mut hub = CloudRetail::new(client, auth);
13736/// // As the method needs a request, you would usually fill it with the desired information
13737/// // into the respective structure. Some of the parts shown here might not be applicable !
13738/// // Values shown here are possibly random and not representative !
13739/// let mut req = GoogleCloudRetailV2Model::default();
13740///
13741/// // You can configure optional parameters by calling the respective setters at will, and
13742/// // execute the final call using `doit()`.
13743/// // Values shown here are possibly random and not representative !
13744/// let result = hub.projects().locations_catalogs_models_create(req, "parent")
13745///              .dry_run(true)
13746///              .doit().await;
13747/// # }
13748/// ```
13749pub struct ProjectLocationCatalogModelCreateCall<'a, C>
13750where
13751    C: 'a,
13752{
13753    hub: &'a CloudRetail<C>,
13754    _request: GoogleCloudRetailV2Model,
13755    _parent: String,
13756    _dry_run: Option<bool>,
13757    _delegate: Option<&'a mut dyn common::Delegate>,
13758    _additional_params: HashMap<String, String>,
13759    _scopes: BTreeSet<String>,
13760}
13761
13762impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelCreateCall<'a, C> {}
13763
13764impl<'a, C> ProjectLocationCatalogModelCreateCall<'a, C>
13765where
13766    C: common::Connector,
13767{
13768    /// Perform the operation you have build so far.
13769    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
13770        use std::borrow::Cow;
13771        use std::io::{Read, Seek};
13772
13773        use common::{url::Params, ToParts};
13774        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13775
13776        let mut dd = common::DefaultDelegate;
13777        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13778        dlg.begin(common::MethodInfo {
13779            id: "retail.projects.locations.catalogs.models.create",
13780            http_method: hyper::Method::POST,
13781        });
13782
13783        for &field in ["alt", "parent", "dryRun"].iter() {
13784            if self._additional_params.contains_key(field) {
13785                dlg.finished(false);
13786                return Err(common::Error::FieldClash(field));
13787            }
13788        }
13789
13790        let mut params = Params::with_capacity(5 + self._additional_params.len());
13791        params.push("parent", self._parent);
13792        if let Some(value) = self._dry_run.as_ref() {
13793            params.push("dryRun", value.to_string());
13794        }
13795
13796        params.extend(self._additional_params.iter());
13797
13798        params.push("alt", "json");
13799        let mut url = self.hub._base_url.clone() + "v2/{+parent}/models";
13800        if self._scopes.is_empty() {
13801            self._scopes
13802                .insert(Scope::CloudPlatform.as_ref().to_string());
13803        }
13804
13805        #[allow(clippy::single_element_loop)]
13806        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13807            url = params.uri_replacement(url, param_name, find_this, true);
13808        }
13809        {
13810            let to_remove = ["parent"];
13811            params.remove_params(&to_remove);
13812        }
13813
13814        let url = params.parse_with_url(&url);
13815
13816        let mut json_mime_type = mime::APPLICATION_JSON;
13817        let mut request_value_reader = {
13818            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13819            common::remove_json_null_values(&mut value);
13820            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13821            serde_json::to_writer(&mut dst, &value).unwrap();
13822            dst
13823        };
13824        let request_size = request_value_reader
13825            .seek(std::io::SeekFrom::End(0))
13826            .unwrap();
13827        request_value_reader
13828            .seek(std::io::SeekFrom::Start(0))
13829            .unwrap();
13830
13831        loop {
13832            let token = match self
13833                .hub
13834                .auth
13835                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13836                .await
13837            {
13838                Ok(token) => token,
13839                Err(e) => match dlg.token(e) {
13840                    Ok(token) => token,
13841                    Err(e) => {
13842                        dlg.finished(false);
13843                        return Err(common::Error::MissingToken(e));
13844                    }
13845                },
13846            };
13847            request_value_reader
13848                .seek(std::io::SeekFrom::Start(0))
13849                .unwrap();
13850            let mut req_result = {
13851                let client = &self.hub.client;
13852                dlg.pre_request();
13853                let mut req_builder = hyper::Request::builder()
13854                    .method(hyper::Method::POST)
13855                    .uri(url.as_str())
13856                    .header(USER_AGENT, self.hub._user_agent.clone());
13857
13858                if let Some(token) = token.as_ref() {
13859                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13860                }
13861
13862                let request = req_builder
13863                    .header(CONTENT_TYPE, json_mime_type.to_string())
13864                    .header(CONTENT_LENGTH, request_size as u64)
13865                    .body(common::to_body(
13866                        request_value_reader.get_ref().clone().into(),
13867                    ));
13868
13869                client.request(request.unwrap()).await
13870            };
13871
13872            match req_result {
13873                Err(err) => {
13874                    if let common::Retry::After(d) = dlg.http_error(&err) {
13875                        sleep(d).await;
13876                        continue;
13877                    }
13878                    dlg.finished(false);
13879                    return Err(common::Error::HttpError(err));
13880                }
13881                Ok(res) => {
13882                    let (mut parts, body) = res.into_parts();
13883                    let mut body = common::Body::new(body);
13884                    if !parts.status.is_success() {
13885                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13886                        let error = serde_json::from_str(&common::to_string(&bytes));
13887                        let response = common::to_response(parts, bytes.into());
13888
13889                        if let common::Retry::After(d) =
13890                            dlg.http_failure(&response, error.as_ref().ok())
13891                        {
13892                            sleep(d).await;
13893                            continue;
13894                        }
13895
13896                        dlg.finished(false);
13897
13898                        return Err(match error {
13899                            Ok(value) => common::Error::BadRequest(value),
13900                            _ => common::Error::Failure(response),
13901                        });
13902                    }
13903                    let response = {
13904                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13905                        let encoded = common::to_string(&bytes);
13906                        match serde_json::from_str(&encoded) {
13907                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13908                            Err(error) => {
13909                                dlg.response_json_decode_error(&encoded, &error);
13910                                return Err(common::Error::JsonDecodeError(
13911                                    encoded.to_string(),
13912                                    error,
13913                                ));
13914                            }
13915                        }
13916                    };
13917
13918                    dlg.finished(true);
13919                    return Ok(response);
13920                }
13921            }
13922        }
13923    }
13924
13925    ///
13926    /// Sets the *request* property to the given value.
13927    ///
13928    /// Even though the property as already been set when instantiating this call,
13929    /// we provide this method for API completeness.
13930    pub fn request(
13931        mut self,
13932        new_value: GoogleCloudRetailV2Model,
13933    ) -> ProjectLocationCatalogModelCreateCall<'a, C> {
13934        self._request = new_value;
13935        self
13936    }
13937    /// Required. The parent resource under which to create the model. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
13938    ///
13939    /// Sets the *parent* path property to the given value.
13940    ///
13941    /// Even though the property as already been set when instantiating this call,
13942    /// we provide this method for API completeness.
13943    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogModelCreateCall<'a, C> {
13944        self._parent = new_value.to_string();
13945        self
13946    }
13947    /// Optional. Whether to run a dry run to validate the request (without actually creating the model).
13948    ///
13949    /// Sets the *dry run* query property to the given value.
13950    pub fn dry_run(mut self, new_value: bool) -> ProjectLocationCatalogModelCreateCall<'a, C> {
13951        self._dry_run = Some(new_value);
13952        self
13953    }
13954    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13955    /// while executing the actual API request.
13956    ///
13957    /// ````text
13958    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13959    /// ````
13960    ///
13961    /// Sets the *delegate* property to the given value.
13962    pub fn delegate(
13963        mut self,
13964        new_value: &'a mut dyn common::Delegate,
13965    ) -> ProjectLocationCatalogModelCreateCall<'a, C> {
13966        self._delegate = Some(new_value);
13967        self
13968    }
13969
13970    /// Set any additional parameter of the query string used in the request.
13971    /// It should be used to set parameters which are not yet available through their own
13972    /// setters.
13973    ///
13974    /// Please note that this method must not be used to set any of the known parameters
13975    /// which have their own setter method. If done anyway, the request will fail.
13976    ///
13977    /// # Additional Parameters
13978    ///
13979    /// * *$.xgafv* (query-string) - V1 error format.
13980    /// * *access_token* (query-string) - OAuth access token.
13981    /// * *alt* (query-string) - Data format for response.
13982    /// * *callback* (query-string) - JSONP
13983    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13984    /// * *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.
13985    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13986    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13987    /// * *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.
13988    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13989    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13990    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelCreateCall<'a, C>
13991    where
13992        T: AsRef<str>,
13993    {
13994        self._additional_params
13995            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13996        self
13997    }
13998
13999    /// Identifies the authorization scope for the method you are building.
14000    ///
14001    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14002    /// [`Scope::CloudPlatform`].
14003    ///
14004    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14005    /// tokens for more than one scope.
14006    ///
14007    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14008    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14009    /// sufficient, a read-write scope will do as well.
14010    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelCreateCall<'a, C>
14011    where
14012        St: AsRef<str>,
14013    {
14014        self._scopes.insert(String::from(scope.as_ref()));
14015        self
14016    }
14017    /// Identifies the authorization scope(s) for the method you are building.
14018    ///
14019    /// See [`Self::add_scope()`] for details.
14020    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelCreateCall<'a, C>
14021    where
14022        I: IntoIterator<Item = St>,
14023        St: AsRef<str>,
14024    {
14025        self._scopes
14026            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14027        self
14028    }
14029
14030    /// Removes all scopes, and no default scope will be used either.
14031    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14032    /// for details).
14033    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelCreateCall<'a, C> {
14034        self._scopes.clear();
14035        self
14036    }
14037}
14038
14039/// Deletes an existing model.
14040///
14041/// A builder for the *locations.catalogs.models.delete* method supported by a *project* resource.
14042/// It is not used directly, but through a [`ProjectMethods`] instance.
14043///
14044/// # Example
14045///
14046/// Instantiate a resource method builder
14047///
14048/// ```test_harness,no_run
14049/// # extern crate hyper;
14050/// # extern crate hyper_rustls;
14051/// # extern crate google_retail2 as retail2;
14052/// # async fn dox() {
14053/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14054///
14055/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14056/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14057/// #     .with_native_roots()
14058/// #     .unwrap()
14059/// #     .https_only()
14060/// #     .enable_http2()
14061/// #     .build();
14062///
14063/// # let executor = hyper_util::rt::TokioExecutor::new();
14064/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14065/// #     secret,
14066/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14067/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14068/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14069/// #     ),
14070/// # ).build().await.unwrap();
14071///
14072/// # let client = hyper_util::client::legacy::Client::builder(
14073/// #     hyper_util::rt::TokioExecutor::new()
14074/// # )
14075/// # .build(
14076/// #     hyper_rustls::HttpsConnectorBuilder::new()
14077/// #         .with_native_roots()
14078/// #         .unwrap()
14079/// #         .https_or_http()
14080/// #         .enable_http2()
14081/// #         .build()
14082/// # );
14083/// # let mut hub = CloudRetail::new(client, auth);
14084/// // You can configure optional parameters by calling the respective setters at will, and
14085/// // execute the final call using `doit()`.
14086/// // Values shown here are possibly random and not representative !
14087/// let result = hub.projects().locations_catalogs_models_delete("name")
14088///              .doit().await;
14089/// # }
14090/// ```
14091pub struct ProjectLocationCatalogModelDeleteCall<'a, C>
14092where
14093    C: 'a,
14094{
14095    hub: &'a CloudRetail<C>,
14096    _name: String,
14097    _delegate: Option<&'a mut dyn common::Delegate>,
14098    _additional_params: HashMap<String, String>,
14099    _scopes: BTreeSet<String>,
14100}
14101
14102impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelDeleteCall<'a, C> {}
14103
14104impl<'a, C> ProjectLocationCatalogModelDeleteCall<'a, C>
14105where
14106    C: common::Connector,
14107{
14108    /// Perform the operation you have build so far.
14109    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
14110        use std::borrow::Cow;
14111        use std::io::{Read, Seek};
14112
14113        use common::{url::Params, ToParts};
14114        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14115
14116        let mut dd = common::DefaultDelegate;
14117        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14118        dlg.begin(common::MethodInfo {
14119            id: "retail.projects.locations.catalogs.models.delete",
14120            http_method: hyper::Method::DELETE,
14121        });
14122
14123        for &field in ["alt", "name"].iter() {
14124            if self._additional_params.contains_key(field) {
14125                dlg.finished(false);
14126                return Err(common::Error::FieldClash(field));
14127            }
14128        }
14129
14130        let mut params = Params::with_capacity(3 + self._additional_params.len());
14131        params.push("name", self._name);
14132
14133        params.extend(self._additional_params.iter());
14134
14135        params.push("alt", "json");
14136        let mut url = self.hub._base_url.clone() + "v2/{+name}";
14137        if self._scopes.is_empty() {
14138            self._scopes
14139                .insert(Scope::CloudPlatform.as_ref().to_string());
14140        }
14141
14142        #[allow(clippy::single_element_loop)]
14143        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14144            url = params.uri_replacement(url, param_name, find_this, true);
14145        }
14146        {
14147            let to_remove = ["name"];
14148            params.remove_params(&to_remove);
14149        }
14150
14151        let url = params.parse_with_url(&url);
14152
14153        loop {
14154            let token = match self
14155                .hub
14156                .auth
14157                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14158                .await
14159            {
14160                Ok(token) => token,
14161                Err(e) => match dlg.token(e) {
14162                    Ok(token) => token,
14163                    Err(e) => {
14164                        dlg.finished(false);
14165                        return Err(common::Error::MissingToken(e));
14166                    }
14167                },
14168            };
14169            let mut req_result = {
14170                let client = &self.hub.client;
14171                dlg.pre_request();
14172                let mut req_builder = hyper::Request::builder()
14173                    .method(hyper::Method::DELETE)
14174                    .uri(url.as_str())
14175                    .header(USER_AGENT, self.hub._user_agent.clone());
14176
14177                if let Some(token) = token.as_ref() {
14178                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14179                }
14180
14181                let request = req_builder
14182                    .header(CONTENT_LENGTH, 0_u64)
14183                    .body(common::to_body::<String>(None));
14184
14185                client.request(request.unwrap()).await
14186            };
14187
14188            match req_result {
14189                Err(err) => {
14190                    if let common::Retry::After(d) = dlg.http_error(&err) {
14191                        sleep(d).await;
14192                        continue;
14193                    }
14194                    dlg.finished(false);
14195                    return Err(common::Error::HttpError(err));
14196                }
14197                Ok(res) => {
14198                    let (mut parts, body) = res.into_parts();
14199                    let mut body = common::Body::new(body);
14200                    if !parts.status.is_success() {
14201                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14202                        let error = serde_json::from_str(&common::to_string(&bytes));
14203                        let response = common::to_response(parts, bytes.into());
14204
14205                        if let common::Retry::After(d) =
14206                            dlg.http_failure(&response, error.as_ref().ok())
14207                        {
14208                            sleep(d).await;
14209                            continue;
14210                        }
14211
14212                        dlg.finished(false);
14213
14214                        return Err(match error {
14215                            Ok(value) => common::Error::BadRequest(value),
14216                            _ => common::Error::Failure(response),
14217                        });
14218                    }
14219                    let response = {
14220                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14221                        let encoded = common::to_string(&bytes);
14222                        match serde_json::from_str(&encoded) {
14223                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14224                            Err(error) => {
14225                                dlg.response_json_decode_error(&encoded, &error);
14226                                return Err(common::Error::JsonDecodeError(
14227                                    encoded.to_string(),
14228                                    error,
14229                                ));
14230                            }
14231                        }
14232                    };
14233
14234                    dlg.finished(true);
14235                    return Ok(response);
14236                }
14237            }
14238        }
14239    }
14240
14241    /// Required. The resource name of the Model to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
14242    ///
14243    /// Sets the *name* path property to the given value.
14244    ///
14245    /// Even though the property as already been set when instantiating this call,
14246    /// we provide this method for API completeness.
14247    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogModelDeleteCall<'a, C> {
14248        self._name = new_value.to_string();
14249        self
14250    }
14251    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14252    /// while executing the actual API request.
14253    ///
14254    /// ````text
14255    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14256    /// ````
14257    ///
14258    /// Sets the *delegate* property to the given value.
14259    pub fn delegate(
14260        mut self,
14261        new_value: &'a mut dyn common::Delegate,
14262    ) -> ProjectLocationCatalogModelDeleteCall<'a, C> {
14263        self._delegate = Some(new_value);
14264        self
14265    }
14266
14267    /// Set any additional parameter of the query string used in the request.
14268    /// It should be used to set parameters which are not yet available through their own
14269    /// setters.
14270    ///
14271    /// Please note that this method must not be used to set any of the known parameters
14272    /// which have their own setter method. If done anyway, the request will fail.
14273    ///
14274    /// # Additional Parameters
14275    ///
14276    /// * *$.xgafv* (query-string) - V1 error format.
14277    /// * *access_token* (query-string) - OAuth access token.
14278    /// * *alt* (query-string) - Data format for response.
14279    /// * *callback* (query-string) - JSONP
14280    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14281    /// * *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.
14282    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14283    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14284    /// * *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.
14285    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14286    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14287    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelDeleteCall<'a, C>
14288    where
14289        T: AsRef<str>,
14290    {
14291        self._additional_params
14292            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14293        self
14294    }
14295
14296    /// Identifies the authorization scope for the method you are building.
14297    ///
14298    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14299    /// [`Scope::CloudPlatform`].
14300    ///
14301    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14302    /// tokens for more than one scope.
14303    ///
14304    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14305    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14306    /// sufficient, a read-write scope will do as well.
14307    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelDeleteCall<'a, C>
14308    where
14309        St: AsRef<str>,
14310    {
14311        self._scopes.insert(String::from(scope.as_ref()));
14312        self
14313    }
14314    /// Identifies the authorization scope(s) for the method you are building.
14315    ///
14316    /// See [`Self::add_scope()`] for details.
14317    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelDeleteCall<'a, C>
14318    where
14319        I: IntoIterator<Item = St>,
14320        St: AsRef<str>,
14321    {
14322        self._scopes
14323            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14324        self
14325    }
14326
14327    /// Removes all scopes, and no default scope will be used either.
14328    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14329    /// for details).
14330    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelDeleteCall<'a, C> {
14331        self._scopes.clear();
14332        self
14333    }
14334}
14335
14336/// Gets a model.
14337///
14338/// A builder for the *locations.catalogs.models.get* method supported by a *project* resource.
14339/// It is not used directly, but through a [`ProjectMethods`] instance.
14340///
14341/// # Example
14342///
14343/// Instantiate a resource method builder
14344///
14345/// ```test_harness,no_run
14346/// # extern crate hyper;
14347/// # extern crate hyper_rustls;
14348/// # extern crate google_retail2 as retail2;
14349/// # async fn dox() {
14350/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14351///
14352/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14353/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14354/// #     .with_native_roots()
14355/// #     .unwrap()
14356/// #     .https_only()
14357/// #     .enable_http2()
14358/// #     .build();
14359///
14360/// # let executor = hyper_util::rt::TokioExecutor::new();
14361/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14362/// #     secret,
14363/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14364/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14365/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14366/// #     ),
14367/// # ).build().await.unwrap();
14368///
14369/// # let client = hyper_util::client::legacy::Client::builder(
14370/// #     hyper_util::rt::TokioExecutor::new()
14371/// # )
14372/// # .build(
14373/// #     hyper_rustls::HttpsConnectorBuilder::new()
14374/// #         .with_native_roots()
14375/// #         .unwrap()
14376/// #         .https_or_http()
14377/// #         .enable_http2()
14378/// #         .build()
14379/// # );
14380/// # let mut hub = CloudRetail::new(client, auth);
14381/// // You can configure optional parameters by calling the respective setters at will, and
14382/// // execute the final call using `doit()`.
14383/// // Values shown here are possibly random and not representative !
14384/// let result = hub.projects().locations_catalogs_models_get("name")
14385///              .doit().await;
14386/// # }
14387/// ```
14388pub struct ProjectLocationCatalogModelGetCall<'a, C>
14389where
14390    C: 'a,
14391{
14392    hub: &'a CloudRetail<C>,
14393    _name: String,
14394    _delegate: Option<&'a mut dyn common::Delegate>,
14395    _additional_params: HashMap<String, String>,
14396    _scopes: BTreeSet<String>,
14397}
14398
14399impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelGetCall<'a, C> {}
14400
14401impl<'a, C> ProjectLocationCatalogModelGetCall<'a, C>
14402where
14403    C: common::Connector,
14404{
14405    /// Perform the operation you have build so far.
14406    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Model)> {
14407        use std::borrow::Cow;
14408        use std::io::{Read, Seek};
14409
14410        use common::{url::Params, ToParts};
14411        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14412
14413        let mut dd = common::DefaultDelegate;
14414        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14415        dlg.begin(common::MethodInfo {
14416            id: "retail.projects.locations.catalogs.models.get",
14417            http_method: hyper::Method::GET,
14418        });
14419
14420        for &field in ["alt", "name"].iter() {
14421            if self._additional_params.contains_key(field) {
14422                dlg.finished(false);
14423                return Err(common::Error::FieldClash(field));
14424            }
14425        }
14426
14427        let mut params = Params::with_capacity(3 + self._additional_params.len());
14428        params.push("name", self._name);
14429
14430        params.extend(self._additional_params.iter());
14431
14432        params.push("alt", "json");
14433        let mut url = self.hub._base_url.clone() + "v2/{+name}";
14434        if self._scopes.is_empty() {
14435            self._scopes
14436                .insert(Scope::CloudPlatform.as_ref().to_string());
14437        }
14438
14439        #[allow(clippy::single_element_loop)]
14440        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14441            url = params.uri_replacement(url, param_name, find_this, true);
14442        }
14443        {
14444            let to_remove = ["name"];
14445            params.remove_params(&to_remove);
14446        }
14447
14448        let url = params.parse_with_url(&url);
14449
14450        loop {
14451            let token = match self
14452                .hub
14453                .auth
14454                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14455                .await
14456            {
14457                Ok(token) => token,
14458                Err(e) => match dlg.token(e) {
14459                    Ok(token) => token,
14460                    Err(e) => {
14461                        dlg.finished(false);
14462                        return Err(common::Error::MissingToken(e));
14463                    }
14464                },
14465            };
14466            let mut req_result = {
14467                let client = &self.hub.client;
14468                dlg.pre_request();
14469                let mut req_builder = hyper::Request::builder()
14470                    .method(hyper::Method::GET)
14471                    .uri(url.as_str())
14472                    .header(USER_AGENT, self.hub._user_agent.clone());
14473
14474                if let Some(token) = token.as_ref() {
14475                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14476                }
14477
14478                let request = req_builder
14479                    .header(CONTENT_LENGTH, 0_u64)
14480                    .body(common::to_body::<String>(None));
14481
14482                client.request(request.unwrap()).await
14483            };
14484
14485            match req_result {
14486                Err(err) => {
14487                    if let common::Retry::After(d) = dlg.http_error(&err) {
14488                        sleep(d).await;
14489                        continue;
14490                    }
14491                    dlg.finished(false);
14492                    return Err(common::Error::HttpError(err));
14493                }
14494                Ok(res) => {
14495                    let (mut parts, body) = res.into_parts();
14496                    let mut body = common::Body::new(body);
14497                    if !parts.status.is_success() {
14498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14499                        let error = serde_json::from_str(&common::to_string(&bytes));
14500                        let response = common::to_response(parts, bytes.into());
14501
14502                        if let common::Retry::After(d) =
14503                            dlg.http_failure(&response, error.as_ref().ok())
14504                        {
14505                            sleep(d).await;
14506                            continue;
14507                        }
14508
14509                        dlg.finished(false);
14510
14511                        return Err(match error {
14512                            Ok(value) => common::Error::BadRequest(value),
14513                            _ => common::Error::Failure(response),
14514                        });
14515                    }
14516                    let response = {
14517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14518                        let encoded = common::to_string(&bytes);
14519                        match serde_json::from_str(&encoded) {
14520                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14521                            Err(error) => {
14522                                dlg.response_json_decode_error(&encoded, &error);
14523                                return Err(common::Error::JsonDecodeError(
14524                                    encoded.to_string(),
14525                                    error,
14526                                ));
14527                            }
14528                        }
14529                    };
14530
14531                    dlg.finished(true);
14532                    return Ok(response);
14533                }
14534            }
14535        }
14536    }
14537
14538    /// Required. The resource name of the Model to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}`
14539    ///
14540    /// Sets the *name* path property to the given value.
14541    ///
14542    /// Even though the property as already been set when instantiating this call,
14543    /// we provide this method for API completeness.
14544    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogModelGetCall<'a, C> {
14545        self._name = new_value.to_string();
14546        self
14547    }
14548    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14549    /// while executing the actual API request.
14550    ///
14551    /// ````text
14552    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14553    /// ````
14554    ///
14555    /// Sets the *delegate* property to the given value.
14556    pub fn delegate(
14557        mut self,
14558        new_value: &'a mut dyn common::Delegate,
14559    ) -> ProjectLocationCatalogModelGetCall<'a, C> {
14560        self._delegate = Some(new_value);
14561        self
14562    }
14563
14564    /// Set any additional parameter of the query string used in the request.
14565    /// It should be used to set parameters which are not yet available through their own
14566    /// setters.
14567    ///
14568    /// Please note that this method must not be used to set any of the known parameters
14569    /// which have their own setter method. If done anyway, the request will fail.
14570    ///
14571    /// # Additional Parameters
14572    ///
14573    /// * *$.xgafv* (query-string) - V1 error format.
14574    /// * *access_token* (query-string) - OAuth access token.
14575    /// * *alt* (query-string) - Data format for response.
14576    /// * *callback* (query-string) - JSONP
14577    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14578    /// * *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.
14579    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14580    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14581    /// * *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.
14582    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14583    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14584    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelGetCall<'a, C>
14585    where
14586        T: AsRef<str>,
14587    {
14588        self._additional_params
14589            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14590        self
14591    }
14592
14593    /// Identifies the authorization scope for the method you are building.
14594    ///
14595    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14596    /// [`Scope::CloudPlatform`].
14597    ///
14598    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14599    /// tokens for more than one scope.
14600    ///
14601    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14602    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14603    /// sufficient, a read-write scope will do as well.
14604    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelGetCall<'a, C>
14605    where
14606        St: AsRef<str>,
14607    {
14608        self._scopes.insert(String::from(scope.as_ref()));
14609        self
14610    }
14611    /// Identifies the authorization scope(s) for the method you are building.
14612    ///
14613    /// See [`Self::add_scope()`] for details.
14614    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelGetCall<'a, C>
14615    where
14616        I: IntoIterator<Item = St>,
14617        St: AsRef<str>,
14618    {
14619        self._scopes
14620            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14621        self
14622    }
14623
14624    /// Removes all scopes, and no default scope will be used either.
14625    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14626    /// for details).
14627    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelGetCall<'a, C> {
14628        self._scopes.clear();
14629        self
14630    }
14631}
14632
14633/// Lists all the models linked to this event store.
14634///
14635/// A builder for the *locations.catalogs.models.list* method supported by a *project* resource.
14636/// It is not used directly, but through a [`ProjectMethods`] instance.
14637///
14638/// # Example
14639///
14640/// Instantiate a resource method builder
14641///
14642/// ```test_harness,no_run
14643/// # extern crate hyper;
14644/// # extern crate hyper_rustls;
14645/// # extern crate google_retail2 as retail2;
14646/// # async fn dox() {
14647/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14648///
14649/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14650/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14651/// #     .with_native_roots()
14652/// #     .unwrap()
14653/// #     .https_only()
14654/// #     .enable_http2()
14655/// #     .build();
14656///
14657/// # let executor = hyper_util::rt::TokioExecutor::new();
14658/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14659/// #     secret,
14660/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14661/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14662/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14663/// #     ),
14664/// # ).build().await.unwrap();
14665///
14666/// # let client = hyper_util::client::legacy::Client::builder(
14667/// #     hyper_util::rt::TokioExecutor::new()
14668/// # )
14669/// # .build(
14670/// #     hyper_rustls::HttpsConnectorBuilder::new()
14671/// #         .with_native_roots()
14672/// #         .unwrap()
14673/// #         .https_or_http()
14674/// #         .enable_http2()
14675/// #         .build()
14676/// # );
14677/// # let mut hub = CloudRetail::new(client, auth);
14678/// // You can configure optional parameters by calling the respective setters at will, and
14679/// // execute the final call using `doit()`.
14680/// // Values shown here are possibly random and not representative !
14681/// let result = hub.projects().locations_catalogs_models_list("parent")
14682///              .page_token("duo")
14683///              .page_size(-34)
14684///              .doit().await;
14685/// # }
14686/// ```
14687pub struct ProjectLocationCatalogModelListCall<'a, C>
14688where
14689    C: 'a,
14690{
14691    hub: &'a CloudRetail<C>,
14692    _parent: String,
14693    _page_token: Option<String>,
14694    _page_size: Option<i32>,
14695    _delegate: Option<&'a mut dyn common::Delegate>,
14696    _additional_params: HashMap<String, String>,
14697    _scopes: BTreeSet<String>,
14698}
14699
14700impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelListCall<'a, C> {}
14701
14702impl<'a, C> ProjectLocationCatalogModelListCall<'a, C>
14703where
14704    C: common::Connector,
14705{
14706    /// Perform the operation you have build so far.
14707    pub async fn doit(
14708        mut self,
14709    ) -> common::Result<(common::Response, GoogleCloudRetailV2ListModelsResponse)> {
14710        use std::borrow::Cow;
14711        use std::io::{Read, Seek};
14712
14713        use common::{url::Params, ToParts};
14714        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14715
14716        let mut dd = common::DefaultDelegate;
14717        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14718        dlg.begin(common::MethodInfo {
14719            id: "retail.projects.locations.catalogs.models.list",
14720            http_method: hyper::Method::GET,
14721        });
14722
14723        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
14724            if self._additional_params.contains_key(field) {
14725                dlg.finished(false);
14726                return Err(common::Error::FieldClash(field));
14727            }
14728        }
14729
14730        let mut params = Params::with_capacity(5 + self._additional_params.len());
14731        params.push("parent", self._parent);
14732        if let Some(value) = self._page_token.as_ref() {
14733            params.push("pageToken", value);
14734        }
14735        if let Some(value) = self._page_size.as_ref() {
14736            params.push("pageSize", value.to_string());
14737        }
14738
14739        params.extend(self._additional_params.iter());
14740
14741        params.push("alt", "json");
14742        let mut url = self.hub._base_url.clone() + "v2/{+parent}/models";
14743        if self._scopes.is_empty() {
14744            self._scopes
14745                .insert(Scope::CloudPlatform.as_ref().to_string());
14746        }
14747
14748        #[allow(clippy::single_element_loop)]
14749        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14750            url = params.uri_replacement(url, param_name, find_this, true);
14751        }
14752        {
14753            let to_remove = ["parent"];
14754            params.remove_params(&to_remove);
14755        }
14756
14757        let url = params.parse_with_url(&url);
14758
14759        loop {
14760            let token = match self
14761                .hub
14762                .auth
14763                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14764                .await
14765            {
14766                Ok(token) => token,
14767                Err(e) => match dlg.token(e) {
14768                    Ok(token) => token,
14769                    Err(e) => {
14770                        dlg.finished(false);
14771                        return Err(common::Error::MissingToken(e));
14772                    }
14773                },
14774            };
14775            let mut req_result = {
14776                let client = &self.hub.client;
14777                dlg.pre_request();
14778                let mut req_builder = hyper::Request::builder()
14779                    .method(hyper::Method::GET)
14780                    .uri(url.as_str())
14781                    .header(USER_AGENT, self.hub._user_agent.clone());
14782
14783                if let Some(token) = token.as_ref() {
14784                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14785                }
14786
14787                let request = req_builder
14788                    .header(CONTENT_LENGTH, 0_u64)
14789                    .body(common::to_body::<String>(None));
14790
14791                client.request(request.unwrap()).await
14792            };
14793
14794            match req_result {
14795                Err(err) => {
14796                    if let common::Retry::After(d) = dlg.http_error(&err) {
14797                        sleep(d).await;
14798                        continue;
14799                    }
14800                    dlg.finished(false);
14801                    return Err(common::Error::HttpError(err));
14802                }
14803                Ok(res) => {
14804                    let (mut parts, body) = res.into_parts();
14805                    let mut body = common::Body::new(body);
14806                    if !parts.status.is_success() {
14807                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14808                        let error = serde_json::from_str(&common::to_string(&bytes));
14809                        let response = common::to_response(parts, bytes.into());
14810
14811                        if let common::Retry::After(d) =
14812                            dlg.http_failure(&response, error.as_ref().ok())
14813                        {
14814                            sleep(d).await;
14815                            continue;
14816                        }
14817
14818                        dlg.finished(false);
14819
14820                        return Err(match error {
14821                            Ok(value) => common::Error::BadRequest(value),
14822                            _ => common::Error::Failure(response),
14823                        });
14824                    }
14825                    let response = {
14826                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14827                        let encoded = common::to_string(&bytes);
14828                        match serde_json::from_str(&encoded) {
14829                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14830                            Err(error) => {
14831                                dlg.response_json_decode_error(&encoded, &error);
14832                                return Err(common::Error::JsonDecodeError(
14833                                    encoded.to_string(),
14834                                    error,
14835                                ));
14836                            }
14837                        }
14838                    };
14839
14840                    dlg.finished(true);
14841                    return Ok(response);
14842                }
14843            }
14844        }
14845    }
14846
14847    /// Required. The parent for which to list models. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
14848    ///
14849    /// Sets the *parent* path property to the given value.
14850    ///
14851    /// Even though the property as already been set when instantiating this call,
14852    /// we provide this method for API completeness.
14853    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogModelListCall<'a, C> {
14854        self._parent = new_value.to_string();
14855        self
14856    }
14857    /// Optional. A page token, received from a previous `ListModels` call. Provide this to retrieve the subsequent page.
14858    ///
14859    /// Sets the *page token* query property to the given value.
14860    pub fn page_token(mut self, new_value: &str) -> ProjectLocationCatalogModelListCall<'a, C> {
14861        self._page_token = Some(new_value.to_string());
14862        self
14863    }
14864    /// Optional. Maximum number of results to return. If unspecified, defaults to 50. Max allowed value is 1000.
14865    ///
14866    /// Sets the *page size* query property to the given value.
14867    pub fn page_size(mut self, new_value: i32) -> ProjectLocationCatalogModelListCall<'a, C> {
14868        self._page_size = Some(new_value);
14869        self
14870    }
14871    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14872    /// while executing the actual API request.
14873    ///
14874    /// ````text
14875    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14876    /// ````
14877    ///
14878    /// Sets the *delegate* property to the given value.
14879    pub fn delegate(
14880        mut self,
14881        new_value: &'a mut dyn common::Delegate,
14882    ) -> ProjectLocationCatalogModelListCall<'a, C> {
14883        self._delegate = Some(new_value);
14884        self
14885    }
14886
14887    /// Set any additional parameter of the query string used in the request.
14888    /// It should be used to set parameters which are not yet available through their own
14889    /// setters.
14890    ///
14891    /// Please note that this method must not be used to set any of the known parameters
14892    /// which have their own setter method. If done anyway, the request will fail.
14893    ///
14894    /// # Additional Parameters
14895    ///
14896    /// * *$.xgafv* (query-string) - V1 error format.
14897    /// * *access_token* (query-string) - OAuth access token.
14898    /// * *alt* (query-string) - Data format for response.
14899    /// * *callback* (query-string) - JSONP
14900    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14901    /// * *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.
14902    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14903    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14904    /// * *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.
14905    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14906    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14907    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelListCall<'a, C>
14908    where
14909        T: AsRef<str>,
14910    {
14911        self._additional_params
14912            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14913        self
14914    }
14915
14916    /// Identifies the authorization scope for the method you are building.
14917    ///
14918    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14919    /// [`Scope::CloudPlatform`].
14920    ///
14921    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14922    /// tokens for more than one scope.
14923    ///
14924    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14925    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14926    /// sufficient, a read-write scope will do as well.
14927    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelListCall<'a, C>
14928    where
14929        St: AsRef<str>,
14930    {
14931        self._scopes.insert(String::from(scope.as_ref()));
14932        self
14933    }
14934    /// Identifies the authorization scope(s) for the method you are building.
14935    ///
14936    /// See [`Self::add_scope()`] for details.
14937    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelListCall<'a, C>
14938    where
14939        I: IntoIterator<Item = St>,
14940        St: AsRef<str>,
14941    {
14942        self._scopes
14943            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14944        self
14945    }
14946
14947    /// Removes all scopes, and no default scope will be used either.
14948    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14949    /// for details).
14950    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelListCall<'a, C> {
14951        self._scopes.clear();
14952        self
14953    }
14954}
14955
14956/// Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.
14957///
14958/// A builder for the *locations.catalogs.models.patch* method supported by a *project* resource.
14959/// It is not used directly, but through a [`ProjectMethods`] instance.
14960///
14961/// # Example
14962///
14963/// Instantiate a resource method builder
14964///
14965/// ```test_harness,no_run
14966/// # extern crate hyper;
14967/// # extern crate hyper_rustls;
14968/// # extern crate google_retail2 as retail2;
14969/// use retail2::api::GoogleCloudRetailV2Model;
14970/// # async fn dox() {
14971/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14972///
14973/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14974/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14975/// #     .with_native_roots()
14976/// #     .unwrap()
14977/// #     .https_only()
14978/// #     .enable_http2()
14979/// #     .build();
14980///
14981/// # let executor = hyper_util::rt::TokioExecutor::new();
14982/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14983/// #     secret,
14984/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14985/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14986/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14987/// #     ),
14988/// # ).build().await.unwrap();
14989///
14990/// # let client = hyper_util::client::legacy::Client::builder(
14991/// #     hyper_util::rt::TokioExecutor::new()
14992/// # )
14993/// # .build(
14994/// #     hyper_rustls::HttpsConnectorBuilder::new()
14995/// #         .with_native_roots()
14996/// #         .unwrap()
14997/// #         .https_or_http()
14998/// #         .enable_http2()
14999/// #         .build()
15000/// # );
15001/// # let mut hub = CloudRetail::new(client, auth);
15002/// // As the method needs a request, you would usually fill it with the desired information
15003/// // into the respective structure. Some of the parts shown here might not be applicable !
15004/// // Values shown here are possibly random and not representative !
15005/// let mut req = GoogleCloudRetailV2Model::default();
15006///
15007/// // You can configure optional parameters by calling the respective setters at will, and
15008/// // execute the final call using `doit()`.
15009/// // Values shown here are possibly random and not representative !
15010/// let result = hub.projects().locations_catalogs_models_patch(req, "name")
15011///              .update_mask(FieldMask::new::<&str>(&[]))
15012///              .doit().await;
15013/// # }
15014/// ```
15015pub struct ProjectLocationCatalogModelPatchCall<'a, C>
15016where
15017    C: 'a,
15018{
15019    hub: &'a CloudRetail<C>,
15020    _request: GoogleCloudRetailV2Model,
15021    _name: String,
15022    _update_mask: Option<common::FieldMask>,
15023    _delegate: Option<&'a mut dyn common::Delegate>,
15024    _additional_params: HashMap<String, String>,
15025    _scopes: BTreeSet<String>,
15026}
15027
15028impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelPatchCall<'a, C> {}
15029
15030impl<'a, C> ProjectLocationCatalogModelPatchCall<'a, C>
15031where
15032    C: common::Connector,
15033{
15034    /// Perform the operation you have build so far.
15035    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Model)> {
15036        use std::borrow::Cow;
15037        use std::io::{Read, Seek};
15038
15039        use common::{url::Params, ToParts};
15040        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15041
15042        let mut dd = common::DefaultDelegate;
15043        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15044        dlg.begin(common::MethodInfo {
15045            id: "retail.projects.locations.catalogs.models.patch",
15046            http_method: hyper::Method::PATCH,
15047        });
15048
15049        for &field in ["alt", "name", "updateMask"].iter() {
15050            if self._additional_params.contains_key(field) {
15051                dlg.finished(false);
15052                return Err(common::Error::FieldClash(field));
15053            }
15054        }
15055
15056        let mut params = Params::with_capacity(5 + self._additional_params.len());
15057        params.push("name", self._name);
15058        if let Some(value) = self._update_mask.as_ref() {
15059            params.push("updateMask", value.to_string());
15060        }
15061
15062        params.extend(self._additional_params.iter());
15063
15064        params.push("alt", "json");
15065        let mut url = self.hub._base_url.clone() + "v2/{+name}";
15066        if self._scopes.is_empty() {
15067            self._scopes
15068                .insert(Scope::CloudPlatform.as_ref().to_string());
15069        }
15070
15071        #[allow(clippy::single_element_loop)]
15072        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15073            url = params.uri_replacement(url, param_name, find_this, true);
15074        }
15075        {
15076            let to_remove = ["name"];
15077            params.remove_params(&to_remove);
15078        }
15079
15080        let url = params.parse_with_url(&url);
15081
15082        let mut json_mime_type = mime::APPLICATION_JSON;
15083        let mut request_value_reader = {
15084            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15085            common::remove_json_null_values(&mut value);
15086            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15087            serde_json::to_writer(&mut dst, &value).unwrap();
15088            dst
15089        };
15090        let request_size = request_value_reader
15091            .seek(std::io::SeekFrom::End(0))
15092            .unwrap();
15093        request_value_reader
15094            .seek(std::io::SeekFrom::Start(0))
15095            .unwrap();
15096
15097        loop {
15098            let token = match self
15099                .hub
15100                .auth
15101                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15102                .await
15103            {
15104                Ok(token) => token,
15105                Err(e) => match dlg.token(e) {
15106                    Ok(token) => token,
15107                    Err(e) => {
15108                        dlg.finished(false);
15109                        return Err(common::Error::MissingToken(e));
15110                    }
15111                },
15112            };
15113            request_value_reader
15114                .seek(std::io::SeekFrom::Start(0))
15115                .unwrap();
15116            let mut req_result = {
15117                let client = &self.hub.client;
15118                dlg.pre_request();
15119                let mut req_builder = hyper::Request::builder()
15120                    .method(hyper::Method::PATCH)
15121                    .uri(url.as_str())
15122                    .header(USER_AGENT, self.hub._user_agent.clone());
15123
15124                if let Some(token) = token.as_ref() {
15125                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15126                }
15127
15128                let request = req_builder
15129                    .header(CONTENT_TYPE, json_mime_type.to_string())
15130                    .header(CONTENT_LENGTH, request_size as u64)
15131                    .body(common::to_body(
15132                        request_value_reader.get_ref().clone().into(),
15133                    ));
15134
15135                client.request(request.unwrap()).await
15136            };
15137
15138            match req_result {
15139                Err(err) => {
15140                    if let common::Retry::After(d) = dlg.http_error(&err) {
15141                        sleep(d).await;
15142                        continue;
15143                    }
15144                    dlg.finished(false);
15145                    return Err(common::Error::HttpError(err));
15146                }
15147                Ok(res) => {
15148                    let (mut parts, body) = res.into_parts();
15149                    let mut body = common::Body::new(body);
15150                    if !parts.status.is_success() {
15151                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15152                        let error = serde_json::from_str(&common::to_string(&bytes));
15153                        let response = common::to_response(parts, bytes.into());
15154
15155                        if let common::Retry::After(d) =
15156                            dlg.http_failure(&response, error.as_ref().ok())
15157                        {
15158                            sleep(d).await;
15159                            continue;
15160                        }
15161
15162                        dlg.finished(false);
15163
15164                        return Err(match error {
15165                            Ok(value) => common::Error::BadRequest(value),
15166                            _ => common::Error::Failure(response),
15167                        });
15168                    }
15169                    let response = {
15170                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15171                        let encoded = common::to_string(&bytes);
15172                        match serde_json::from_str(&encoded) {
15173                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15174                            Err(error) => {
15175                                dlg.response_json_decode_error(&encoded, &error);
15176                                return Err(common::Error::JsonDecodeError(
15177                                    encoded.to_string(),
15178                                    error,
15179                                ));
15180                            }
15181                        }
15182                    };
15183
15184                    dlg.finished(true);
15185                    return Ok(response);
15186                }
15187            }
15188        }
15189    }
15190
15191    ///
15192    /// Sets the *request* property to the given value.
15193    ///
15194    /// Even though the property as already been set when instantiating this call,
15195    /// we provide this method for API completeness.
15196    pub fn request(
15197        mut self,
15198        new_value: GoogleCloudRetailV2Model,
15199    ) -> ProjectLocationCatalogModelPatchCall<'a, C> {
15200        self._request = new_value;
15201        self
15202    }
15203    /// Required. The fully qualified resource name of the model. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` catalog_id has char limit of 50. recommendation_model_id has char limit of 40.
15204    ///
15205    /// Sets the *name* path property to the given value.
15206    ///
15207    /// Even though the property as already been set when instantiating this call,
15208    /// we provide this method for API completeness.
15209    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogModelPatchCall<'a, C> {
15210        self._name = new_value.to_string();
15211        self
15212    }
15213    /// Optional. Indicates which fields in the provided 'model' to update. If not set, by default updates all fields.
15214    ///
15215    /// Sets the *update mask* query property to the given value.
15216    pub fn update_mask(
15217        mut self,
15218        new_value: common::FieldMask,
15219    ) -> ProjectLocationCatalogModelPatchCall<'a, C> {
15220        self._update_mask = Some(new_value);
15221        self
15222    }
15223    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15224    /// while executing the actual API request.
15225    ///
15226    /// ````text
15227    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15228    /// ````
15229    ///
15230    /// Sets the *delegate* property to the given value.
15231    pub fn delegate(
15232        mut self,
15233        new_value: &'a mut dyn common::Delegate,
15234    ) -> ProjectLocationCatalogModelPatchCall<'a, C> {
15235        self._delegate = Some(new_value);
15236        self
15237    }
15238
15239    /// Set any additional parameter of the query string used in the request.
15240    /// It should be used to set parameters which are not yet available through their own
15241    /// setters.
15242    ///
15243    /// Please note that this method must not be used to set any of the known parameters
15244    /// which have their own setter method. If done anyway, the request will fail.
15245    ///
15246    /// # Additional Parameters
15247    ///
15248    /// * *$.xgafv* (query-string) - V1 error format.
15249    /// * *access_token* (query-string) - OAuth access token.
15250    /// * *alt* (query-string) - Data format for response.
15251    /// * *callback* (query-string) - JSONP
15252    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15253    /// * *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.
15254    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15255    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15256    /// * *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.
15257    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15258    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15259    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelPatchCall<'a, C>
15260    where
15261        T: AsRef<str>,
15262    {
15263        self._additional_params
15264            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15265        self
15266    }
15267
15268    /// Identifies the authorization scope for the method you are building.
15269    ///
15270    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15271    /// [`Scope::CloudPlatform`].
15272    ///
15273    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15274    /// tokens for more than one scope.
15275    ///
15276    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15277    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15278    /// sufficient, a read-write scope will do as well.
15279    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelPatchCall<'a, C>
15280    where
15281        St: AsRef<str>,
15282    {
15283        self._scopes.insert(String::from(scope.as_ref()));
15284        self
15285    }
15286    /// Identifies the authorization scope(s) for the method you are building.
15287    ///
15288    /// See [`Self::add_scope()`] for details.
15289    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelPatchCall<'a, C>
15290    where
15291        I: IntoIterator<Item = St>,
15292        St: AsRef<str>,
15293    {
15294        self._scopes
15295            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15296        self
15297    }
15298
15299    /// Removes all scopes, and no default scope will be used either.
15300    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15301    /// for details).
15302    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelPatchCall<'a, C> {
15303        self._scopes.clear();
15304        self
15305    }
15306}
15307
15308/// Pauses the training of an existing model.
15309///
15310/// A builder for the *locations.catalogs.models.pause* method supported by a *project* resource.
15311/// It is not used directly, but through a [`ProjectMethods`] instance.
15312///
15313/// # Example
15314///
15315/// Instantiate a resource method builder
15316///
15317/// ```test_harness,no_run
15318/// # extern crate hyper;
15319/// # extern crate hyper_rustls;
15320/// # extern crate google_retail2 as retail2;
15321/// use retail2::api::GoogleCloudRetailV2PauseModelRequest;
15322/// # async fn dox() {
15323/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15324///
15325/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15326/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15327/// #     .with_native_roots()
15328/// #     .unwrap()
15329/// #     .https_only()
15330/// #     .enable_http2()
15331/// #     .build();
15332///
15333/// # let executor = hyper_util::rt::TokioExecutor::new();
15334/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15335/// #     secret,
15336/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15337/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15338/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15339/// #     ),
15340/// # ).build().await.unwrap();
15341///
15342/// # let client = hyper_util::client::legacy::Client::builder(
15343/// #     hyper_util::rt::TokioExecutor::new()
15344/// # )
15345/// # .build(
15346/// #     hyper_rustls::HttpsConnectorBuilder::new()
15347/// #         .with_native_roots()
15348/// #         .unwrap()
15349/// #         .https_or_http()
15350/// #         .enable_http2()
15351/// #         .build()
15352/// # );
15353/// # let mut hub = CloudRetail::new(client, auth);
15354/// // As the method needs a request, you would usually fill it with the desired information
15355/// // into the respective structure. Some of the parts shown here might not be applicable !
15356/// // Values shown here are possibly random and not representative !
15357/// let mut req = GoogleCloudRetailV2PauseModelRequest::default();
15358///
15359/// // You can configure optional parameters by calling the respective setters at will, and
15360/// // execute the final call using `doit()`.
15361/// // Values shown here are possibly random and not representative !
15362/// let result = hub.projects().locations_catalogs_models_pause(req, "name")
15363///              .doit().await;
15364/// # }
15365/// ```
15366pub struct ProjectLocationCatalogModelPauseCall<'a, C>
15367where
15368    C: 'a,
15369{
15370    hub: &'a CloudRetail<C>,
15371    _request: GoogleCloudRetailV2PauseModelRequest,
15372    _name: String,
15373    _delegate: Option<&'a mut dyn common::Delegate>,
15374    _additional_params: HashMap<String, String>,
15375    _scopes: BTreeSet<String>,
15376}
15377
15378impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelPauseCall<'a, C> {}
15379
15380impl<'a, C> ProjectLocationCatalogModelPauseCall<'a, C>
15381where
15382    C: common::Connector,
15383{
15384    /// Perform the operation you have build so far.
15385    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Model)> {
15386        use std::borrow::Cow;
15387        use std::io::{Read, Seek};
15388
15389        use common::{url::Params, ToParts};
15390        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15391
15392        let mut dd = common::DefaultDelegate;
15393        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15394        dlg.begin(common::MethodInfo {
15395            id: "retail.projects.locations.catalogs.models.pause",
15396            http_method: hyper::Method::POST,
15397        });
15398
15399        for &field in ["alt", "name"].iter() {
15400            if self._additional_params.contains_key(field) {
15401                dlg.finished(false);
15402                return Err(common::Error::FieldClash(field));
15403            }
15404        }
15405
15406        let mut params = Params::with_capacity(4 + self._additional_params.len());
15407        params.push("name", self._name);
15408
15409        params.extend(self._additional_params.iter());
15410
15411        params.push("alt", "json");
15412        let mut url = self.hub._base_url.clone() + "v2/{+name}:pause";
15413        if self._scopes.is_empty() {
15414            self._scopes
15415                .insert(Scope::CloudPlatform.as_ref().to_string());
15416        }
15417
15418        #[allow(clippy::single_element_loop)]
15419        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15420            url = params.uri_replacement(url, param_name, find_this, true);
15421        }
15422        {
15423            let to_remove = ["name"];
15424            params.remove_params(&to_remove);
15425        }
15426
15427        let url = params.parse_with_url(&url);
15428
15429        let mut json_mime_type = mime::APPLICATION_JSON;
15430        let mut request_value_reader = {
15431            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15432            common::remove_json_null_values(&mut value);
15433            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15434            serde_json::to_writer(&mut dst, &value).unwrap();
15435            dst
15436        };
15437        let request_size = request_value_reader
15438            .seek(std::io::SeekFrom::End(0))
15439            .unwrap();
15440        request_value_reader
15441            .seek(std::io::SeekFrom::Start(0))
15442            .unwrap();
15443
15444        loop {
15445            let token = match self
15446                .hub
15447                .auth
15448                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15449                .await
15450            {
15451                Ok(token) => token,
15452                Err(e) => match dlg.token(e) {
15453                    Ok(token) => token,
15454                    Err(e) => {
15455                        dlg.finished(false);
15456                        return Err(common::Error::MissingToken(e));
15457                    }
15458                },
15459            };
15460            request_value_reader
15461                .seek(std::io::SeekFrom::Start(0))
15462                .unwrap();
15463            let mut req_result = {
15464                let client = &self.hub.client;
15465                dlg.pre_request();
15466                let mut req_builder = hyper::Request::builder()
15467                    .method(hyper::Method::POST)
15468                    .uri(url.as_str())
15469                    .header(USER_AGENT, self.hub._user_agent.clone());
15470
15471                if let Some(token) = token.as_ref() {
15472                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15473                }
15474
15475                let request = req_builder
15476                    .header(CONTENT_TYPE, json_mime_type.to_string())
15477                    .header(CONTENT_LENGTH, request_size as u64)
15478                    .body(common::to_body(
15479                        request_value_reader.get_ref().clone().into(),
15480                    ));
15481
15482                client.request(request.unwrap()).await
15483            };
15484
15485            match req_result {
15486                Err(err) => {
15487                    if let common::Retry::After(d) = dlg.http_error(&err) {
15488                        sleep(d).await;
15489                        continue;
15490                    }
15491                    dlg.finished(false);
15492                    return Err(common::Error::HttpError(err));
15493                }
15494                Ok(res) => {
15495                    let (mut parts, body) = res.into_parts();
15496                    let mut body = common::Body::new(body);
15497                    if !parts.status.is_success() {
15498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15499                        let error = serde_json::from_str(&common::to_string(&bytes));
15500                        let response = common::to_response(parts, bytes.into());
15501
15502                        if let common::Retry::After(d) =
15503                            dlg.http_failure(&response, error.as_ref().ok())
15504                        {
15505                            sleep(d).await;
15506                            continue;
15507                        }
15508
15509                        dlg.finished(false);
15510
15511                        return Err(match error {
15512                            Ok(value) => common::Error::BadRequest(value),
15513                            _ => common::Error::Failure(response),
15514                        });
15515                    }
15516                    let response = {
15517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15518                        let encoded = common::to_string(&bytes);
15519                        match serde_json::from_str(&encoded) {
15520                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15521                            Err(error) => {
15522                                dlg.response_json_decode_error(&encoded, &error);
15523                                return Err(common::Error::JsonDecodeError(
15524                                    encoded.to_string(),
15525                                    error,
15526                                ));
15527                            }
15528                        }
15529                    };
15530
15531                    dlg.finished(true);
15532                    return Ok(response);
15533                }
15534            }
15535        }
15536    }
15537
15538    ///
15539    /// Sets the *request* property to the given value.
15540    ///
15541    /// Even though the property as already been set when instantiating this call,
15542    /// we provide this method for API completeness.
15543    pub fn request(
15544        mut self,
15545        new_value: GoogleCloudRetailV2PauseModelRequest,
15546    ) -> ProjectLocationCatalogModelPauseCall<'a, C> {
15547        self._request = new_value;
15548        self
15549    }
15550    /// Required. The name of the model to pause. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
15551    ///
15552    /// Sets the *name* path property to the given value.
15553    ///
15554    /// Even though the property as already been set when instantiating this call,
15555    /// we provide this method for API completeness.
15556    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogModelPauseCall<'a, C> {
15557        self._name = new_value.to_string();
15558        self
15559    }
15560    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15561    /// while executing the actual API request.
15562    ///
15563    /// ````text
15564    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15565    /// ````
15566    ///
15567    /// Sets the *delegate* property to the given value.
15568    pub fn delegate(
15569        mut self,
15570        new_value: &'a mut dyn common::Delegate,
15571    ) -> ProjectLocationCatalogModelPauseCall<'a, C> {
15572        self._delegate = Some(new_value);
15573        self
15574    }
15575
15576    /// Set any additional parameter of the query string used in the request.
15577    /// It should be used to set parameters which are not yet available through their own
15578    /// setters.
15579    ///
15580    /// Please note that this method must not be used to set any of the known parameters
15581    /// which have their own setter method. If done anyway, the request will fail.
15582    ///
15583    /// # Additional Parameters
15584    ///
15585    /// * *$.xgafv* (query-string) - V1 error format.
15586    /// * *access_token* (query-string) - OAuth access token.
15587    /// * *alt* (query-string) - Data format for response.
15588    /// * *callback* (query-string) - JSONP
15589    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15590    /// * *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.
15591    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15592    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15593    /// * *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.
15594    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15595    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15596    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelPauseCall<'a, C>
15597    where
15598        T: AsRef<str>,
15599    {
15600        self._additional_params
15601            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15602        self
15603    }
15604
15605    /// Identifies the authorization scope for the method you are building.
15606    ///
15607    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15608    /// [`Scope::CloudPlatform`].
15609    ///
15610    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15611    /// tokens for more than one scope.
15612    ///
15613    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15614    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15615    /// sufficient, a read-write scope will do as well.
15616    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelPauseCall<'a, C>
15617    where
15618        St: AsRef<str>,
15619    {
15620        self._scopes.insert(String::from(scope.as_ref()));
15621        self
15622    }
15623    /// Identifies the authorization scope(s) for the method you are building.
15624    ///
15625    /// See [`Self::add_scope()`] for details.
15626    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelPauseCall<'a, C>
15627    where
15628        I: IntoIterator<Item = St>,
15629        St: AsRef<str>,
15630    {
15631        self._scopes
15632            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15633        self
15634    }
15635
15636    /// Removes all scopes, and no default scope will be used either.
15637    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15638    /// for details).
15639    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelPauseCall<'a, C> {
15640        self._scopes.clear();
15641        self
15642    }
15643}
15644
15645/// Resumes the training of an existing model.
15646///
15647/// A builder for the *locations.catalogs.models.resume* method supported by a *project* resource.
15648/// It is not used directly, but through a [`ProjectMethods`] instance.
15649///
15650/// # Example
15651///
15652/// Instantiate a resource method builder
15653///
15654/// ```test_harness,no_run
15655/// # extern crate hyper;
15656/// # extern crate hyper_rustls;
15657/// # extern crate google_retail2 as retail2;
15658/// use retail2::api::GoogleCloudRetailV2ResumeModelRequest;
15659/// # async fn dox() {
15660/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15661///
15662/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15663/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15664/// #     .with_native_roots()
15665/// #     .unwrap()
15666/// #     .https_only()
15667/// #     .enable_http2()
15668/// #     .build();
15669///
15670/// # let executor = hyper_util::rt::TokioExecutor::new();
15671/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15672/// #     secret,
15673/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15674/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15675/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15676/// #     ),
15677/// # ).build().await.unwrap();
15678///
15679/// # let client = hyper_util::client::legacy::Client::builder(
15680/// #     hyper_util::rt::TokioExecutor::new()
15681/// # )
15682/// # .build(
15683/// #     hyper_rustls::HttpsConnectorBuilder::new()
15684/// #         .with_native_roots()
15685/// #         .unwrap()
15686/// #         .https_or_http()
15687/// #         .enable_http2()
15688/// #         .build()
15689/// # );
15690/// # let mut hub = CloudRetail::new(client, auth);
15691/// // As the method needs a request, you would usually fill it with the desired information
15692/// // into the respective structure. Some of the parts shown here might not be applicable !
15693/// // Values shown here are possibly random and not representative !
15694/// let mut req = GoogleCloudRetailV2ResumeModelRequest::default();
15695///
15696/// // You can configure optional parameters by calling the respective setters at will, and
15697/// // execute the final call using `doit()`.
15698/// // Values shown here are possibly random and not representative !
15699/// let result = hub.projects().locations_catalogs_models_resume(req, "name")
15700///              .doit().await;
15701/// # }
15702/// ```
15703pub struct ProjectLocationCatalogModelResumeCall<'a, C>
15704where
15705    C: 'a,
15706{
15707    hub: &'a CloudRetail<C>,
15708    _request: GoogleCloudRetailV2ResumeModelRequest,
15709    _name: String,
15710    _delegate: Option<&'a mut dyn common::Delegate>,
15711    _additional_params: HashMap<String, String>,
15712    _scopes: BTreeSet<String>,
15713}
15714
15715impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelResumeCall<'a, C> {}
15716
15717impl<'a, C> ProjectLocationCatalogModelResumeCall<'a, C>
15718where
15719    C: common::Connector,
15720{
15721    /// Perform the operation you have build so far.
15722    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Model)> {
15723        use std::borrow::Cow;
15724        use std::io::{Read, Seek};
15725
15726        use common::{url::Params, ToParts};
15727        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15728
15729        let mut dd = common::DefaultDelegate;
15730        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15731        dlg.begin(common::MethodInfo {
15732            id: "retail.projects.locations.catalogs.models.resume",
15733            http_method: hyper::Method::POST,
15734        });
15735
15736        for &field in ["alt", "name"].iter() {
15737            if self._additional_params.contains_key(field) {
15738                dlg.finished(false);
15739                return Err(common::Error::FieldClash(field));
15740            }
15741        }
15742
15743        let mut params = Params::with_capacity(4 + self._additional_params.len());
15744        params.push("name", self._name);
15745
15746        params.extend(self._additional_params.iter());
15747
15748        params.push("alt", "json");
15749        let mut url = self.hub._base_url.clone() + "v2/{+name}:resume";
15750        if self._scopes.is_empty() {
15751            self._scopes
15752                .insert(Scope::CloudPlatform.as_ref().to_string());
15753        }
15754
15755        #[allow(clippy::single_element_loop)]
15756        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15757            url = params.uri_replacement(url, param_name, find_this, true);
15758        }
15759        {
15760            let to_remove = ["name"];
15761            params.remove_params(&to_remove);
15762        }
15763
15764        let url = params.parse_with_url(&url);
15765
15766        let mut json_mime_type = mime::APPLICATION_JSON;
15767        let mut request_value_reader = {
15768            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15769            common::remove_json_null_values(&mut value);
15770            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15771            serde_json::to_writer(&mut dst, &value).unwrap();
15772            dst
15773        };
15774        let request_size = request_value_reader
15775            .seek(std::io::SeekFrom::End(0))
15776            .unwrap();
15777        request_value_reader
15778            .seek(std::io::SeekFrom::Start(0))
15779            .unwrap();
15780
15781        loop {
15782            let token = match self
15783                .hub
15784                .auth
15785                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15786                .await
15787            {
15788                Ok(token) => token,
15789                Err(e) => match dlg.token(e) {
15790                    Ok(token) => token,
15791                    Err(e) => {
15792                        dlg.finished(false);
15793                        return Err(common::Error::MissingToken(e));
15794                    }
15795                },
15796            };
15797            request_value_reader
15798                .seek(std::io::SeekFrom::Start(0))
15799                .unwrap();
15800            let mut req_result = {
15801                let client = &self.hub.client;
15802                dlg.pre_request();
15803                let mut req_builder = hyper::Request::builder()
15804                    .method(hyper::Method::POST)
15805                    .uri(url.as_str())
15806                    .header(USER_AGENT, self.hub._user_agent.clone());
15807
15808                if let Some(token) = token.as_ref() {
15809                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15810                }
15811
15812                let request = req_builder
15813                    .header(CONTENT_TYPE, json_mime_type.to_string())
15814                    .header(CONTENT_LENGTH, request_size as u64)
15815                    .body(common::to_body(
15816                        request_value_reader.get_ref().clone().into(),
15817                    ));
15818
15819                client.request(request.unwrap()).await
15820            };
15821
15822            match req_result {
15823                Err(err) => {
15824                    if let common::Retry::After(d) = dlg.http_error(&err) {
15825                        sleep(d).await;
15826                        continue;
15827                    }
15828                    dlg.finished(false);
15829                    return Err(common::Error::HttpError(err));
15830                }
15831                Ok(res) => {
15832                    let (mut parts, body) = res.into_parts();
15833                    let mut body = common::Body::new(body);
15834                    if !parts.status.is_success() {
15835                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15836                        let error = serde_json::from_str(&common::to_string(&bytes));
15837                        let response = common::to_response(parts, bytes.into());
15838
15839                        if let common::Retry::After(d) =
15840                            dlg.http_failure(&response, error.as_ref().ok())
15841                        {
15842                            sleep(d).await;
15843                            continue;
15844                        }
15845
15846                        dlg.finished(false);
15847
15848                        return Err(match error {
15849                            Ok(value) => common::Error::BadRequest(value),
15850                            _ => common::Error::Failure(response),
15851                        });
15852                    }
15853                    let response = {
15854                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15855                        let encoded = common::to_string(&bytes);
15856                        match serde_json::from_str(&encoded) {
15857                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15858                            Err(error) => {
15859                                dlg.response_json_decode_error(&encoded, &error);
15860                                return Err(common::Error::JsonDecodeError(
15861                                    encoded.to_string(),
15862                                    error,
15863                                ));
15864                            }
15865                        }
15866                    };
15867
15868                    dlg.finished(true);
15869                    return Ok(response);
15870                }
15871            }
15872        }
15873    }
15874
15875    ///
15876    /// Sets the *request* property to the given value.
15877    ///
15878    /// Even though the property as already been set when instantiating this call,
15879    /// we provide this method for API completeness.
15880    pub fn request(
15881        mut self,
15882        new_value: GoogleCloudRetailV2ResumeModelRequest,
15883    ) -> ProjectLocationCatalogModelResumeCall<'a, C> {
15884        self._request = new_value;
15885        self
15886    }
15887    /// Required. The name of the model to resume. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
15888    ///
15889    /// Sets the *name* path property to the given value.
15890    ///
15891    /// Even though the property as already been set when instantiating this call,
15892    /// we provide this method for API completeness.
15893    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogModelResumeCall<'a, C> {
15894        self._name = new_value.to_string();
15895        self
15896    }
15897    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15898    /// while executing the actual API request.
15899    ///
15900    /// ````text
15901    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15902    /// ````
15903    ///
15904    /// Sets the *delegate* property to the given value.
15905    pub fn delegate(
15906        mut self,
15907        new_value: &'a mut dyn common::Delegate,
15908    ) -> ProjectLocationCatalogModelResumeCall<'a, C> {
15909        self._delegate = Some(new_value);
15910        self
15911    }
15912
15913    /// Set any additional parameter of the query string used in the request.
15914    /// It should be used to set parameters which are not yet available through their own
15915    /// setters.
15916    ///
15917    /// Please note that this method must not be used to set any of the known parameters
15918    /// which have their own setter method. If done anyway, the request will fail.
15919    ///
15920    /// # Additional Parameters
15921    ///
15922    /// * *$.xgafv* (query-string) - V1 error format.
15923    /// * *access_token* (query-string) - OAuth access token.
15924    /// * *alt* (query-string) - Data format for response.
15925    /// * *callback* (query-string) - JSONP
15926    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15927    /// * *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.
15928    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15929    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15930    /// * *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.
15931    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15932    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15933    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelResumeCall<'a, C>
15934    where
15935        T: AsRef<str>,
15936    {
15937        self._additional_params
15938            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15939        self
15940    }
15941
15942    /// Identifies the authorization scope for the method you are building.
15943    ///
15944    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15945    /// [`Scope::CloudPlatform`].
15946    ///
15947    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15948    /// tokens for more than one scope.
15949    ///
15950    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15951    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15952    /// sufficient, a read-write scope will do as well.
15953    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelResumeCall<'a, C>
15954    where
15955        St: AsRef<str>,
15956    {
15957        self._scopes.insert(String::from(scope.as_ref()));
15958        self
15959    }
15960    /// Identifies the authorization scope(s) for the method you are building.
15961    ///
15962    /// See [`Self::add_scope()`] for details.
15963    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelResumeCall<'a, C>
15964    where
15965        I: IntoIterator<Item = St>,
15966        St: AsRef<str>,
15967    {
15968        self._scopes
15969            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15970        self
15971    }
15972
15973    /// Removes all scopes, and no default scope will be used either.
15974    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15975    /// for details).
15976    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelResumeCall<'a, C> {
15977        self._scopes.clear();
15978        self
15979    }
15980}
15981
15982/// Tunes an existing model.
15983///
15984/// A builder for the *locations.catalogs.models.tune* method supported by a *project* resource.
15985/// It is not used directly, but through a [`ProjectMethods`] instance.
15986///
15987/// # Example
15988///
15989/// Instantiate a resource method builder
15990///
15991/// ```test_harness,no_run
15992/// # extern crate hyper;
15993/// # extern crate hyper_rustls;
15994/// # extern crate google_retail2 as retail2;
15995/// use retail2::api::GoogleCloudRetailV2TuneModelRequest;
15996/// # async fn dox() {
15997/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15998///
15999/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16000/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16001/// #     .with_native_roots()
16002/// #     .unwrap()
16003/// #     .https_only()
16004/// #     .enable_http2()
16005/// #     .build();
16006///
16007/// # let executor = hyper_util::rt::TokioExecutor::new();
16008/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16009/// #     secret,
16010/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16011/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16012/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16013/// #     ),
16014/// # ).build().await.unwrap();
16015///
16016/// # let client = hyper_util::client::legacy::Client::builder(
16017/// #     hyper_util::rt::TokioExecutor::new()
16018/// # )
16019/// # .build(
16020/// #     hyper_rustls::HttpsConnectorBuilder::new()
16021/// #         .with_native_roots()
16022/// #         .unwrap()
16023/// #         .https_or_http()
16024/// #         .enable_http2()
16025/// #         .build()
16026/// # );
16027/// # let mut hub = CloudRetail::new(client, auth);
16028/// // As the method needs a request, you would usually fill it with the desired information
16029/// // into the respective structure. Some of the parts shown here might not be applicable !
16030/// // Values shown here are possibly random and not representative !
16031/// let mut req = GoogleCloudRetailV2TuneModelRequest::default();
16032///
16033/// // You can configure optional parameters by calling the respective setters at will, and
16034/// // execute the final call using `doit()`.
16035/// // Values shown here are possibly random and not representative !
16036/// let result = hub.projects().locations_catalogs_models_tune(req, "name")
16037///              .doit().await;
16038/// # }
16039/// ```
16040pub struct ProjectLocationCatalogModelTuneCall<'a, C>
16041where
16042    C: 'a,
16043{
16044    hub: &'a CloudRetail<C>,
16045    _request: GoogleCloudRetailV2TuneModelRequest,
16046    _name: String,
16047    _delegate: Option<&'a mut dyn common::Delegate>,
16048    _additional_params: HashMap<String, String>,
16049    _scopes: BTreeSet<String>,
16050}
16051
16052impl<'a, C> common::CallBuilder for ProjectLocationCatalogModelTuneCall<'a, C> {}
16053
16054impl<'a, C> ProjectLocationCatalogModelTuneCall<'a, C>
16055where
16056    C: common::Connector,
16057{
16058    /// Perform the operation you have build so far.
16059    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
16060        use std::borrow::Cow;
16061        use std::io::{Read, Seek};
16062
16063        use common::{url::Params, ToParts};
16064        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16065
16066        let mut dd = common::DefaultDelegate;
16067        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16068        dlg.begin(common::MethodInfo {
16069            id: "retail.projects.locations.catalogs.models.tune",
16070            http_method: hyper::Method::POST,
16071        });
16072
16073        for &field in ["alt", "name"].iter() {
16074            if self._additional_params.contains_key(field) {
16075                dlg.finished(false);
16076                return Err(common::Error::FieldClash(field));
16077            }
16078        }
16079
16080        let mut params = Params::with_capacity(4 + self._additional_params.len());
16081        params.push("name", self._name);
16082
16083        params.extend(self._additional_params.iter());
16084
16085        params.push("alt", "json");
16086        let mut url = self.hub._base_url.clone() + "v2/{+name}:tune";
16087        if self._scopes.is_empty() {
16088            self._scopes
16089                .insert(Scope::CloudPlatform.as_ref().to_string());
16090        }
16091
16092        #[allow(clippy::single_element_loop)]
16093        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16094            url = params.uri_replacement(url, param_name, find_this, true);
16095        }
16096        {
16097            let to_remove = ["name"];
16098            params.remove_params(&to_remove);
16099        }
16100
16101        let url = params.parse_with_url(&url);
16102
16103        let mut json_mime_type = mime::APPLICATION_JSON;
16104        let mut request_value_reader = {
16105            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16106            common::remove_json_null_values(&mut value);
16107            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16108            serde_json::to_writer(&mut dst, &value).unwrap();
16109            dst
16110        };
16111        let request_size = request_value_reader
16112            .seek(std::io::SeekFrom::End(0))
16113            .unwrap();
16114        request_value_reader
16115            .seek(std::io::SeekFrom::Start(0))
16116            .unwrap();
16117
16118        loop {
16119            let token = match self
16120                .hub
16121                .auth
16122                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16123                .await
16124            {
16125                Ok(token) => token,
16126                Err(e) => match dlg.token(e) {
16127                    Ok(token) => token,
16128                    Err(e) => {
16129                        dlg.finished(false);
16130                        return Err(common::Error::MissingToken(e));
16131                    }
16132                },
16133            };
16134            request_value_reader
16135                .seek(std::io::SeekFrom::Start(0))
16136                .unwrap();
16137            let mut req_result = {
16138                let client = &self.hub.client;
16139                dlg.pre_request();
16140                let mut req_builder = hyper::Request::builder()
16141                    .method(hyper::Method::POST)
16142                    .uri(url.as_str())
16143                    .header(USER_AGENT, self.hub._user_agent.clone());
16144
16145                if let Some(token) = token.as_ref() {
16146                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16147                }
16148
16149                let request = req_builder
16150                    .header(CONTENT_TYPE, json_mime_type.to_string())
16151                    .header(CONTENT_LENGTH, request_size as u64)
16152                    .body(common::to_body(
16153                        request_value_reader.get_ref().clone().into(),
16154                    ));
16155
16156                client.request(request.unwrap()).await
16157            };
16158
16159            match req_result {
16160                Err(err) => {
16161                    if let common::Retry::After(d) = dlg.http_error(&err) {
16162                        sleep(d).await;
16163                        continue;
16164                    }
16165                    dlg.finished(false);
16166                    return Err(common::Error::HttpError(err));
16167                }
16168                Ok(res) => {
16169                    let (mut parts, body) = res.into_parts();
16170                    let mut body = common::Body::new(body);
16171                    if !parts.status.is_success() {
16172                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16173                        let error = serde_json::from_str(&common::to_string(&bytes));
16174                        let response = common::to_response(parts, bytes.into());
16175
16176                        if let common::Retry::After(d) =
16177                            dlg.http_failure(&response, error.as_ref().ok())
16178                        {
16179                            sleep(d).await;
16180                            continue;
16181                        }
16182
16183                        dlg.finished(false);
16184
16185                        return Err(match error {
16186                            Ok(value) => common::Error::BadRequest(value),
16187                            _ => common::Error::Failure(response),
16188                        });
16189                    }
16190                    let response = {
16191                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16192                        let encoded = common::to_string(&bytes);
16193                        match serde_json::from_str(&encoded) {
16194                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16195                            Err(error) => {
16196                                dlg.response_json_decode_error(&encoded, &error);
16197                                return Err(common::Error::JsonDecodeError(
16198                                    encoded.to_string(),
16199                                    error,
16200                                ));
16201                            }
16202                        }
16203                    };
16204
16205                    dlg.finished(true);
16206                    return Ok(response);
16207                }
16208            }
16209        }
16210    }
16211
16212    ///
16213    /// Sets the *request* property to the given value.
16214    ///
16215    /// Even though the property as already been set when instantiating this call,
16216    /// we provide this method for API completeness.
16217    pub fn request(
16218        mut self,
16219        new_value: GoogleCloudRetailV2TuneModelRequest,
16220    ) -> ProjectLocationCatalogModelTuneCall<'a, C> {
16221        self._request = new_value;
16222        self
16223    }
16224    /// Required. The resource name of the model to tune. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
16225    ///
16226    /// Sets the *name* path property to the given value.
16227    ///
16228    /// Even though the property as already been set when instantiating this call,
16229    /// we provide this method for API completeness.
16230    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogModelTuneCall<'a, C> {
16231        self._name = new_value.to_string();
16232        self
16233    }
16234    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16235    /// while executing the actual API request.
16236    ///
16237    /// ````text
16238    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16239    /// ````
16240    ///
16241    /// Sets the *delegate* property to the given value.
16242    pub fn delegate(
16243        mut self,
16244        new_value: &'a mut dyn common::Delegate,
16245    ) -> ProjectLocationCatalogModelTuneCall<'a, C> {
16246        self._delegate = Some(new_value);
16247        self
16248    }
16249
16250    /// Set any additional parameter of the query string used in the request.
16251    /// It should be used to set parameters which are not yet available through their own
16252    /// setters.
16253    ///
16254    /// Please note that this method must not be used to set any of the known parameters
16255    /// which have their own setter method. If done anyway, the request will fail.
16256    ///
16257    /// # Additional Parameters
16258    ///
16259    /// * *$.xgafv* (query-string) - V1 error format.
16260    /// * *access_token* (query-string) - OAuth access token.
16261    /// * *alt* (query-string) - Data format for response.
16262    /// * *callback* (query-string) - JSONP
16263    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16264    /// * *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.
16265    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16266    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16267    /// * *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.
16268    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16269    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16270    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogModelTuneCall<'a, C>
16271    where
16272        T: AsRef<str>,
16273    {
16274        self._additional_params
16275            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16276        self
16277    }
16278
16279    /// Identifies the authorization scope for the method you are building.
16280    ///
16281    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16282    /// [`Scope::CloudPlatform`].
16283    ///
16284    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16285    /// tokens for more than one scope.
16286    ///
16287    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16288    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16289    /// sufficient, a read-write scope will do as well.
16290    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogModelTuneCall<'a, C>
16291    where
16292        St: AsRef<str>,
16293    {
16294        self._scopes.insert(String::from(scope.as_ref()));
16295        self
16296    }
16297    /// Identifies the authorization scope(s) for the method you are building.
16298    ///
16299    /// See [`Self::add_scope()`] for details.
16300    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogModelTuneCall<'a, C>
16301    where
16302        I: IntoIterator<Item = St>,
16303        St: AsRef<str>,
16304    {
16305        self._scopes
16306            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16307        self
16308    }
16309
16310    /// Removes all scopes, and no default scope will be used either.
16311    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16312    /// for details).
16313    pub fn clear_scopes(mut self) -> ProjectLocationCatalogModelTuneCall<'a, C> {
16314        self._scopes.clear();
16315        self
16316    }
16317}
16318
16319/// 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.
16320///
16321/// A builder for the *locations.catalogs.operations.get* method supported by a *project* resource.
16322/// It is not used directly, but through a [`ProjectMethods`] instance.
16323///
16324/// # Example
16325///
16326/// Instantiate a resource method builder
16327///
16328/// ```test_harness,no_run
16329/// # extern crate hyper;
16330/// # extern crate hyper_rustls;
16331/// # extern crate google_retail2 as retail2;
16332/// # async fn dox() {
16333/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16334///
16335/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16336/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16337/// #     .with_native_roots()
16338/// #     .unwrap()
16339/// #     .https_only()
16340/// #     .enable_http2()
16341/// #     .build();
16342///
16343/// # let executor = hyper_util::rt::TokioExecutor::new();
16344/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16345/// #     secret,
16346/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16347/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16348/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16349/// #     ),
16350/// # ).build().await.unwrap();
16351///
16352/// # let client = hyper_util::client::legacy::Client::builder(
16353/// #     hyper_util::rt::TokioExecutor::new()
16354/// # )
16355/// # .build(
16356/// #     hyper_rustls::HttpsConnectorBuilder::new()
16357/// #         .with_native_roots()
16358/// #         .unwrap()
16359/// #         .https_or_http()
16360/// #         .enable_http2()
16361/// #         .build()
16362/// # );
16363/// # let mut hub = CloudRetail::new(client, auth);
16364/// // You can configure optional parameters by calling the respective setters at will, and
16365/// // execute the final call using `doit()`.
16366/// // Values shown here are possibly random and not representative !
16367/// let result = hub.projects().locations_catalogs_operations_get("name")
16368///              .doit().await;
16369/// # }
16370/// ```
16371pub struct ProjectLocationCatalogOperationGetCall<'a, C>
16372where
16373    C: 'a,
16374{
16375    hub: &'a CloudRetail<C>,
16376    _name: String,
16377    _delegate: Option<&'a mut dyn common::Delegate>,
16378    _additional_params: HashMap<String, String>,
16379    _scopes: BTreeSet<String>,
16380}
16381
16382impl<'a, C> common::CallBuilder for ProjectLocationCatalogOperationGetCall<'a, C> {}
16383
16384impl<'a, C> ProjectLocationCatalogOperationGetCall<'a, C>
16385where
16386    C: common::Connector,
16387{
16388    /// Perform the operation you have build so far.
16389    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
16390        use std::borrow::Cow;
16391        use std::io::{Read, Seek};
16392
16393        use common::{url::Params, ToParts};
16394        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16395
16396        let mut dd = common::DefaultDelegate;
16397        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16398        dlg.begin(common::MethodInfo {
16399            id: "retail.projects.locations.catalogs.operations.get",
16400            http_method: hyper::Method::GET,
16401        });
16402
16403        for &field in ["alt", "name"].iter() {
16404            if self._additional_params.contains_key(field) {
16405                dlg.finished(false);
16406                return Err(common::Error::FieldClash(field));
16407            }
16408        }
16409
16410        let mut params = Params::with_capacity(3 + self._additional_params.len());
16411        params.push("name", self._name);
16412
16413        params.extend(self._additional_params.iter());
16414
16415        params.push("alt", "json");
16416        let mut url = self.hub._base_url.clone() + "v2/{+name}";
16417        if self._scopes.is_empty() {
16418            self._scopes
16419                .insert(Scope::CloudPlatform.as_ref().to_string());
16420        }
16421
16422        #[allow(clippy::single_element_loop)]
16423        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16424            url = params.uri_replacement(url, param_name, find_this, true);
16425        }
16426        {
16427            let to_remove = ["name"];
16428            params.remove_params(&to_remove);
16429        }
16430
16431        let url = params.parse_with_url(&url);
16432
16433        loop {
16434            let token = match self
16435                .hub
16436                .auth
16437                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16438                .await
16439            {
16440                Ok(token) => token,
16441                Err(e) => match dlg.token(e) {
16442                    Ok(token) => token,
16443                    Err(e) => {
16444                        dlg.finished(false);
16445                        return Err(common::Error::MissingToken(e));
16446                    }
16447                },
16448            };
16449            let mut req_result = {
16450                let client = &self.hub.client;
16451                dlg.pre_request();
16452                let mut req_builder = hyper::Request::builder()
16453                    .method(hyper::Method::GET)
16454                    .uri(url.as_str())
16455                    .header(USER_AGENT, self.hub._user_agent.clone());
16456
16457                if let Some(token) = token.as_ref() {
16458                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16459                }
16460
16461                let request = req_builder
16462                    .header(CONTENT_LENGTH, 0_u64)
16463                    .body(common::to_body::<String>(None));
16464
16465                client.request(request.unwrap()).await
16466            };
16467
16468            match req_result {
16469                Err(err) => {
16470                    if let common::Retry::After(d) = dlg.http_error(&err) {
16471                        sleep(d).await;
16472                        continue;
16473                    }
16474                    dlg.finished(false);
16475                    return Err(common::Error::HttpError(err));
16476                }
16477                Ok(res) => {
16478                    let (mut parts, body) = res.into_parts();
16479                    let mut body = common::Body::new(body);
16480                    if !parts.status.is_success() {
16481                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16482                        let error = serde_json::from_str(&common::to_string(&bytes));
16483                        let response = common::to_response(parts, bytes.into());
16484
16485                        if let common::Retry::After(d) =
16486                            dlg.http_failure(&response, error.as_ref().ok())
16487                        {
16488                            sleep(d).await;
16489                            continue;
16490                        }
16491
16492                        dlg.finished(false);
16493
16494                        return Err(match error {
16495                            Ok(value) => common::Error::BadRequest(value),
16496                            _ => common::Error::Failure(response),
16497                        });
16498                    }
16499                    let response = {
16500                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16501                        let encoded = common::to_string(&bytes);
16502                        match serde_json::from_str(&encoded) {
16503                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16504                            Err(error) => {
16505                                dlg.response_json_decode_error(&encoded, &error);
16506                                return Err(common::Error::JsonDecodeError(
16507                                    encoded.to_string(),
16508                                    error,
16509                                ));
16510                            }
16511                        }
16512                    };
16513
16514                    dlg.finished(true);
16515                    return Ok(response);
16516                }
16517            }
16518        }
16519    }
16520
16521    /// The name of the operation resource.
16522    ///
16523    /// Sets the *name* path property to the given value.
16524    ///
16525    /// Even though the property as already been set when instantiating this call,
16526    /// we provide this method for API completeness.
16527    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogOperationGetCall<'a, C> {
16528        self._name = new_value.to_string();
16529        self
16530    }
16531    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16532    /// while executing the actual API request.
16533    ///
16534    /// ````text
16535    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16536    /// ````
16537    ///
16538    /// Sets the *delegate* property to the given value.
16539    pub fn delegate(
16540        mut self,
16541        new_value: &'a mut dyn common::Delegate,
16542    ) -> ProjectLocationCatalogOperationGetCall<'a, C> {
16543        self._delegate = Some(new_value);
16544        self
16545    }
16546
16547    /// Set any additional parameter of the query string used in the request.
16548    /// It should be used to set parameters which are not yet available through their own
16549    /// setters.
16550    ///
16551    /// Please note that this method must not be used to set any of the known parameters
16552    /// which have their own setter method. If done anyway, the request will fail.
16553    ///
16554    /// # Additional Parameters
16555    ///
16556    /// * *$.xgafv* (query-string) - V1 error format.
16557    /// * *access_token* (query-string) - OAuth access token.
16558    /// * *alt* (query-string) - Data format for response.
16559    /// * *callback* (query-string) - JSONP
16560    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16561    /// * *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.
16562    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16563    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16564    /// * *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.
16565    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16566    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16567    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogOperationGetCall<'a, C>
16568    where
16569        T: AsRef<str>,
16570    {
16571        self._additional_params
16572            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16573        self
16574    }
16575
16576    /// Identifies the authorization scope for the method you are building.
16577    ///
16578    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16579    /// [`Scope::CloudPlatform`].
16580    ///
16581    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16582    /// tokens for more than one scope.
16583    ///
16584    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16585    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16586    /// sufficient, a read-write scope will do as well.
16587    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogOperationGetCall<'a, C>
16588    where
16589        St: AsRef<str>,
16590    {
16591        self._scopes.insert(String::from(scope.as_ref()));
16592        self
16593    }
16594    /// Identifies the authorization scope(s) for the method you are building.
16595    ///
16596    /// See [`Self::add_scope()`] for details.
16597    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogOperationGetCall<'a, C>
16598    where
16599        I: IntoIterator<Item = St>,
16600        St: AsRef<str>,
16601    {
16602        self._scopes
16603            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16604        self
16605    }
16606
16607    /// Removes all scopes, and no default scope will be used either.
16608    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16609    /// for details).
16610    pub fn clear_scopes(mut self) -> ProjectLocationCatalogOperationGetCall<'a, C> {
16611        self._scopes.clear();
16612        self
16613    }
16614}
16615
16616/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
16617///
16618/// A builder for the *locations.catalogs.operations.list* method supported by a *project* resource.
16619/// It is not used directly, but through a [`ProjectMethods`] instance.
16620///
16621/// # Example
16622///
16623/// Instantiate a resource method builder
16624///
16625/// ```test_harness,no_run
16626/// # extern crate hyper;
16627/// # extern crate hyper_rustls;
16628/// # extern crate google_retail2 as retail2;
16629/// # async fn dox() {
16630/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16631///
16632/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16633/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16634/// #     .with_native_roots()
16635/// #     .unwrap()
16636/// #     .https_only()
16637/// #     .enable_http2()
16638/// #     .build();
16639///
16640/// # let executor = hyper_util::rt::TokioExecutor::new();
16641/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16642/// #     secret,
16643/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16644/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16645/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16646/// #     ),
16647/// # ).build().await.unwrap();
16648///
16649/// # let client = hyper_util::client::legacy::Client::builder(
16650/// #     hyper_util::rt::TokioExecutor::new()
16651/// # )
16652/// # .build(
16653/// #     hyper_rustls::HttpsConnectorBuilder::new()
16654/// #         .with_native_roots()
16655/// #         .unwrap()
16656/// #         .https_or_http()
16657/// #         .enable_http2()
16658/// #         .build()
16659/// # );
16660/// # let mut hub = CloudRetail::new(client, auth);
16661/// // You can configure optional parameters by calling the respective setters at will, and
16662/// // execute the final call using `doit()`.
16663/// // Values shown here are possibly random and not representative !
16664/// let result = hub.projects().locations_catalogs_operations_list("name")
16665///              .return_partial_success(false)
16666///              .page_token("Stet")
16667///              .page_size(-99)
16668///              .filter("duo")
16669///              .doit().await;
16670/// # }
16671/// ```
16672pub struct ProjectLocationCatalogOperationListCall<'a, C>
16673where
16674    C: 'a,
16675{
16676    hub: &'a CloudRetail<C>,
16677    _name: String,
16678    _return_partial_success: Option<bool>,
16679    _page_token: Option<String>,
16680    _page_size: Option<i32>,
16681    _filter: Option<String>,
16682    _delegate: Option<&'a mut dyn common::Delegate>,
16683    _additional_params: HashMap<String, String>,
16684    _scopes: BTreeSet<String>,
16685}
16686
16687impl<'a, C> common::CallBuilder for ProjectLocationCatalogOperationListCall<'a, C> {}
16688
16689impl<'a, C> ProjectLocationCatalogOperationListCall<'a, C>
16690where
16691    C: common::Connector,
16692{
16693    /// Perform the operation you have build so far.
16694    pub async fn doit(
16695        mut self,
16696    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
16697        use std::borrow::Cow;
16698        use std::io::{Read, Seek};
16699
16700        use common::{url::Params, ToParts};
16701        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16702
16703        let mut dd = common::DefaultDelegate;
16704        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16705        dlg.begin(common::MethodInfo {
16706            id: "retail.projects.locations.catalogs.operations.list",
16707            http_method: hyper::Method::GET,
16708        });
16709
16710        for &field in [
16711            "alt",
16712            "name",
16713            "returnPartialSuccess",
16714            "pageToken",
16715            "pageSize",
16716            "filter",
16717        ]
16718        .iter()
16719        {
16720            if self._additional_params.contains_key(field) {
16721                dlg.finished(false);
16722                return Err(common::Error::FieldClash(field));
16723            }
16724        }
16725
16726        let mut params = Params::with_capacity(7 + self._additional_params.len());
16727        params.push("name", self._name);
16728        if let Some(value) = self._return_partial_success.as_ref() {
16729            params.push("returnPartialSuccess", value.to_string());
16730        }
16731        if let Some(value) = self._page_token.as_ref() {
16732            params.push("pageToken", value);
16733        }
16734        if let Some(value) = self._page_size.as_ref() {
16735            params.push("pageSize", value.to_string());
16736        }
16737        if let Some(value) = self._filter.as_ref() {
16738            params.push("filter", value);
16739        }
16740
16741        params.extend(self._additional_params.iter());
16742
16743        params.push("alt", "json");
16744        let mut url = self.hub._base_url.clone() + "v2/{+name}/operations";
16745        if self._scopes.is_empty() {
16746            self._scopes
16747                .insert(Scope::CloudPlatform.as_ref().to_string());
16748        }
16749
16750        #[allow(clippy::single_element_loop)]
16751        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16752            url = params.uri_replacement(url, param_name, find_this, true);
16753        }
16754        {
16755            let to_remove = ["name"];
16756            params.remove_params(&to_remove);
16757        }
16758
16759        let url = params.parse_with_url(&url);
16760
16761        loop {
16762            let token = match self
16763                .hub
16764                .auth
16765                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16766                .await
16767            {
16768                Ok(token) => token,
16769                Err(e) => match dlg.token(e) {
16770                    Ok(token) => token,
16771                    Err(e) => {
16772                        dlg.finished(false);
16773                        return Err(common::Error::MissingToken(e));
16774                    }
16775                },
16776            };
16777            let mut req_result = {
16778                let client = &self.hub.client;
16779                dlg.pre_request();
16780                let mut req_builder = hyper::Request::builder()
16781                    .method(hyper::Method::GET)
16782                    .uri(url.as_str())
16783                    .header(USER_AGENT, self.hub._user_agent.clone());
16784
16785                if let Some(token) = token.as_ref() {
16786                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16787                }
16788
16789                let request = req_builder
16790                    .header(CONTENT_LENGTH, 0_u64)
16791                    .body(common::to_body::<String>(None));
16792
16793                client.request(request.unwrap()).await
16794            };
16795
16796            match req_result {
16797                Err(err) => {
16798                    if let common::Retry::After(d) = dlg.http_error(&err) {
16799                        sleep(d).await;
16800                        continue;
16801                    }
16802                    dlg.finished(false);
16803                    return Err(common::Error::HttpError(err));
16804                }
16805                Ok(res) => {
16806                    let (mut parts, body) = res.into_parts();
16807                    let mut body = common::Body::new(body);
16808                    if !parts.status.is_success() {
16809                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16810                        let error = serde_json::from_str(&common::to_string(&bytes));
16811                        let response = common::to_response(parts, bytes.into());
16812
16813                        if let common::Retry::After(d) =
16814                            dlg.http_failure(&response, error.as_ref().ok())
16815                        {
16816                            sleep(d).await;
16817                            continue;
16818                        }
16819
16820                        dlg.finished(false);
16821
16822                        return Err(match error {
16823                            Ok(value) => common::Error::BadRequest(value),
16824                            _ => common::Error::Failure(response),
16825                        });
16826                    }
16827                    let response = {
16828                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16829                        let encoded = common::to_string(&bytes);
16830                        match serde_json::from_str(&encoded) {
16831                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16832                            Err(error) => {
16833                                dlg.response_json_decode_error(&encoded, &error);
16834                                return Err(common::Error::JsonDecodeError(
16835                                    encoded.to_string(),
16836                                    error,
16837                                ));
16838                            }
16839                        }
16840                    };
16841
16842                    dlg.finished(true);
16843                    return Ok(response);
16844                }
16845            }
16846        }
16847    }
16848
16849    /// The name of the operation's parent resource.
16850    ///
16851    /// Sets the *name* path property to the given value.
16852    ///
16853    /// Even though the property as already been set when instantiating this call,
16854    /// we provide this method for API completeness.
16855    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogOperationListCall<'a, C> {
16856        self._name = new_value.to_string();
16857        self
16858    }
16859    /// 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.
16860    ///
16861    /// Sets the *return partial success* query property to the given value.
16862    pub fn return_partial_success(
16863        mut self,
16864        new_value: bool,
16865    ) -> ProjectLocationCatalogOperationListCall<'a, C> {
16866        self._return_partial_success = Some(new_value);
16867        self
16868    }
16869    /// The standard list page token.
16870    ///
16871    /// Sets the *page token* query property to the given value.
16872    pub fn page_token(mut self, new_value: &str) -> ProjectLocationCatalogOperationListCall<'a, C> {
16873        self._page_token = Some(new_value.to_string());
16874        self
16875    }
16876    /// The standard list page size.
16877    ///
16878    /// Sets the *page size* query property to the given value.
16879    pub fn page_size(mut self, new_value: i32) -> ProjectLocationCatalogOperationListCall<'a, C> {
16880        self._page_size = Some(new_value);
16881        self
16882    }
16883    /// The standard list filter.
16884    ///
16885    /// Sets the *filter* query property to the given value.
16886    pub fn filter(mut self, new_value: &str) -> ProjectLocationCatalogOperationListCall<'a, C> {
16887        self._filter = Some(new_value.to_string());
16888        self
16889    }
16890    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16891    /// while executing the actual API request.
16892    ///
16893    /// ````text
16894    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16895    /// ````
16896    ///
16897    /// Sets the *delegate* property to the given value.
16898    pub fn delegate(
16899        mut self,
16900        new_value: &'a mut dyn common::Delegate,
16901    ) -> ProjectLocationCatalogOperationListCall<'a, C> {
16902        self._delegate = Some(new_value);
16903        self
16904    }
16905
16906    /// Set any additional parameter of the query string used in the request.
16907    /// It should be used to set parameters which are not yet available through their own
16908    /// setters.
16909    ///
16910    /// Please note that this method must not be used to set any of the known parameters
16911    /// which have their own setter method. If done anyway, the request will fail.
16912    ///
16913    /// # Additional Parameters
16914    ///
16915    /// * *$.xgafv* (query-string) - V1 error format.
16916    /// * *access_token* (query-string) - OAuth access token.
16917    /// * *alt* (query-string) - Data format for response.
16918    /// * *callback* (query-string) - JSONP
16919    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16920    /// * *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.
16921    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16922    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16923    /// * *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.
16924    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16925    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16926    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogOperationListCall<'a, C>
16927    where
16928        T: AsRef<str>,
16929    {
16930        self._additional_params
16931            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16932        self
16933    }
16934
16935    /// Identifies the authorization scope for the method you are building.
16936    ///
16937    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16938    /// [`Scope::CloudPlatform`].
16939    ///
16940    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16941    /// tokens for more than one scope.
16942    ///
16943    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16944    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16945    /// sufficient, a read-write scope will do as well.
16946    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogOperationListCall<'a, C>
16947    where
16948        St: AsRef<str>,
16949    {
16950        self._scopes.insert(String::from(scope.as_ref()));
16951        self
16952    }
16953    /// Identifies the authorization scope(s) for the method you are building.
16954    ///
16955    /// See [`Self::add_scope()`] for details.
16956    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogOperationListCall<'a, C>
16957    where
16958        I: IntoIterator<Item = St>,
16959        St: AsRef<str>,
16960    {
16961        self._scopes
16962            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16963        self
16964    }
16965
16966    /// Removes all scopes, and no default scope will be used either.
16967    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16968    /// for details).
16969    pub fn clear_scopes(mut self) -> ProjectLocationCatalogOperationListCall<'a, C> {
16970        self._scopes.clear();
16971        self
16972    }
16973}
16974
16975/// Performs a conversational search. This feature is only available for users who have Conversational Search enabled.
16976///
16977/// A builder for the *locations.catalogs.placements.conversationalSearch* method supported by a *project* resource.
16978/// It is not used directly, but through a [`ProjectMethods`] instance.
16979///
16980/// # Example
16981///
16982/// Instantiate a resource method builder
16983///
16984/// ```test_harness,no_run
16985/// # extern crate hyper;
16986/// # extern crate hyper_rustls;
16987/// # extern crate google_retail2 as retail2;
16988/// use retail2::api::GoogleCloudRetailV2ConversationalSearchRequest;
16989/// # async fn dox() {
16990/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16991///
16992/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16993/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16994/// #     .with_native_roots()
16995/// #     .unwrap()
16996/// #     .https_only()
16997/// #     .enable_http2()
16998/// #     .build();
16999///
17000/// # let executor = hyper_util::rt::TokioExecutor::new();
17001/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17002/// #     secret,
17003/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17004/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17005/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17006/// #     ),
17007/// # ).build().await.unwrap();
17008///
17009/// # let client = hyper_util::client::legacy::Client::builder(
17010/// #     hyper_util::rt::TokioExecutor::new()
17011/// # )
17012/// # .build(
17013/// #     hyper_rustls::HttpsConnectorBuilder::new()
17014/// #         .with_native_roots()
17015/// #         .unwrap()
17016/// #         .https_or_http()
17017/// #         .enable_http2()
17018/// #         .build()
17019/// # );
17020/// # let mut hub = CloudRetail::new(client, auth);
17021/// // As the method needs a request, you would usually fill it with the desired information
17022/// // into the respective structure. Some of the parts shown here might not be applicable !
17023/// // Values shown here are possibly random and not representative !
17024/// let mut req = GoogleCloudRetailV2ConversationalSearchRequest::default();
17025///
17026/// // You can configure optional parameters by calling the respective setters at will, and
17027/// // execute the final call using `doit()`.
17028/// // Values shown here are possibly random and not representative !
17029/// let result = hub.projects().locations_catalogs_placements_conversational_search(req, "placement")
17030///              .doit().await;
17031/// # }
17032/// ```
17033pub struct ProjectLocationCatalogPlacementConversationalSearchCall<'a, C>
17034where
17035    C: 'a,
17036{
17037    hub: &'a CloudRetail<C>,
17038    _request: GoogleCloudRetailV2ConversationalSearchRequest,
17039    _placement: String,
17040    _delegate: Option<&'a mut dyn common::Delegate>,
17041    _additional_params: HashMap<String, String>,
17042    _scopes: BTreeSet<String>,
17043}
17044
17045impl<'a, C> common::CallBuilder for ProjectLocationCatalogPlacementConversationalSearchCall<'a, C> {}
17046
17047impl<'a, C> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C>
17048where
17049    C: common::Connector,
17050{
17051    /// Perform the operation you have build so far.
17052    pub async fn doit(
17053        mut self,
17054    ) -> common::Result<(
17055        common::Response,
17056        GoogleCloudRetailV2ConversationalSearchResponse,
17057    )> {
17058        use std::borrow::Cow;
17059        use std::io::{Read, Seek};
17060
17061        use common::{url::Params, ToParts};
17062        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17063
17064        let mut dd = common::DefaultDelegate;
17065        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17066        dlg.begin(common::MethodInfo {
17067            id: "retail.projects.locations.catalogs.placements.conversationalSearch",
17068            http_method: hyper::Method::POST,
17069        });
17070
17071        for &field in ["alt", "placement"].iter() {
17072            if self._additional_params.contains_key(field) {
17073                dlg.finished(false);
17074                return Err(common::Error::FieldClash(field));
17075            }
17076        }
17077
17078        let mut params = Params::with_capacity(4 + self._additional_params.len());
17079        params.push("placement", self._placement);
17080
17081        params.extend(self._additional_params.iter());
17082
17083        params.push("alt", "json");
17084        let mut url = self.hub._base_url.clone() + "v2/{+placement}:conversationalSearch";
17085        if self._scopes.is_empty() {
17086            self._scopes
17087                .insert(Scope::CloudPlatform.as_ref().to_string());
17088        }
17089
17090        #[allow(clippy::single_element_loop)]
17091        for &(find_this, param_name) in [("{+placement}", "placement")].iter() {
17092            url = params.uri_replacement(url, param_name, find_this, true);
17093        }
17094        {
17095            let to_remove = ["placement"];
17096            params.remove_params(&to_remove);
17097        }
17098
17099        let url = params.parse_with_url(&url);
17100
17101        let mut json_mime_type = mime::APPLICATION_JSON;
17102        let mut request_value_reader = {
17103            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17104            common::remove_json_null_values(&mut value);
17105            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17106            serde_json::to_writer(&mut dst, &value).unwrap();
17107            dst
17108        };
17109        let request_size = request_value_reader
17110            .seek(std::io::SeekFrom::End(0))
17111            .unwrap();
17112        request_value_reader
17113            .seek(std::io::SeekFrom::Start(0))
17114            .unwrap();
17115
17116        loop {
17117            let token = match self
17118                .hub
17119                .auth
17120                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17121                .await
17122            {
17123                Ok(token) => token,
17124                Err(e) => match dlg.token(e) {
17125                    Ok(token) => token,
17126                    Err(e) => {
17127                        dlg.finished(false);
17128                        return Err(common::Error::MissingToken(e));
17129                    }
17130                },
17131            };
17132            request_value_reader
17133                .seek(std::io::SeekFrom::Start(0))
17134                .unwrap();
17135            let mut req_result = {
17136                let client = &self.hub.client;
17137                dlg.pre_request();
17138                let mut req_builder = hyper::Request::builder()
17139                    .method(hyper::Method::POST)
17140                    .uri(url.as_str())
17141                    .header(USER_AGENT, self.hub._user_agent.clone());
17142
17143                if let Some(token) = token.as_ref() {
17144                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17145                }
17146
17147                let request = req_builder
17148                    .header(CONTENT_TYPE, json_mime_type.to_string())
17149                    .header(CONTENT_LENGTH, request_size as u64)
17150                    .body(common::to_body(
17151                        request_value_reader.get_ref().clone().into(),
17152                    ));
17153
17154                client.request(request.unwrap()).await
17155            };
17156
17157            match req_result {
17158                Err(err) => {
17159                    if let common::Retry::After(d) = dlg.http_error(&err) {
17160                        sleep(d).await;
17161                        continue;
17162                    }
17163                    dlg.finished(false);
17164                    return Err(common::Error::HttpError(err));
17165                }
17166                Ok(res) => {
17167                    let (mut parts, body) = res.into_parts();
17168                    let mut body = common::Body::new(body);
17169                    if !parts.status.is_success() {
17170                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17171                        let error = serde_json::from_str(&common::to_string(&bytes));
17172                        let response = common::to_response(parts, bytes.into());
17173
17174                        if let common::Retry::After(d) =
17175                            dlg.http_failure(&response, error.as_ref().ok())
17176                        {
17177                            sleep(d).await;
17178                            continue;
17179                        }
17180
17181                        dlg.finished(false);
17182
17183                        return Err(match error {
17184                            Ok(value) => common::Error::BadRequest(value),
17185                            _ => common::Error::Failure(response),
17186                        });
17187                    }
17188                    let response = {
17189                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17190                        let encoded = common::to_string(&bytes);
17191                        match serde_json::from_str(&encoded) {
17192                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17193                            Err(error) => {
17194                                dlg.response_json_decode_error(&encoded, &error);
17195                                return Err(common::Error::JsonDecodeError(
17196                                    encoded.to_string(),
17197                                    error,
17198                                ));
17199                            }
17200                        }
17201                    };
17202
17203                    dlg.finished(true);
17204                    return Ok(response);
17205                }
17206            }
17207        }
17208    }
17209
17210    ///
17211    /// Sets the *request* property to the given value.
17212    ///
17213    /// Even though the property as already been set when instantiating this call,
17214    /// we provide this method for API completeness.
17215    pub fn request(
17216        mut self,
17217        new_value: GoogleCloudRetailV2ConversationalSearchRequest,
17218    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C> {
17219        self._request = new_value;
17220        self
17221    }
17222    /// Required. The resource name of the search engine placement, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search` or `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` This field is used to identify the serving config name and the set of models that will be used to make the search.
17223    ///
17224    /// Sets the *placement* path property to the given value.
17225    ///
17226    /// Even though the property as already been set when instantiating this call,
17227    /// we provide this method for API completeness.
17228    pub fn placement(
17229        mut self,
17230        new_value: &str,
17231    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C> {
17232        self._placement = new_value.to_string();
17233        self
17234    }
17235    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17236    /// while executing the actual API request.
17237    ///
17238    /// ````text
17239    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17240    /// ````
17241    ///
17242    /// Sets the *delegate* property to the given value.
17243    pub fn delegate(
17244        mut self,
17245        new_value: &'a mut dyn common::Delegate,
17246    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C> {
17247        self._delegate = Some(new_value);
17248        self
17249    }
17250
17251    /// Set any additional parameter of the query string used in the request.
17252    /// It should be used to set parameters which are not yet available through their own
17253    /// setters.
17254    ///
17255    /// Please note that this method must not be used to set any of the known parameters
17256    /// which have their own setter method. If done anyway, the request will fail.
17257    ///
17258    /// # Additional Parameters
17259    ///
17260    /// * *$.xgafv* (query-string) - V1 error format.
17261    /// * *access_token* (query-string) - OAuth access token.
17262    /// * *alt* (query-string) - Data format for response.
17263    /// * *callback* (query-string) - JSONP
17264    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17265    /// * *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.
17266    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17267    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17268    /// * *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.
17269    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17270    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17271    pub fn param<T>(
17272        mut self,
17273        name: T,
17274        value: T,
17275    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C>
17276    where
17277        T: AsRef<str>,
17278    {
17279        self._additional_params
17280            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17281        self
17282    }
17283
17284    /// Identifies the authorization scope for the method you are building.
17285    ///
17286    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17287    /// [`Scope::CloudPlatform`].
17288    ///
17289    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17290    /// tokens for more than one scope.
17291    ///
17292    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17293    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17294    /// sufficient, a read-write scope will do as well.
17295    pub fn add_scope<St>(
17296        mut self,
17297        scope: St,
17298    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C>
17299    where
17300        St: AsRef<str>,
17301    {
17302        self._scopes.insert(String::from(scope.as_ref()));
17303        self
17304    }
17305    /// Identifies the authorization scope(s) for the method you are building.
17306    ///
17307    /// See [`Self::add_scope()`] for details.
17308    pub fn add_scopes<I, St>(
17309        mut self,
17310        scopes: I,
17311    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C>
17312    where
17313        I: IntoIterator<Item = St>,
17314        St: AsRef<str>,
17315    {
17316        self._scopes
17317            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17318        self
17319    }
17320
17321    /// Removes all scopes, and no default scope will be used either.
17322    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17323    /// for details).
17324    pub fn clear_scopes(
17325        mut self,
17326    ) -> ProjectLocationCatalogPlacementConversationalSearchCall<'a, C> {
17327        self._scopes.clear();
17328        self
17329    }
17330}
17331
17332/// Makes a recommendation prediction.
17333///
17334/// A builder for the *locations.catalogs.placements.predict* method supported by a *project* resource.
17335/// It is not used directly, but through a [`ProjectMethods`] instance.
17336///
17337/// # Example
17338///
17339/// Instantiate a resource method builder
17340///
17341/// ```test_harness,no_run
17342/// # extern crate hyper;
17343/// # extern crate hyper_rustls;
17344/// # extern crate google_retail2 as retail2;
17345/// use retail2::api::GoogleCloudRetailV2PredictRequest;
17346/// # async fn dox() {
17347/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17348///
17349/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17350/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17351/// #     .with_native_roots()
17352/// #     .unwrap()
17353/// #     .https_only()
17354/// #     .enable_http2()
17355/// #     .build();
17356///
17357/// # let executor = hyper_util::rt::TokioExecutor::new();
17358/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17359/// #     secret,
17360/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17361/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17362/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17363/// #     ),
17364/// # ).build().await.unwrap();
17365///
17366/// # let client = hyper_util::client::legacy::Client::builder(
17367/// #     hyper_util::rt::TokioExecutor::new()
17368/// # )
17369/// # .build(
17370/// #     hyper_rustls::HttpsConnectorBuilder::new()
17371/// #         .with_native_roots()
17372/// #         .unwrap()
17373/// #         .https_or_http()
17374/// #         .enable_http2()
17375/// #         .build()
17376/// # );
17377/// # let mut hub = CloudRetail::new(client, auth);
17378/// // As the method needs a request, you would usually fill it with the desired information
17379/// // into the respective structure. Some of the parts shown here might not be applicable !
17380/// // Values shown here are possibly random and not representative !
17381/// let mut req = GoogleCloudRetailV2PredictRequest::default();
17382///
17383/// // You can configure optional parameters by calling the respective setters at will, and
17384/// // execute the final call using `doit()`.
17385/// // Values shown here are possibly random and not representative !
17386/// let result = hub.projects().locations_catalogs_placements_predict(req, "placement")
17387///              .doit().await;
17388/// # }
17389/// ```
17390pub struct ProjectLocationCatalogPlacementPredictCall<'a, C>
17391where
17392    C: 'a,
17393{
17394    hub: &'a CloudRetail<C>,
17395    _request: GoogleCloudRetailV2PredictRequest,
17396    _placement: String,
17397    _delegate: Option<&'a mut dyn common::Delegate>,
17398    _additional_params: HashMap<String, String>,
17399    _scopes: BTreeSet<String>,
17400}
17401
17402impl<'a, C> common::CallBuilder for ProjectLocationCatalogPlacementPredictCall<'a, C> {}
17403
17404impl<'a, C> ProjectLocationCatalogPlacementPredictCall<'a, C>
17405where
17406    C: common::Connector,
17407{
17408    /// Perform the operation you have build so far.
17409    pub async fn doit(
17410        mut self,
17411    ) -> common::Result<(common::Response, GoogleCloudRetailV2PredictResponse)> {
17412        use std::borrow::Cow;
17413        use std::io::{Read, Seek};
17414
17415        use common::{url::Params, ToParts};
17416        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17417
17418        let mut dd = common::DefaultDelegate;
17419        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17420        dlg.begin(common::MethodInfo {
17421            id: "retail.projects.locations.catalogs.placements.predict",
17422            http_method: hyper::Method::POST,
17423        });
17424
17425        for &field in ["alt", "placement"].iter() {
17426            if self._additional_params.contains_key(field) {
17427                dlg.finished(false);
17428                return Err(common::Error::FieldClash(field));
17429            }
17430        }
17431
17432        let mut params = Params::with_capacity(4 + self._additional_params.len());
17433        params.push("placement", self._placement);
17434
17435        params.extend(self._additional_params.iter());
17436
17437        params.push("alt", "json");
17438        let mut url = self.hub._base_url.clone() + "v2/{+placement}:predict";
17439        if self._scopes.is_empty() {
17440            self._scopes
17441                .insert(Scope::CloudPlatform.as_ref().to_string());
17442        }
17443
17444        #[allow(clippy::single_element_loop)]
17445        for &(find_this, param_name) in [("{+placement}", "placement")].iter() {
17446            url = params.uri_replacement(url, param_name, find_this, true);
17447        }
17448        {
17449            let to_remove = ["placement"];
17450            params.remove_params(&to_remove);
17451        }
17452
17453        let url = params.parse_with_url(&url);
17454
17455        let mut json_mime_type = mime::APPLICATION_JSON;
17456        let mut request_value_reader = {
17457            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17458            common::remove_json_null_values(&mut value);
17459            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17460            serde_json::to_writer(&mut dst, &value).unwrap();
17461            dst
17462        };
17463        let request_size = request_value_reader
17464            .seek(std::io::SeekFrom::End(0))
17465            .unwrap();
17466        request_value_reader
17467            .seek(std::io::SeekFrom::Start(0))
17468            .unwrap();
17469
17470        loop {
17471            let token = match self
17472                .hub
17473                .auth
17474                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17475                .await
17476            {
17477                Ok(token) => token,
17478                Err(e) => match dlg.token(e) {
17479                    Ok(token) => token,
17480                    Err(e) => {
17481                        dlg.finished(false);
17482                        return Err(common::Error::MissingToken(e));
17483                    }
17484                },
17485            };
17486            request_value_reader
17487                .seek(std::io::SeekFrom::Start(0))
17488                .unwrap();
17489            let mut req_result = {
17490                let client = &self.hub.client;
17491                dlg.pre_request();
17492                let mut req_builder = hyper::Request::builder()
17493                    .method(hyper::Method::POST)
17494                    .uri(url.as_str())
17495                    .header(USER_AGENT, self.hub._user_agent.clone());
17496
17497                if let Some(token) = token.as_ref() {
17498                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17499                }
17500
17501                let request = req_builder
17502                    .header(CONTENT_TYPE, json_mime_type.to_string())
17503                    .header(CONTENT_LENGTH, request_size as u64)
17504                    .body(common::to_body(
17505                        request_value_reader.get_ref().clone().into(),
17506                    ));
17507
17508                client.request(request.unwrap()).await
17509            };
17510
17511            match req_result {
17512                Err(err) => {
17513                    if let common::Retry::After(d) = dlg.http_error(&err) {
17514                        sleep(d).await;
17515                        continue;
17516                    }
17517                    dlg.finished(false);
17518                    return Err(common::Error::HttpError(err));
17519                }
17520                Ok(res) => {
17521                    let (mut parts, body) = res.into_parts();
17522                    let mut body = common::Body::new(body);
17523                    if !parts.status.is_success() {
17524                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17525                        let error = serde_json::from_str(&common::to_string(&bytes));
17526                        let response = common::to_response(parts, bytes.into());
17527
17528                        if let common::Retry::After(d) =
17529                            dlg.http_failure(&response, error.as_ref().ok())
17530                        {
17531                            sleep(d).await;
17532                            continue;
17533                        }
17534
17535                        dlg.finished(false);
17536
17537                        return Err(match error {
17538                            Ok(value) => common::Error::BadRequest(value),
17539                            _ => common::Error::Failure(response),
17540                        });
17541                    }
17542                    let response = {
17543                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17544                        let encoded = common::to_string(&bytes);
17545                        match serde_json::from_str(&encoded) {
17546                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17547                            Err(error) => {
17548                                dlg.response_json_decode_error(&encoded, &error);
17549                                return Err(common::Error::JsonDecodeError(
17550                                    encoded.to_string(),
17551                                    error,
17552                                ));
17553                            }
17554                        }
17555                    };
17556
17557                    dlg.finished(true);
17558                    return Ok(response);
17559                }
17560            }
17561        }
17562    }
17563
17564    ///
17565    /// Sets the *request* property to the given value.
17566    ///
17567    /// Even though the property as already been set when instantiating this call,
17568    /// we provide this method for API completeness.
17569    pub fn request(
17570        mut self,
17571        new_value: GoogleCloudRetailV2PredictRequest,
17572    ) -> ProjectLocationCatalogPlacementPredictCall<'a, C> {
17573        self._request = new_value;
17574        self
17575    }
17576    /// Required. Full resource name of the format: `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` or `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. We recommend using the `servingConfigs` resource. `placements` is a legacy resource. The ID of the Recommendations AI serving config or placement. Before you can request predictions from your model, you must create at least one serving config or placement for it. For more information, see [Manage serving configs] (https://cloud.google.com/retail/docs/manage-configs). The full list of available serving configs can be seen at https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs
17577    ///
17578    /// Sets the *placement* path property to the given value.
17579    ///
17580    /// Even though the property as already been set when instantiating this call,
17581    /// we provide this method for API completeness.
17582    pub fn placement(
17583        mut self,
17584        new_value: &str,
17585    ) -> ProjectLocationCatalogPlacementPredictCall<'a, C> {
17586        self._placement = new_value.to_string();
17587        self
17588    }
17589    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17590    /// while executing the actual API request.
17591    ///
17592    /// ````text
17593    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17594    /// ````
17595    ///
17596    /// Sets the *delegate* property to the given value.
17597    pub fn delegate(
17598        mut self,
17599        new_value: &'a mut dyn common::Delegate,
17600    ) -> ProjectLocationCatalogPlacementPredictCall<'a, C> {
17601        self._delegate = Some(new_value);
17602        self
17603    }
17604
17605    /// Set any additional parameter of the query string used in the request.
17606    /// It should be used to set parameters which are not yet available through their own
17607    /// setters.
17608    ///
17609    /// Please note that this method must not be used to set any of the known parameters
17610    /// which have their own setter method. If done anyway, the request will fail.
17611    ///
17612    /// # Additional Parameters
17613    ///
17614    /// * *$.xgafv* (query-string) - V1 error format.
17615    /// * *access_token* (query-string) - OAuth access token.
17616    /// * *alt* (query-string) - Data format for response.
17617    /// * *callback* (query-string) - JSONP
17618    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17619    /// * *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.
17620    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17621    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17622    /// * *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.
17623    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17624    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17625    pub fn param<T>(
17626        mut self,
17627        name: T,
17628        value: T,
17629    ) -> ProjectLocationCatalogPlacementPredictCall<'a, C>
17630    where
17631        T: AsRef<str>,
17632    {
17633        self._additional_params
17634            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17635        self
17636    }
17637
17638    /// Identifies the authorization scope for the method you are building.
17639    ///
17640    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17641    /// [`Scope::CloudPlatform`].
17642    ///
17643    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17644    /// tokens for more than one scope.
17645    ///
17646    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17647    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17648    /// sufficient, a read-write scope will do as well.
17649    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogPlacementPredictCall<'a, C>
17650    where
17651        St: AsRef<str>,
17652    {
17653        self._scopes.insert(String::from(scope.as_ref()));
17654        self
17655    }
17656    /// Identifies the authorization scope(s) for the method you are building.
17657    ///
17658    /// See [`Self::add_scope()`] for details.
17659    pub fn add_scopes<I, St>(
17660        mut self,
17661        scopes: I,
17662    ) -> ProjectLocationCatalogPlacementPredictCall<'a, C>
17663    where
17664        I: IntoIterator<Item = St>,
17665        St: AsRef<str>,
17666    {
17667        self._scopes
17668            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17669        self
17670    }
17671
17672    /// Removes all scopes, and no default scope will be used either.
17673    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17674    /// for details).
17675    pub fn clear_scopes(mut self) -> ProjectLocationCatalogPlacementPredictCall<'a, C> {
17676        self._scopes.clear();
17677        self
17678    }
17679}
17680
17681/// Performs a search. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
17682///
17683/// A builder for the *locations.catalogs.placements.search* method supported by a *project* resource.
17684/// It is not used directly, but through a [`ProjectMethods`] instance.
17685///
17686/// # Example
17687///
17688/// Instantiate a resource method builder
17689///
17690/// ```test_harness,no_run
17691/// # extern crate hyper;
17692/// # extern crate hyper_rustls;
17693/// # extern crate google_retail2 as retail2;
17694/// use retail2::api::GoogleCloudRetailV2SearchRequest;
17695/// # async fn dox() {
17696/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17697///
17698/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17699/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17700/// #     .with_native_roots()
17701/// #     .unwrap()
17702/// #     .https_only()
17703/// #     .enable_http2()
17704/// #     .build();
17705///
17706/// # let executor = hyper_util::rt::TokioExecutor::new();
17707/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17708/// #     secret,
17709/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17710/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17711/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17712/// #     ),
17713/// # ).build().await.unwrap();
17714///
17715/// # let client = hyper_util::client::legacy::Client::builder(
17716/// #     hyper_util::rt::TokioExecutor::new()
17717/// # )
17718/// # .build(
17719/// #     hyper_rustls::HttpsConnectorBuilder::new()
17720/// #         .with_native_roots()
17721/// #         .unwrap()
17722/// #         .https_or_http()
17723/// #         .enable_http2()
17724/// #         .build()
17725/// # );
17726/// # let mut hub = CloudRetail::new(client, auth);
17727/// // As the method needs a request, you would usually fill it with the desired information
17728/// // into the respective structure. Some of the parts shown here might not be applicable !
17729/// // Values shown here are possibly random and not representative !
17730/// let mut req = GoogleCloudRetailV2SearchRequest::default();
17731///
17732/// // You can configure optional parameters by calling the respective setters at will, and
17733/// // execute the final call using `doit()`.
17734/// // Values shown here are possibly random and not representative !
17735/// let result = hub.projects().locations_catalogs_placements_search(req, "placement")
17736///              .doit().await;
17737/// # }
17738/// ```
17739pub struct ProjectLocationCatalogPlacementSearchCall<'a, C>
17740where
17741    C: 'a,
17742{
17743    hub: &'a CloudRetail<C>,
17744    _request: GoogleCloudRetailV2SearchRequest,
17745    _placement: String,
17746    _delegate: Option<&'a mut dyn common::Delegate>,
17747    _additional_params: HashMap<String, String>,
17748    _scopes: BTreeSet<String>,
17749}
17750
17751impl<'a, C> common::CallBuilder for ProjectLocationCatalogPlacementSearchCall<'a, C> {}
17752
17753impl<'a, C> ProjectLocationCatalogPlacementSearchCall<'a, C>
17754where
17755    C: common::Connector,
17756{
17757    /// Perform the operation you have build so far.
17758    pub async fn doit(
17759        mut self,
17760    ) -> common::Result<(common::Response, GoogleCloudRetailV2SearchResponse)> {
17761        use std::borrow::Cow;
17762        use std::io::{Read, Seek};
17763
17764        use common::{url::Params, ToParts};
17765        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17766
17767        let mut dd = common::DefaultDelegate;
17768        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17769        dlg.begin(common::MethodInfo {
17770            id: "retail.projects.locations.catalogs.placements.search",
17771            http_method: hyper::Method::POST,
17772        });
17773
17774        for &field in ["alt", "placement"].iter() {
17775            if self._additional_params.contains_key(field) {
17776                dlg.finished(false);
17777                return Err(common::Error::FieldClash(field));
17778            }
17779        }
17780
17781        let mut params = Params::with_capacity(4 + self._additional_params.len());
17782        params.push("placement", self._placement);
17783
17784        params.extend(self._additional_params.iter());
17785
17786        params.push("alt", "json");
17787        let mut url = self.hub._base_url.clone() + "v2/{+placement}:search";
17788        if self._scopes.is_empty() {
17789            self._scopes
17790                .insert(Scope::CloudPlatform.as_ref().to_string());
17791        }
17792
17793        #[allow(clippy::single_element_loop)]
17794        for &(find_this, param_name) in [("{+placement}", "placement")].iter() {
17795            url = params.uri_replacement(url, param_name, find_this, true);
17796        }
17797        {
17798            let to_remove = ["placement"];
17799            params.remove_params(&to_remove);
17800        }
17801
17802        let url = params.parse_with_url(&url);
17803
17804        let mut json_mime_type = mime::APPLICATION_JSON;
17805        let mut request_value_reader = {
17806            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17807            common::remove_json_null_values(&mut value);
17808            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17809            serde_json::to_writer(&mut dst, &value).unwrap();
17810            dst
17811        };
17812        let request_size = request_value_reader
17813            .seek(std::io::SeekFrom::End(0))
17814            .unwrap();
17815        request_value_reader
17816            .seek(std::io::SeekFrom::Start(0))
17817            .unwrap();
17818
17819        loop {
17820            let token = match self
17821                .hub
17822                .auth
17823                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17824                .await
17825            {
17826                Ok(token) => token,
17827                Err(e) => match dlg.token(e) {
17828                    Ok(token) => token,
17829                    Err(e) => {
17830                        dlg.finished(false);
17831                        return Err(common::Error::MissingToken(e));
17832                    }
17833                },
17834            };
17835            request_value_reader
17836                .seek(std::io::SeekFrom::Start(0))
17837                .unwrap();
17838            let mut req_result = {
17839                let client = &self.hub.client;
17840                dlg.pre_request();
17841                let mut req_builder = hyper::Request::builder()
17842                    .method(hyper::Method::POST)
17843                    .uri(url.as_str())
17844                    .header(USER_AGENT, self.hub._user_agent.clone());
17845
17846                if let Some(token) = token.as_ref() {
17847                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17848                }
17849
17850                let request = req_builder
17851                    .header(CONTENT_TYPE, json_mime_type.to_string())
17852                    .header(CONTENT_LENGTH, request_size as u64)
17853                    .body(common::to_body(
17854                        request_value_reader.get_ref().clone().into(),
17855                    ));
17856
17857                client.request(request.unwrap()).await
17858            };
17859
17860            match req_result {
17861                Err(err) => {
17862                    if let common::Retry::After(d) = dlg.http_error(&err) {
17863                        sleep(d).await;
17864                        continue;
17865                    }
17866                    dlg.finished(false);
17867                    return Err(common::Error::HttpError(err));
17868                }
17869                Ok(res) => {
17870                    let (mut parts, body) = res.into_parts();
17871                    let mut body = common::Body::new(body);
17872                    if !parts.status.is_success() {
17873                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17874                        let error = serde_json::from_str(&common::to_string(&bytes));
17875                        let response = common::to_response(parts, bytes.into());
17876
17877                        if let common::Retry::After(d) =
17878                            dlg.http_failure(&response, error.as_ref().ok())
17879                        {
17880                            sleep(d).await;
17881                            continue;
17882                        }
17883
17884                        dlg.finished(false);
17885
17886                        return Err(match error {
17887                            Ok(value) => common::Error::BadRequest(value),
17888                            _ => common::Error::Failure(response),
17889                        });
17890                    }
17891                    let response = {
17892                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17893                        let encoded = common::to_string(&bytes);
17894                        match serde_json::from_str(&encoded) {
17895                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17896                            Err(error) => {
17897                                dlg.response_json_decode_error(&encoded, &error);
17898                                return Err(common::Error::JsonDecodeError(
17899                                    encoded.to_string(),
17900                                    error,
17901                                ));
17902                            }
17903                        }
17904                    };
17905
17906                    dlg.finished(true);
17907                    return Ok(response);
17908                }
17909            }
17910        }
17911    }
17912
17913    ///
17914    /// Sets the *request* property to the given value.
17915    ///
17916    /// Even though the property as already been set when instantiating this call,
17917    /// we provide this method for API completeness.
17918    pub fn request(
17919        mut self,
17920        new_value: GoogleCloudRetailV2SearchRequest,
17921    ) -> ProjectLocationCatalogPlacementSearchCall<'a, C> {
17922        self._request = new_value;
17923        self
17924    }
17925    /// Required. The resource name of the Retail Search serving config, such as `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` or the name of the legacy placement resource, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. This field is used to identify the serving config name and the set of models that are used to make the search.
17926    ///
17927    /// Sets the *placement* path property to the given value.
17928    ///
17929    /// Even though the property as already been set when instantiating this call,
17930    /// we provide this method for API completeness.
17931    pub fn placement(
17932        mut self,
17933        new_value: &str,
17934    ) -> ProjectLocationCatalogPlacementSearchCall<'a, C> {
17935        self._placement = new_value.to_string();
17936        self
17937    }
17938    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17939    /// while executing the actual API request.
17940    ///
17941    /// ````text
17942    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17943    /// ````
17944    ///
17945    /// Sets the *delegate* property to the given value.
17946    pub fn delegate(
17947        mut self,
17948        new_value: &'a mut dyn common::Delegate,
17949    ) -> ProjectLocationCatalogPlacementSearchCall<'a, C> {
17950        self._delegate = Some(new_value);
17951        self
17952    }
17953
17954    /// Set any additional parameter of the query string used in the request.
17955    /// It should be used to set parameters which are not yet available through their own
17956    /// setters.
17957    ///
17958    /// Please note that this method must not be used to set any of the known parameters
17959    /// which have their own setter method. If done anyway, the request will fail.
17960    ///
17961    /// # Additional Parameters
17962    ///
17963    /// * *$.xgafv* (query-string) - V1 error format.
17964    /// * *access_token* (query-string) - OAuth access token.
17965    /// * *alt* (query-string) - Data format for response.
17966    /// * *callback* (query-string) - JSONP
17967    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17968    /// * *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.
17969    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17970    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17971    /// * *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.
17972    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17973    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17974    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogPlacementSearchCall<'a, C>
17975    where
17976        T: AsRef<str>,
17977    {
17978        self._additional_params
17979            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17980        self
17981    }
17982
17983    /// Identifies the authorization scope for the method you are building.
17984    ///
17985    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17986    /// [`Scope::CloudPlatform`].
17987    ///
17988    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17989    /// tokens for more than one scope.
17990    ///
17991    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17992    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17993    /// sufficient, a read-write scope will do as well.
17994    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogPlacementSearchCall<'a, C>
17995    where
17996        St: AsRef<str>,
17997    {
17998        self._scopes.insert(String::from(scope.as_ref()));
17999        self
18000    }
18001    /// Identifies the authorization scope(s) for the method you are building.
18002    ///
18003    /// See [`Self::add_scope()`] for details.
18004    pub fn add_scopes<I, St>(
18005        mut self,
18006        scopes: I,
18007    ) -> ProjectLocationCatalogPlacementSearchCall<'a, C>
18008    where
18009        I: IntoIterator<Item = St>,
18010        St: AsRef<str>,
18011    {
18012        self._scopes
18013            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18014        self
18015    }
18016
18017    /// Removes all scopes, and no default scope will be used either.
18018    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18019    /// for details).
18020    pub fn clear_scopes(mut self) -> ProjectLocationCatalogPlacementSearchCall<'a, C> {
18021        self._scopes.clear();
18022        self
18023    }
18024}
18025
18026/// Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.
18027///
18028/// A builder for the *locations.catalogs.servingConfigs.addControl* method supported by a *project* resource.
18029/// It is not used directly, but through a [`ProjectMethods`] instance.
18030///
18031/// # Example
18032///
18033/// Instantiate a resource method builder
18034///
18035/// ```test_harness,no_run
18036/// # extern crate hyper;
18037/// # extern crate hyper_rustls;
18038/// # extern crate google_retail2 as retail2;
18039/// use retail2::api::GoogleCloudRetailV2AddControlRequest;
18040/// # async fn dox() {
18041/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18042///
18043/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18044/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18045/// #     .with_native_roots()
18046/// #     .unwrap()
18047/// #     .https_only()
18048/// #     .enable_http2()
18049/// #     .build();
18050///
18051/// # let executor = hyper_util::rt::TokioExecutor::new();
18052/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18053/// #     secret,
18054/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18055/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18056/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18057/// #     ),
18058/// # ).build().await.unwrap();
18059///
18060/// # let client = hyper_util::client::legacy::Client::builder(
18061/// #     hyper_util::rt::TokioExecutor::new()
18062/// # )
18063/// # .build(
18064/// #     hyper_rustls::HttpsConnectorBuilder::new()
18065/// #         .with_native_roots()
18066/// #         .unwrap()
18067/// #         .https_or_http()
18068/// #         .enable_http2()
18069/// #         .build()
18070/// # );
18071/// # let mut hub = CloudRetail::new(client, auth);
18072/// // As the method needs a request, you would usually fill it with the desired information
18073/// // into the respective structure. Some of the parts shown here might not be applicable !
18074/// // Values shown here are possibly random and not representative !
18075/// let mut req = GoogleCloudRetailV2AddControlRequest::default();
18076///
18077/// // You can configure optional parameters by calling the respective setters at will, and
18078/// // execute the final call using `doit()`.
18079/// // Values shown here are possibly random and not representative !
18080/// let result = hub.projects().locations_catalogs_serving_configs_add_control(req, "servingConfig")
18081///              .doit().await;
18082/// # }
18083/// ```
18084pub struct ProjectLocationCatalogServingConfigAddControlCall<'a, C>
18085where
18086    C: 'a,
18087{
18088    hub: &'a CloudRetail<C>,
18089    _request: GoogleCloudRetailV2AddControlRequest,
18090    _serving_config: String,
18091    _delegate: Option<&'a mut dyn common::Delegate>,
18092    _additional_params: HashMap<String, String>,
18093    _scopes: BTreeSet<String>,
18094}
18095
18096impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigAddControlCall<'a, C> {}
18097
18098impl<'a, C> ProjectLocationCatalogServingConfigAddControlCall<'a, C>
18099where
18100    C: common::Connector,
18101{
18102    /// Perform the operation you have build so far.
18103    pub async fn doit(
18104        mut self,
18105    ) -> common::Result<(common::Response, GoogleCloudRetailV2ServingConfig)> {
18106        use std::borrow::Cow;
18107        use std::io::{Read, Seek};
18108
18109        use common::{url::Params, ToParts};
18110        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18111
18112        let mut dd = common::DefaultDelegate;
18113        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18114        dlg.begin(common::MethodInfo {
18115            id: "retail.projects.locations.catalogs.servingConfigs.addControl",
18116            http_method: hyper::Method::POST,
18117        });
18118
18119        for &field in ["alt", "servingConfig"].iter() {
18120            if self._additional_params.contains_key(field) {
18121                dlg.finished(false);
18122                return Err(common::Error::FieldClash(field));
18123            }
18124        }
18125
18126        let mut params = Params::with_capacity(4 + self._additional_params.len());
18127        params.push("servingConfig", self._serving_config);
18128
18129        params.extend(self._additional_params.iter());
18130
18131        params.push("alt", "json");
18132        let mut url = self.hub._base_url.clone() + "v2/{+servingConfig}:addControl";
18133        if self._scopes.is_empty() {
18134            self._scopes
18135                .insert(Scope::CloudPlatform.as_ref().to_string());
18136        }
18137
18138        #[allow(clippy::single_element_loop)]
18139        for &(find_this, param_name) in [("{+servingConfig}", "servingConfig")].iter() {
18140            url = params.uri_replacement(url, param_name, find_this, true);
18141        }
18142        {
18143            let to_remove = ["servingConfig"];
18144            params.remove_params(&to_remove);
18145        }
18146
18147        let url = params.parse_with_url(&url);
18148
18149        let mut json_mime_type = mime::APPLICATION_JSON;
18150        let mut request_value_reader = {
18151            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18152            common::remove_json_null_values(&mut value);
18153            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18154            serde_json::to_writer(&mut dst, &value).unwrap();
18155            dst
18156        };
18157        let request_size = request_value_reader
18158            .seek(std::io::SeekFrom::End(0))
18159            .unwrap();
18160        request_value_reader
18161            .seek(std::io::SeekFrom::Start(0))
18162            .unwrap();
18163
18164        loop {
18165            let token = match self
18166                .hub
18167                .auth
18168                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18169                .await
18170            {
18171                Ok(token) => token,
18172                Err(e) => match dlg.token(e) {
18173                    Ok(token) => token,
18174                    Err(e) => {
18175                        dlg.finished(false);
18176                        return Err(common::Error::MissingToken(e));
18177                    }
18178                },
18179            };
18180            request_value_reader
18181                .seek(std::io::SeekFrom::Start(0))
18182                .unwrap();
18183            let mut req_result = {
18184                let client = &self.hub.client;
18185                dlg.pre_request();
18186                let mut req_builder = hyper::Request::builder()
18187                    .method(hyper::Method::POST)
18188                    .uri(url.as_str())
18189                    .header(USER_AGENT, self.hub._user_agent.clone());
18190
18191                if let Some(token) = token.as_ref() {
18192                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18193                }
18194
18195                let request = req_builder
18196                    .header(CONTENT_TYPE, json_mime_type.to_string())
18197                    .header(CONTENT_LENGTH, request_size as u64)
18198                    .body(common::to_body(
18199                        request_value_reader.get_ref().clone().into(),
18200                    ));
18201
18202                client.request(request.unwrap()).await
18203            };
18204
18205            match req_result {
18206                Err(err) => {
18207                    if let common::Retry::After(d) = dlg.http_error(&err) {
18208                        sleep(d).await;
18209                        continue;
18210                    }
18211                    dlg.finished(false);
18212                    return Err(common::Error::HttpError(err));
18213                }
18214                Ok(res) => {
18215                    let (mut parts, body) = res.into_parts();
18216                    let mut body = common::Body::new(body);
18217                    if !parts.status.is_success() {
18218                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18219                        let error = serde_json::from_str(&common::to_string(&bytes));
18220                        let response = common::to_response(parts, bytes.into());
18221
18222                        if let common::Retry::After(d) =
18223                            dlg.http_failure(&response, error.as_ref().ok())
18224                        {
18225                            sleep(d).await;
18226                            continue;
18227                        }
18228
18229                        dlg.finished(false);
18230
18231                        return Err(match error {
18232                            Ok(value) => common::Error::BadRequest(value),
18233                            _ => common::Error::Failure(response),
18234                        });
18235                    }
18236                    let response = {
18237                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18238                        let encoded = common::to_string(&bytes);
18239                        match serde_json::from_str(&encoded) {
18240                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18241                            Err(error) => {
18242                                dlg.response_json_decode_error(&encoded, &error);
18243                                return Err(common::Error::JsonDecodeError(
18244                                    encoded.to_string(),
18245                                    error,
18246                                ));
18247                            }
18248                        }
18249                    };
18250
18251                    dlg.finished(true);
18252                    return Ok(response);
18253                }
18254            }
18255        }
18256    }
18257
18258    ///
18259    /// Sets the *request* property to the given value.
18260    ///
18261    /// Even though the property as already been set when instantiating this call,
18262    /// we provide this method for API completeness.
18263    pub fn request(
18264        mut self,
18265        new_value: GoogleCloudRetailV2AddControlRequest,
18266    ) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C> {
18267        self._request = new_value;
18268        self
18269    }
18270    /// Required. The source ServingConfig resource name . Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
18271    ///
18272    /// Sets the *serving config* path property to the given value.
18273    ///
18274    /// Even though the property as already been set when instantiating this call,
18275    /// we provide this method for API completeness.
18276    pub fn serving_config(
18277        mut self,
18278        new_value: &str,
18279    ) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C> {
18280        self._serving_config = new_value.to_string();
18281        self
18282    }
18283    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18284    /// while executing the actual API request.
18285    ///
18286    /// ````text
18287    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18288    /// ````
18289    ///
18290    /// Sets the *delegate* property to the given value.
18291    pub fn delegate(
18292        mut self,
18293        new_value: &'a mut dyn common::Delegate,
18294    ) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C> {
18295        self._delegate = Some(new_value);
18296        self
18297    }
18298
18299    /// Set any additional parameter of the query string used in the request.
18300    /// It should be used to set parameters which are not yet available through their own
18301    /// setters.
18302    ///
18303    /// Please note that this method must not be used to set any of the known parameters
18304    /// which have their own setter method. If done anyway, the request will fail.
18305    ///
18306    /// # Additional Parameters
18307    ///
18308    /// * *$.xgafv* (query-string) - V1 error format.
18309    /// * *access_token* (query-string) - OAuth access token.
18310    /// * *alt* (query-string) - Data format for response.
18311    /// * *callback* (query-string) - JSONP
18312    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18313    /// * *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.
18314    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18315    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18316    /// * *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.
18317    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18318    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18319    pub fn param<T>(
18320        mut self,
18321        name: T,
18322        value: T,
18323    ) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C>
18324    where
18325        T: AsRef<str>,
18326    {
18327        self._additional_params
18328            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18329        self
18330    }
18331
18332    /// Identifies the authorization scope for the method you are building.
18333    ///
18334    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18335    /// [`Scope::CloudPlatform`].
18336    ///
18337    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18338    /// tokens for more than one scope.
18339    ///
18340    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18341    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18342    /// sufficient, a read-write scope will do as well.
18343    pub fn add_scope<St>(
18344        mut self,
18345        scope: St,
18346    ) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C>
18347    where
18348        St: AsRef<str>,
18349    {
18350        self._scopes.insert(String::from(scope.as_ref()));
18351        self
18352    }
18353    /// Identifies the authorization scope(s) for the method you are building.
18354    ///
18355    /// See [`Self::add_scope()`] for details.
18356    pub fn add_scopes<I, St>(
18357        mut self,
18358        scopes: I,
18359    ) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C>
18360    where
18361        I: IntoIterator<Item = St>,
18362        St: AsRef<str>,
18363    {
18364        self._scopes
18365            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18366        self
18367    }
18368
18369    /// Removes all scopes, and no default scope will be used either.
18370    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18371    /// for details).
18372    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigAddControlCall<'a, C> {
18373        self._scopes.clear();
18374        self
18375    }
18376}
18377
18378/// Performs a conversational search. This feature is only available for users who have Conversational Search enabled.
18379///
18380/// A builder for the *locations.catalogs.servingConfigs.conversationalSearch* method supported by a *project* resource.
18381/// It is not used directly, but through a [`ProjectMethods`] instance.
18382///
18383/// # Example
18384///
18385/// Instantiate a resource method builder
18386///
18387/// ```test_harness,no_run
18388/// # extern crate hyper;
18389/// # extern crate hyper_rustls;
18390/// # extern crate google_retail2 as retail2;
18391/// use retail2::api::GoogleCloudRetailV2ConversationalSearchRequest;
18392/// # async fn dox() {
18393/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18394///
18395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18396/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18397/// #     .with_native_roots()
18398/// #     .unwrap()
18399/// #     .https_only()
18400/// #     .enable_http2()
18401/// #     .build();
18402///
18403/// # let executor = hyper_util::rt::TokioExecutor::new();
18404/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18405/// #     secret,
18406/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18407/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18408/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18409/// #     ),
18410/// # ).build().await.unwrap();
18411///
18412/// # let client = hyper_util::client::legacy::Client::builder(
18413/// #     hyper_util::rt::TokioExecutor::new()
18414/// # )
18415/// # .build(
18416/// #     hyper_rustls::HttpsConnectorBuilder::new()
18417/// #         .with_native_roots()
18418/// #         .unwrap()
18419/// #         .https_or_http()
18420/// #         .enable_http2()
18421/// #         .build()
18422/// # );
18423/// # let mut hub = CloudRetail::new(client, auth);
18424/// // As the method needs a request, you would usually fill it with the desired information
18425/// // into the respective structure. Some of the parts shown here might not be applicable !
18426/// // Values shown here are possibly random and not representative !
18427/// let mut req = GoogleCloudRetailV2ConversationalSearchRequest::default();
18428///
18429/// // You can configure optional parameters by calling the respective setters at will, and
18430/// // execute the final call using `doit()`.
18431/// // Values shown here are possibly random and not representative !
18432/// let result = hub.projects().locations_catalogs_serving_configs_conversational_search(req, "placement")
18433///              .doit().await;
18434/// # }
18435/// ```
18436pub struct ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C>
18437where
18438    C: 'a,
18439{
18440    hub: &'a CloudRetail<C>,
18441    _request: GoogleCloudRetailV2ConversationalSearchRequest,
18442    _placement: String,
18443    _delegate: Option<&'a mut dyn common::Delegate>,
18444    _additional_params: HashMap<String, String>,
18445    _scopes: BTreeSet<String>,
18446}
18447
18448impl<'a, C> common::CallBuilder
18449    for ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C>
18450{
18451}
18452
18453impl<'a, C> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C>
18454where
18455    C: common::Connector,
18456{
18457    /// Perform the operation you have build so far.
18458    pub async fn doit(
18459        mut self,
18460    ) -> common::Result<(
18461        common::Response,
18462        GoogleCloudRetailV2ConversationalSearchResponse,
18463    )> {
18464        use std::borrow::Cow;
18465        use std::io::{Read, Seek};
18466
18467        use common::{url::Params, ToParts};
18468        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18469
18470        let mut dd = common::DefaultDelegate;
18471        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18472        dlg.begin(common::MethodInfo {
18473            id: "retail.projects.locations.catalogs.servingConfigs.conversationalSearch",
18474            http_method: hyper::Method::POST,
18475        });
18476
18477        for &field in ["alt", "placement"].iter() {
18478            if self._additional_params.contains_key(field) {
18479                dlg.finished(false);
18480                return Err(common::Error::FieldClash(field));
18481            }
18482        }
18483
18484        let mut params = Params::with_capacity(4 + self._additional_params.len());
18485        params.push("placement", self._placement);
18486
18487        params.extend(self._additional_params.iter());
18488
18489        params.push("alt", "json");
18490        let mut url = self.hub._base_url.clone() + "v2/{+placement}:conversationalSearch";
18491        if self._scopes.is_empty() {
18492            self._scopes
18493                .insert(Scope::CloudPlatform.as_ref().to_string());
18494        }
18495
18496        #[allow(clippy::single_element_loop)]
18497        for &(find_this, param_name) in [("{+placement}", "placement")].iter() {
18498            url = params.uri_replacement(url, param_name, find_this, true);
18499        }
18500        {
18501            let to_remove = ["placement"];
18502            params.remove_params(&to_remove);
18503        }
18504
18505        let url = params.parse_with_url(&url);
18506
18507        let mut json_mime_type = mime::APPLICATION_JSON;
18508        let mut request_value_reader = {
18509            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18510            common::remove_json_null_values(&mut value);
18511            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18512            serde_json::to_writer(&mut dst, &value).unwrap();
18513            dst
18514        };
18515        let request_size = request_value_reader
18516            .seek(std::io::SeekFrom::End(0))
18517            .unwrap();
18518        request_value_reader
18519            .seek(std::io::SeekFrom::Start(0))
18520            .unwrap();
18521
18522        loop {
18523            let token = match self
18524                .hub
18525                .auth
18526                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18527                .await
18528            {
18529                Ok(token) => token,
18530                Err(e) => match dlg.token(e) {
18531                    Ok(token) => token,
18532                    Err(e) => {
18533                        dlg.finished(false);
18534                        return Err(common::Error::MissingToken(e));
18535                    }
18536                },
18537            };
18538            request_value_reader
18539                .seek(std::io::SeekFrom::Start(0))
18540                .unwrap();
18541            let mut req_result = {
18542                let client = &self.hub.client;
18543                dlg.pre_request();
18544                let mut req_builder = hyper::Request::builder()
18545                    .method(hyper::Method::POST)
18546                    .uri(url.as_str())
18547                    .header(USER_AGENT, self.hub._user_agent.clone());
18548
18549                if let Some(token) = token.as_ref() {
18550                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18551                }
18552
18553                let request = req_builder
18554                    .header(CONTENT_TYPE, json_mime_type.to_string())
18555                    .header(CONTENT_LENGTH, request_size as u64)
18556                    .body(common::to_body(
18557                        request_value_reader.get_ref().clone().into(),
18558                    ));
18559
18560                client.request(request.unwrap()).await
18561            };
18562
18563            match req_result {
18564                Err(err) => {
18565                    if let common::Retry::After(d) = dlg.http_error(&err) {
18566                        sleep(d).await;
18567                        continue;
18568                    }
18569                    dlg.finished(false);
18570                    return Err(common::Error::HttpError(err));
18571                }
18572                Ok(res) => {
18573                    let (mut parts, body) = res.into_parts();
18574                    let mut body = common::Body::new(body);
18575                    if !parts.status.is_success() {
18576                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18577                        let error = serde_json::from_str(&common::to_string(&bytes));
18578                        let response = common::to_response(parts, bytes.into());
18579
18580                        if let common::Retry::After(d) =
18581                            dlg.http_failure(&response, error.as_ref().ok())
18582                        {
18583                            sleep(d).await;
18584                            continue;
18585                        }
18586
18587                        dlg.finished(false);
18588
18589                        return Err(match error {
18590                            Ok(value) => common::Error::BadRequest(value),
18591                            _ => common::Error::Failure(response),
18592                        });
18593                    }
18594                    let response = {
18595                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18596                        let encoded = common::to_string(&bytes);
18597                        match serde_json::from_str(&encoded) {
18598                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18599                            Err(error) => {
18600                                dlg.response_json_decode_error(&encoded, &error);
18601                                return Err(common::Error::JsonDecodeError(
18602                                    encoded.to_string(),
18603                                    error,
18604                                ));
18605                            }
18606                        }
18607                    };
18608
18609                    dlg.finished(true);
18610                    return Ok(response);
18611                }
18612            }
18613        }
18614    }
18615
18616    ///
18617    /// Sets the *request* property to the given value.
18618    ///
18619    /// Even though the property as already been set when instantiating this call,
18620    /// we provide this method for API completeness.
18621    pub fn request(
18622        mut self,
18623        new_value: GoogleCloudRetailV2ConversationalSearchRequest,
18624    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C> {
18625        self._request = new_value;
18626        self
18627    }
18628    /// Required. The resource name of the search engine placement, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search` or `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` This field is used to identify the serving config name and the set of models that will be used to make the search.
18629    ///
18630    /// Sets the *placement* path property to the given value.
18631    ///
18632    /// Even though the property as already been set when instantiating this call,
18633    /// we provide this method for API completeness.
18634    pub fn placement(
18635        mut self,
18636        new_value: &str,
18637    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C> {
18638        self._placement = new_value.to_string();
18639        self
18640    }
18641    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18642    /// while executing the actual API request.
18643    ///
18644    /// ````text
18645    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18646    /// ````
18647    ///
18648    /// Sets the *delegate* property to the given value.
18649    pub fn delegate(
18650        mut self,
18651        new_value: &'a mut dyn common::Delegate,
18652    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C> {
18653        self._delegate = Some(new_value);
18654        self
18655    }
18656
18657    /// Set any additional parameter of the query string used in the request.
18658    /// It should be used to set parameters which are not yet available through their own
18659    /// setters.
18660    ///
18661    /// Please note that this method must not be used to set any of the known parameters
18662    /// which have their own setter method. If done anyway, the request will fail.
18663    ///
18664    /// # Additional Parameters
18665    ///
18666    /// * *$.xgafv* (query-string) - V1 error format.
18667    /// * *access_token* (query-string) - OAuth access token.
18668    /// * *alt* (query-string) - Data format for response.
18669    /// * *callback* (query-string) - JSONP
18670    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18671    /// * *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.
18672    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18673    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18674    /// * *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.
18675    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18676    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18677    pub fn param<T>(
18678        mut self,
18679        name: T,
18680        value: T,
18681    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C>
18682    where
18683        T: AsRef<str>,
18684    {
18685        self._additional_params
18686            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18687        self
18688    }
18689
18690    /// Identifies the authorization scope for the method you are building.
18691    ///
18692    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18693    /// [`Scope::CloudPlatform`].
18694    ///
18695    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18696    /// tokens for more than one scope.
18697    ///
18698    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18699    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18700    /// sufficient, a read-write scope will do as well.
18701    pub fn add_scope<St>(
18702        mut self,
18703        scope: St,
18704    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C>
18705    where
18706        St: AsRef<str>,
18707    {
18708        self._scopes.insert(String::from(scope.as_ref()));
18709        self
18710    }
18711    /// Identifies the authorization scope(s) for the method you are building.
18712    ///
18713    /// See [`Self::add_scope()`] for details.
18714    pub fn add_scopes<I, St>(
18715        mut self,
18716        scopes: I,
18717    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C>
18718    where
18719        I: IntoIterator<Item = St>,
18720        St: AsRef<str>,
18721    {
18722        self._scopes
18723            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18724        self
18725    }
18726
18727    /// Removes all scopes, and no default scope will be used either.
18728    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18729    /// for details).
18730    pub fn clear_scopes(
18731        mut self,
18732    ) -> ProjectLocationCatalogServingConfigConversationalSearchCall<'a, C> {
18733        self._scopes.clear();
18734        self
18735    }
18736}
18737
18738/// Creates a ServingConfig. A maximum of 100 ServingConfigs are allowed in a Catalog, otherwise a FAILED_PRECONDITION error is returned.
18739///
18740/// A builder for the *locations.catalogs.servingConfigs.create* method supported by a *project* resource.
18741/// It is not used directly, but through a [`ProjectMethods`] instance.
18742///
18743/// # Example
18744///
18745/// Instantiate a resource method builder
18746///
18747/// ```test_harness,no_run
18748/// # extern crate hyper;
18749/// # extern crate hyper_rustls;
18750/// # extern crate google_retail2 as retail2;
18751/// use retail2::api::GoogleCloudRetailV2ServingConfig;
18752/// # async fn dox() {
18753/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18754///
18755/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18756/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18757/// #     .with_native_roots()
18758/// #     .unwrap()
18759/// #     .https_only()
18760/// #     .enable_http2()
18761/// #     .build();
18762///
18763/// # let executor = hyper_util::rt::TokioExecutor::new();
18764/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18765/// #     secret,
18766/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18767/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18768/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18769/// #     ),
18770/// # ).build().await.unwrap();
18771///
18772/// # let client = hyper_util::client::legacy::Client::builder(
18773/// #     hyper_util::rt::TokioExecutor::new()
18774/// # )
18775/// # .build(
18776/// #     hyper_rustls::HttpsConnectorBuilder::new()
18777/// #         .with_native_roots()
18778/// #         .unwrap()
18779/// #         .https_or_http()
18780/// #         .enable_http2()
18781/// #         .build()
18782/// # );
18783/// # let mut hub = CloudRetail::new(client, auth);
18784/// // As the method needs a request, you would usually fill it with the desired information
18785/// // into the respective structure. Some of the parts shown here might not be applicable !
18786/// // Values shown here are possibly random and not representative !
18787/// let mut req = GoogleCloudRetailV2ServingConfig::default();
18788///
18789/// // You can configure optional parameters by calling the respective setters at will, and
18790/// // execute the final call using `doit()`.
18791/// // Values shown here are possibly random and not representative !
18792/// let result = hub.projects().locations_catalogs_serving_configs_create(req, "parent")
18793///              .serving_config_id("Lorem")
18794///              .doit().await;
18795/// # }
18796/// ```
18797pub struct ProjectLocationCatalogServingConfigCreateCall<'a, C>
18798where
18799    C: 'a,
18800{
18801    hub: &'a CloudRetail<C>,
18802    _request: GoogleCloudRetailV2ServingConfig,
18803    _parent: String,
18804    _serving_config_id: Option<String>,
18805    _delegate: Option<&'a mut dyn common::Delegate>,
18806    _additional_params: HashMap<String, String>,
18807    _scopes: BTreeSet<String>,
18808}
18809
18810impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigCreateCall<'a, C> {}
18811
18812impl<'a, C> ProjectLocationCatalogServingConfigCreateCall<'a, C>
18813where
18814    C: common::Connector,
18815{
18816    /// Perform the operation you have build so far.
18817    pub async fn doit(
18818        mut self,
18819    ) -> common::Result<(common::Response, GoogleCloudRetailV2ServingConfig)> {
18820        use std::borrow::Cow;
18821        use std::io::{Read, Seek};
18822
18823        use common::{url::Params, ToParts};
18824        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18825
18826        let mut dd = common::DefaultDelegate;
18827        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18828        dlg.begin(common::MethodInfo {
18829            id: "retail.projects.locations.catalogs.servingConfigs.create",
18830            http_method: hyper::Method::POST,
18831        });
18832
18833        for &field in ["alt", "parent", "servingConfigId"].iter() {
18834            if self._additional_params.contains_key(field) {
18835                dlg.finished(false);
18836                return Err(common::Error::FieldClash(field));
18837            }
18838        }
18839
18840        let mut params = Params::with_capacity(5 + self._additional_params.len());
18841        params.push("parent", self._parent);
18842        if let Some(value) = self._serving_config_id.as_ref() {
18843            params.push("servingConfigId", value);
18844        }
18845
18846        params.extend(self._additional_params.iter());
18847
18848        params.push("alt", "json");
18849        let mut url = self.hub._base_url.clone() + "v2/{+parent}/servingConfigs";
18850        if self._scopes.is_empty() {
18851            self._scopes
18852                .insert(Scope::CloudPlatform.as_ref().to_string());
18853        }
18854
18855        #[allow(clippy::single_element_loop)]
18856        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18857            url = params.uri_replacement(url, param_name, find_this, true);
18858        }
18859        {
18860            let to_remove = ["parent"];
18861            params.remove_params(&to_remove);
18862        }
18863
18864        let url = params.parse_with_url(&url);
18865
18866        let mut json_mime_type = mime::APPLICATION_JSON;
18867        let mut request_value_reader = {
18868            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18869            common::remove_json_null_values(&mut value);
18870            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18871            serde_json::to_writer(&mut dst, &value).unwrap();
18872            dst
18873        };
18874        let request_size = request_value_reader
18875            .seek(std::io::SeekFrom::End(0))
18876            .unwrap();
18877        request_value_reader
18878            .seek(std::io::SeekFrom::Start(0))
18879            .unwrap();
18880
18881        loop {
18882            let token = match self
18883                .hub
18884                .auth
18885                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18886                .await
18887            {
18888                Ok(token) => token,
18889                Err(e) => match dlg.token(e) {
18890                    Ok(token) => token,
18891                    Err(e) => {
18892                        dlg.finished(false);
18893                        return Err(common::Error::MissingToken(e));
18894                    }
18895                },
18896            };
18897            request_value_reader
18898                .seek(std::io::SeekFrom::Start(0))
18899                .unwrap();
18900            let mut req_result = {
18901                let client = &self.hub.client;
18902                dlg.pre_request();
18903                let mut req_builder = hyper::Request::builder()
18904                    .method(hyper::Method::POST)
18905                    .uri(url.as_str())
18906                    .header(USER_AGENT, self.hub._user_agent.clone());
18907
18908                if let Some(token) = token.as_ref() {
18909                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18910                }
18911
18912                let request = req_builder
18913                    .header(CONTENT_TYPE, json_mime_type.to_string())
18914                    .header(CONTENT_LENGTH, request_size as u64)
18915                    .body(common::to_body(
18916                        request_value_reader.get_ref().clone().into(),
18917                    ));
18918
18919                client.request(request.unwrap()).await
18920            };
18921
18922            match req_result {
18923                Err(err) => {
18924                    if let common::Retry::After(d) = dlg.http_error(&err) {
18925                        sleep(d).await;
18926                        continue;
18927                    }
18928                    dlg.finished(false);
18929                    return Err(common::Error::HttpError(err));
18930                }
18931                Ok(res) => {
18932                    let (mut parts, body) = res.into_parts();
18933                    let mut body = common::Body::new(body);
18934                    if !parts.status.is_success() {
18935                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18936                        let error = serde_json::from_str(&common::to_string(&bytes));
18937                        let response = common::to_response(parts, bytes.into());
18938
18939                        if let common::Retry::After(d) =
18940                            dlg.http_failure(&response, error.as_ref().ok())
18941                        {
18942                            sleep(d).await;
18943                            continue;
18944                        }
18945
18946                        dlg.finished(false);
18947
18948                        return Err(match error {
18949                            Ok(value) => common::Error::BadRequest(value),
18950                            _ => common::Error::Failure(response),
18951                        });
18952                    }
18953                    let response = {
18954                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18955                        let encoded = common::to_string(&bytes);
18956                        match serde_json::from_str(&encoded) {
18957                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18958                            Err(error) => {
18959                                dlg.response_json_decode_error(&encoded, &error);
18960                                return Err(common::Error::JsonDecodeError(
18961                                    encoded.to_string(),
18962                                    error,
18963                                ));
18964                            }
18965                        }
18966                    };
18967
18968                    dlg.finished(true);
18969                    return Ok(response);
18970                }
18971            }
18972        }
18973    }
18974
18975    ///
18976    /// Sets the *request* property to the given value.
18977    ///
18978    /// Even though the property as already been set when instantiating this call,
18979    /// we provide this method for API completeness.
18980    pub fn request(
18981        mut self,
18982        new_value: GoogleCloudRetailV2ServingConfig,
18983    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C> {
18984        self._request = new_value;
18985        self
18986    }
18987    /// Required. Full resource name of parent. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
18988    ///
18989    /// Sets the *parent* path property to the given value.
18990    ///
18991    /// Even though the property as already been set when instantiating this call,
18992    /// we provide this method for API completeness.
18993    pub fn parent(
18994        mut self,
18995        new_value: &str,
18996    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C> {
18997        self._parent = new_value.to_string();
18998        self
18999    }
19000    /// Required. The ID to use for the ServingConfig, which will become the final component of the ServingConfig's resource name. This value should be 4-63 characters, and valid characters are /a-z-_/.
19001    ///
19002    /// Sets the *serving config id* query property to the given value.
19003    pub fn serving_config_id(
19004        mut self,
19005        new_value: &str,
19006    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C> {
19007        self._serving_config_id = Some(new_value.to_string());
19008        self
19009    }
19010    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19011    /// while executing the actual API request.
19012    ///
19013    /// ````text
19014    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19015    /// ````
19016    ///
19017    /// Sets the *delegate* property to the given value.
19018    pub fn delegate(
19019        mut self,
19020        new_value: &'a mut dyn common::Delegate,
19021    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C> {
19022        self._delegate = Some(new_value);
19023        self
19024    }
19025
19026    /// Set any additional parameter of the query string used in the request.
19027    /// It should be used to set parameters which are not yet available through their own
19028    /// setters.
19029    ///
19030    /// Please note that this method must not be used to set any of the known parameters
19031    /// which have their own setter method. If done anyway, the request will fail.
19032    ///
19033    /// # Additional Parameters
19034    ///
19035    /// * *$.xgafv* (query-string) - V1 error format.
19036    /// * *access_token* (query-string) - OAuth access token.
19037    /// * *alt* (query-string) - Data format for response.
19038    /// * *callback* (query-string) - JSONP
19039    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19040    /// * *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.
19041    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19042    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19043    /// * *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.
19044    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19045    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19046    pub fn param<T>(
19047        mut self,
19048        name: T,
19049        value: T,
19050    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C>
19051    where
19052        T: AsRef<str>,
19053    {
19054        self._additional_params
19055            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19056        self
19057    }
19058
19059    /// Identifies the authorization scope for the method you are building.
19060    ///
19061    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19062    /// [`Scope::CloudPlatform`].
19063    ///
19064    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19065    /// tokens for more than one scope.
19066    ///
19067    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19068    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19069    /// sufficient, a read-write scope will do as well.
19070    pub fn add_scope<St>(
19071        mut self,
19072        scope: St,
19073    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C>
19074    where
19075        St: AsRef<str>,
19076    {
19077        self._scopes.insert(String::from(scope.as_ref()));
19078        self
19079    }
19080    /// Identifies the authorization scope(s) for the method you are building.
19081    ///
19082    /// See [`Self::add_scope()`] for details.
19083    pub fn add_scopes<I, St>(
19084        mut self,
19085        scopes: I,
19086    ) -> ProjectLocationCatalogServingConfigCreateCall<'a, C>
19087    where
19088        I: IntoIterator<Item = St>,
19089        St: AsRef<str>,
19090    {
19091        self._scopes
19092            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19093        self
19094    }
19095
19096    /// Removes all scopes, and no default scope will be used either.
19097    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19098    /// for details).
19099    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigCreateCall<'a, C> {
19100        self._scopes.clear();
19101        self
19102    }
19103}
19104
19105/// Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.
19106///
19107/// A builder for the *locations.catalogs.servingConfigs.delete* method supported by a *project* resource.
19108/// It is not used directly, but through a [`ProjectMethods`] instance.
19109///
19110/// # Example
19111///
19112/// Instantiate a resource method builder
19113///
19114/// ```test_harness,no_run
19115/// # extern crate hyper;
19116/// # extern crate hyper_rustls;
19117/// # extern crate google_retail2 as retail2;
19118/// # async fn dox() {
19119/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19120///
19121/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19122/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19123/// #     .with_native_roots()
19124/// #     .unwrap()
19125/// #     .https_only()
19126/// #     .enable_http2()
19127/// #     .build();
19128///
19129/// # let executor = hyper_util::rt::TokioExecutor::new();
19130/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19131/// #     secret,
19132/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19133/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19134/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19135/// #     ),
19136/// # ).build().await.unwrap();
19137///
19138/// # let client = hyper_util::client::legacy::Client::builder(
19139/// #     hyper_util::rt::TokioExecutor::new()
19140/// # )
19141/// # .build(
19142/// #     hyper_rustls::HttpsConnectorBuilder::new()
19143/// #         .with_native_roots()
19144/// #         .unwrap()
19145/// #         .https_or_http()
19146/// #         .enable_http2()
19147/// #         .build()
19148/// # );
19149/// # let mut hub = CloudRetail::new(client, auth);
19150/// // You can configure optional parameters by calling the respective setters at will, and
19151/// // execute the final call using `doit()`.
19152/// // Values shown here are possibly random and not representative !
19153/// let result = hub.projects().locations_catalogs_serving_configs_delete("name")
19154///              .doit().await;
19155/// # }
19156/// ```
19157pub struct ProjectLocationCatalogServingConfigDeleteCall<'a, C>
19158where
19159    C: 'a,
19160{
19161    hub: &'a CloudRetail<C>,
19162    _name: String,
19163    _delegate: Option<&'a mut dyn common::Delegate>,
19164    _additional_params: HashMap<String, String>,
19165    _scopes: BTreeSet<String>,
19166}
19167
19168impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigDeleteCall<'a, C> {}
19169
19170impl<'a, C> ProjectLocationCatalogServingConfigDeleteCall<'a, C>
19171where
19172    C: common::Connector,
19173{
19174    /// Perform the operation you have build so far.
19175    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
19176        use std::borrow::Cow;
19177        use std::io::{Read, Seek};
19178
19179        use common::{url::Params, ToParts};
19180        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19181
19182        let mut dd = common::DefaultDelegate;
19183        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19184        dlg.begin(common::MethodInfo {
19185            id: "retail.projects.locations.catalogs.servingConfigs.delete",
19186            http_method: hyper::Method::DELETE,
19187        });
19188
19189        for &field in ["alt", "name"].iter() {
19190            if self._additional_params.contains_key(field) {
19191                dlg.finished(false);
19192                return Err(common::Error::FieldClash(field));
19193            }
19194        }
19195
19196        let mut params = Params::with_capacity(3 + self._additional_params.len());
19197        params.push("name", self._name);
19198
19199        params.extend(self._additional_params.iter());
19200
19201        params.push("alt", "json");
19202        let mut url = self.hub._base_url.clone() + "v2/{+name}";
19203        if self._scopes.is_empty() {
19204            self._scopes
19205                .insert(Scope::CloudPlatform.as_ref().to_string());
19206        }
19207
19208        #[allow(clippy::single_element_loop)]
19209        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19210            url = params.uri_replacement(url, param_name, find_this, true);
19211        }
19212        {
19213            let to_remove = ["name"];
19214            params.remove_params(&to_remove);
19215        }
19216
19217        let url = params.parse_with_url(&url);
19218
19219        loop {
19220            let token = match self
19221                .hub
19222                .auth
19223                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19224                .await
19225            {
19226                Ok(token) => token,
19227                Err(e) => match dlg.token(e) {
19228                    Ok(token) => token,
19229                    Err(e) => {
19230                        dlg.finished(false);
19231                        return Err(common::Error::MissingToken(e));
19232                    }
19233                },
19234            };
19235            let mut req_result = {
19236                let client = &self.hub.client;
19237                dlg.pre_request();
19238                let mut req_builder = hyper::Request::builder()
19239                    .method(hyper::Method::DELETE)
19240                    .uri(url.as_str())
19241                    .header(USER_AGENT, self.hub._user_agent.clone());
19242
19243                if let Some(token) = token.as_ref() {
19244                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19245                }
19246
19247                let request = req_builder
19248                    .header(CONTENT_LENGTH, 0_u64)
19249                    .body(common::to_body::<String>(None));
19250
19251                client.request(request.unwrap()).await
19252            };
19253
19254            match req_result {
19255                Err(err) => {
19256                    if let common::Retry::After(d) = dlg.http_error(&err) {
19257                        sleep(d).await;
19258                        continue;
19259                    }
19260                    dlg.finished(false);
19261                    return Err(common::Error::HttpError(err));
19262                }
19263                Ok(res) => {
19264                    let (mut parts, body) = res.into_parts();
19265                    let mut body = common::Body::new(body);
19266                    if !parts.status.is_success() {
19267                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19268                        let error = serde_json::from_str(&common::to_string(&bytes));
19269                        let response = common::to_response(parts, bytes.into());
19270
19271                        if let common::Retry::After(d) =
19272                            dlg.http_failure(&response, error.as_ref().ok())
19273                        {
19274                            sleep(d).await;
19275                            continue;
19276                        }
19277
19278                        dlg.finished(false);
19279
19280                        return Err(match error {
19281                            Ok(value) => common::Error::BadRequest(value),
19282                            _ => common::Error::Failure(response),
19283                        });
19284                    }
19285                    let response = {
19286                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19287                        let encoded = common::to_string(&bytes);
19288                        match serde_json::from_str(&encoded) {
19289                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19290                            Err(error) => {
19291                                dlg.response_json_decode_error(&encoded, &error);
19292                                return Err(common::Error::JsonDecodeError(
19293                                    encoded.to_string(),
19294                                    error,
19295                                ));
19296                            }
19297                        }
19298                    };
19299
19300                    dlg.finished(true);
19301                    return Ok(response);
19302                }
19303            }
19304        }
19305    }
19306
19307    /// Required. The resource name of the ServingConfig to delete. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
19308    ///
19309    /// Sets the *name* path property to the given value.
19310    ///
19311    /// Even though the property as already been set when instantiating this call,
19312    /// we provide this method for API completeness.
19313    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogServingConfigDeleteCall<'a, C> {
19314        self._name = new_value.to_string();
19315        self
19316    }
19317    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19318    /// while executing the actual API request.
19319    ///
19320    /// ````text
19321    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19322    /// ````
19323    ///
19324    /// Sets the *delegate* property to the given value.
19325    pub fn delegate(
19326        mut self,
19327        new_value: &'a mut dyn common::Delegate,
19328    ) -> ProjectLocationCatalogServingConfigDeleteCall<'a, C> {
19329        self._delegate = Some(new_value);
19330        self
19331    }
19332
19333    /// Set any additional parameter of the query string used in the request.
19334    /// It should be used to set parameters which are not yet available through their own
19335    /// setters.
19336    ///
19337    /// Please note that this method must not be used to set any of the known parameters
19338    /// which have their own setter method. If done anyway, the request will fail.
19339    ///
19340    /// # Additional Parameters
19341    ///
19342    /// * *$.xgafv* (query-string) - V1 error format.
19343    /// * *access_token* (query-string) - OAuth access token.
19344    /// * *alt* (query-string) - Data format for response.
19345    /// * *callback* (query-string) - JSONP
19346    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19347    /// * *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.
19348    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19349    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19350    /// * *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.
19351    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19352    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19353    pub fn param<T>(
19354        mut self,
19355        name: T,
19356        value: T,
19357    ) -> ProjectLocationCatalogServingConfigDeleteCall<'a, C>
19358    where
19359        T: AsRef<str>,
19360    {
19361        self._additional_params
19362            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19363        self
19364    }
19365
19366    /// Identifies the authorization scope for the method you are building.
19367    ///
19368    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19369    /// [`Scope::CloudPlatform`].
19370    ///
19371    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19372    /// tokens for more than one scope.
19373    ///
19374    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19375    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19376    /// sufficient, a read-write scope will do as well.
19377    pub fn add_scope<St>(
19378        mut self,
19379        scope: St,
19380    ) -> ProjectLocationCatalogServingConfigDeleteCall<'a, C>
19381    where
19382        St: AsRef<str>,
19383    {
19384        self._scopes.insert(String::from(scope.as_ref()));
19385        self
19386    }
19387    /// Identifies the authorization scope(s) for the method you are building.
19388    ///
19389    /// See [`Self::add_scope()`] for details.
19390    pub fn add_scopes<I, St>(
19391        mut self,
19392        scopes: I,
19393    ) -> ProjectLocationCatalogServingConfigDeleteCall<'a, C>
19394    where
19395        I: IntoIterator<Item = St>,
19396        St: AsRef<str>,
19397    {
19398        self._scopes
19399            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19400        self
19401    }
19402
19403    /// Removes all scopes, and no default scope will be used either.
19404    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19405    /// for details).
19406    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigDeleteCall<'a, C> {
19407        self._scopes.clear();
19408        self
19409    }
19410}
19411
19412/// Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.
19413///
19414/// A builder for the *locations.catalogs.servingConfigs.get* method supported by a *project* resource.
19415/// It is not used directly, but through a [`ProjectMethods`] instance.
19416///
19417/// # Example
19418///
19419/// Instantiate a resource method builder
19420///
19421/// ```test_harness,no_run
19422/// # extern crate hyper;
19423/// # extern crate hyper_rustls;
19424/// # extern crate google_retail2 as retail2;
19425/// # async fn dox() {
19426/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19427///
19428/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19429/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19430/// #     .with_native_roots()
19431/// #     .unwrap()
19432/// #     .https_only()
19433/// #     .enable_http2()
19434/// #     .build();
19435///
19436/// # let executor = hyper_util::rt::TokioExecutor::new();
19437/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19438/// #     secret,
19439/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19440/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19441/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19442/// #     ),
19443/// # ).build().await.unwrap();
19444///
19445/// # let client = hyper_util::client::legacy::Client::builder(
19446/// #     hyper_util::rt::TokioExecutor::new()
19447/// # )
19448/// # .build(
19449/// #     hyper_rustls::HttpsConnectorBuilder::new()
19450/// #         .with_native_roots()
19451/// #         .unwrap()
19452/// #         .https_or_http()
19453/// #         .enable_http2()
19454/// #         .build()
19455/// # );
19456/// # let mut hub = CloudRetail::new(client, auth);
19457/// // You can configure optional parameters by calling the respective setters at will, and
19458/// // execute the final call using `doit()`.
19459/// // Values shown here are possibly random and not representative !
19460/// let result = hub.projects().locations_catalogs_serving_configs_get("name")
19461///              .doit().await;
19462/// # }
19463/// ```
19464pub struct ProjectLocationCatalogServingConfigGetCall<'a, C>
19465where
19466    C: 'a,
19467{
19468    hub: &'a CloudRetail<C>,
19469    _name: String,
19470    _delegate: Option<&'a mut dyn common::Delegate>,
19471    _additional_params: HashMap<String, String>,
19472    _scopes: BTreeSet<String>,
19473}
19474
19475impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigGetCall<'a, C> {}
19476
19477impl<'a, C> ProjectLocationCatalogServingConfigGetCall<'a, C>
19478where
19479    C: common::Connector,
19480{
19481    /// Perform the operation you have build so far.
19482    pub async fn doit(
19483        mut self,
19484    ) -> common::Result<(common::Response, GoogleCloudRetailV2ServingConfig)> {
19485        use std::borrow::Cow;
19486        use std::io::{Read, Seek};
19487
19488        use common::{url::Params, ToParts};
19489        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19490
19491        let mut dd = common::DefaultDelegate;
19492        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19493        dlg.begin(common::MethodInfo {
19494            id: "retail.projects.locations.catalogs.servingConfigs.get",
19495            http_method: hyper::Method::GET,
19496        });
19497
19498        for &field in ["alt", "name"].iter() {
19499            if self._additional_params.contains_key(field) {
19500                dlg.finished(false);
19501                return Err(common::Error::FieldClash(field));
19502            }
19503        }
19504
19505        let mut params = Params::with_capacity(3 + self._additional_params.len());
19506        params.push("name", self._name);
19507
19508        params.extend(self._additional_params.iter());
19509
19510        params.push("alt", "json");
19511        let mut url = self.hub._base_url.clone() + "v2/{+name}";
19512        if self._scopes.is_empty() {
19513            self._scopes
19514                .insert(Scope::CloudPlatform.as_ref().to_string());
19515        }
19516
19517        #[allow(clippy::single_element_loop)]
19518        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19519            url = params.uri_replacement(url, param_name, find_this, true);
19520        }
19521        {
19522            let to_remove = ["name"];
19523            params.remove_params(&to_remove);
19524        }
19525
19526        let url = params.parse_with_url(&url);
19527
19528        loop {
19529            let token = match self
19530                .hub
19531                .auth
19532                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19533                .await
19534            {
19535                Ok(token) => token,
19536                Err(e) => match dlg.token(e) {
19537                    Ok(token) => token,
19538                    Err(e) => {
19539                        dlg.finished(false);
19540                        return Err(common::Error::MissingToken(e));
19541                    }
19542                },
19543            };
19544            let mut req_result = {
19545                let client = &self.hub.client;
19546                dlg.pre_request();
19547                let mut req_builder = hyper::Request::builder()
19548                    .method(hyper::Method::GET)
19549                    .uri(url.as_str())
19550                    .header(USER_AGENT, self.hub._user_agent.clone());
19551
19552                if let Some(token) = token.as_ref() {
19553                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19554                }
19555
19556                let request = req_builder
19557                    .header(CONTENT_LENGTH, 0_u64)
19558                    .body(common::to_body::<String>(None));
19559
19560                client.request(request.unwrap()).await
19561            };
19562
19563            match req_result {
19564                Err(err) => {
19565                    if let common::Retry::After(d) = dlg.http_error(&err) {
19566                        sleep(d).await;
19567                        continue;
19568                    }
19569                    dlg.finished(false);
19570                    return Err(common::Error::HttpError(err));
19571                }
19572                Ok(res) => {
19573                    let (mut parts, body) = res.into_parts();
19574                    let mut body = common::Body::new(body);
19575                    if !parts.status.is_success() {
19576                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19577                        let error = serde_json::from_str(&common::to_string(&bytes));
19578                        let response = common::to_response(parts, bytes.into());
19579
19580                        if let common::Retry::After(d) =
19581                            dlg.http_failure(&response, error.as_ref().ok())
19582                        {
19583                            sleep(d).await;
19584                            continue;
19585                        }
19586
19587                        dlg.finished(false);
19588
19589                        return Err(match error {
19590                            Ok(value) => common::Error::BadRequest(value),
19591                            _ => common::Error::Failure(response),
19592                        });
19593                    }
19594                    let response = {
19595                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19596                        let encoded = common::to_string(&bytes);
19597                        match serde_json::from_str(&encoded) {
19598                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19599                            Err(error) => {
19600                                dlg.response_json_decode_error(&encoded, &error);
19601                                return Err(common::Error::JsonDecodeError(
19602                                    encoded.to_string(),
19603                                    error,
19604                                ));
19605                            }
19606                        }
19607                    };
19608
19609                    dlg.finished(true);
19610                    return Ok(response);
19611                }
19612            }
19613        }
19614    }
19615
19616    /// Required. The resource name of the ServingConfig to get. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
19617    ///
19618    /// Sets the *name* path property to the given value.
19619    ///
19620    /// Even though the property as already been set when instantiating this call,
19621    /// we provide this method for API completeness.
19622    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogServingConfigGetCall<'a, C> {
19623        self._name = new_value.to_string();
19624        self
19625    }
19626    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19627    /// while executing the actual API request.
19628    ///
19629    /// ````text
19630    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19631    /// ````
19632    ///
19633    /// Sets the *delegate* property to the given value.
19634    pub fn delegate(
19635        mut self,
19636        new_value: &'a mut dyn common::Delegate,
19637    ) -> ProjectLocationCatalogServingConfigGetCall<'a, C> {
19638        self._delegate = Some(new_value);
19639        self
19640    }
19641
19642    /// Set any additional parameter of the query string used in the request.
19643    /// It should be used to set parameters which are not yet available through their own
19644    /// setters.
19645    ///
19646    /// Please note that this method must not be used to set any of the known parameters
19647    /// which have their own setter method. If done anyway, the request will fail.
19648    ///
19649    /// # Additional Parameters
19650    ///
19651    /// * *$.xgafv* (query-string) - V1 error format.
19652    /// * *access_token* (query-string) - OAuth access token.
19653    /// * *alt* (query-string) - Data format for response.
19654    /// * *callback* (query-string) - JSONP
19655    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19656    /// * *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.
19657    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19658    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19659    /// * *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.
19660    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19661    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19662    pub fn param<T>(
19663        mut self,
19664        name: T,
19665        value: T,
19666    ) -> ProjectLocationCatalogServingConfigGetCall<'a, C>
19667    where
19668        T: AsRef<str>,
19669    {
19670        self._additional_params
19671            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19672        self
19673    }
19674
19675    /// Identifies the authorization scope for the method you are building.
19676    ///
19677    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19678    /// [`Scope::CloudPlatform`].
19679    ///
19680    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19681    /// tokens for more than one scope.
19682    ///
19683    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19684    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19685    /// sufficient, a read-write scope will do as well.
19686    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogServingConfigGetCall<'a, C>
19687    where
19688        St: AsRef<str>,
19689    {
19690        self._scopes.insert(String::from(scope.as_ref()));
19691        self
19692    }
19693    /// Identifies the authorization scope(s) for the method you are building.
19694    ///
19695    /// See [`Self::add_scope()`] for details.
19696    pub fn add_scopes<I, St>(
19697        mut self,
19698        scopes: I,
19699    ) -> ProjectLocationCatalogServingConfigGetCall<'a, C>
19700    where
19701        I: IntoIterator<Item = St>,
19702        St: AsRef<str>,
19703    {
19704        self._scopes
19705            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19706        self
19707    }
19708
19709    /// Removes all scopes, and no default scope will be used either.
19710    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19711    /// for details).
19712    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigGetCall<'a, C> {
19713        self._scopes.clear();
19714        self
19715    }
19716}
19717
19718/// Lists all ServingConfigs linked to this catalog.
19719///
19720/// A builder for the *locations.catalogs.servingConfigs.list* method supported by a *project* resource.
19721/// It is not used directly, but through a [`ProjectMethods`] instance.
19722///
19723/// # Example
19724///
19725/// Instantiate a resource method builder
19726///
19727/// ```test_harness,no_run
19728/// # extern crate hyper;
19729/// # extern crate hyper_rustls;
19730/// # extern crate google_retail2 as retail2;
19731/// # async fn dox() {
19732/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19733///
19734/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19735/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19736/// #     .with_native_roots()
19737/// #     .unwrap()
19738/// #     .https_only()
19739/// #     .enable_http2()
19740/// #     .build();
19741///
19742/// # let executor = hyper_util::rt::TokioExecutor::new();
19743/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19744/// #     secret,
19745/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19746/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19747/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19748/// #     ),
19749/// # ).build().await.unwrap();
19750///
19751/// # let client = hyper_util::client::legacy::Client::builder(
19752/// #     hyper_util::rt::TokioExecutor::new()
19753/// # )
19754/// # .build(
19755/// #     hyper_rustls::HttpsConnectorBuilder::new()
19756/// #         .with_native_roots()
19757/// #         .unwrap()
19758/// #         .https_or_http()
19759/// #         .enable_http2()
19760/// #         .build()
19761/// # );
19762/// # let mut hub = CloudRetail::new(client, auth);
19763/// // You can configure optional parameters by calling the respective setters at will, and
19764/// // execute the final call using `doit()`.
19765/// // Values shown here are possibly random and not representative !
19766/// let result = hub.projects().locations_catalogs_serving_configs_list("parent")
19767///              .page_token("accusam")
19768///              .page_size(-59)
19769///              .doit().await;
19770/// # }
19771/// ```
19772pub struct ProjectLocationCatalogServingConfigListCall<'a, C>
19773where
19774    C: 'a,
19775{
19776    hub: &'a CloudRetail<C>,
19777    _parent: String,
19778    _page_token: Option<String>,
19779    _page_size: Option<i32>,
19780    _delegate: Option<&'a mut dyn common::Delegate>,
19781    _additional_params: HashMap<String, String>,
19782    _scopes: BTreeSet<String>,
19783}
19784
19785impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigListCall<'a, C> {}
19786
19787impl<'a, C> ProjectLocationCatalogServingConfigListCall<'a, C>
19788where
19789    C: common::Connector,
19790{
19791    /// Perform the operation you have build so far.
19792    pub async fn doit(
19793        mut self,
19794    ) -> common::Result<(
19795        common::Response,
19796        GoogleCloudRetailV2ListServingConfigsResponse,
19797    )> {
19798        use std::borrow::Cow;
19799        use std::io::{Read, Seek};
19800
19801        use common::{url::Params, ToParts};
19802        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19803
19804        let mut dd = common::DefaultDelegate;
19805        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19806        dlg.begin(common::MethodInfo {
19807            id: "retail.projects.locations.catalogs.servingConfigs.list",
19808            http_method: hyper::Method::GET,
19809        });
19810
19811        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
19812            if self._additional_params.contains_key(field) {
19813                dlg.finished(false);
19814                return Err(common::Error::FieldClash(field));
19815            }
19816        }
19817
19818        let mut params = Params::with_capacity(5 + self._additional_params.len());
19819        params.push("parent", self._parent);
19820        if let Some(value) = self._page_token.as_ref() {
19821            params.push("pageToken", value);
19822        }
19823        if let Some(value) = self._page_size.as_ref() {
19824            params.push("pageSize", value.to_string());
19825        }
19826
19827        params.extend(self._additional_params.iter());
19828
19829        params.push("alt", "json");
19830        let mut url = self.hub._base_url.clone() + "v2/{+parent}/servingConfigs";
19831        if self._scopes.is_empty() {
19832            self._scopes
19833                .insert(Scope::CloudPlatform.as_ref().to_string());
19834        }
19835
19836        #[allow(clippy::single_element_loop)]
19837        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19838            url = params.uri_replacement(url, param_name, find_this, true);
19839        }
19840        {
19841            let to_remove = ["parent"];
19842            params.remove_params(&to_remove);
19843        }
19844
19845        let url = params.parse_with_url(&url);
19846
19847        loop {
19848            let token = match self
19849                .hub
19850                .auth
19851                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19852                .await
19853            {
19854                Ok(token) => token,
19855                Err(e) => match dlg.token(e) {
19856                    Ok(token) => token,
19857                    Err(e) => {
19858                        dlg.finished(false);
19859                        return Err(common::Error::MissingToken(e));
19860                    }
19861                },
19862            };
19863            let mut req_result = {
19864                let client = &self.hub.client;
19865                dlg.pre_request();
19866                let mut req_builder = hyper::Request::builder()
19867                    .method(hyper::Method::GET)
19868                    .uri(url.as_str())
19869                    .header(USER_AGENT, self.hub._user_agent.clone());
19870
19871                if let Some(token) = token.as_ref() {
19872                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19873                }
19874
19875                let request = req_builder
19876                    .header(CONTENT_LENGTH, 0_u64)
19877                    .body(common::to_body::<String>(None));
19878
19879                client.request(request.unwrap()).await
19880            };
19881
19882            match req_result {
19883                Err(err) => {
19884                    if let common::Retry::After(d) = dlg.http_error(&err) {
19885                        sleep(d).await;
19886                        continue;
19887                    }
19888                    dlg.finished(false);
19889                    return Err(common::Error::HttpError(err));
19890                }
19891                Ok(res) => {
19892                    let (mut parts, body) = res.into_parts();
19893                    let mut body = common::Body::new(body);
19894                    if !parts.status.is_success() {
19895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19896                        let error = serde_json::from_str(&common::to_string(&bytes));
19897                        let response = common::to_response(parts, bytes.into());
19898
19899                        if let common::Retry::After(d) =
19900                            dlg.http_failure(&response, error.as_ref().ok())
19901                        {
19902                            sleep(d).await;
19903                            continue;
19904                        }
19905
19906                        dlg.finished(false);
19907
19908                        return Err(match error {
19909                            Ok(value) => common::Error::BadRequest(value),
19910                            _ => common::Error::Failure(response),
19911                        });
19912                    }
19913                    let response = {
19914                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19915                        let encoded = common::to_string(&bytes);
19916                        match serde_json::from_str(&encoded) {
19917                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19918                            Err(error) => {
19919                                dlg.response_json_decode_error(&encoded, &error);
19920                                return Err(common::Error::JsonDecodeError(
19921                                    encoded.to_string(),
19922                                    error,
19923                                ));
19924                            }
19925                        }
19926                    };
19927
19928                    dlg.finished(true);
19929                    return Ok(response);
19930                }
19931            }
19932        }
19933    }
19934
19935    /// Required. The catalog resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
19936    ///
19937    /// Sets the *parent* path property to the given value.
19938    ///
19939    /// Even though the property as already been set when instantiating this call,
19940    /// we provide this method for API completeness.
19941    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogServingConfigListCall<'a, C> {
19942        self._parent = new_value.to_string();
19943        self
19944    }
19945    /// Optional. A page token, received from a previous `ListServingConfigs` call. Provide this to retrieve the subsequent page.
19946    ///
19947    /// Sets the *page token* query property to the given value.
19948    pub fn page_token(
19949        mut self,
19950        new_value: &str,
19951    ) -> ProjectLocationCatalogServingConfigListCall<'a, C> {
19952        self._page_token = Some(new_value.to_string());
19953        self
19954    }
19955    /// Optional. Maximum number of results to return. If unspecified, defaults to 100. If a value greater than 100 is provided, at most 100 results are returned.
19956    ///
19957    /// Sets the *page size* query property to the given value.
19958    pub fn page_size(
19959        mut self,
19960        new_value: i32,
19961    ) -> ProjectLocationCatalogServingConfigListCall<'a, C> {
19962        self._page_size = Some(new_value);
19963        self
19964    }
19965    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19966    /// while executing the actual API request.
19967    ///
19968    /// ````text
19969    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19970    /// ````
19971    ///
19972    /// Sets the *delegate* property to the given value.
19973    pub fn delegate(
19974        mut self,
19975        new_value: &'a mut dyn common::Delegate,
19976    ) -> ProjectLocationCatalogServingConfigListCall<'a, C> {
19977        self._delegate = Some(new_value);
19978        self
19979    }
19980
19981    /// Set any additional parameter of the query string used in the request.
19982    /// It should be used to set parameters which are not yet available through their own
19983    /// setters.
19984    ///
19985    /// Please note that this method must not be used to set any of the known parameters
19986    /// which have their own setter method. If done anyway, the request will fail.
19987    ///
19988    /// # Additional Parameters
19989    ///
19990    /// * *$.xgafv* (query-string) - V1 error format.
19991    /// * *access_token* (query-string) - OAuth access token.
19992    /// * *alt* (query-string) - Data format for response.
19993    /// * *callback* (query-string) - JSONP
19994    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19995    /// * *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.
19996    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19997    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19998    /// * *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.
19999    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20000    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20001    pub fn param<T>(
20002        mut self,
20003        name: T,
20004        value: T,
20005    ) -> ProjectLocationCatalogServingConfigListCall<'a, C>
20006    where
20007        T: AsRef<str>,
20008    {
20009        self._additional_params
20010            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20011        self
20012    }
20013
20014    /// Identifies the authorization scope for the method you are building.
20015    ///
20016    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20017    /// [`Scope::CloudPlatform`].
20018    ///
20019    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20020    /// tokens for more than one scope.
20021    ///
20022    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20023    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20024    /// sufficient, a read-write scope will do as well.
20025    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogServingConfigListCall<'a, C>
20026    where
20027        St: AsRef<str>,
20028    {
20029        self._scopes.insert(String::from(scope.as_ref()));
20030        self
20031    }
20032    /// Identifies the authorization scope(s) for the method you are building.
20033    ///
20034    /// See [`Self::add_scope()`] for details.
20035    pub fn add_scopes<I, St>(
20036        mut self,
20037        scopes: I,
20038    ) -> ProjectLocationCatalogServingConfigListCall<'a, C>
20039    where
20040        I: IntoIterator<Item = St>,
20041        St: AsRef<str>,
20042    {
20043        self._scopes
20044            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20045        self
20046    }
20047
20048    /// Removes all scopes, and no default scope will be used either.
20049    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20050    /// for details).
20051    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigListCall<'a, C> {
20052        self._scopes.clear();
20053        self
20054    }
20055}
20056
20057/// Updates a ServingConfig.
20058///
20059/// A builder for the *locations.catalogs.servingConfigs.patch* method supported by a *project* resource.
20060/// It is not used directly, but through a [`ProjectMethods`] instance.
20061///
20062/// # Example
20063///
20064/// Instantiate a resource method builder
20065///
20066/// ```test_harness,no_run
20067/// # extern crate hyper;
20068/// # extern crate hyper_rustls;
20069/// # extern crate google_retail2 as retail2;
20070/// use retail2::api::GoogleCloudRetailV2ServingConfig;
20071/// # async fn dox() {
20072/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20073///
20074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20075/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20076/// #     .with_native_roots()
20077/// #     .unwrap()
20078/// #     .https_only()
20079/// #     .enable_http2()
20080/// #     .build();
20081///
20082/// # let executor = hyper_util::rt::TokioExecutor::new();
20083/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20084/// #     secret,
20085/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20086/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20087/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20088/// #     ),
20089/// # ).build().await.unwrap();
20090///
20091/// # let client = hyper_util::client::legacy::Client::builder(
20092/// #     hyper_util::rt::TokioExecutor::new()
20093/// # )
20094/// # .build(
20095/// #     hyper_rustls::HttpsConnectorBuilder::new()
20096/// #         .with_native_roots()
20097/// #         .unwrap()
20098/// #         .https_or_http()
20099/// #         .enable_http2()
20100/// #         .build()
20101/// # );
20102/// # let mut hub = CloudRetail::new(client, auth);
20103/// // As the method needs a request, you would usually fill it with the desired information
20104/// // into the respective structure. Some of the parts shown here might not be applicable !
20105/// // Values shown here are possibly random and not representative !
20106/// let mut req = GoogleCloudRetailV2ServingConfig::default();
20107///
20108/// // You can configure optional parameters by calling the respective setters at will, and
20109/// // execute the final call using `doit()`.
20110/// // Values shown here are possibly random and not representative !
20111/// let result = hub.projects().locations_catalogs_serving_configs_patch(req, "name")
20112///              .update_mask(FieldMask::new::<&str>(&[]))
20113///              .doit().await;
20114/// # }
20115/// ```
20116pub struct ProjectLocationCatalogServingConfigPatchCall<'a, C>
20117where
20118    C: 'a,
20119{
20120    hub: &'a CloudRetail<C>,
20121    _request: GoogleCloudRetailV2ServingConfig,
20122    _name: String,
20123    _update_mask: Option<common::FieldMask>,
20124    _delegate: Option<&'a mut dyn common::Delegate>,
20125    _additional_params: HashMap<String, String>,
20126    _scopes: BTreeSet<String>,
20127}
20128
20129impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigPatchCall<'a, C> {}
20130
20131impl<'a, C> ProjectLocationCatalogServingConfigPatchCall<'a, C>
20132where
20133    C: common::Connector,
20134{
20135    /// Perform the operation you have build so far.
20136    pub async fn doit(
20137        mut self,
20138    ) -> common::Result<(common::Response, GoogleCloudRetailV2ServingConfig)> {
20139        use std::borrow::Cow;
20140        use std::io::{Read, Seek};
20141
20142        use common::{url::Params, ToParts};
20143        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20144
20145        let mut dd = common::DefaultDelegate;
20146        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20147        dlg.begin(common::MethodInfo {
20148            id: "retail.projects.locations.catalogs.servingConfigs.patch",
20149            http_method: hyper::Method::PATCH,
20150        });
20151
20152        for &field in ["alt", "name", "updateMask"].iter() {
20153            if self._additional_params.contains_key(field) {
20154                dlg.finished(false);
20155                return Err(common::Error::FieldClash(field));
20156            }
20157        }
20158
20159        let mut params = Params::with_capacity(5 + self._additional_params.len());
20160        params.push("name", self._name);
20161        if let Some(value) = self._update_mask.as_ref() {
20162            params.push("updateMask", value.to_string());
20163        }
20164
20165        params.extend(self._additional_params.iter());
20166
20167        params.push("alt", "json");
20168        let mut url = self.hub._base_url.clone() + "v2/{+name}";
20169        if self._scopes.is_empty() {
20170            self._scopes
20171                .insert(Scope::CloudPlatform.as_ref().to_string());
20172        }
20173
20174        #[allow(clippy::single_element_loop)]
20175        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20176            url = params.uri_replacement(url, param_name, find_this, true);
20177        }
20178        {
20179            let to_remove = ["name"];
20180            params.remove_params(&to_remove);
20181        }
20182
20183        let url = params.parse_with_url(&url);
20184
20185        let mut json_mime_type = mime::APPLICATION_JSON;
20186        let mut request_value_reader = {
20187            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20188            common::remove_json_null_values(&mut value);
20189            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20190            serde_json::to_writer(&mut dst, &value).unwrap();
20191            dst
20192        };
20193        let request_size = request_value_reader
20194            .seek(std::io::SeekFrom::End(0))
20195            .unwrap();
20196        request_value_reader
20197            .seek(std::io::SeekFrom::Start(0))
20198            .unwrap();
20199
20200        loop {
20201            let token = match self
20202                .hub
20203                .auth
20204                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20205                .await
20206            {
20207                Ok(token) => token,
20208                Err(e) => match dlg.token(e) {
20209                    Ok(token) => token,
20210                    Err(e) => {
20211                        dlg.finished(false);
20212                        return Err(common::Error::MissingToken(e));
20213                    }
20214                },
20215            };
20216            request_value_reader
20217                .seek(std::io::SeekFrom::Start(0))
20218                .unwrap();
20219            let mut req_result = {
20220                let client = &self.hub.client;
20221                dlg.pre_request();
20222                let mut req_builder = hyper::Request::builder()
20223                    .method(hyper::Method::PATCH)
20224                    .uri(url.as_str())
20225                    .header(USER_AGENT, self.hub._user_agent.clone());
20226
20227                if let Some(token) = token.as_ref() {
20228                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20229                }
20230
20231                let request = req_builder
20232                    .header(CONTENT_TYPE, json_mime_type.to_string())
20233                    .header(CONTENT_LENGTH, request_size as u64)
20234                    .body(common::to_body(
20235                        request_value_reader.get_ref().clone().into(),
20236                    ));
20237
20238                client.request(request.unwrap()).await
20239            };
20240
20241            match req_result {
20242                Err(err) => {
20243                    if let common::Retry::After(d) = dlg.http_error(&err) {
20244                        sleep(d).await;
20245                        continue;
20246                    }
20247                    dlg.finished(false);
20248                    return Err(common::Error::HttpError(err));
20249                }
20250                Ok(res) => {
20251                    let (mut parts, body) = res.into_parts();
20252                    let mut body = common::Body::new(body);
20253                    if !parts.status.is_success() {
20254                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20255                        let error = serde_json::from_str(&common::to_string(&bytes));
20256                        let response = common::to_response(parts, bytes.into());
20257
20258                        if let common::Retry::After(d) =
20259                            dlg.http_failure(&response, error.as_ref().ok())
20260                        {
20261                            sleep(d).await;
20262                            continue;
20263                        }
20264
20265                        dlg.finished(false);
20266
20267                        return Err(match error {
20268                            Ok(value) => common::Error::BadRequest(value),
20269                            _ => common::Error::Failure(response),
20270                        });
20271                    }
20272                    let response = {
20273                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20274                        let encoded = common::to_string(&bytes);
20275                        match serde_json::from_str(&encoded) {
20276                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20277                            Err(error) => {
20278                                dlg.response_json_decode_error(&encoded, &error);
20279                                return Err(common::Error::JsonDecodeError(
20280                                    encoded.to_string(),
20281                                    error,
20282                                ));
20283                            }
20284                        }
20285                    };
20286
20287                    dlg.finished(true);
20288                    return Ok(response);
20289                }
20290            }
20291        }
20292    }
20293
20294    ///
20295    /// Sets the *request* property to the given value.
20296    ///
20297    /// Even though the property as already been set when instantiating this call,
20298    /// we provide this method for API completeness.
20299    pub fn request(
20300        mut self,
20301        new_value: GoogleCloudRetailV2ServingConfig,
20302    ) -> ProjectLocationCatalogServingConfigPatchCall<'a, C> {
20303        self._request = new_value;
20304        self
20305    }
20306    /// Immutable. Fully qualified name `projects/*/locations/global/catalogs/*/servingConfig/*`
20307    ///
20308    /// Sets the *name* path property to the given value.
20309    ///
20310    /// Even though the property as already been set when instantiating this call,
20311    /// we provide this method for API completeness.
20312    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogServingConfigPatchCall<'a, C> {
20313        self._name = new_value.to_string();
20314        self
20315    }
20316    /// Indicates which fields in the provided ServingConfig to update. The following are NOT supported: * ServingConfig.name If not set, all supported fields are updated.
20317    ///
20318    /// Sets the *update mask* query property to the given value.
20319    pub fn update_mask(
20320        mut self,
20321        new_value: common::FieldMask,
20322    ) -> ProjectLocationCatalogServingConfigPatchCall<'a, C> {
20323        self._update_mask = Some(new_value);
20324        self
20325    }
20326    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20327    /// while executing the actual API request.
20328    ///
20329    /// ````text
20330    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20331    /// ````
20332    ///
20333    /// Sets the *delegate* property to the given value.
20334    pub fn delegate(
20335        mut self,
20336        new_value: &'a mut dyn common::Delegate,
20337    ) -> ProjectLocationCatalogServingConfigPatchCall<'a, C> {
20338        self._delegate = Some(new_value);
20339        self
20340    }
20341
20342    /// Set any additional parameter of the query string used in the request.
20343    /// It should be used to set parameters which are not yet available through their own
20344    /// setters.
20345    ///
20346    /// Please note that this method must not be used to set any of the known parameters
20347    /// which have their own setter method. If done anyway, the request will fail.
20348    ///
20349    /// # Additional Parameters
20350    ///
20351    /// * *$.xgafv* (query-string) - V1 error format.
20352    /// * *access_token* (query-string) - OAuth access token.
20353    /// * *alt* (query-string) - Data format for response.
20354    /// * *callback* (query-string) - JSONP
20355    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20356    /// * *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.
20357    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20358    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20359    /// * *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.
20360    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20361    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20362    pub fn param<T>(
20363        mut self,
20364        name: T,
20365        value: T,
20366    ) -> ProjectLocationCatalogServingConfigPatchCall<'a, C>
20367    where
20368        T: AsRef<str>,
20369    {
20370        self._additional_params
20371            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20372        self
20373    }
20374
20375    /// Identifies the authorization scope for the method you are building.
20376    ///
20377    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20378    /// [`Scope::CloudPlatform`].
20379    ///
20380    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20381    /// tokens for more than one scope.
20382    ///
20383    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20384    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20385    /// sufficient, a read-write scope will do as well.
20386    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogServingConfigPatchCall<'a, C>
20387    where
20388        St: AsRef<str>,
20389    {
20390        self._scopes.insert(String::from(scope.as_ref()));
20391        self
20392    }
20393    /// Identifies the authorization scope(s) for the method you are building.
20394    ///
20395    /// See [`Self::add_scope()`] for details.
20396    pub fn add_scopes<I, St>(
20397        mut self,
20398        scopes: I,
20399    ) -> ProjectLocationCatalogServingConfigPatchCall<'a, C>
20400    where
20401        I: IntoIterator<Item = St>,
20402        St: AsRef<str>,
20403    {
20404        self._scopes
20405            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20406        self
20407    }
20408
20409    /// Removes all scopes, and no default scope will be used either.
20410    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20411    /// for details).
20412    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigPatchCall<'a, C> {
20413        self._scopes.clear();
20414        self
20415    }
20416}
20417
20418/// Makes a recommendation prediction.
20419///
20420/// A builder for the *locations.catalogs.servingConfigs.predict* method supported by a *project* resource.
20421/// It is not used directly, but through a [`ProjectMethods`] instance.
20422///
20423/// # Example
20424///
20425/// Instantiate a resource method builder
20426///
20427/// ```test_harness,no_run
20428/// # extern crate hyper;
20429/// # extern crate hyper_rustls;
20430/// # extern crate google_retail2 as retail2;
20431/// use retail2::api::GoogleCloudRetailV2PredictRequest;
20432/// # async fn dox() {
20433/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20434///
20435/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20436/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20437/// #     .with_native_roots()
20438/// #     .unwrap()
20439/// #     .https_only()
20440/// #     .enable_http2()
20441/// #     .build();
20442///
20443/// # let executor = hyper_util::rt::TokioExecutor::new();
20444/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20445/// #     secret,
20446/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20447/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20448/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20449/// #     ),
20450/// # ).build().await.unwrap();
20451///
20452/// # let client = hyper_util::client::legacy::Client::builder(
20453/// #     hyper_util::rt::TokioExecutor::new()
20454/// # )
20455/// # .build(
20456/// #     hyper_rustls::HttpsConnectorBuilder::new()
20457/// #         .with_native_roots()
20458/// #         .unwrap()
20459/// #         .https_or_http()
20460/// #         .enable_http2()
20461/// #         .build()
20462/// # );
20463/// # let mut hub = CloudRetail::new(client, auth);
20464/// // As the method needs a request, you would usually fill it with the desired information
20465/// // into the respective structure. Some of the parts shown here might not be applicable !
20466/// // Values shown here are possibly random and not representative !
20467/// let mut req = GoogleCloudRetailV2PredictRequest::default();
20468///
20469/// // You can configure optional parameters by calling the respective setters at will, and
20470/// // execute the final call using `doit()`.
20471/// // Values shown here are possibly random and not representative !
20472/// let result = hub.projects().locations_catalogs_serving_configs_predict(req, "placement")
20473///              .doit().await;
20474/// # }
20475/// ```
20476pub struct ProjectLocationCatalogServingConfigPredictCall<'a, C>
20477where
20478    C: 'a,
20479{
20480    hub: &'a CloudRetail<C>,
20481    _request: GoogleCloudRetailV2PredictRequest,
20482    _placement: String,
20483    _delegate: Option<&'a mut dyn common::Delegate>,
20484    _additional_params: HashMap<String, String>,
20485    _scopes: BTreeSet<String>,
20486}
20487
20488impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigPredictCall<'a, C> {}
20489
20490impl<'a, C> ProjectLocationCatalogServingConfigPredictCall<'a, C>
20491where
20492    C: common::Connector,
20493{
20494    /// Perform the operation you have build so far.
20495    pub async fn doit(
20496        mut self,
20497    ) -> common::Result<(common::Response, GoogleCloudRetailV2PredictResponse)> {
20498        use std::borrow::Cow;
20499        use std::io::{Read, Seek};
20500
20501        use common::{url::Params, ToParts};
20502        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20503
20504        let mut dd = common::DefaultDelegate;
20505        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20506        dlg.begin(common::MethodInfo {
20507            id: "retail.projects.locations.catalogs.servingConfigs.predict",
20508            http_method: hyper::Method::POST,
20509        });
20510
20511        for &field in ["alt", "placement"].iter() {
20512            if self._additional_params.contains_key(field) {
20513                dlg.finished(false);
20514                return Err(common::Error::FieldClash(field));
20515            }
20516        }
20517
20518        let mut params = Params::with_capacity(4 + self._additional_params.len());
20519        params.push("placement", self._placement);
20520
20521        params.extend(self._additional_params.iter());
20522
20523        params.push("alt", "json");
20524        let mut url = self.hub._base_url.clone() + "v2/{+placement}:predict";
20525        if self._scopes.is_empty() {
20526            self._scopes
20527                .insert(Scope::CloudPlatform.as_ref().to_string());
20528        }
20529
20530        #[allow(clippy::single_element_loop)]
20531        for &(find_this, param_name) in [("{+placement}", "placement")].iter() {
20532            url = params.uri_replacement(url, param_name, find_this, true);
20533        }
20534        {
20535            let to_remove = ["placement"];
20536            params.remove_params(&to_remove);
20537        }
20538
20539        let url = params.parse_with_url(&url);
20540
20541        let mut json_mime_type = mime::APPLICATION_JSON;
20542        let mut request_value_reader = {
20543            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20544            common::remove_json_null_values(&mut value);
20545            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20546            serde_json::to_writer(&mut dst, &value).unwrap();
20547            dst
20548        };
20549        let request_size = request_value_reader
20550            .seek(std::io::SeekFrom::End(0))
20551            .unwrap();
20552        request_value_reader
20553            .seek(std::io::SeekFrom::Start(0))
20554            .unwrap();
20555
20556        loop {
20557            let token = match self
20558                .hub
20559                .auth
20560                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20561                .await
20562            {
20563                Ok(token) => token,
20564                Err(e) => match dlg.token(e) {
20565                    Ok(token) => token,
20566                    Err(e) => {
20567                        dlg.finished(false);
20568                        return Err(common::Error::MissingToken(e));
20569                    }
20570                },
20571            };
20572            request_value_reader
20573                .seek(std::io::SeekFrom::Start(0))
20574                .unwrap();
20575            let mut req_result = {
20576                let client = &self.hub.client;
20577                dlg.pre_request();
20578                let mut req_builder = hyper::Request::builder()
20579                    .method(hyper::Method::POST)
20580                    .uri(url.as_str())
20581                    .header(USER_AGENT, self.hub._user_agent.clone());
20582
20583                if let Some(token) = token.as_ref() {
20584                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20585                }
20586
20587                let request = req_builder
20588                    .header(CONTENT_TYPE, json_mime_type.to_string())
20589                    .header(CONTENT_LENGTH, request_size as u64)
20590                    .body(common::to_body(
20591                        request_value_reader.get_ref().clone().into(),
20592                    ));
20593
20594                client.request(request.unwrap()).await
20595            };
20596
20597            match req_result {
20598                Err(err) => {
20599                    if let common::Retry::After(d) = dlg.http_error(&err) {
20600                        sleep(d).await;
20601                        continue;
20602                    }
20603                    dlg.finished(false);
20604                    return Err(common::Error::HttpError(err));
20605                }
20606                Ok(res) => {
20607                    let (mut parts, body) = res.into_parts();
20608                    let mut body = common::Body::new(body);
20609                    if !parts.status.is_success() {
20610                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20611                        let error = serde_json::from_str(&common::to_string(&bytes));
20612                        let response = common::to_response(parts, bytes.into());
20613
20614                        if let common::Retry::After(d) =
20615                            dlg.http_failure(&response, error.as_ref().ok())
20616                        {
20617                            sleep(d).await;
20618                            continue;
20619                        }
20620
20621                        dlg.finished(false);
20622
20623                        return Err(match error {
20624                            Ok(value) => common::Error::BadRequest(value),
20625                            _ => common::Error::Failure(response),
20626                        });
20627                    }
20628                    let response = {
20629                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20630                        let encoded = common::to_string(&bytes);
20631                        match serde_json::from_str(&encoded) {
20632                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20633                            Err(error) => {
20634                                dlg.response_json_decode_error(&encoded, &error);
20635                                return Err(common::Error::JsonDecodeError(
20636                                    encoded.to_string(),
20637                                    error,
20638                                ));
20639                            }
20640                        }
20641                    };
20642
20643                    dlg.finished(true);
20644                    return Ok(response);
20645                }
20646            }
20647        }
20648    }
20649
20650    ///
20651    /// Sets the *request* property to the given value.
20652    ///
20653    /// Even though the property as already been set when instantiating this call,
20654    /// we provide this method for API completeness.
20655    pub fn request(
20656        mut self,
20657        new_value: GoogleCloudRetailV2PredictRequest,
20658    ) -> ProjectLocationCatalogServingConfigPredictCall<'a, C> {
20659        self._request = new_value;
20660        self
20661    }
20662    /// Required. Full resource name of the format: `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` or `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. We recommend using the `servingConfigs` resource. `placements` is a legacy resource. The ID of the Recommendations AI serving config or placement. Before you can request predictions from your model, you must create at least one serving config or placement for it. For more information, see [Manage serving configs] (https://cloud.google.com/retail/docs/manage-configs). The full list of available serving configs can be seen at https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs
20663    ///
20664    /// Sets the *placement* path property to the given value.
20665    ///
20666    /// Even though the property as already been set when instantiating this call,
20667    /// we provide this method for API completeness.
20668    pub fn placement(
20669        mut self,
20670        new_value: &str,
20671    ) -> ProjectLocationCatalogServingConfigPredictCall<'a, C> {
20672        self._placement = new_value.to_string();
20673        self
20674    }
20675    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20676    /// while executing the actual API request.
20677    ///
20678    /// ````text
20679    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20680    /// ````
20681    ///
20682    /// Sets the *delegate* property to the given value.
20683    pub fn delegate(
20684        mut self,
20685        new_value: &'a mut dyn common::Delegate,
20686    ) -> ProjectLocationCatalogServingConfigPredictCall<'a, C> {
20687        self._delegate = Some(new_value);
20688        self
20689    }
20690
20691    /// Set any additional parameter of the query string used in the request.
20692    /// It should be used to set parameters which are not yet available through their own
20693    /// setters.
20694    ///
20695    /// Please note that this method must not be used to set any of the known parameters
20696    /// which have their own setter method. If done anyway, the request will fail.
20697    ///
20698    /// # Additional Parameters
20699    ///
20700    /// * *$.xgafv* (query-string) - V1 error format.
20701    /// * *access_token* (query-string) - OAuth access token.
20702    /// * *alt* (query-string) - Data format for response.
20703    /// * *callback* (query-string) - JSONP
20704    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20705    /// * *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.
20706    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20707    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20708    /// * *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.
20709    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20710    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20711    pub fn param<T>(
20712        mut self,
20713        name: T,
20714        value: T,
20715    ) -> ProjectLocationCatalogServingConfigPredictCall<'a, C>
20716    where
20717        T: AsRef<str>,
20718    {
20719        self._additional_params
20720            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20721        self
20722    }
20723
20724    /// Identifies the authorization scope for the method you are building.
20725    ///
20726    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20727    /// [`Scope::CloudPlatform`].
20728    ///
20729    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20730    /// tokens for more than one scope.
20731    ///
20732    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20733    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20734    /// sufficient, a read-write scope will do as well.
20735    pub fn add_scope<St>(
20736        mut self,
20737        scope: St,
20738    ) -> ProjectLocationCatalogServingConfigPredictCall<'a, C>
20739    where
20740        St: AsRef<str>,
20741    {
20742        self._scopes.insert(String::from(scope.as_ref()));
20743        self
20744    }
20745    /// Identifies the authorization scope(s) for the method you are building.
20746    ///
20747    /// See [`Self::add_scope()`] for details.
20748    pub fn add_scopes<I, St>(
20749        mut self,
20750        scopes: I,
20751    ) -> ProjectLocationCatalogServingConfigPredictCall<'a, C>
20752    where
20753        I: IntoIterator<Item = St>,
20754        St: AsRef<str>,
20755    {
20756        self._scopes
20757            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20758        self
20759    }
20760
20761    /// Removes all scopes, and no default scope will be used either.
20762    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20763    /// for details).
20764    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigPredictCall<'a, C> {
20765        self._scopes.clear();
20766        self
20767    }
20768}
20769
20770/// Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.
20771///
20772/// A builder for the *locations.catalogs.servingConfigs.removeControl* method supported by a *project* resource.
20773/// It is not used directly, but through a [`ProjectMethods`] instance.
20774///
20775/// # Example
20776///
20777/// Instantiate a resource method builder
20778///
20779/// ```test_harness,no_run
20780/// # extern crate hyper;
20781/// # extern crate hyper_rustls;
20782/// # extern crate google_retail2 as retail2;
20783/// use retail2::api::GoogleCloudRetailV2RemoveControlRequest;
20784/// # async fn dox() {
20785/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20786///
20787/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20788/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20789/// #     .with_native_roots()
20790/// #     .unwrap()
20791/// #     .https_only()
20792/// #     .enable_http2()
20793/// #     .build();
20794///
20795/// # let executor = hyper_util::rt::TokioExecutor::new();
20796/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20797/// #     secret,
20798/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20799/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20800/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20801/// #     ),
20802/// # ).build().await.unwrap();
20803///
20804/// # let client = hyper_util::client::legacy::Client::builder(
20805/// #     hyper_util::rt::TokioExecutor::new()
20806/// # )
20807/// # .build(
20808/// #     hyper_rustls::HttpsConnectorBuilder::new()
20809/// #         .with_native_roots()
20810/// #         .unwrap()
20811/// #         .https_or_http()
20812/// #         .enable_http2()
20813/// #         .build()
20814/// # );
20815/// # let mut hub = CloudRetail::new(client, auth);
20816/// // As the method needs a request, you would usually fill it with the desired information
20817/// // into the respective structure. Some of the parts shown here might not be applicable !
20818/// // Values shown here are possibly random and not representative !
20819/// let mut req = GoogleCloudRetailV2RemoveControlRequest::default();
20820///
20821/// // You can configure optional parameters by calling the respective setters at will, and
20822/// // execute the final call using `doit()`.
20823/// // Values shown here are possibly random and not representative !
20824/// let result = hub.projects().locations_catalogs_serving_configs_remove_control(req, "servingConfig")
20825///              .doit().await;
20826/// # }
20827/// ```
20828pub struct ProjectLocationCatalogServingConfigRemoveControlCall<'a, C>
20829where
20830    C: 'a,
20831{
20832    hub: &'a CloudRetail<C>,
20833    _request: GoogleCloudRetailV2RemoveControlRequest,
20834    _serving_config: String,
20835    _delegate: Option<&'a mut dyn common::Delegate>,
20836    _additional_params: HashMap<String, String>,
20837    _scopes: BTreeSet<String>,
20838}
20839
20840impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigRemoveControlCall<'a, C> {}
20841
20842impl<'a, C> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C>
20843where
20844    C: common::Connector,
20845{
20846    /// Perform the operation you have build so far.
20847    pub async fn doit(
20848        mut self,
20849    ) -> common::Result<(common::Response, GoogleCloudRetailV2ServingConfig)> {
20850        use std::borrow::Cow;
20851        use std::io::{Read, Seek};
20852
20853        use common::{url::Params, ToParts};
20854        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20855
20856        let mut dd = common::DefaultDelegate;
20857        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20858        dlg.begin(common::MethodInfo {
20859            id: "retail.projects.locations.catalogs.servingConfigs.removeControl",
20860            http_method: hyper::Method::POST,
20861        });
20862
20863        for &field in ["alt", "servingConfig"].iter() {
20864            if self._additional_params.contains_key(field) {
20865                dlg.finished(false);
20866                return Err(common::Error::FieldClash(field));
20867            }
20868        }
20869
20870        let mut params = Params::with_capacity(4 + self._additional_params.len());
20871        params.push("servingConfig", self._serving_config);
20872
20873        params.extend(self._additional_params.iter());
20874
20875        params.push("alt", "json");
20876        let mut url = self.hub._base_url.clone() + "v2/{+servingConfig}:removeControl";
20877        if self._scopes.is_empty() {
20878            self._scopes
20879                .insert(Scope::CloudPlatform.as_ref().to_string());
20880        }
20881
20882        #[allow(clippy::single_element_loop)]
20883        for &(find_this, param_name) in [("{+servingConfig}", "servingConfig")].iter() {
20884            url = params.uri_replacement(url, param_name, find_this, true);
20885        }
20886        {
20887            let to_remove = ["servingConfig"];
20888            params.remove_params(&to_remove);
20889        }
20890
20891        let url = params.parse_with_url(&url);
20892
20893        let mut json_mime_type = mime::APPLICATION_JSON;
20894        let mut request_value_reader = {
20895            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20896            common::remove_json_null_values(&mut value);
20897            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20898            serde_json::to_writer(&mut dst, &value).unwrap();
20899            dst
20900        };
20901        let request_size = request_value_reader
20902            .seek(std::io::SeekFrom::End(0))
20903            .unwrap();
20904        request_value_reader
20905            .seek(std::io::SeekFrom::Start(0))
20906            .unwrap();
20907
20908        loop {
20909            let token = match self
20910                .hub
20911                .auth
20912                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20913                .await
20914            {
20915                Ok(token) => token,
20916                Err(e) => match dlg.token(e) {
20917                    Ok(token) => token,
20918                    Err(e) => {
20919                        dlg.finished(false);
20920                        return Err(common::Error::MissingToken(e));
20921                    }
20922                },
20923            };
20924            request_value_reader
20925                .seek(std::io::SeekFrom::Start(0))
20926                .unwrap();
20927            let mut req_result = {
20928                let client = &self.hub.client;
20929                dlg.pre_request();
20930                let mut req_builder = hyper::Request::builder()
20931                    .method(hyper::Method::POST)
20932                    .uri(url.as_str())
20933                    .header(USER_AGENT, self.hub._user_agent.clone());
20934
20935                if let Some(token) = token.as_ref() {
20936                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20937                }
20938
20939                let request = req_builder
20940                    .header(CONTENT_TYPE, json_mime_type.to_string())
20941                    .header(CONTENT_LENGTH, request_size as u64)
20942                    .body(common::to_body(
20943                        request_value_reader.get_ref().clone().into(),
20944                    ));
20945
20946                client.request(request.unwrap()).await
20947            };
20948
20949            match req_result {
20950                Err(err) => {
20951                    if let common::Retry::After(d) = dlg.http_error(&err) {
20952                        sleep(d).await;
20953                        continue;
20954                    }
20955                    dlg.finished(false);
20956                    return Err(common::Error::HttpError(err));
20957                }
20958                Ok(res) => {
20959                    let (mut parts, body) = res.into_parts();
20960                    let mut body = common::Body::new(body);
20961                    if !parts.status.is_success() {
20962                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20963                        let error = serde_json::from_str(&common::to_string(&bytes));
20964                        let response = common::to_response(parts, bytes.into());
20965
20966                        if let common::Retry::After(d) =
20967                            dlg.http_failure(&response, error.as_ref().ok())
20968                        {
20969                            sleep(d).await;
20970                            continue;
20971                        }
20972
20973                        dlg.finished(false);
20974
20975                        return Err(match error {
20976                            Ok(value) => common::Error::BadRequest(value),
20977                            _ => common::Error::Failure(response),
20978                        });
20979                    }
20980                    let response = {
20981                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20982                        let encoded = common::to_string(&bytes);
20983                        match serde_json::from_str(&encoded) {
20984                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20985                            Err(error) => {
20986                                dlg.response_json_decode_error(&encoded, &error);
20987                                return Err(common::Error::JsonDecodeError(
20988                                    encoded.to_string(),
20989                                    error,
20990                                ));
20991                            }
20992                        }
20993                    };
20994
20995                    dlg.finished(true);
20996                    return Ok(response);
20997                }
20998            }
20999        }
21000    }
21001
21002    ///
21003    /// Sets the *request* property to the given value.
21004    ///
21005    /// Even though the property as already been set when instantiating this call,
21006    /// we provide this method for API completeness.
21007    pub fn request(
21008        mut self,
21009        new_value: GoogleCloudRetailV2RemoveControlRequest,
21010    ) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C> {
21011        self._request = new_value;
21012        self
21013    }
21014    /// Required. The source ServingConfig resource name . Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
21015    ///
21016    /// Sets the *serving config* path property to the given value.
21017    ///
21018    /// Even though the property as already been set when instantiating this call,
21019    /// we provide this method for API completeness.
21020    pub fn serving_config(
21021        mut self,
21022        new_value: &str,
21023    ) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C> {
21024        self._serving_config = new_value.to_string();
21025        self
21026    }
21027    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21028    /// while executing the actual API request.
21029    ///
21030    /// ````text
21031    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21032    /// ````
21033    ///
21034    /// Sets the *delegate* property to the given value.
21035    pub fn delegate(
21036        mut self,
21037        new_value: &'a mut dyn common::Delegate,
21038    ) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C> {
21039        self._delegate = Some(new_value);
21040        self
21041    }
21042
21043    /// Set any additional parameter of the query string used in the request.
21044    /// It should be used to set parameters which are not yet available through their own
21045    /// setters.
21046    ///
21047    /// Please note that this method must not be used to set any of the known parameters
21048    /// which have their own setter method. If done anyway, the request will fail.
21049    ///
21050    /// # Additional Parameters
21051    ///
21052    /// * *$.xgafv* (query-string) - V1 error format.
21053    /// * *access_token* (query-string) - OAuth access token.
21054    /// * *alt* (query-string) - Data format for response.
21055    /// * *callback* (query-string) - JSONP
21056    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21057    /// * *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.
21058    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21059    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21060    /// * *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.
21061    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21062    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21063    pub fn param<T>(
21064        mut self,
21065        name: T,
21066        value: T,
21067    ) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C>
21068    where
21069        T: AsRef<str>,
21070    {
21071        self._additional_params
21072            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21073        self
21074    }
21075
21076    /// Identifies the authorization scope for the method you are building.
21077    ///
21078    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21079    /// [`Scope::CloudPlatform`].
21080    ///
21081    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21082    /// tokens for more than one scope.
21083    ///
21084    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21085    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21086    /// sufficient, a read-write scope will do as well.
21087    pub fn add_scope<St>(
21088        mut self,
21089        scope: St,
21090    ) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C>
21091    where
21092        St: AsRef<str>,
21093    {
21094        self._scopes.insert(String::from(scope.as_ref()));
21095        self
21096    }
21097    /// Identifies the authorization scope(s) for the method you are building.
21098    ///
21099    /// See [`Self::add_scope()`] for details.
21100    pub fn add_scopes<I, St>(
21101        mut self,
21102        scopes: I,
21103    ) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C>
21104    where
21105        I: IntoIterator<Item = St>,
21106        St: AsRef<str>,
21107    {
21108        self._scopes
21109            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21110        self
21111    }
21112
21113    /// Removes all scopes, and no default scope will be used either.
21114    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21115    /// for details).
21116    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigRemoveControlCall<'a, C> {
21117        self._scopes.clear();
21118        self
21119    }
21120}
21121
21122/// Performs a search. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
21123///
21124/// A builder for the *locations.catalogs.servingConfigs.search* method supported by a *project* resource.
21125/// It is not used directly, but through a [`ProjectMethods`] instance.
21126///
21127/// # Example
21128///
21129/// Instantiate a resource method builder
21130///
21131/// ```test_harness,no_run
21132/// # extern crate hyper;
21133/// # extern crate hyper_rustls;
21134/// # extern crate google_retail2 as retail2;
21135/// use retail2::api::GoogleCloudRetailV2SearchRequest;
21136/// # async fn dox() {
21137/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21138///
21139/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21140/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21141/// #     .with_native_roots()
21142/// #     .unwrap()
21143/// #     .https_only()
21144/// #     .enable_http2()
21145/// #     .build();
21146///
21147/// # let executor = hyper_util::rt::TokioExecutor::new();
21148/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21149/// #     secret,
21150/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21151/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21152/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21153/// #     ),
21154/// # ).build().await.unwrap();
21155///
21156/// # let client = hyper_util::client::legacy::Client::builder(
21157/// #     hyper_util::rt::TokioExecutor::new()
21158/// # )
21159/// # .build(
21160/// #     hyper_rustls::HttpsConnectorBuilder::new()
21161/// #         .with_native_roots()
21162/// #         .unwrap()
21163/// #         .https_or_http()
21164/// #         .enable_http2()
21165/// #         .build()
21166/// # );
21167/// # let mut hub = CloudRetail::new(client, auth);
21168/// // As the method needs a request, you would usually fill it with the desired information
21169/// // into the respective structure. Some of the parts shown here might not be applicable !
21170/// // Values shown here are possibly random and not representative !
21171/// let mut req = GoogleCloudRetailV2SearchRequest::default();
21172///
21173/// // You can configure optional parameters by calling the respective setters at will, and
21174/// // execute the final call using `doit()`.
21175/// // Values shown here are possibly random and not representative !
21176/// let result = hub.projects().locations_catalogs_serving_configs_search(req, "placement")
21177///              .doit().await;
21178/// # }
21179/// ```
21180pub struct ProjectLocationCatalogServingConfigSearchCall<'a, C>
21181where
21182    C: 'a,
21183{
21184    hub: &'a CloudRetail<C>,
21185    _request: GoogleCloudRetailV2SearchRequest,
21186    _placement: String,
21187    _delegate: Option<&'a mut dyn common::Delegate>,
21188    _additional_params: HashMap<String, String>,
21189    _scopes: BTreeSet<String>,
21190}
21191
21192impl<'a, C> common::CallBuilder for ProjectLocationCatalogServingConfigSearchCall<'a, C> {}
21193
21194impl<'a, C> ProjectLocationCatalogServingConfigSearchCall<'a, C>
21195where
21196    C: common::Connector,
21197{
21198    /// Perform the operation you have build so far.
21199    pub async fn doit(
21200        mut self,
21201    ) -> common::Result<(common::Response, GoogleCloudRetailV2SearchResponse)> {
21202        use std::borrow::Cow;
21203        use std::io::{Read, Seek};
21204
21205        use common::{url::Params, ToParts};
21206        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21207
21208        let mut dd = common::DefaultDelegate;
21209        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21210        dlg.begin(common::MethodInfo {
21211            id: "retail.projects.locations.catalogs.servingConfigs.search",
21212            http_method: hyper::Method::POST,
21213        });
21214
21215        for &field in ["alt", "placement"].iter() {
21216            if self._additional_params.contains_key(field) {
21217                dlg.finished(false);
21218                return Err(common::Error::FieldClash(field));
21219            }
21220        }
21221
21222        let mut params = Params::with_capacity(4 + self._additional_params.len());
21223        params.push("placement", self._placement);
21224
21225        params.extend(self._additional_params.iter());
21226
21227        params.push("alt", "json");
21228        let mut url = self.hub._base_url.clone() + "v2/{+placement}:search";
21229        if self._scopes.is_empty() {
21230            self._scopes
21231                .insert(Scope::CloudPlatform.as_ref().to_string());
21232        }
21233
21234        #[allow(clippy::single_element_loop)]
21235        for &(find_this, param_name) in [("{+placement}", "placement")].iter() {
21236            url = params.uri_replacement(url, param_name, find_this, true);
21237        }
21238        {
21239            let to_remove = ["placement"];
21240            params.remove_params(&to_remove);
21241        }
21242
21243        let url = params.parse_with_url(&url);
21244
21245        let mut json_mime_type = mime::APPLICATION_JSON;
21246        let mut request_value_reader = {
21247            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21248            common::remove_json_null_values(&mut value);
21249            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21250            serde_json::to_writer(&mut dst, &value).unwrap();
21251            dst
21252        };
21253        let request_size = request_value_reader
21254            .seek(std::io::SeekFrom::End(0))
21255            .unwrap();
21256        request_value_reader
21257            .seek(std::io::SeekFrom::Start(0))
21258            .unwrap();
21259
21260        loop {
21261            let token = match self
21262                .hub
21263                .auth
21264                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21265                .await
21266            {
21267                Ok(token) => token,
21268                Err(e) => match dlg.token(e) {
21269                    Ok(token) => token,
21270                    Err(e) => {
21271                        dlg.finished(false);
21272                        return Err(common::Error::MissingToken(e));
21273                    }
21274                },
21275            };
21276            request_value_reader
21277                .seek(std::io::SeekFrom::Start(0))
21278                .unwrap();
21279            let mut req_result = {
21280                let client = &self.hub.client;
21281                dlg.pre_request();
21282                let mut req_builder = hyper::Request::builder()
21283                    .method(hyper::Method::POST)
21284                    .uri(url.as_str())
21285                    .header(USER_AGENT, self.hub._user_agent.clone());
21286
21287                if let Some(token) = token.as_ref() {
21288                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21289                }
21290
21291                let request = req_builder
21292                    .header(CONTENT_TYPE, json_mime_type.to_string())
21293                    .header(CONTENT_LENGTH, request_size as u64)
21294                    .body(common::to_body(
21295                        request_value_reader.get_ref().clone().into(),
21296                    ));
21297
21298                client.request(request.unwrap()).await
21299            };
21300
21301            match req_result {
21302                Err(err) => {
21303                    if let common::Retry::After(d) = dlg.http_error(&err) {
21304                        sleep(d).await;
21305                        continue;
21306                    }
21307                    dlg.finished(false);
21308                    return Err(common::Error::HttpError(err));
21309                }
21310                Ok(res) => {
21311                    let (mut parts, body) = res.into_parts();
21312                    let mut body = common::Body::new(body);
21313                    if !parts.status.is_success() {
21314                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21315                        let error = serde_json::from_str(&common::to_string(&bytes));
21316                        let response = common::to_response(parts, bytes.into());
21317
21318                        if let common::Retry::After(d) =
21319                            dlg.http_failure(&response, error.as_ref().ok())
21320                        {
21321                            sleep(d).await;
21322                            continue;
21323                        }
21324
21325                        dlg.finished(false);
21326
21327                        return Err(match error {
21328                            Ok(value) => common::Error::BadRequest(value),
21329                            _ => common::Error::Failure(response),
21330                        });
21331                    }
21332                    let response = {
21333                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21334                        let encoded = common::to_string(&bytes);
21335                        match serde_json::from_str(&encoded) {
21336                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21337                            Err(error) => {
21338                                dlg.response_json_decode_error(&encoded, &error);
21339                                return Err(common::Error::JsonDecodeError(
21340                                    encoded.to_string(),
21341                                    error,
21342                                ));
21343                            }
21344                        }
21345                    };
21346
21347                    dlg.finished(true);
21348                    return Ok(response);
21349                }
21350            }
21351        }
21352    }
21353
21354    ///
21355    /// Sets the *request* property to the given value.
21356    ///
21357    /// Even though the property as already been set when instantiating this call,
21358    /// we provide this method for API completeness.
21359    pub fn request(
21360        mut self,
21361        new_value: GoogleCloudRetailV2SearchRequest,
21362    ) -> ProjectLocationCatalogServingConfigSearchCall<'a, C> {
21363        self._request = new_value;
21364        self
21365    }
21366    /// Required. The resource name of the Retail Search serving config, such as `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` or the name of the legacy placement resource, such as `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. This field is used to identify the serving config name and the set of models that are used to make the search.
21367    ///
21368    /// Sets the *placement* path property to the given value.
21369    ///
21370    /// Even though the property as already been set when instantiating this call,
21371    /// we provide this method for API completeness.
21372    pub fn placement(
21373        mut self,
21374        new_value: &str,
21375    ) -> ProjectLocationCatalogServingConfigSearchCall<'a, C> {
21376        self._placement = new_value.to_string();
21377        self
21378    }
21379    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21380    /// while executing the actual API request.
21381    ///
21382    /// ````text
21383    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21384    /// ````
21385    ///
21386    /// Sets the *delegate* property to the given value.
21387    pub fn delegate(
21388        mut self,
21389        new_value: &'a mut dyn common::Delegate,
21390    ) -> ProjectLocationCatalogServingConfigSearchCall<'a, C> {
21391        self._delegate = Some(new_value);
21392        self
21393    }
21394
21395    /// Set any additional parameter of the query string used in the request.
21396    /// It should be used to set parameters which are not yet available through their own
21397    /// setters.
21398    ///
21399    /// Please note that this method must not be used to set any of the known parameters
21400    /// which have their own setter method. If done anyway, the request will fail.
21401    ///
21402    /// # Additional Parameters
21403    ///
21404    /// * *$.xgafv* (query-string) - V1 error format.
21405    /// * *access_token* (query-string) - OAuth access token.
21406    /// * *alt* (query-string) - Data format for response.
21407    /// * *callback* (query-string) - JSONP
21408    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21409    /// * *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.
21410    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21411    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21412    /// * *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.
21413    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21414    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21415    pub fn param<T>(
21416        mut self,
21417        name: T,
21418        value: T,
21419    ) -> ProjectLocationCatalogServingConfigSearchCall<'a, C>
21420    where
21421        T: AsRef<str>,
21422    {
21423        self._additional_params
21424            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21425        self
21426    }
21427
21428    /// Identifies the authorization scope for the method you are building.
21429    ///
21430    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21431    /// [`Scope::CloudPlatform`].
21432    ///
21433    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21434    /// tokens for more than one scope.
21435    ///
21436    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21437    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21438    /// sufficient, a read-write scope will do as well.
21439    pub fn add_scope<St>(
21440        mut self,
21441        scope: St,
21442    ) -> ProjectLocationCatalogServingConfigSearchCall<'a, C>
21443    where
21444        St: AsRef<str>,
21445    {
21446        self._scopes.insert(String::from(scope.as_ref()));
21447        self
21448    }
21449    /// Identifies the authorization scope(s) for the method you are building.
21450    ///
21451    /// See [`Self::add_scope()`] for details.
21452    pub fn add_scopes<I, St>(
21453        mut self,
21454        scopes: I,
21455    ) -> ProjectLocationCatalogServingConfigSearchCall<'a, C>
21456    where
21457        I: IntoIterator<Item = St>,
21458        St: AsRef<str>,
21459    {
21460        self._scopes
21461            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21462        self
21463    }
21464
21465    /// Removes all scopes, and no default scope will be used either.
21466    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21467    /// for details).
21468    pub fn clear_scopes(mut self) -> ProjectLocationCatalogServingConfigSearchCall<'a, C> {
21469        self._scopes.clear();
21470        self
21471    }
21472}
21473
21474/// Writes a single user event from the browser. For larger user event payload over 16 KB, the POST method should be used instead, otherwise a 400 Bad Request error is returned. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.
21475///
21476/// A builder for the *locations.catalogs.userEvents.collect* method supported by a *project* resource.
21477/// It is not used directly, but through a [`ProjectMethods`] instance.
21478///
21479/// # Example
21480///
21481/// Instantiate a resource method builder
21482///
21483/// ```test_harness,no_run
21484/// # extern crate hyper;
21485/// # extern crate hyper_rustls;
21486/// # extern crate google_retail2 as retail2;
21487/// use retail2::api::GoogleCloudRetailV2CollectUserEventRequest;
21488/// # async fn dox() {
21489/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21490///
21491/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21492/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21493/// #     .with_native_roots()
21494/// #     .unwrap()
21495/// #     .https_only()
21496/// #     .enable_http2()
21497/// #     .build();
21498///
21499/// # let executor = hyper_util::rt::TokioExecutor::new();
21500/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21501/// #     secret,
21502/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21503/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21504/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21505/// #     ),
21506/// # ).build().await.unwrap();
21507///
21508/// # let client = hyper_util::client::legacy::Client::builder(
21509/// #     hyper_util::rt::TokioExecutor::new()
21510/// # )
21511/// # .build(
21512/// #     hyper_rustls::HttpsConnectorBuilder::new()
21513/// #         .with_native_roots()
21514/// #         .unwrap()
21515/// #         .https_or_http()
21516/// #         .enable_http2()
21517/// #         .build()
21518/// # );
21519/// # let mut hub = CloudRetail::new(client, auth);
21520/// // As the method needs a request, you would usually fill it with the desired information
21521/// // into the respective structure. Some of the parts shown here might not be applicable !
21522/// // Values shown here are possibly random and not representative !
21523/// let mut req = GoogleCloudRetailV2CollectUserEventRequest::default();
21524///
21525/// // You can configure optional parameters by calling the respective setters at will, and
21526/// // execute the final call using `doit()`.
21527/// // Values shown here are possibly random and not representative !
21528/// let result = hub.projects().locations_catalogs_user_events_collect(req, "parent")
21529///              .doit().await;
21530/// # }
21531/// ```
21532pub struct ProjectLocationCatalogUserEventCollectCall<'a, C>
21533where
21534    C: 'a,
21535{
21536    hub: &'a CloudRetail<C>,
21537    _request: GoogleCloudRetailV2CollectUserEventRequest,
21538    _parent: String,
21539    _delegate: Option<&'a mut dyn common::Delegate>,
21540    _additional_params: HashMap<String, String>,
21541    _scopes: BTreeSet<String>,
21542}
21543
21544impl<'a, C> common::CallBuilder for ProjectLocationCatalogUserEventCollectCall<'a, C> {}
21545
21546impl<'a, C> ProjectLocationCatalogUserEventCollectCall<'a, C>
21547where
21548    C: common::Connector,
21549{
21550    /// Perform the operation you have build so far.
21551    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleApiHttpBody)> {
21552        use std::borrow::Cow;
21553        use std::io::{Read, Seek};
21554
21555        use common::{url::Params, ToParts};
21556        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21557
21558        let mut dd = common::DefaultDelegate;
21559        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21560        dlg.begin(common::MethodInfo {
21561            id: "retail.projects.locations.catalogs.userEvents.collect",
21562            http_method: hyper::Method::POST,
21563        });
21564
21565        for &field in ["alt", "parent"].iter() {
21566            if self._additional_params.contains_key(field) {
21567                dlg.finished(false);
21568                return Err(common::Error::FieldClash(field));
21569            }
21570        }
21571
21572        let mut params = Params::with_capacity(4 + self._additional_params.len());
21573        params.push("parent", self._parent);
21574
21575        params.extend(self._additional_params.iter());
21576
21577        params.push("alt", "json");
21578        let mut url = self.hub._base_url.clone() + "v2/{+parent}/userEvents:collect";
21579        if self._scopes.is_empty() {
21580            self._scopes
21581                .insert(Scope::CloudPlatform.as_ref().to_string());
21582        }
21583
21584        #[allow(clippy::single_element_loop)]
21585        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21586            url = params.uri_replacement(url, param_name, find_this, true);
21587        }
21588        {
21589            let to_remove = ["parent"];
21590            params.remove_params(&to_remove);
21591        }
21592
21593        let url = params.parse_with_url(&url);
21594
21595        let mut json_mime_type = mime::APPLICATION_JSON;
21596        let mut request_value_reader = {
21597            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21598            common::remove_json_null_values(&mut value);
21599            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21600            serde_json::to_writer(&mut dst, &value).unwrap();
21601            dst
21602        };
21603        let request_size = request_value_reader
21604            .seek(std::io::SeekFrom::End(0))
21605            .unwrap();
21606        request_value_reader
21607            .seek(std::io::SeekFrom::Start(0))
21608            .unwrap();
21609
21610        loop {
21611            let token = match self
21612                .hub
21613                .auth
21614                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21615                .await
21616            {
21617                Ok(token) => token,
21618                Err(e) => match dlg.token(e) {
21619                    Ok(token) => token,
21620                    Err(e) => {
21621                        dlg.finished(false);
21622                        return Err(common::Error::MissingToken(e));
21623                    }
21624                },
21625            };
21626            request_value_reader
21627                .seek(std::io::SeekFrom::Start(0))
21628                .unwrap();
21629            let mut req_result = {
21630                let client = &self.hub.client;
21631                dlg.pre_request();
21632                let mut req_builder = hyper::Request::builder()
21633                    .method(hyper::Method::POST)
21634                    .uri(url.as_str())
21635                    .header(USER_AGENT, self.hub._user_agent.clone());
21636
21637                if let Some(token) = token.as_ref() {
21638                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21639                }
21640
21641                let request = req_builder
21642                    .header(CONTENT_TYPE, json_mime_type.to_string())
21643                    .header(CONTENT_LENGTH, request_size as u64)
21644                    .body(common::to_body(
21645                        request_value_reader.get_ref().clone().into(),
21646                    ));
21647
21648                client.request(request.unwrap()).await
21649            };
21650
21651            match req_result {
21652                Err(err) => {
21653                    if let common::Retry::After(d) = dlg.http_error(&err) {
21654                        sleep(d).await;
21655                        continue;
21656                    }
21657                    dlg.finished(false);
21658                    return Err(common::Error::HttpError(err));
21659                }
21660                Ok(res) => {
21661                    let (mut parts, body) = res.into_parts();
21662                    let mut body = common::Body::new(body);
21663                    if !parts.status.is_success() {
21664                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21665                        let error = serde_json::from_str(&common::to_string(&bytes));
21666                        let response = common::to_response(parts, bytes.into());
21667
21668                        if let common::Retry::After(d) =
21669                            dlg.http_failure(&response, error.as_ref().ok())
21670                        {
21671                            sleep(d).await;
21672                            continue;
21673                        }
21674
21675                        dlg.finished(false);
21676
21677                        return Err(match error {
21678                            Ok(value) => common::Error::BadRequest(value),
21679                            _ => common::Error::Failure(response),
21680                        });
21681                    }
21682                    let response = {
21683                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21684                        let encoded = common::to_string(&bytes);
21685                        match serde_json::from_str(&encoded) {
21686                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21687                            Err(error) => {
21688                                dlg.response_json_decode_error(&encoded, &error);
21689                                return Err(common::Error::JsonDecodeError(
21690                                    encoded.to_string(),
21691                                    error,
21692                                ));
21693                            }
21694                        }
21695                    };
21696
21697                    dlg.finished(true);
21698                    return Ok(response);
21699                }
21700            }
21701        }
21702    }
21703
21704    ///
21705    /// Sets the *request* property to the given value.
21706    ///
21707    /// Even though the property as already been set when instantiating this call,
21708    /// we provide this method for API completeness.
21709    pub fn request(
21710        mut self,
21711        new_value: GoogleCloudRetailV2CollectUserEventRequest,
21712    ) -> ProjectLocationCatalogUserEventCollectCall<'a, C> {
21713        self._request = new_value;
21714        self
21715    }
21716    /// Required. The parent catalog name, such as `projects/1234/locations/global/catalogs/default_catalog`.
21717    ///
21718    /// Sets the *parent* path property to the given value.
21719    ///
21720    /// Even though the property as already been set when instantiating this call,
21721    /// we provide this method for API completeness.
21722    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogUserEventCollectCall<'a, C> {
21723        self._parent = new_value.to_string();
21724        self
21725    }
21726    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21727    /// while executing the actual API request.
21728    ///
21729    /// ````text
21730    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21731    /// ````
21732    ///
21733    /// Sets the *delegate* property to the given value.
21734    pub fn delegate(
21735        mut self,
21736        new_value: &'a mut dyn common::Delegate,
21737    ) -> ProjectLocationCatalogUserEventCollectCall<'a, C> {
21738        self._delegate = Some(new_value);
21739        self
21740    }
21741
21742    /// Set any additional parameter of the query string used in the request.
21743    /// It should be used to set parameters which are not yet available through their own
21744    /// setters.
21745    ///
21746    /// Please note that this method must not be used to set any of the known parameters
21747    /// which have their own setter method. If done anyway, the request will fail.
21748    ///
21749    /// # Additional Parameters
21750    ///
21751    /// * *$.xgafv* (query-string) - V1 error format.
21752    /// * *access_token* (query-string) - OAuth access token.
21753    /// * *alt* (query-string) - Data format for response.
21754    /// * *callback* (query-string) - JSONP
21755    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21756    /// * *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.
21757    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21758    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21759    /// * *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.
21760    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21761    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21762    pub fn param<T>(
21763        mut self,
21764        name: T,
21765        value: T,
21766    ) -> ProjectLocationCatalogUserEventCollectCall<'a, C>
21767    where
21768        T: AsRef<str>,
21769    {
21770        self._additional_params
21771            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21772        self
21773    }
21774
21775    /// Identifies the authorization scope for the method you are building.
21776    ///
21777    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21778    /// [`Scope::CloudPlatform`].
21779    ///
21780    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21781    /// tokens for more than one scope.
21782    ///
21783    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21784    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21785    /// sufficient, a read-write scope will do as well.
21786    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogUserEventCollectCall<'a, C>
21787    where
21788        St: AsRef<str>,
21789    {
21790        self._scopes.insert(String::from(scope.as_ref()));
21791        self
21792    }
21793    /// Identifies the authorization scope(s) for the method you are building.
21794    ///
21795    /// See [`Self::add_scope()`] for details.
21796    pub fn add_scopes<I, St>(
21797        mut self,
21798        scopes: I,
21799    ) -> ProjectLocationCatalogUserEventCollectCall<'a, C>
21800    where
21801        I: IntoIterator<Item = St>,
21802        St: AsRef<str>,
21803    {
21804        self._scopes
21805            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21806        self
21807    }
21808
21809    /// Removes all scopes, and no default scope will be used either.
21810    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21811    /// for details).
21812    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUserEventCollectCall<'a, C> {
21813        self._scopes.clear();
21814        self
21815    }
21816}
21817
21818/// 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`.
21819///
21820/// A builder for the *locations.catalogs.userEvents.import* method supported by a *project* resource.
21821/// It is not used directly, but through a [`ProjectMethods`] instance.
21822///
21823/// # Example
21824///
21825/// Instantiate a resource method builder
21826///
21827/// ```test_harness,no_run
21828/// # extern crate hyper;
21829/// # extern crate hyper_rustls;
21830/// # extern crate google_retail2 as retail2;
21831/// use retail2::api::GoogleCloudRetailV2ImportUserEventsRequest;
21832/// # async fn dox() {
21833/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21834///
21835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21836/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21837/// #     .with_native_roots()
21838/// #     .unwrap()
21839/// #     .https_only()
21840/// #     .enable_http2()
21841/// #     .build();
21842///
21843/// # let executor = hyper_util::rt::TokioExecutor::new();
21844/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21845/// #     secret,
21846/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21847/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21848/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21849/// #     ),
21850/// # ).build().await.unwrap();
21851///
21852/// # let client = hyper_util::client::legacy::Client::builder(
21853/// #     hyper_util::rt::TokioExecutor::new()
21854/// # )
21855/// # .build(
21856/// #     hyper_rustls::HttpsConnectorBuilder::new()
21857/// #         .with_native_roots()
21858/// #         .unwrap()
21859/// #         .https_or_http()
21860/// #         .enable_http2()
21861/// #         .build()
21862/// # );
21863/// # let mut hub = CloudRetail::new(client, auth);
21864/// // As the method needs a request, you would usually fill it with the desired information
21865/// // into the respective structure. Some of the parts shown here might not be applicable !
21866/// // Values shown here are possibly random and not representative !
21867/// let mut req = GoogleCloudRetailV2ImportUserEventsRequest::default();
21868///
21869/// // You can configure optional parameters by calling the respective setters at will, and
21870/// // execute the final call using `doit()`.
21871/// // Values shown here are possibly random and not representative !
21872/// let result = hub.projects().locations_catalogs_user_events_import(req, "parent")
21873///              .doit().await;
21874/// # }
21875/// ```
21876pub struct ProjectLocationCatalogUserEventImportCall<'a, C>
21877where
21878    C: 'a,
21879{
21880    hub: &'a CloudRetail<C>,
21881    _request: GoogleCloudRetailV2ImportUserEventsRequest,
21882    _parent: String,
21883    _delegate: Option<&'a mut dyn common::Delegate>,
21884    _additional_params: HashMap<String, String>,
21885    _scopes: BTreeSet<String>,
21886}
21887
21888impl<'a, C> common::CallBuilder for ProjectLocationCatalogUserEventImportCall<'a, C> {}
21889
21890impl<'a, C> ProjectLocationCatalogUserEventImportCall<'a, C>
21891where
21892    C: common::Connector,
21893{
21894    /// Perform the operation you have build so far.
21895    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
21896        use std::borrow::Cow;
21897        use std::io::{Read, Seek};
21898
21899        use common::{url::Params, ToParts};
21900        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21901
21902        let mut dd = common::DefaultDelegate;
21903        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21904        dlg.begin(common::MethodInfo {
21905            id: "retail.projects.locations.catalogs.userEvents.import",
21906            http_method: hyper::Method::POST,
21907        });
21908
21909        for &field in ["alt", "parent"].iter() {
21910            if self._additional_params.contains_key(field) {
21911                dlg.finished(false);
21912                return Err(common::Error::FieldClash(field));
21913            }
21914        }
21915
21916        let mut params = Params::with_capacity(4 + self._additional_params.len());
21917        params.push("parent", self._parent);
21918
21919        params.extend(self._additional_params.iter());
21920
21921        params.push("alt", "json");
21922        let mut url = self.hub._base_url.clone() + "v2/{+parent}/userEvents:import";
21923        if self._scopes.is_empty() {
21924            self._scopes
21925                .insert(Scope::CloudPlatform.as_ref().to_string());
21926        }
21927
21928        #[allow(clippy::single_element_loop)]
21929        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21930            url = params.uri_replacement(url, param_name, find_this, true);
21931        }
21932        {
21933            let to_remove = ["parent"];
21934            params.remove_params(&to_remove);
21935        }
21936
21937        let url = params.parse_with_url(&url);
21938
21939        let mut json_mime_type = mime::APPLICATION_JSON;
21940        let mut request_value_reader = {
21941            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21942            common::remove_json_null_values(&mut value);
21943            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21944            serde_json::to_writer(&mut dst, &value).unwrap();
21945            dst
21946        };
21947        let request_size = request_value_reader
21948            .seek(std::io::SeekFrom::End(0))
21949            .unwrap();
21950        request_value_reader
21951            .seek(std::io::SeekFrom::Start(0))
21952            .unwrap();
21953
21954        loop {
21955            let token = match self
21956                .hub
21957                .auth
21958                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21959                .await
21960            {
21961                Ok(token) => token,
21962                Err(e) => match dlg.token(e) {
21963                    Ok(token) => token,
21964                    Err(e) => {
21965                        dlg.finished(false);
21966                        return Err(common::Error::MissingToken(e));
21967                    }
21968                },
21969            };
21970            request_value_reader
21971                .seek(std::io::SeekFrom::Start(0))
21972                .unwrap();
21973            let mut req_result = {
21974                let client = &self.hub.client;
21975                dlg.pre_request();
21976                let mut req_builder = hyper::Request::builder()
21977                    .method(hyper::Method::POST)
21978                    .uri(url.as_str())
21979                    .header(USER_AGENT, self.hub._user_agent.clone());
21980
21981                if let Some(token) = token.as_ref() {
21982                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21983                }
21984
21985                let request = req_builder
21986                    .header(CONTENT_TYPE, json_mime_type.to_string())
21987                    .header(CONTENT_LENGTH, request_size as u64)
21988                    .body(common::to_body(
21989                        request_value_reader.get_ref().clone().into(),
21990                    ));
21991
21992                client.request(request.unwrap()).await
21993            };
21994
21995            match req_result {
21996                Err(err) => {
21997                    if let common::Retry::After(d) = dlg.http_error(&err) {
21998                        sleep(d).await;
21999                        continue;
22000                    }
22001                    dlg.finished(false);
22002                    return Err(common::Error::HttpError(err));
22003                }
22004                Ok(res) => {
22005                    let (mut parts, body) = res.into_parts();
22006                    let mut body = common::Body::new(body);
22007                    if !parts.status.is_success() {
22008                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22009                        let error = serde_json::from_str(&common::to_string(&bytes));
22010                        let response = common::to_response(parts, bytes.into());
22011
22012                        if let common::Retry::After(d) =
22013                            dlg.http_failure(&response, error.as_ref().ok())
22014                        {
22015                            sleep(d).await;
22016                            continue;
22017                        }
22018
22019                        dlg.finished(false);
22020
22021                        return Err(match error {
22022                            Ok(value) => common::Error::BadRequest(value),
22023                            _ => common::Error::Failure(response),
22024                        });
22025                    }
22026                    let response = {
22027                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22028                        let encoded = common::to_string(&bytes);
22029                        match serde_json::from_str(&encoded) {
22030                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22031                            Err(error) => {
22032                                dlg.response_json_decode_error(&encoded, &error);
22033                                return Err(common::Error::JsonDecodeError(
22034                                    encoded.to_string(),
22035                                    error,
22036                                ));
22037                            }
22038                        }
22039                    };
22040
22041                    dlg.finished(true);
22042                    return Ok(response);
22043                }
22044            }
22045        }
22046    }
22047
22048    ///
22049    /// Sets the *request* property to the given value.
22050    ///
22051    /// Even though the property as already been set when instantiating this call,
22052    /// we provide this method for API completeness.
22053    pub fn request(
22054        mut self,
22055        new_value: GoogleCloudRetailV2ImportUserEventsRequest,
22056    ) -> ProjectLocationCatalogUserEventImportCall<'a, C> {
22057        self._request = new_value;
22058        self
22059    }
22060    /// Required. `projects/1234/locations/global/catalogs/default_catalog`
22061    ///
22062    /// Sets the *parent* path property to the given value.
22063    ///
22064    /// Even though the property as already been set when instantiating this call,
22065    /// we provide this method for API completeness.
22066    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogUserEventImportCall<'a, C> {
22067        self._parent = new_value.to_string();
22068        self
22069    }
22070    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22071    /// while executing the actual API request.
22072    ///
22073    /// ````text
22074    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22075    /// ````
22076    ///
22077    /// Sets the *delegate* property to the given value.
22078    pub fn delegate(
22079        mut self,
22080        new_value: &'a mut dyn common::Delegate,
22081    ) -> ProjectLocationCatalogUserEventImportCall<'a, C> {
22082        self._delegate = Some(new_value);
22083        self
22084    }
22085
22086    /// Set any additional parameter of the query string used in the request.
22087    /// It should be used to set parameters which are not yet available through their own
22088    /// setters.
22089    ///
22090    /// Please note that this method must not be used to set any of the known parameters
22091    /// which have their own setter method. If done anyway, the request will fail.
22092    ///
22093    /// # Additional Parameters
22094    ///
22095    /// * *$.xgafv* (query-string) - V1 error format.
22096    /// * *access_token* (query-string) - OAuth access token.
22097    /// * *alt* (query-string) - Data format for response.
22098    /// * *callback* (query-string) - JSONP
22099    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22100    /// * *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.
22101    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22102    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22103    /// * *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.
22104    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22105    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22106    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogUserEventImportCall<'a, C>
22107    where
22108        T: AsRef<str>,
22109    {
22110        self._additional_params
22111            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22112        self
22113    }
22114
22115    /// Identifies the authorization scope for the method you are building.
22116    ///
22117    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22118    /// [`Scope::CloudPlatform`].
22119    ///
22120    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22121    /// tokens for more than one scope.
22122    ///
22123    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22124    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22125    /// sufficient, a read-write scope will do as well.
22126    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogUserEventImportCall<'a, C>
22127    where
22128        St: AsRef<str>,
22129    {
22130        self._scopes.insert(String::from(scope.as_ref()));
22131        self
22132    }
22133    /// Identifies the authorization scope(s) for the method you are building.
22134    ///
22135    /// See [`Self::add_scope()`] for details.
22136    pub fn add_scopes<I, St>(
22137        mut self,
22138        scopes: I,
22139    ) -> ProjectLocationCatalogUserEventImportCall<'a, C>
22140    where
22141        I: IntoIterator<Item = St>,
22142        St: AsRef<str>,
22143    {
22144        self._scopes
22145            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22146        self
22147    }
22148
22149    /// Removes all scopes, and no default scope will be used either.
22150    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22151    /// for details).
22152    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUserEventImportCall<'a, C> {
22153        self._scopes.clear();
22154        self
22155    }
22156}
22157
22158/// 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.
22159///
22160/// A builder for the *locations.catalogs.userEvents.purge* method supported by a *project* resource.
22161/// It is not used directly, but through a [`ProjectMethods`] instance.
22162///
22163/// # Example
22164///
22165/// Instantiate a resource method builder
22166///
22167/// ```test_harness,no_run
22168/// # extern crate hyper;
22169/// # extern crate hyper_rustls;
22170/// # extern crate google_retail2 as retail2;
22171/// use retail2::api::GoogleCloudRetailV2PurgeUserEventsRequest;
22172/// # async fn dox() {
22173/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22174///
22175/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22176/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22177/// #     .with_native_roots()
22178/// #     .unwrap()
22179/// #     .https_only()
22180/// #     .enable_http2()
22181/// #     .build();
22182///
22183/// # let executor = hyper_util::rt::TokioExecutor::new();
22184/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22185/// #     secret,
22186/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22187/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22188/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22189/// #     ),
22190/// # ).build().await.unwrap();
22191///
22192/// # let client = hyper_util::client::legacy::Client::builder(
22193/// #     hyper_util::rt::TokioExecutor::new()
22194/// # )
22195/// # .build(
22196/// #     hyper_rustls::HttpsConnectorBuilder::new()
22197/// #         .with_native_roots()
22198/// #         .unwrap()
22199/// #         .https_or_http()
22200/// #         .enable_http2()
22201/// #         .build()
22202/// # );
22203/// # let mut hub = CloudRetail::new(client, auth);
22204/// // As the method needs a request, you would usually fill it with the desired information
22205/// // into the respective structure. Some of the parts shown here might not be applicable !
22206/// // Values shown here are possibly random and not representative !
22207/// let mut req = GoogleCloudRetailV2PurgeUserEventsRequest::default();
22208///
22209/// // You can configure optional parameters by calling the respective setters at will, and
22210/// // execute the final call using `doit()`.
22211/// // Values shown here are possibly random and not representative !
22212/// let result = hub.projects().locations_catalogs_user_events_purge(req, "parent")
22213///              .doit().await;
22214/// # }
22215/// ```
22216pub struct ProjectLocationCatalogUserEventPurgeCall<'a, C>
22217where
22218    C: 'a,
22219{
22220    hub: &'a CloudRetail<C>,
22221    _request: GoogleCloudRetailV2PurgeUserEventsRequest,
22222    _parent: String,
22223    _delegate: Option<&'a mut dyn common::Delegate>,
22224    _additional_params: HashMap<String, String>,
22225    _scopes: BTreeSet<String>,
22226}
22227
22228impl<'a, C> common::CallBuilder for ProjectLocationCatalogUserEventPurgeCall<'a, C> {}
22229
22230impl<'a, C> ProjectLocationCatalogUserEventPurgeCall<'a, C>
22231where
22232    C: common::Connector,
22233{
22234    /// Perform the operation you have build so far.
22235    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
22236        use std::borrow::Cow;
22237        use std::io::{Read, Seek};
22238
22239        use common::{url::Params, ToParts};
22240        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22241
22242        let mut dd = common::DefaultDelegate;
22243        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22244        dlg.begin(common::MethodInfo {
22245            id: "retail.projects.locations.catalogs.userEvents.purge",
22246            http_method: hyper::Method::POST,
22247        });
22248
22249        for &field in ["alt", "parent"].iter() {
22250            if self._additional_params.contains_key(field) {
22251                dlg.finished(false);
22252                return Err(common::Error::FieldClash(field));
22253            }
22254        }
22255
22256        let mut params = Params::with_capacity(4 + self._additional_params.len());
22257        params.push("parent", self._parent);
22258
22259        params.extend(self._additional_params.iter());
22260
22261        params.push("alt", "json");
22262        let mut url = self.hub._base_url.clone() + "v2/{+parent}/userEvents:purge";
22263        if self._scopes.is_empty() {
22264            self._scopes
22265                .insert(Scope::CloudPlatform.as_ref().to_string());
22266        }
22267
22268        #[allow(clippy::single_element_loop)]
22269        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22270            url = params.uri_replacement(url, param_name, find_this, true);
22271        }
22272        {
22273            let to_remove = ["parent"];
22274            params.remove_params(&to_remove);
22275        }
22276
22277        let url = params.parse_with_url(&url);
22278
22279        let mut json_mime_type = mime::APPLICATION_JSON;
22280        let mut request_value_reader = {
22281            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22282            common::remove_json_null_values(&mut value);
22283            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22284            serde_json::to_writer(&mut dst, &value).unwrap();
22285            dst
22286        };
22287        let request_size = request_value_reader
22288            .seek(std::io::SeekFrom::End(0))
22289            .unwrap();
22290        request_value_reader
22291            .seek(std::io::SeekFrom::Start(0))
22292            .unwrap();
22293
22294        loop {
22295            let token = match self
22296                .hub
22297                .auth
22298                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22299                .await
22300            {
22301                Ok(token) => token,
22302                Err(e) => match dlg.token(e) {
22303                    Ok(token) => token,
22304                    Err(e) => {
22305                        dlg.finished(false);
22306                        return Err(common::Error::MissingToken(e));
22307                    }
22308                },
22309            };
22310            request_value_reader
22311                .seek(std::io::SeekFrom::Start(0))
22312                .unwrap();
22313            let mut req_result = {
22314                let client = &self.hub.client;
22315                dlg.pre_request();
22316                let mut req_builder = hyper::Request::builder()
22317                    .method(hyper::Method::POST)
22318                    .uri(url.as_str())
22319                    .header(USER_AGENT, self.hub._user_agent.clone());
22320
22321                if let Some(token) = token.as_ref() {
22322                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22323                }
22324
22325                let request = req_builder
22326                    .header(CONTENT_TYPE, json_mime_type.to_string())
22327                    .header(CONTENT_LENGTH, request_size as u64)
22328                    .body(common::to_body(
22329                        request_value_reader.get_ref().clone().into(),
22330                    ));
22331
22332                client.request(request.unwrap()).await
22333            };
22334
22335            match req_result {
22336                Err(err) => {
22337                    if let common::Retry::After(d) = dlg.http_error(&err) {
22338                        sleep(d).await;
22339                        continue;
22340                    }
22341                    dlg.finished(false);
22342                    return Err(common::Error::HttpError(err));
22343                }
22344                Ok(res) => {
22345                    let (mut parts, body) = res.into_parts();
22346                    let mut body = common::Body::new(body);
22347                    if !parts.status.is_success() {
22348                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22349                        let error = serde_json::from_str(&common::to_string(&bytes));
22350                        let response = common::to_response(parts, bytes.into());
22351
22352                        if let common::Retry::After(d) =
22353                            dlg.http_failure(&response, error.as_ref().ok())
22354                        {
22355                            sleep(d).await;
22356                            continue;
22357                        }
22358
22359                        dlg.finished(false);
22360
22361                        return Err(match error {
22362                            Ok(value) => common::Error::BadRequest(value),
22363                            _ => common::Error::Failure(response),
22364                        });
22365                    }
22366                    let response = {
22367                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22368                        let encoded = common::to_string(&bytes);
22369                        match serde_json::from_str(&encoded) {
22370                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22371                            Err(error) => {
22372                                dlg.response_json_decode_error(&encoded, &error);
22373                                return Err(common::Error::JsonDecodeError(
22374                                    encoded.to_string(),
22375                                    error,
22376                                ));
22377                            }
22378                        }
22379                    };
22380
22381                    dlg.finished(true);
22382                    return Ok(response);
22383                }
22384            }
22385        }
22386    }
22387
22388    ///
22389    /// Sets the *request* property to the given value.
22390    ///
22391    /// Even though the property as already been set when instantiating this call,
22392    /// we provide this method for API completeness.
22393    pub fn request(
22394        mut self,
22395        new_value: GoogleCloudRetailV2PurgeUserEventsRequest,
22396    ) -> ProjectLocationCatalogUserEventPurgeCall<'a, C> {
22397        self._request = new_value;
22398        self
22399    }
22400    /// Required. The resource name of the catalog under which the events are created. The format is `projects/${projectId}/locations/global/catalogs/${catalogId}`
22401    ///
22402    /// Sets the *parent* path property to the given value.
22403    ///
22404    /// Even though the property as already been set when instantiating this call,
22405    /// we provide this method for API completeness.
22406    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogUserEventPurgeCall<'a, C> {
22407        self._parent = new_value.to_string();
22408        self
22409    }
22410    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22411    /// while executing the actual API request.
22412    ///
22413    /// ````text
22414    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22415    /// ````
22416    ///
22417    /// Sets the *delegate* property to the given value.
22418    pub fn delegate(
22419        mut self,
22420        new_value: &'a mut dyn common::Delegate,
22421    ) -> ProjectLocationCatalogUserEventPurgeCall<'a, C> {
22422        self._delegate = Some(new_value);
22423        self
22424    }
22425
22426    /// Set any additional parameter of the query string used in the request.
22427    /// It should be used to set parameters which are not yet available through their own
22428    /// setters.
22429    ///
22430    /// Please note that this method must not be used to set any of the known parameters
22431    /// which have their own setter method. If done anyway, the request will fail.
22432    ///
22433    /// # Additional Parameters
22434    ///
22435    /// * *$.xgafv* (query-string) - V1 error format.
22436    /// * *access_token* (query-string) - OAuth access token.
22437    /// * *alt* (query-string) - Data format for response.
22438    /// * *callback* (query-string) - JSONP
22439    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22440    /// * *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.
22441    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22442    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22443    /// * *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.
22444    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22445    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22446    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogUserEventPurgeCall<'a, C>
22447    where
22448        T: AsRef<str>,
22449    {
22450        self._additional_params
22451            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22452        self
22453    }
22454
22455    /// Identifies the authorization scope for the method you are building.
22456    ///
22457    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22458    /// [`Scope::CloudPlatform`].
22459    ///
22460    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22461    /// tokens for more than one scope.
22462    ///
22463    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22464    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22465    /// sufficient, a read-write scope will do as well.
22466    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogUserEventPurgeCall<'a, C>
22467    where
22468        St: AsRef<str>,
22469    {
22470        self._scopes.insert(String::from(scope.as_ref()));
22471        self
22472    }
22473    /// Identifies the authorization scope(s) for the method you are building.
22474    ///
22475    /// See [`Self::add_scope()`] for details.
22476    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogUserEventPurgeCall<'a, C>
22477    where
22478        I: IntoIterator<Item = St>,
22479        St: AsRef<str>,
22480    {
22481        self._scopes
22482            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22483        self
22484    }
22485
22486    /// Removes all scopes, and no default scope will be used either.
22487    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22488    /// for details).
22489    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUserEventPurgeCall<'a, C> {
22490        self._scopes.clear();
22491        self
22492    }
22493}
22494
22495/// Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.
22496///
22497/// A builder for the *locations.catalogs.userEvents.rejoin* method supported by a *project* resource.
22498/// It is not used directly, but through a [`ProjectMethods`] instance.
22499///
22500/// # Example
22501///
22502/// Instantiate a resource method builder
22503///
22504/// ```test_harness,no_run
22505/// # extern crate hyper;
22506/// # extern crate hyper_rustls;
22507/// # extern crate google_retail2 as retail2;
22508/// use retail2::api::GoogleCloudRetailV2RejoinUserEventsRequest;
22509/// # async fn dox() {
22510/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22511///
22512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22513/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22514/// #     .with_native_roots()
22515/// #     .unwrap()
22516/// #     .https_only()
22517/// #     .enable_http2()
22518/// #     .build();
22519///
22520/// # let executor = hyper_util::rt::TokioExecutor::new();
22521/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22522/// #     secret,
22523/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22524/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22525/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22526/// #     ),
22527/// # ).build().await.unwrap();
22528///
22529/// # let client = hyper_util::client::legacy::Client::builder(
22530/// #     hyper_util::rt::TokioExecutor::new()
22531/// # )
22532/// # .build(
22533/// #     hyper_rustls::HttpsConnectorBuilder::new()
22534/// #         .with_native_roots()
22535/// #         .unwrap()
22536/// #         .https_or_http()
22537/// #         .enable_http2()
22538/// #         .build()
22539/// # );
22540/// # let mut hub = CloudRetail::new(client, auth);
22541/// // As the method needs a request, you would usually fill it with the desired information
22542/// // into the respective structure. Some of the parts shown here might not be applicable !
22543/// // Values shown here are possibly random and not representative !
22544/// let mut req = GoogleCloudRetailV2RejoinUserEventsRequest::default();
22545///
22546/// // You can configure optional parameters by calling the respective setters at will, and
22547/// // execute the final call using `doit()`.
22548/// // Values shown here are possibly random and not representative !
22549/// let result = hub.projects().locations_catalogs_user_events_rejoin(req, "parent")
22550///              .doit().await;
22551/// # }
22552/// ```
22553pub struct ProjectLocationCatalogUserEventRejoinCall<'a, C>
22554where
22555    C: 'a,
22556{
22557    hub: &'a CloudRetail<C>,
22558    _request: GoogleCloudRetailV2RejoinUserEventsRequest,
22559    _parent: String,
22560    _delegate: Option<&'a mut dyn common::Delegate>,
22561    _additional_params: HashMap<String, String>,
22562    _scopes: BTreeSet<String>,
22563}
22564
22565impl<'a, C> common::CallBuilder for ProjectLocationCatalogUserEventRejoinCall<'a, C> {}
22566
22567impl<'a, C> ProjectLocationCatalogUserEventRejoinCall<'a, C>
22568where
22569    C: common::Connector,
22570{
22571    /// Perform the operation you have build so far.
22572    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
22573        use std::borrow::Cow;
22574        use std::io::{Read, Seek};
22575
22576        use common::{url::Params, ToParts};
22577        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22578
22579        let mut dd = common::DefaultDelegate;
22580        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22581        dlg.begin(common::MethodInfo {
22582            id: "retail.projects.locations.catalogs.userEvents.rejoin",
22583            http_method: hyper::Method::POST,
22584        });
22585
22586        for &field in ["alt", "parent"].iter() {
22587            if self._additional_params.contains_key(field) {
22588                dlg.finished(false);
22589                return Err(common::Error::FieldClash(field));
22590            }
22591        }
22592
22593        let mut params = Params::with_capacity(4 + self._additional_params.len());
22594        params.push("parent", self._parent);
22595
22596        params.extend(self._additional_params.iter());
22597
22598        params.push("alt", "json");
22599        let mut url = self.hub._base_url.clone() + "v2/{+parent}/userEvents:rejoin";
22600        if self._scopes.is_empty() {
22601            self._scopes
22602                .insert(Scope::CloudPlatform.as_ref().to_string());
22603        }
22604
22605        #[allow(clippy::single_element_loop)]
22606        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22607            url = params.uri_replacement(url, param_name, find_this, true);
22608        }
22609        {
22610            let to_remove = ["parent"];
22611            params.remove_params(&to_remove);
22612        }
22613
22614        let url = params.parse_with_url(&url);
22615
22616        let mut json_mime_type = mime::APPLICATION_JSON;
22617        let mut request_value_reader = {
22618            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22619            common::remove_json_null_values(&mut value);
22620            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22621            serde_json::to_writer(&mut dst, &value).unwrap();
22622            dst
22623        };
22624        let request_size = request_value_reader
22625            .seek(std::io::SeekFrom::End(0))
22626            .unwrap();
22627        request_value_reader
22628            .seek(std::io::SeekFrom::Start(0))
22629            .unwrap();
22630
22631        loop {
22632            let token = match self
22633                .hub
22634                .auth
22635                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22636                .await
22637            {
22638                Ok(token) => token,
22639                Err(e) => match dlg.token(e) {
22640                    Ok(token) => token,
22641                    Err(e) => {
22642                        dlg.finished(false);
22643                        return Err(common::Error::MissingToken(e));
22644                    }
22645                },
22646            };
22647            request_value_reader
22648                .seek(std::io::SeekFrom::Start(0))
22649                .unwrap();
22650            let mut req_result = {
22651                let client = &self.hub.client;
22652                dlg.pre_request();
22653                let mut req_builder = hyper::Request::builder()
22654                    .method(hyper::Method::POST)
22655                    .uri(url.as_str())
22656                    .header(USER_AGENT, self.hub._user_agent.clone());
22657
22658                if let Some(token) = token.as_ref() {
22659                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22660                }
22661
22662                let request = req_builder
22663                    .header(CONTENT_TYPE, json_mime_type.to_string())
22664                    .header(CONTENT_LENGTH, request_size as u64)
22665                    .body(common::to_body(
22666                        request_value_reader.get_ref().clone().into(),
22667                    ));
22668
22669                client.request(request.unwrap()).await
22670            };
22671
22672            match req_result {
22673                Err(err) => {
22674                    if let common::Retry::After(d) = dlg.http_error(&err) {
22675                        sleep(d).await;
22676                        continue;
22677                    }
22678                    dlg.finished(false);
22679                    return Err(common::Error::HttpError(err));
22680                }
22681                Ok(res) => {
22682                    let (mut parts, body) = res.into_parts();
22683                    let mut body = common::Body::new(body);
22684                    if !parts.status.is_success() {
22685                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22686                        let error = serde_json::from_str(&common::to_string(&bytes));
22687                        let response = common::to_response(parts, bytes.into());
22688
22689                        if let common::Retry::After(d) =
22690                            dlg.http_failure(&response, error.as_ref().ok())
22691                        {
22692                            sleep(d).await;
22693                            continue;
22694                        }
22695
22696                        dlg.finished(false);
22697
22698                        return Err(match error {
22699                            Ok(value) => common::Error::BadRequest(value),
22700                            _ => common::Error::Failure(response),
22701                        });
22702                    }
22703                    let response = {
22704                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22705                        let encoded = common::to_string(&bytes);
22706                        match serde_json::from_str(&encoded) {
22707                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22708                            Err(error) => {
22709                                dlg.response_json_decode_error(&encoded, &error);
22710                                return Err(common::Error::JsonDecodeError(
22711                                    encoded.to_string(),
22712                                    error,
22713                                ));
22714                            }
22715                        }
22716                    };
22717
22718                    dlg.finished(true);
22719                    return Ok(response);
22720                }
22721            }
22722        }
22723    }
22724
22725    ///
22726    /// Sets the *request* property to the given value.
22727    ///
22728    /// Even though the property as already been set when instantiating this call,
22729    /// we provide this method for API completeness.
22730    pub fn request(
22731        mut self,
22732        new_value: GoogleCloudRetailV2RejoinUserEventsRequest,
22733    ) -> ProjectLocationCatalogUserEventRejoinCall<'a, C> {
22734        self._request = new_value;
22735        self
22736    }
22737    /// Required. The parent catalog resource name, such as `projects/1234/locations/global/catalogs/default_catalog`.
22738    ///
22739    /// Sets the *parent* path property to the given value.
22740    ///
22741    /// Even though the property as already been set when instantiating this call,
22742    /// we provide this method for API completeness.
22743    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogUserEventRejoinCall<'a, C> {
22744        self._parent = new_value.to_string();
22745        self
22746    }
22747    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22748    /// while executing the actual API request.
22749    ///
22750    /// ````text
22751    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22752    /// ````
22753    ///
22754    /// Sets the *delegate* property to the given value.
22755    pub fn delegate(
22756        mut self,
22757        new_value: &'a mut dyn common::Delegate,
22758    ) -> ProjectLocationCatalogUserEventRejoinCall<'a, C> {
22759        self._delegate = Some(new_value);
22760        self
22761    }
22762
22763    /// Set any additional parameter of the query string used in the request.
22764    /// It should be used to set parameters which are not yet available through their own
22765    /// setters.
22766    ///
22767    /// Please note that this method must not be used to set any of the known parameters
22768    /// which have their own setter method. If done anyway, the request will fail.
22769    ///
22770    /// # Additional Parameters
22771    ///
22772    /// * *$.xgafv* (query-string) - V1 error format.
22773    /// * *access_token* (query-string) - OAuth access token.
22774    /// * *alt* (query-string) - Data format for response.
22775    /// * *callback* (query-string) - JSONP
22776    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22777    /// * *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.
22778    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22779    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22780    /// * *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.
22781    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22782    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22783    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogUserEventRejoinCall<'a, C>
22784    where
22785        T: AsRef<str>,
22786    {
22787        self._additional_params
22788            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22789        self
22790    }
22791
22792    /// Identifies the authorization scope for the method you are building.
22793    ///
22794    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22795    /// [`Scope::CloudPlatform`].
22796    ///
22797    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22798    /// tokens for more than one scope.
22799    ///
22800    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22801    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22802    /// sufficient, a read-write scope will do as well.
22803    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogUserEventRejoinCall<'a, C>
22804    where
22805        St: AsRef<str>,
22806    {
22807        self._scopes.insert(String::from(scope.as_ref()));
22808        self
22809    }
22810    /// Identifies the authorization scope(s) for the method you are building.
22811    ///
22812    /// See [`Self::add_scope()`] for details.
22813    pub fn add_scopes<I, St>(
22814        mut self,
22815        scopes: I,
22816    ) -> ProjectLocationCatalogUserEventRejoinCall<'a, C>
22817    where
22818        I: IntoIterator<Item = St>,
22819        St: AsRef<str>,
22820    {
22821        self._scopes
22822            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22823        self
22824    }
22825
22826    /// Removes all scopes, and no default scope will be used either.
22827    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22828    /// for details).
22829    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUserEventRejoinCall<'a, C> {
22830        self._scopes.clear();
22831        self
22832    }
22833}
22834
22835/// Writes a single user event.
22836///
22837/// A builder for the *locations.catalogs.userEvents.write* method supported by a *project* resource.
22838/// It is not used directly, but through a [`ProjectMethods`] instance.
22839///
22840/// # Example
22841///
22842/// Instantiate a resource method builder
22843///
22844/// ```test_harness,no_run
22845/// # extern crate hyper;
22846/// # extern crate hyper_rustls;
22847/// # extern crate google_retail2 as retail2;
22848/// use retail2::api::GoogleCloudRetailV2UserEvent;
22849/// # async fn dox() {
22850/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22851///
22852/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22853/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22854/// #     .with_native_roots()
22855/// #     .unwrap()
22856/// #     .https_only()
22857/// #     .enable_http2()
22858/// #     .build();
22859///
22860/// # let executor = hyper_util::rt::TokioExecutor::new();
22861/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22862/// #     secret,
22863/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22864/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22865/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22866/// #     ),
22867/// # ).build().await.unwrap();
22868///
22869/// # let client = hyper_util::client::legacy::Client::builder(
22870/// #     hyper_util::rt::TokioExecutor::new()
22871/// # )
22872/// # .build(
22873/// #     hyper_rustls::HttpsConnectorBuilder::new()
22874/// #         .with_native_roots()
22875/// #         .unwrap()
22876/// #         .https_or_http()
22877/// #         .enable_http2()
22878/// #         .build()
22879/// # );
22880/// # let mut hub = CloudRetail::new(client, auth);
22881/// // As the method needs a request, you would usually fill it with the desired information
22882/// // into the respective structure. Some of the parts shown here might not be applicable !
22883/// // Values shown here are possibly random and not representative !
22884/// let mut req = GoogleCloudRetailV2UserEvent::default();
22885///
22886/// // You can configure optional parameters by calling the respective setters at will, and
22887/// // execute the final call using `doit()`.
22888/// // Values shown here are possibly random and not representative !
22889/// let result = hub.projects().locations_catalogs_user_events_write(req, "parent")
22890///              .write_async(true)
22891///              .doit().await;
22892/// # }
22893/// ```
22894pub struct ProjectLocationCatalogUserEventWriteCall<'a, C>
22895where
22896    C: 'a,
22897{
22898    hub: &'a CloudRetail<C>,
22899    _request: GoogleCloudRetailV2UserEvent,
22900    _parent: String,
22901    _write_async: Option<bool>,
22902    _delegate: Option<&'a mut dyn common::Delegate>,
22903    _additional_params: HashMap<String, String>,
22904    _scopes: BTreeSet<String>,
22905}
22906
22907impl<'a, C> common::CallBuilder for ProjectLocationCatalogUserEventWriteCall<'a, C> {}
22908
22909impl<'a, C> ProjectLocationCatalogUserEventWriteCall<'a, C>
22910where
22911    C: common::Connector,
22912{
22913    /// Perform the operation you have build so far.
22914    pub async fn doit(
22915        mut self,
22916    ) -> common::Result<(common::Response, GoogleCloudRetailV2UserEvent)> {
22917        use std::borrow::Cow;
22918        use std::io::{Read, Seek};
22919
22920        use common::{url::Params, ToParts};
22921        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22922
22923        let mut dd = common::DefaultDelegate;
22924        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22925        dlg.begin(common::MethodInfo {
22926            id: "retail.projects.locations.catalogs.userEvents.write",
22927            http_method: hyper::Method::POST,
22928        });
22929
22930        for &field in ["alt", "parent", "writeAsync"].iter() {
22931            if self._additional_params.contains_key(field) {
22932                dlg.finished(false);
22933                return Err(common::Error::FieldClash(field));
22934            }
22935        }
22936
22937        let mut params = Params::with_capacity(5 + self._additional_params.len());
22938        params.push("parent", self._parent);
22939        if let Some(value) = self._write_async.as_ref() {
22940            params.push("writeAsync", value.to_string());
22941        }
22942
22943        params.extend(self._additional_params.iter());
22944
22945        params.push("alt", "json");
22946        let mut url = self.hub._base_url.clone() + "v2/{+parent}/userEvents:write";
22947        if self._scopes.is_empty() {
22948            self._scopes
22949                .insert(Scope::CloudPlatform.as_ref().to_string());
22950        }
22951
22952        #[allow(clippy::single_element_loop)]
22953        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22954            url = params.uri_replacement(url, param_name, find_this, true);
22955        }
22956        {
22957            let to_remove = ["parent"];
22958            params.remove_params(&to_remove);
22959        }
22960
22961        let url = params.parse_with_url(&url);
22962
22963        let mut json_mime_type = mime::APPLICATION_JSON;
22964        let mut request_value_reader = {
22965            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22966            common::remove_json_null_values(&mut value);
22967            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22968            serde_json::to_writer(&mut dst, &value).unwrap();
22969            dst
22970        };
22971        let request_size = request_value_reader
22972            .seek(std::io::SeekFrom::End(0))
22973            .unwrap();
22974        request_value_reader
22975            .seek(std::io::SeekFrom::Start(0))
22976            .unwrap();
22977
22978        loop {
22979            let token = match self
22980                .hub
22981                .auth
22982                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22983                .await
22984            {
22985                Ok(token) => token,
22986                Err(e) => match dlg.token(e) {
22987                    Ok(token) => token,
22988                    Err(e) => {
22989                        dlg.finished(false);
22990                        return Err(common::Error::MissingToken(e));
22991                    }
22992                },
22993            };
22994            request_value_reader
22995                .seek(std::io::SeekFrom::Start(0))
22996                .unwrap();
22997            let mut req_result = {
22998                let client = &self.hub.client;
22999                dlg.pre_request();
23000                let mut req_builder = hyper::Request::builder()
23001                    .method(hyper::Method::POST)
23002                    .uri(url.as_str())
23003                    .header(USER_AGENT, self.hub._user_agent.clone());
23004
23005                if let Some(token) = token.as_ref() {
23006                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23007                }
23008
23009                let request = req_builder
23010                    .header(CONTENT_TYPE, json_mime_type.to_string())
23011                    .header(CONTENT_LENGTH, request_size as u64)
23012                    .body(common::to_body(
23013                        request_value_reader.get_ref().clone().into(),
23014                    ));
23015
23016                client.request(request.unwrap()).await
23017            };
23018
23019            match req_result {
23020                Err(err) => {
23021                    if let common::Retry::After(d) = dlg.http_error(&err) {
23022                        sleep(d).await;
23023                        continue;
23024                    }
23025                    dlg.finished(false);
23026                    return Err(common::Error::HttpError(err));
23027                }
23028                Ok(res) => {
23029                    let (mut parts, body) = res.into_parts();
23030                    let mut body = common::Body::new(body);
23031                    if !parts.status.is_success() {
23032                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23033                        let error = serde_json::from_str(&common::to_string(&bytes));
23034                        let response = common::to_response(parts, bytes.into());
23035
23036                        if let common::Retry::After(d) =
23037                            dlg.http_failure(&response, error.as_ref().ok())
23038                        {
23039                            sleep(d).await;
23040                            continue;
23041                        }
23042
23043                        dlg.finished(false);
23044
23045                        return Err(match error {
23046                            Ok(value) => common::Error::BadRequest(value),
23047                            _ => common::Error::Failure(response),
23048                        });
23049                    }
23050                    let response = {
23051                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23052                        let encoded = common::to_string(&bytes);
23053                        match serde_json::from_str(&encoded) {
23054                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23055                            Err(error) => {
23056                                dlg.response_json_decode_error(&encoded, &error);
23057                                return Err(common::Error::JsonDecodeError(
23058                                    encoded.to_string(),
23059                                    error,
23060                                ));
23061                            }
23062                        }
23063                    };
23064
23065                    dlg.finished(true);
23066                    return Ok(response);
23067                }
23068            }
23069        }
23070    }
23071
23072    ///
23073    /// Sets the *request* property to the given value.
23074    ///
23075    /// Even though the property as already been set when instantiating this call,
23076    /// we provide this method for API completeness.
23077    pub fn request(
23078        mut self,
23079        new_value: GoogleCloudRetailV2UserEvent,
23080    ) -> ProjectLocationCatalogUserEventWriteCall<'a, C> {
23081        self._request = new_value;
23082        self
23083    }
23084    /// Required. The parent catalog resource name, such as `projects/1234/locations/global/catalogs/default_catalog`.
23085    ///
23086    /// Sets the *parent* path property to the given value.
23087    ///
23088    /// Even though the property as already been set when instantiating this call,
23089    /// we provide this method for API completeness.
23090    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogUserEventWriteCall<'a, C> {
23091        self._parent = new_value.to_string();
23092        self
23093    }
23094    /// If set to true, the user event will be written asynchronously after validation, and the API will respond without waiting for the write. Therefore, silent failures can occur even if the API returns success. In case of silent failures, error messages can be found in Stackdriver logs.
23095    ///
23096    /// Sets the *write async* query property to the given value.
23097    pub fn write_async(
23098        mut self,
23099        new_value: bool,
23100    ) -> ProjectLocationCatalogUserEventWriteCall<'a, C> {
23101        self._write_async = Some(new_value);
23102        self
23103    }
23104    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23105    /// while executing the actual API request.
23106    ///
23107    /// ````text
23108    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23109    /// ````
23110    ///
23111    /// Sets the *delegate* property to the given value.
23112    pub fn delegate(
23113        mut self,
23114        new_value: &'a mut dyn common::Delegate,
23115    ) -> ProjectLocationCatalogUserEventWriteCall<'a, C> {
23116        self._delegate = Some(new_value);
23117        self
23118    }
23119
23120    /// Set any additional parameter of the query string used in the request.
23121    /// It should be used to set parameters which are not yet available through their own
23122    /// setters.
23123    ///
23124    /// Please note that this method must not be used to set any of the known parameters
23125    /// which have their own setter method. If done anyway, the request will fail.
23126    ///
23127    /// # Additional Parameters
23128    ///
23129    /// * *$.xgafv* (query-string) - V1 error format.
23130    /// * *access_token* (query-string) - OAuth access token.
23131    /// * *alt* (query-string) - Data format for response.
23132    /// * *callback* (query-string) - JSONP
23133    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23134    /// * *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.
23135    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23136    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23137    /// * *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.
23138    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23139    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23140    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogUserEventWriteCall<'a, C>
23141    where
23142        T: AsRef<str>,
23143    {
23144        self._additional_params
23145            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23146        self
23147    }
23148
23149    /// Identifies the authorization scope for the method you are building.
23150    ///
23151    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23152    /// [`Scope::CloudPlatform`].
23153    ///
23154    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23155    /// tokens for more than one scope.
23156    ///
23157    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23158    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23159    /// sufficient, a read-write scope will do as well.
23160    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogUserEventWriteCall<'a, C>
23161    where
23162        St: AsRef<str>,
23163    {
23164        self._scopes.insert(String::from(scope.as_ref()));
23165        self
23166    }
23167    /// Identifies the authorization scope(s) for the method you are building.
23168    ///
23169    /// See [`Self::add_scope()`] for details.
23170    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogUserEventWriteCall<'a, C>
23171    where
23172        I: IntoIterator<Item = St>,
23173        St: AsRef<str>,
23174    {
23175        self._scopes
23176            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23177        self
23178    }
23179
23180    /// Removes all scopes, and no default scope will be used either.
23181    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23182    /// for details).
23183    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUserEventWriteCall<'a, C> {
23184        self._scopes.clear();
23185        self
23186    }
23187}
23188
23189/// Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
23190///
23191/// A builder for the *locations.catalogs.completeQuery* method supported by a *project* resource.
23192/// It is not used directly, but through a [`ProjectMethods`] instance.
23193///
23194/// # Example
23195///
23196/// Instantiate a resource method builder
23197///
23198/// ```test_harness,no_run
23199/// # extern crate hyper;
23200/// # extern crate hyper_rustls;
23201/// # extern crate google_retail2 as retail2;
23202/// # async fn dox() {
23203/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23204///
23205/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23206/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23207/// #     .with_native_roots()
23208/// #     .unwrap()
23209/// #     .https_only()
23210/// #     .enable_http2()
23211/// #     .build();
23212///
23213/// # let executor = hyper_util::rt::TokioExecutor::new();
23214/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23215/// #     secret,
23216/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23217/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23218/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23219/// #     ),
23220/// # ).build().await.unwrap();
23221///
23222/// # let client = hyper_util::client::legacy::Client::builder(
23223/// #     hyper_util::rt::TokioExecutor::new()
23224/// # )
23225/// # .build(
23226/// #     hyper_rustls::HttpsConnectorBuilder::new()
23227/// #         .with_native_roots()
23228/// #         .unwrap()
23229/// #         .https_or_http()
23230/// #         .enable_http2()
23231/// #         .build()
23232/// # );
23233/// # let mut hub = CloudRetail::new(client, auth);
23234/// // You can configure optional parameters by calling the respective setters at will, and
23235/// // execute the final call using `doit()`.
23236/// // Values shown here are possibly random and not representative !
23237/// let result = hub.projects().locations_catalogs_complete_query("catalog")
23238///              .visitor_id("accusam")
23239///              .query("voluptua.")
23240///              .max_suggestions(-34)
23241///              .add_language_codes("dolore")
23242///              .entity("dolore")
23243///              .enable_attribute_suggestions(false)
23244///              .device_type("amet.")
23245///              .dataset("ea")
23246///              .doit().await;
23247/// # }
23248/// ```
23249pub struct ProjectLocationCatalogCompleteQueryCall<'a, C>
23250where
23251    C: 'a,
23252{
23253    hub: &'a CloudRetail<C>,
23254    _catalog: String,
23255    _visitor_id: Option<String>,
23256    _query: Option<String>,
23257    _max_suggestions: Option<i32>,
23258    _language_codes: Vec<String>,
23259    _entity: Option<String>,
23260    _enable_attribute_suggestions: Option<bool>,
23261    _device_type: Option<String>,
23262    _dataset: Option<String>,
23263    _delegate: Option<&'a mut dyn common::Delegate>,
23264    _additional_params: HashMap<String, String>,
23265    _scopes: BTreeSet<String>,
23266}
23267
23268impl<'a, C> common::CallBuilder for ProjectLocationCatalogCompleteQueryCall<'a, C> {}
23269
23270impl<'a, C> ProjectLocationCatalogCompleteQueryCall<'a, C>
23271where
23272    C: common::Connector,
23273{
23274    /// Perform the operation you have build so far.
23275    pub async fn doit(
23276        mut self,
23277    ) -> common::Result<(common::Response, GoogleCloudRetailV2CompleteQueryResponse)> {
23278        use std::borrow::Cow;
23279        use std::io::{Read, Seek};
23280
23281        use common::{url::Params, ToParts};
23282        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23283
23284        let mut dd = common::DefaultDelegate;
23285        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23286        dlg.begin(common::MethodInfo {
23287            id: "retail.projects.locations.catalogs.completeQuery",
23288            http_method: hyper::Method::GET,
23289        });
23290
23291        for &field in [
23292            "alt",
23293            "catalog",
23294            "visitorId",
23295            "query",
23296            "maxSuggestions",
23297            "languageCodes",
23298            "entity",
23299            "enableAttributeSuggestions",
23300            "deviceType",
23301            "dataset",
23302        ]
23303        .iter()
23304        {
23305            if self._additional_params.contains_key(field) {
23306                dlg.finished(false);
23307                return Err(common::Error::FieldClash(field));
23308            }
23309        }
23310
23311        let mut params = Params::with_capacity(11 + self._additional_params.len());
23312        params.push("catalog", self._catalog);
23313        if let Some(value) = self._visitor_id.as_ref() {
23314            params.push("visitorId", value);
23315        }
23316        if let Some(value) = self._query.as_ref() {
23317            params.push("query", value);
23318        }
23319        if let Some(value) = self._max_suggestions.as_ref() {
23320            params.push("maxSuggestions", value.to_string());
23321        }
23322        if !self._language_codes.is_empty() {
23323            for f in self._language_codes.iter() {
23324                params.push("languageCodes", f);
23325            }
23326        }
23327        if let Some(value) = self._entity.as_ref() {
23328            params.push("entity", value);
23329        }
23330        if let Some(value) = self._enable_attribute_suggestions.as_ref() {
23331            params.push("enableAttributeSuggestions", value.to_string());
23332        }
23333        if let Some(value) = self._device_type.as_ref() {
23334            params.push("deviceType", value);
23335        }
23336        if let Some(value) = self._dataset.as_ref() {
23337            params.push("dataset", value);
23338        }
23339
23340        params.extend(self._additional_params.iter());
23341
23342        params.push("alt", "json");
23343        let mut url = self.hub._base_url.clone() + "v2/{+catalog}:completeQuery";
23344        if self._scopes.is_empty() {
23345            self._scopes
23346                .insert(Scope::CloudPlatform.as_ref().to_string());
23347        }
23348
23349        #[allow(clippy::single_element_loop)]
23350        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
23351            url = params.uri_replacement(url, param_name, find_this, true);
23352        }
23353        {
23354            let to_remove = ["catalog"];
23355            params.remove_params(&to_remove);
23356        }
23357
23358        let url = params.parse_with_url(&url);
23359
23360        loop {
23361            let token = match self
23362                .hub
23363                .auth
23364                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23365                .await
23366            {
23367                Ok(token) => token,
23368                Err(e) => match dlg.token(e) {
23369                    Ok(token) => token,
23370                    Err(e) => {
23371                        dlg.finished(false);
23372                        return Err(common::Error::MissingToken(e));
23373                    }
23374                },
23375            };
23376            let mut req_result = {
23377                let client = &self.hub.client;
23378                dlg.pre_request();
23379                let mut req_builder = hyper::Request::builder()
23380                    .method(hyper::Method::GET)
23381                    .uri(url.as_str())
23382                    .header(USER_AGENT, self.hub._user_agent.clone());
23383
23384                if let Some(token) = token.as_ref() {
23385                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23386                }
23387
23388                let request = req_builder
23389                    .header(CONTENT_LENGTH, 0_u64)
23390                    .body(common::to_body::<String>(None));
23391
23392                client.request(request.unwrap()).await
23393            };
23394
23395            match req_result {
23396                Err(err) => {
23397                    if let common::Retry::After(d) = dlg.http_error(&err) {
23398                        sleep(d).await;
23399                        continue;
23400                    }
23401                    dlg.finished(false);
23402                    return Err(common::Error::HttpError(err));
23403                }
23404                Ok(res) => {
23405                    let (mut parts, body) = res.into_parts();
23406                    let mut body = common::Body::new(body);
23407                    if !parts.status.is_success() {
23408                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23409                        let error = serde_json::from_str(&common::to_string(&bytes));
23410                        let response = common::to_response(parts, bytes.into());
23411
23412                        if let common::Retry::After(d) =
23413                            dlg.http_failure(&response, error.as_ref().ok())
23414                        {
23415                            sleep(d).await;
23416                            continue;
23417                        }
23418
23419                        dlg.finished(false);
23420
23421                        return Err(match error {
23422                            Ok(value) => common::Error::BadRequest(value),
23423                            _ => common::Error::Failure(response),
23424                        });
23425                    }
23426                    let response = {
23427                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23428                        let encoded = common::to_string(&bytes);
23429                        match serde_json::from_str(&encoded) {
23430                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23431                            Err(error) => {
23432                                dlg.response_json_decode_error(&encoded, &error);
23433                                return Err(common::Error::JsonDecodeError(
23434                                    encoded.to_string(),
23435                                    error,
23436                                ));
23437                            }
23438                        }
23439                    };
23440
23441                    dlg.finished(true);
23442                    return Ok(response);
23443                }
23444            }
23445        }
23446    }
23447
23448    /// Required. Catalog for which the completion is performed. Full resource name of catalog, such as `projects/*/locations/global/catalogs/default_catalog`.
23449    ///
23450    /// Sets the *catalog* path property to the given value.
23451    ///
23452    /// Even though the property as already been set when instantiating this call,
23453    /// we provide this method for API completeness.
23454    pub fn catalog(mut self, new_value: &str) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23455        self._catalog = new_value.to_string();
23456        self
23457    }
23458    /// Recommended field. A unique identifier for tracking visitors. 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. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error is returned.
23459    ///
23460    /// Sets the *visitor id* query property to the given value.
23461    pub fn visitor_id(mut self, new_value: &str) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23462        self._visitor_id = Some(new_value.to_string());
23463        self
23464    }
23465    /// Required. The query used to generate suggestions. The maximum number of allowed characters is 255.
23466    ///
23467    /// Sets the *query* query property to the given value.
23468    pub fn query(mut self, new_value: &str) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23469        self._query = Some(new_value.to_string());
23470        self
23471    }
23472    /// Completion max suggestions. If left unset or set to 0, then will fallback to the configured value CompletionConfig.max_suggestions. The maximum allowed max suggestions is 20. If it is set higher, it will be capped by 20.
23473    ///
23474    /// Sets the *max suggestions* query property to the given value.
23475    pub fn max_suggestions(
23476        mut self,
23477        new_value: i32,
23478    ) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23479        self._max_suggestions = Some(new_value);
23480        self
23481    }
23482    /// Note that this field applies for `user-data` dataset only. For requests with `cloud-retail` dataset, setting this field has no effect. The language filters applied to the output suggestions. If set, it should contain the language of the query. If not set, suggestions are returned without considering language restrictions. This is the BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum number of language codes is 3.
23483    ///
23484    /// Append the given value to the *language codes* query property.
23485    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
23486    pub fn add_language_codes(
23487        mut self,
23488        new_value: &str,
23489    ) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23490        self._language_codes.push(new_value.to_string());
23491        self
23492    }
23493    /// The entity for customers who run multiple entities, domains, sites, or regions, for example, `Google US`, `Google Ads`, `Waymo`, `google.com`, `youtube.com`, etc. If this is set, it must be an exact match with UserEvent.entity to get per-entity autocomplete results. This field will be applied to `completion_results` only. It has no effect on the `attribute_results`. Also, this entity should be limited to 256 characters, if too long, it will be truncated to 256 characters in both generation and serving time, and may lead to mis-match. To ensure it works, please set the entity with string within 256 characters.
23494    ///
23495    /// Sets the *entity* query property to the given value.
23496    pub fn entity(mut self, new_value: &str) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23497        self._entity = Some(new_value.to_string());
23498        self
23499    }
23500    /// If true, attribute suggestions are enabled and provided in the response. This field is only available for the `cloud-retail` dataset.
23501    ///
23502    /// Sets the *enable attribute suggestions* query property to the given value.
23503    pub fn enable_attribute_suggestions(
23504        mut self,
23505        new_value: bool,
23506    ) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23507        self._enable_attribute_suggestions = Some(new_value);
23508        self
23509    }
23510    /// The device type context for completion suggestions. We recommend that you leave this field empty. It can apply different suggestions on different device types, e.g. `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device types. Supported formats: * `UNKNOWN_DEVICE_TYPE` * `DESKTOP` * `MOBILE` * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`.
23511    ///
23512    /// Sets the *device type* query property to the given value.
23513    pub fn device_type(
23514        mut self,
23515        new_value: &str,
23516    ) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23517        self._device_type = Some(new_value.to_string());
23518        self
23519    }
23520    /// Determines which dataset to use for fetching completion. "user-data" will use the dataset imported through CompletionService.ImportCompletionData. `cloud-retail` will use the dataset generated by Cloud Retail based on user events. If left empty, completions will be fetched from the `user-data` dataset. Current supported values: * user-data * cloud-retail: This option requires enabling auto-learning function first. See [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset).
23521    ///
23522    /// Sets the *dataset* query property to the given value.
23523    pub fn dataset(mut self, new_value: &str) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23524        self._dataset = Some(new_value.to_string());
23525        self
23526    }
23527    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23528    /// while executing the actual API request.
23529    ///
23530    /// ````text
23531    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23532    /// ````
23533    ///
23534    /// Sets the *delegate* property to the given value.
23535    pub fn delegate(
23536        mut self,
23537        new_value: &'a mut dyn common::Delegate,
23538    ) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23539        self._delegate = Some(new_value);
23540        self
23541    }
23542
23543    /// Set any additional parameter of the query string used in the request.
23544    /// It should be used to set parameters which are not yet available through their own
23545    /// setters.
23546    ///
23547    /// Please note that this method must not be used to set any of the known parameters
23548    /// which have their own setter method. If done anyway, the request will fail.
23549    ///
23550    /// # Additional Parameters
23551    ///
23552    /// * *$.xgafv* (query-string) - V1 error format.
23553    /// * *access_token* (query-string) - OAuth access token.
23554    /// * *alt* (query-string) - Data format for response.
23555    /// * *callback* (query-string) - JSONP
23556    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23557    /// * *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.
23558    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23559    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23560    /// * *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.
23561    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23562    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23563    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogCompleteQueryCall<'a, C>
23564    where
23565        T: AsRef<str>,
23566    {
23567        self._additional_params
23568            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23569        self
23570    }
23571
23572    /// Identifies the authorization scope for the method you are building.
23573    ///
23574    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23575    /// [`Scope::CloudPlatform`].
23576    ///
23577    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23578    /// tokens for more than one scope.
23579    ///
23580    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23581    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23582    /// sufficient, a read-write scope will do as well.
23583    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogCompleteQueryCall<'a, C>
23584    where
23585        St: AsRef<str>,
23586    {
23587        self._scopes.insert(String::from(scope.as_ref()));
23588        self
23589    }
23590    /// Identifies the authorization scope(s) for the method you are building.
23591    ///
23592    /// See [`Self::add_scope()`] for details.
23593    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogCompleteQueryCall<'a, C>
23594    where
23595        I: IntoIterator<Item = St>,
23596        St: AsRef<str>,
23597    {
23598        self._scopes
23599            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23600        self
23601    }
23602
23603    /// Removes all scopes, and no default scope will be used either.
23604    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23605    /// for details).
23606    pub fn clear_scopes(mut self) -> ProjectLocationCatalogCompleteQueryCall<'a, C> {
23607        self._scopes.clear();
23608        self
23609    }
23610}
23611
23612/// Exports analytics metrics. `Operation.response` is of type `ExportAnalyticsMetricsResponse`. `Operation.metadata` is of type `ExportMetadata`.
23613///
23614/// A builder for the *locations.catalogs.exportAnalyticsMetrics* method supported by a *project* resource.
23615/// It is not used directly, but through a [`ProjectMethods`] instance.
23616///
23617/// # Example
23618///
23619/// Instantiate a resource method builder
23620///
23621/// ```test_harness,no_run
23622/// # extern crate hyper;
23623/// # extern crate hyper_rustls;
23624/// # extern crate google_retail2 as retail2;
23625/// use retail2::api::GoogleCloudRetailV2ExportAnalyticsMetricsRequest;
23626/// # async fn dox() {
23627/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23628///
23629/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23630/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23631/// #     .with_native_roots()
23632/// #     .unwrap()
23633/// #     .https_only()
23634/// #     .enable_http2()
23635/// #     .build();
23636///
23637/// # let executor = hyper_util::rt::TokioExecutor::new();
23638/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23639/// #     secret,
23640/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23641/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23642/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23643/// #     ),
23644/// # ).build().await.unwrap();
23645///
23646/// # let client = hyper_util::client::legacy::Client::builder(
23647/// #     hyper_util::rt::TokioExecutor::new()
23648/// # )
23649/// # .build(
23650/// #     hyper_rustls::HttpsConnectorBuilder::new()
23651/// #         .with_native_roots()
23652/// #         .unwrap()
23653/// #         .https_or_http()
23654/// #         .enable_http2()
23655/// #         .build()
23656/// # );
23657/// # let mut hub = CloudRetail::new(client, auth);
23658/// // As the method needs a request, you would usually fill it with the desired information
23659/// // into the respective structure. Some of the parts shown here might not be applicable !
23660/// // Values shown here are possibly random and not representative !
23661/// let mut req = GoogleCloudRetailV2ExportAnalyticsMetricsRequest::default();
23662///
23663/// // You can configure optional parameters by calling the respective setters at will, and
23664/// // execute the final call using `doit()`.
23665/// // Values shown here are possibly random and not representative !
23666/// let result = hub.projects().locations_catalogs_export_analytics_metrics(req, "catalog")
23667///              .doit().await;
23668/// # }
23669/// ```
23670pub struct ProjectLocationCatalogExportAnalyticsMetricCall<'a, C>
23671where
23672    C: 'a,
23673{
23674    hub: &'a CloudRetail<C>,
23675    _request: GoogleCloudRetailV2ExportAnalyticsMetricsRequest,
23676    _catalog: String,
23677    _delegate: Option<&'a mut dyn common::Delegate>,
23678    _additional_params: HashMap<String, String>,
23679    _scopes: BTreeSet<String>,
23680}
23681
23682impl<'a, C> common::CallBuilder for ProjectLocationCatalogExportAnalyticsMetricCall<'a, C> {}
23683
23684impl<'a, C> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C>
23685where
23686    C: common::Connector,
23687{
23688    /// Perform the operation you have build so far.
23689    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
23690        use std::borrow::Cow;
23691        use std::io::{Read, Seek};
23692
23693        use common::{url::Params, ToParts};
23694        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23695
23696        let mut dd = common::DefaultDelegate;
23697        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23698        dlg.begin(common::MethodInfo {
23699            id: "retail.projects.locations.catalogs.exportAnalyticsMetrics",
23700            http_method: hyper::Method::POST,
23701        });
23702
23703        for &field in ["alt", "catalog"].iter() {
23704            if self._additional_params.contains_key(field) {
23705                dlg.finished(false);
23706                return Err(common::Error::FieldClash(field));
23707            }
23708        }
23709
23710        let mut params = Params::with_capacity(4 + self._additional_params.len());
23711        params.push("catalog", self._catalog);
23712
23713        params.extend(self._additional_params.iter());
23714
23715        params.push("alt", "json");
23716        let mut url = self.hub._base_url.clone() + "v2/{+catalog}:exportAnalyticsMetrics";
23717        if self._scopes.is_empty() {
23718            self._scopes
23719                .insert(Scope::CloudPlatform.as_ref().to_string());
23720        }
23721
23722        #[allow(clippy::single_element_loop)]
23723        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
23724            url = params.uri_replacement(url, param_name, find_this, true);
23725        }
23726        {
23727            let to_remove = ["catalog"];
23728            params.remove_params(&to_remove);
23729        }
23730
23731        let url = params.parse_with_url(&url);
23732
23733        let mut json_mime_type = mime::APPLICATION_JSON;
23734        let mut request_value_reader = {
23735            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23736            common::remove_json_null_values(&mut value);
23737            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23738            serde_json::to_writer(&mut dst, &value).unwrap();
23739            dst
23740        };
23741        let request_size = request_value_reader
23742            .seek(std::io::SeekFrom::End(0))
23743            .unwrap();
23744        request_value_reader
23745            .seek(std::io::SeekFrom::Start(0))
23746            .unwrap();
23747
23748        loop {
23749            let token = match self
23750                .hub
23751                .auth
23752                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23753                .await
23754            {
23755                Ok(token) => token,
23756                Err(e) => match dlg.token(e) {
23757                    Ok(token) => token,
23758                    Err(e) => {
23759                        dlg.finished(false);
23760                        return Err(common::Error::MissingToken(e));
23761                    }
23762                },
23763            };
23764            request_value_reader
23765                .seek(std::io::SeekFrom::Start(0))
23766                .unwrap();
23767            let mut req_result = {
23768                let client = &self.hub.client;
23769                dlg.pre_request();
23770                let mut req_builder = hyper::Request::builder()
23771                    .method(hyper::Method::POST)
23772                    .uri(url.as_str())
23773                    .header(USER_AGENT, self.hub._user_agent.clone());
23774
23775                if let Some(token) = token.as_ref() {
23776                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23777                }
23778
23779                let request = req_builder
23780                    .header(CONTENT_TYPE, json_mime_type.to_string())
23781                    .header(CONTENT_LENGTH, request_size as u64)
23782                    .body(common::to_body(
23783                        request_value_reader.get_ref().clone().into(),
23784                    ));
23785
23786                client.request(request.unwrap()).await
23787            };
23788
23789            match req_result {
23790                Err(err) => {
23791                    if let common::Retry::After(d) = dlg.http_error(&err) {
23792                        sleep(d).await;
23793                        continue;
23794                    }
23795                    dlg.finished(false);
23796                    return Err(common::Error::HttpError(err));
23797                }
23798                Ok(res) => {
23799                    let (mut parts, body) = res.into_parts();
23800                    let mut body = common::Body::new(body);
23801                    if !parts.status.is_success() {
23802                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23803                        let error = serde_json::from_str(&common::to_string(&bytes));
23804                        let response = common::to_response(parts, bytes.into());
23805
23806                        if let common::Retry::After(d) =
23807                            dlg.http_failure(&response, error.as_ref().ok())
23808                        {
23809                            sleep(d).await;
23810                            continue;
23811                        }
23812
23813                        dlg.finished(false);
23814
23815                        return Err(match error {
23816                            Ok(value) => common::Error::BadRequest(value),
23817                            _ => common::Error::Failure(response),
23818                        });
23819                    }
23820                    let response = {
23821                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23822                        let encoded = common::to_string(&bytes);
23823                        match serde_json::from_str(&encoded) {
23824                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23825                            Err(error) => {
23826                                dlg.response_json_decode_error(&encoded, &error);
23827                                return Err(common::Error::JsonDecodeError(
23828                                    encoded.to_string(),
23829                                    error,
23830                                ));
23831                            }
23832                        }
23833                    };
23834
23835                    dlg.finished(true);
23836                    return Ok(response);
23837                }
23838            }
23839        }
23840    }
23841
23842    ///
23843    /// Sets the *request* property to the given value.
23844    ///
23845    /// Even though the property as already been set when instantiating this call,
23846    /// we provide this method for API completeness.
23847    pub fn request(
23848        mut self,
23849        new_value: GoogleCloudRetailV2ExportAnalyticsMetricsRequest,
23850    ) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C> {
23851        self._request = new_value;
23852        self
23853    }
23854    /// Required. Full resource name of the parent catalog. Expected format: `projects/*/locations/*/catalogs/*`
23855    ///
23856    /// Sets the *catalog* path property to the given value.
23857    ///
23858    /// Even though the property as already been set when instantiating this call,
23859    /// we provide this method for API completeness.
23860    pub fn catalog(
23861        mut self,
23862        new_value: &str,
23863    ) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C> {
23864        self._catalog = new_value.to_string();
23865        self
23866    }
23867    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23868    /// while executing the actual API request.
23869    ///
23870    /// ````text
23871    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23872    /// ````
23873    ///
23874    /// Sets the *delegate* property to the given value.
23875    pub fn delegate(
23876        mut self,
23877        new_value: &'a mut dyn common::Delegate,
23878    ) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C> {
23879        self._delegate = Some(new_value);
23880        self
23881    }
23882
23883    /// Set any additional parameter of the query string used in the request.
23884    /// It should be used to set parameters which are not yet available through their own
23885    /// setters.
23886    ///
23887    /// Please note that this method must not be used to set any of the known parameters
23888    /// which have their own setter method. If done anyway, the request will fail.
23889    ///
23890    /// # Additional Parameters
23891    ///
23892    /// * *$.xgafv* (query-string) - V1 error format.
23893    /// * *access_token* (query-string) - OAuth access token.
23894    /// * *alt* (query-string) - Data format for response.
23895    /// * *callback* (query-string) - JSONP
23896    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23897    /// * *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.
23898    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23899    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23900    /// * *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.
23901    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23902    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23903    pub fn param<T>(
23904        mut self,
23905        name: T,
23906        value: T,
23907    ) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C>
23908    where
23909        T: AsRef<str>,
23910    {
23911        self._additional_params
23912            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23913        self
23914    }
23915
23916    /// Identifies the authorization scope for the method you are building.
23917    ///
23918    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23919    /// [`Scope::CloudPlatform`].
23920    ///
23921    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23922    /// tokens for more than one scope.
23923    ///
23924    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23925    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23926    /// sufficient, a read-write scope will do as well.
23927    pub fn add_scope<St>(
23928        mut self,
23929        scope: St,
23930    ) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C>
23931    where
23932        St: AsRef<str>,
23933    {
23934        self._scopes.insert(String::from(scope.as_ref()));
23935        self
23936    }
23937    /// Identifies the authorization scope(s) for the method you are building.
23938    ///
23939    /// See [`Self::add_scope()`] for details.
23940    pub fn add_scopes<I, St>(
23941        mut self,
23942        scopes: I,
23943    ) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C>
23944    where
23945        I: IntoIterator<Item = St>,
23946        St: AsRef<str>,
23947    {
23948        self._scopes
23949            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23950        self
23951    }
23952
23953    /// Removes all scopes, and no default scope will be used either.
23954    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23955    /// for details).
23956    pub fn clear_scopes(mut self) -> ProjectLocationCatalogExportAnalyticsMetricCall<'a, C> {
23957        self._scopes.clear();
23958        self
23959    }
23960}
23961
23962/// Gets an AttributesConfig.
23963///
23964/// A builder for the *locations.catalogs.getAttributesConfig* method supported by a *project* resource.
23965/// It is not used directly, but through a [`ProjectMethods`] instance.
23966///
23967/// # Example
23968///
23969/// Instantiate a resource method builder
23970///
23971/// ```test_harness,no_run
23972/// # extern crate hyper;
23973/// # extern crate hyper_rustls;
23974/// # extern crate google_retail2 as retail2;
23975/// # async fn dox() {
23976/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23977///
23978/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23979/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23980/// #     .with_native_roots()
23981/// #     .unwrap()
23982/// #     .https_only()
23983/// #     .enable_http2()
23984/// #     .build();
23985///
23986/// # let executor = hyper_util::rt::TokioExecutor::new();
23987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23988/// #     secret,
23989/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23990/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23991/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23992/// #     ),
23993/// # ).build().await.unwrap();
23994///
23995/// # let client = hyper_util::client::legacy::Client::builder(
23996/// #     hyper_util::rt::TokioExecutor::new()
23997/// # )
23998/// # .build(
23999/// #     hyper_rustls::HttpsConnectorBuilder::new()
24000/// #         .with_native_roots()
24001/// #         .unwrap()
24002/// #         .https_or_http()
24003/// #         .enable_http2()
24004/// #         .build()
24005/// # );
24006/// # let mut hub = CloudRetail::new(client, auth);
24007/// // You can configure optional parameters by calling the respective setters at will, and
24008/// // execute the final call using `doit()`.
24009/// // Values shown here are possibly random and not representative !
24010/// let result = hub.projects().locations_catalogs_get_attributes_config("name")
24011///              .doit().await;
24012/// # }
24013/// ```
24014pub struct ProjectLocationCatalogGetAttributesConfigCall<'a, C>
24015where
24016    C: 'a,
24017{
24018    hub: &'a CloudRetail<C>,
24019    _name: String,
24020    _delegate: Option<&'a mut dyn common::Delegate>,
24021    _additional_params: HashMap<String, String>,
24022    _scopes: BTreeSet<String>,
24023}
24024
24025impl<'a, C> common::CallBuilder for ProjectLocationCatalogGetAttributesConfigCall<'a, C> {}
24026
24027impl<'a, C> ProjectLocationCatalogGetAttributesConfigCall<'a, C>
24028where
24029    C: common::Connector,
24030{
24031    /// Perform the operation you have build so far.
24032    pub async fn doit(
24033        mut self,
24034    ) -> common::Result<(common::Response, GoogleCloudRetailV2AttributesConfig)> {
24035        use std::borrow::Cow;
24036        use std::io::{Read, Seek};
24037
24038        use common::{url::Params, ToParts};
24039        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24040
24041        let mut dd = common::DefaultDelegate;
24042        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24043        dlg.begin(common::MethodInfo {
24044            id: "retail.projects.locations.catalogs.getAttributesConfig",
24045            http_method: hyper::Method::GET,
24046        });
24047
24048        for &field in ["alt", "name"].iter() {
24049            if self._additional_params.contains_key(field) {
24050                dlg.finished(false);
24051                return Err(common::Error::FieldClash(field));
24052            }
24053        }
24054
24055        let mut params = Params::with_capacity(3 + self._additional_params.len());
24056        params.push("name", self._name);
24057
24058        params.extend(self._additional_params.iter());
24059
24060        params.push("alt", "json");
24061        let mut url = self.hub._base_url.clone() + "v2/{+name}";
24062        if self._scopes.is_empty() {
24063            self._scopes
24064                .insert(Scope::CloudPlatform.as_ref().to_string());
24065        }
24066
24067        #[allow(clippy::single_element_loop)]
24068        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24069            url = params.uri_replacement(url, param_name, find_this, true);
24070        }
24071        {
24072            let to_remove = ["name"];
24073            params.remove_params(&to_remove);
24074        }
24075
24076        let url = params.parse_with_url(&url);
24077
24078        loop {
24079            let token = match self
24080                .hub
24081                .auth
24082                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24083                .await
24084            {
24085                Ok(token) => token,
24086                Err(e) => match dlg.token(e) {
24087                    Ok(token) => token,
24088                    Err(e) => {
24089                        dlg.finished(false);
24090                        return Err(common::Error::MissingToken(e));
24091                    }
24092                },
24093            };
24094            let mut req_result = {
24095                let client = &self.hub.client;
24096                dlg.pre_request();
24097                let mut req_builder = hyper::Request::builder()
24098                    .method(hyper::Method::GET)
24099                    .uri(url.as_str())
24100                    .header(USER_AGENT, self.hub._user_agent.clone());
24101
24102                if let Some(token) = token.as_ref() {
24103                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24104                }
24105
24106                let request = req_builder
24107                    .header(CONTENT_LENGTH, 0_u64)
24108                    .body(common::to_body::<String>(None));
24109
24110                client.request(request.unwrap()).await
24111            };
24112
24113            match req_result {
24114                Err(err) => {
24115                    if let common::Retry::After(d) = dlg.http_error(&err) {
24116                        sleep(d).await;
24117                        continue;
24118                    }
24119                    dlg.finished(false);
24120                    return Err(common::Error::HttpError(err));
24121                }
24122                Ok(res) => {
24123                    let (mut parts, body) = res.into_parts();
24124                    let mut body = common::Body::new(body);
24125                    if !parts.status.is_success() {
24126                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24127                        let error = serde_json::from_str(&common::to_string(&bytes));
24128                        let response = common::to_response(parts, bytes.into());
24129
24130                        if let common::Retry::After(d) =
24131                            dlg.http_failure(&response, error.as_ref().ok())
24132                        {
24133                            sleep(d).await;
24134                            continue;
24135                        }
24136
24137                        dlg.finished(false);
24138
24139                        return Err(match error {
24140                            Ok(value) => common::Error::BadRequest(value),
24141                            _ => common::Error::Failure(response),
24142                        });
24143                    }
24144                    let response = {
24145                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24146                        let encoded = common::to_string(&bytes);
24147                        match serde_json::from_str(&encoded) {
24148                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24149                            Err(error) => {
24150                                dlg.response_json_decode_error(&encoded, &error);
24151                                return Err(common::Error::JsonDecodeError(
24152                                    encoded.to_string(),
24153                                    error,
24154                                ));
24155                            }
24156                        }
24157                    };
24158
24159                    dlg.finished(true);
24160                    return Ok(response);
24161                }
24162            }
24163        }
24164    }
24165
24166    /// Required. Full AttributesConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
24167    ///
24168    /// Sets the *name* path property to the given value.
24169    ///
24170    /// Even though the property as already been set when instantiating this call,
24171    /// we provide this method for API completeness.
24172    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogGetAttributesConfigCall<'a, C> {
24173        self._name = new_value.to_string();
24174        self
24175    }
24176    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24177    /// while executing the actual API request.
24178    ///
24179    /// ````text
24180    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24181    /// ````
24182    ///
24183    /// Sets the *delegate* property to the given value.
24184    pub fn delegate(
24185        mut self,
24186        new_value: &'a mut dyn common::Delegate,
24187    ) -> ProjectLocationCatalogGetAttributesConfigCall<'a, C> {
24188        self._delegate = Some(new_value);
24189        self
24190    }
24191
24192    /// Set any additional parameter of the query string used in the request.
24193    /// It should be used to set parameters which are not yet available through their own
24194    /// setters.
24195    ///
24196    /// Please note that this method must not be used to set any of the known parameters
24197    /// which have their own setter method. If done anyway, the request will fail.
24198    ///
24199    /// # Additional Parameters
24200    ///
24201    /// * *$.xgafv* (query-string) - V1 error format.
24202    /// * *access_token* (query-string) - OAuth access token.
24203    /// * *alt* (query-string) - Data format for response.
24204    /// * *callback* (query-string) - JSONP
24205    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24206    /// * *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.
24207    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24208    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24209    /// * *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.
24210    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24211    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24212    pub fn param<T>(
24213        mut self,
24214        name: T,
24215        value: T,
24216    ) -> ProjectLocationCatalogGetAttributesConfigCall<'a, C>
24217    where
24218        T: AsRef<str>,
24219    {
24220        self._additional_params
24221            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24222        self
24223    }
24224
24225    /// Identifies the authorization scope for the method you are building.
24226    ///
24227    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24228    /// [`Scope::CloudPlatform`].
24229    ///
24230    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24231    /// tokens for more than one scope.
24232    ///
24233    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24234    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24235    /// sufficient, a read-write scope will do as well.
24236    pub fn add_scope<St>(
24237        mut self,
24238        scope: St,
24239    ) -> ProjectLocationCatalogGetAttributesConfigCall<'a, C>
24240    where
24241        St: AsRef<str>,
24242    {
24243        self._scopes.insert(String::from(scope.as_ref()));
24244        self
24245    }
24246    /// Identifies the authorization scope(s) for the method you are building.
24247    ///
24248    /// See [`Self::add_scope()`] for details.
24249    pub fn add_scopes<I, St>(
24250        mut self,
24251        scopes: I,
24252    ) -> ProjectLocationCatalogGetAttributesConfigCall<'a, C>
24253    where
24254        I: IntoIterator<Item = St>,
24255        St: AsRef<str>,
24256    {
24257        self._scopes
24258            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24259        self
24260    }
24261
24262    /// Removes all scopes, and no default scope will be used either.
24263    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24264    /// for details).
24265    pub fn clear_scopes(mut self) -> ProjectLocationCatalogGetAttributesConfigCall<'a, C> {
24266        self._scopes.clear();
24267        self
24268    }
24269}
24270
24271/// Gets a CompletionConfig.
24272///
24273/// A builder for the *locations.catalogs.getCompletionConfig* method supported by a *project* resource.
24274/// It is not used directly, but through a [`ProjectMethods`] instance.
24275///
24276/// # Example
24277///
24278/// Instantiate a resource method builder
24279///
24280/// ```test_harness,no_run
24281/// # extern crate hyper;
24282/// # extern crate hyper_rustls;
24283/// # extern crate google_retail2 as retail2;
24284/// # async fn dox() {
24285/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24286///
24287/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24288/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24289/// #     .with_native_roots()
24290/// #     .unwrap()
24291/// #     .https_only()
24292/// #     .enable_http2()
24293/// #     .build();
24294///
24295/// # let executor = hyper_util::rt::TokioExecutor::new();
24296/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24297/// #     secret,
24298/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24299/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24300/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24301/// #     ),
24302/// # ).build().await.unwrap();
24303///
24304/// # let client = hyper_util::client::legacy::Client::builder(
24305/// #     hyper_util::rt::TokioExecutor::new()
24306/// # )
24307/// # .build(
24308/// #     hyper_rustls::HttpsConnectorBuilder::new()
24309/// #         .with_native_roots()
24310/// #         .unwrap()
24311/// #         .https_or_http()
24312/// #         .enable_http2()
24313/// #         .build()
24314/// # );
24315/// # let mut hub = CloudRetail::new(client, auth);
24316/// // You can configure optional parameters by calling the respective setters at will, and
24317/// // execute the final call using `doit()`.
24318/// // Values shown here are possibly random and not representative !
24319/// let result = hub.projects().locations_catalogs_get_completion_config("name")
24320///              .doit().await;
24321/// # }
24322/// ```
24323pub struct ProjectLocationCatalogGetCompletionConfigCall<'a, C>
24324where
24325    C: 'a,
24326{
24327    hub: &'a CloudRetail<C>,
24328    _name: String,
24329    _delegate: Option<&'a mut dyn common::Delegate>,
24330    _additional_params: HashMap<String, String>,
24331    _scopes: BTreeSet<String>,
24332}
24333
24334impl<'a, C> common::CallBuilder for ProjectLocationCatalogGetCompletionConfigCall<'a, C> {}
24335
24336impl<'a, C> ProjectLocationCatalogGetCompletionConfigCall<'a, C>
24337where
24338    C: common::Connector,
24339{
24340    /// Perform the operation you have build so far.
24341    pub async fn doit(
24342        mut self,
24343    ) -> common::Result<(common::Response, GoogleCloudRetailV2CompletionConfig)> {
24344        use std::borrow::Cow;
24345        use std::io::{Read, Seek};
24346
24347        use common::{url::Params, ToParts};
24348        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24349
24350        let mut dd = common::DefaultDelegate;
24351        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24352        dlg.begin(common::MethodInfo {
24353            id: "retail.projects.locations.catalogs.getCompletionConfig",
24354            http_method: hyper::Method::GET,
24355        });
24356
24357        for &field in ["alt", "name"].iter() {
24358            if self._additional_params.contains_key(field) {
24359                dlg.finished(false);
24360                return Err(common::Error::FieldClash(field));
24361            }
24362        }
24363
24364        let mut params = Params::with_capacity(3 + self._additional_params.len());
24365        params.push("name", self._name);
24366
24367        params.extend(self._additional_params.iter());
24368
24369        params.push("alt", "json");
24370        let mut url = self.hub._base_url.clone() + "v2/{+name}";
24371        if self._scopes.is_empty() {
24372            self._scopes
24373                .insert(Scope::CloudPlatform.as_ref().to_string());
24374        }
24375
24376        #[allow(clippy::single_element_loop)]
24377        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24378            url = params.uri_replacement(url, param_name, find_this, true);
24379        }
24380        {
24381            let to_remove = ["name"];
24382            params.remove_params(&to_remove);
24383        }
24384
24385        let url = params.parse_with_url(&url);
24386
24387        loop {
24388            let token = match self
24389                .hub
24390                .auth
24391                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24392                .await
24393            {
24394                Ok(token) => token,
24395                Err(e) => match dlg.token(e) {
24396                    Ok(token) => token,
24397                    Err(e) => {
24398                        dlg.finished(false);
24399                        return Err(common::Error::MissingToken(e));
24400                    }
24401                },
24402            };
24403            let mut req_result = {
24404                let client = &self.hub.client;
24405                dlg.pre_request();
24406                let mut req_builder = hyper::Request::builder()
24407                    .method(hyper::Method::GET)
24408                    .uri(url.as_str())
24409                    .header(USER_AGENT, self.hub._user_agent.clone());
24410
24411                if let Some(token) = token.as_ref() {
24412                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24413                }
24414
24415                let request = req_builder
24416                    .header(CONTENT_LENGTH, 0_u64)
24417                    .body(common::to_body::<String>(None));
24418
24419                client.request(request.unwrap()).await
24420            };
24421
24422            match req_result {
24423                Err(err) => {
24424                    if let common::Retry::After(d) = dlg.http_error(&err) {
24425                        sleep(d).await;
24426                        continue;
24427                    }
24428                    dlg.finished(false);
24429                    return Err(common::Error::HttpError(err));
24430                }
24431                Ok(res) => {
24432                    let (mut parts, body) = res.into_parts();
24433                    let mut body = common::Body::new(body);
24434                    if !parts.status.is_success() {
24435                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24436                        let error = serde_json::from_str(&common::to_string(&bytes));
24437                        let response = common::to_response(parts, bytes.into());
24438
24439                        if let common::Retry::After(d) =
24440                            dlg.http_failure(&response, error.as_ref().ok())
24441                        {
24442                            sleep(d).await;
24443                            continue;
24444                        }
24445
24446                        dlg.finished(false);
24447
24448                        return Err(match error {
24449                            Ok(value) => common::Error::BadRequest(value),
24450                            _ => common::Error::Failure(response),
24451                        });
24452                    }
24453                    let response = {
24454                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24455                        let encoded = common::to_string(&bytes);
24456                        match serde_json::from_str(&encoded) {
24457                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24458                            Err(error) => {
24459                                dlg.response_json_decode_error(&encoded, &error);
24460                                return Err(common::Error::JsonDecodeError(
24461                                    encoded.to_string(),
24462                                    error,
24463                                ));
24464                            }
24465                        }
24466                    };
24467
24468                    dlg.finished(true);
24469                    return Ok(response);
24470                }
24471            }
24472        }
24473    }
24474
24475    /// Required. Full CompletionConfig resource name. Format: `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig`
24476    ///
24477    /// Sets the *name* path property to the given value.
24478    ///
24479    /// Even though the property as already been set when instantiating this call,
24480    /// we provide this method for API completeness.
24481    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogGetCompletionConfigCall<'a, C> {
24482        self._name = new_value.to_string();
24483        self
24484    }
24485    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24486    /// while executing the actual API request.
24487    ///
24488    /// ````text
24489    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24490    /// ````
24491    ///
24492    /// Sets the *delegate* property to the given value.
24493    pub fn delegate(
24494        mut self,
24495        new_value: &'a mut dyn common::Delegate,
24496    ) -> ProjectLocationCatalogGetCompletionConfigCall<'a, C> {
24497        self._delegate = Some(new_value);
24498        self
24499    }
24500
24501    /// Set any additional parameter of the query string used in the request.
24502    /// It should be used to set parameters which are not yet available through their own
24503    /// setters.
24504    ///
24505    /// Please note that this method must not be used to set any of the known parameters
24506    /// which have their own setter method. If done anyway, the request will fail.
24507    ///
24508    /// # Additional Parameters
24509    ///
24510    /// * *$.xgafv* (query-string) - V1 error format.
24511    /// * *access_token* (query-string) - OAuth access token.
24512    /// * *alt* (query-string) - Data format for response.
24513    /// * *callback* (query-string) - JSONP
24514    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24515    /// * *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.
24516    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24517    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24518    /// * *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.
24519    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24520    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24521    pub fn param<T>(
24522        mut self,
24523        name: T,
24524        value: T,
24525    ) -> ProjectLocationCatalogGetCompletionConfigCall<'a, C>
24526    where
24527        T: AsRef<str>,
24528    {
24529        self._additional_params
24530            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24531        self
24532    }
24533
24534    /// Identifies the authorization scope for the method you are building.
24535    ///
24536    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24537    /// [`Scope::CloudPlatform`].
24538    ///
24539    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24540    /// tokens for more than one scope.
24541    ///
24542    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24543    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24544    /// sufficient, a read-write scope will do as well.
24545    pub fn add_scope<St>(
24546        mut self,
24547        scope: St,
24548    ) -> ProjectLocationCatalogGetCompletionConfigCall<'a, C>
24549    where
24550        St: AsRef<str>,
24551    {
24552        self._scopes.insert(String::from(scope.as_ref()));
24553        self
24554    }
24555    /// Identifies the authorization scope(s) for the method you are building.
24556    ///
24557    /// See [`Self::add_scope()`] for details.
24558    pub fn add_scopes<I, St>(
24559        mut self,
24560        scopes: I,
24561    ) -> ProjectLocationCatalogGetCompletionConfigCall<'a, C>
24562    where
24563        I: IntoIterator<Item = St>,
24564        St: AsRef<str>,
24565    {
24566        self._scopes
24567            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24568        self
24569    }
24570
24571    /// Removes all scopes, and no default scope will be used either.
24572    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24573    /// for details).
24574    pub fn clear_scopes(mut self) -> ProjectLocationCatalogGetCompletionConfigCall<'a, C> {
24575        self._scopes.clear();
24576        self
24577    }
24578}
24579
24580/// Returns the conversational search customization config for a given catalog.
24581///
24582/// A builder for the *locations.catalogs.getConversationalSearchCustomizationConfig* method supported by a *project* resource.
24583/// It is not used directly, but through a [`ProjectMethods`] instance.
24584///
24585/// # Example
24586///
24587/// Instantiate a resource method builder
24588///
24589/// ```test_harness,no_run
24590/// # extern crate hyper;
24591/// # extern crate hyper_rustls;
24592/// # extern crate google_retail2 as retail2;
24593/// # async fn dox() {
24594/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24595///
24596/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24597/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24598/// #     .with_native_roots()
24599/// #     .unwrap()
24600/// #     .https_only()
24601/// #     .enable_http2()
24602/// #     .build();
24603///
24604/// # let executor = hyper_util::rt::TokioExecutor::new();
24605/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24606/// #     secret,
24607/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24608/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24609/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24610/// #     ),
24611/// # ).build().await.unwrap();
24612///
24613/// # let client = hyper_util::client::legacy::Client::builder(
24614/// #     hyper_util::rt::TokioExecutor::new()
24615/// # )
24616/// # .build(
24617/// #     hyper_rustls::HttpsConnectorBuilder::new()
24618/// #         .with_native_roots()
24619/// #         .unwrap()
24620/// #         .https_or_http()
24621/// #         .enable_http2()
24622/// #         .build()
24623/// # );
24624/// # let mut hub = CloudRetail::new(client, auth);
24625/// // You can configure optional parameters by calling the respective setters at will, and
24626/// // execute the final call using `doit()`.
24627/// // Values shown here are possibly random and not representative !
24628/// let result = hub.projects().locations_catalogs_get_conversational_search_customization_config("name")
24629///              .doit().await;
24630/// # }
24631/// ```
24632pub struct ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C>
24633where
24634    C: 'a,
24635{
24636    hub: &'a CloudRetail<C>,
24637    _name: String,
24638    _delegate: Option<&'a mut dyn common::Delegate>,
24639    _additional_params: HashMap<String, String>,
24640    _scopes: BTreeSet<String>,
24641}
24642
24643impl<'a, C> common::CallBuilder
24644    for ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C>
24645{
24646}
24647
24648impl<'a, C> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C>
24649where
24650    C: common::Connector,
24651{
24652    /// Perform the operation you have build so far.
24653    pub async fn doit(
24654        mut self,
24655    ) -> common::Result<(
24656        common::Response,
24657        GoogleCloudRetailV2ConversationalSearchCustomizationConfig,
24658    )> {
24659        use std::borrow::Cow;
24660        use std::io::{Read, Seek};
24661
24662        use common::{url::Params, ToParts};
24663        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24664
24665        let mut dd = common::DefaultDelegate;
24666        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24667        dlg.begin(common::MethodInfo {
24668            id: "retail.projects.locations.catalogs.getConversationalSearchCustomizationConfig",
24669            http_method: hyper::Method::GET,
24670        });
24671
24672        for &field in ["alt", "name"].iter() {
24673            if self._additional_params.contains_key(field) {
24674                dlg.finished(false);
24675                return Err(common::Error::FieldClash(field));
24676            }
24677        }
24678
24679        let mut params = Params::with_capacity(3 + self._additional_params.len());
24680        params.push("name", self._name);
24681
24682        params.extend(self._additional_params.iter());
24683
24684        params.push("alt", "json");
24685        let mut url =
24686            self.hub._base_url.clone() + "v2/{+name}/conversationalSearchCustomizationConfig";
24687        if self._scopes.is_empty() {
24688            self._scopes
24689                .insert(Scope::CloudPlatform.as_ref().to_string());
24690        }
24691
24692        #[allow(clippy::single_element_loop)]
24693        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24694            url = params.uri_replacement(url, param_name, find_this, true);
24695        }
24696        {
24697            let to_remove = ["name"];
24698            params.remove_params(&to_remove);
24699        }
24700
24701        let url = params.parse_with_url(&url);
24702
24703        loop {
24704            let token = match self
24705                .hub
24706                .auth
24707                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24708                .await
24709            {
24710                Ok(token) => token,
24711                Err(e) => match dlg.token(e) {
24712                    Ok(token) => token,
24713                    Err(e) => {
24714                        dlg.finished(false);
24715                        return Err(common::Error::MissingToken(e));
24716                    }
24717                },
24718            };
24719            let mut req_result = {
24720                let client = &self.hub.client;
24721                dlg.pre_request();
24722                let mut req_builder = hyper::Request::builder()
24723                    .method(hyper::Method::GET)
24724                    .uri(url.as_str())
24725                    .header(USER_AGENT, self.hub._user_agent.clone());
24726
24727                if let Some(token) = token.as_ref() {
24728                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24729                }
24730
24731                let request = req_builder
24732                    .header(CONTENT_LENGTH, 0_u64)
24733                    .body(common::to_body::<String>(None));
24734
24735                client.request(request.unwrap()).await
24736            };
24737
24738            match req_result {
24739                Err(err) => {
24740                    if let common::Retry::After(d) = dlg.http_error(&err) {
24741                        sleep(d).await;
24742                        continue;
24743                    }
24744                    dlg.finished(false);
24745                    return Err(common::Error::HttpError(err));
24746                }
24747                Ok(res) => {
24748                    let (mut parts, body) = res.into_parts();
24749                    let mut body = common::Body::new(body);
24750                    if !parts.status.is_success() {
24751                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24752                        let error = serde_json::from_str(&common::to_string(&bytes));
24753                        let response = common::to_response(parts, bytes.into());
24754
24755                        if let common::Retry::After(d) =
24756                            dlg.http_failure(&response, error.as_ref().ok())
24757                        {
24758                            sleep(d).await;
24759                            continue;
24760                        }
24761
24762                        dlg.finished(false);
24763
24764                        return Err(match error {
24765                            Ok(value) => common::Error::BadRequest(value),
24766                            _ => common::Error::Failure(response),
24767                        });
24768                    }
24769                    let response = {
24770                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24771                        let encoded = common::to_string(&bytes);
24772                        match serde_json::from_str(&encoded) {
24773                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24774                            Err(error) => {
24775                                dlg.response_json_decode_error(&encoded, &error);
24776                                return Err(common::Error::JsonDecodeError(
24777                                    encoded.to_string(),
24778                                    error,
24779                                ));
24780                            }
24781                        }
24782                    };
24783
24784                    dlg.finished(true);
24785                    return Ok(response);
24786                }
24787            }
24788        }
24789    }
24790
24791    /// Required. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
24792    ///
24793    /// Sets the *name* path property to the given value.
24794    ///
24795    /// Even though the property as already been set when instantiating this call,
24796    /// we provide this method for API completeness.
24797    pub fn name(
24798        mut self,
24799        new_value: &str,
24800    ) -> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C> {
24801        self._name = new_value.to_string();
24802        self
24803    }
24804    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24805    /// while executing the actual API request.
24806    ///
24807    /// ````text
24808    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24809    /// ````
24810    ///
24811    /// Sets the *delegate* property to the given value.
24812    pub fn delegate(
24813        mut self,
24814        new_value: &'a mut dyn common::Delegate,
24815    ) -> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C> {
24816        self._delegate = Some(new_value);
24817        self
24818    }
24819
24820    /// Set any additional parameter of the query string used in the request.
24821    /// It should be used to set parameters which are not yet available through their own
24822    /// setters.
24823    ///
24824    /// Please note that this method must not be used to set any of the known parameters
24825    /// which have their own setter method. If done anyway, the request will fail.
24826    ///
24827    /// # Additional Parameters
24828    ///
24829    /// * *$.xgafv* (query-string) - V1 error format.
24830    /// * *access_token* (query-string) - OAuth access token.
24831    /// * *alt* (query-string) - Data format for response.
24832    /// * *callback* (query-string) - JSONP
24833    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24834    /// * *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.
24835    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24836    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24837    /// * *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.
24838    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24839    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24840    pub fn param<T>(
24841        mut self,
24842        name: T,
24843        value: T,
24844    ) -> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C>
24845    where
24846        T: AsRef<str>,
24847    {
24848        self._additional_params
24849            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24850        self
24851    }
24852
24853    /// Identifies the authorization scope for the method you are building.
24854    ///
24855    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24856    /// [`Scope::CloudPlatform`].
24857    ///
24858    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24859    /// tokens for more than one scope.
24860    ///
24861    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24862    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24863    /// sufficient, a read-write scope will do as well.
24864    pub fn add_scope<St>(
24865        mut self,
24866        scope: St,
24867    ) -> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C>
24868    where
24869        St: AsRef<str>,
24870    {
24871        self._scopes.insert(String::from(scope.as_ref()));
24872        self
24873    }
24874    /// Identifies the authorization scope(s) for the method you are building.
24875    ///
24876    /// See [`Self::add_scope()`] for details.
24877    pub fn add_scopes<I, St>(
24878        mut self,
24879        scopes: I,
24880    ) -> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C>
24881    where
24882        I: IntoIterator<Item = St>,
24883        St: AsRef<str>,
24884    {
24885        self._scopes
24886            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24887        self
24888    }
24889
24890    /// Removes all scopes, and no default scope will be used either.
24891    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24892    /// for details).
24893    pub fn clear_scopes(
24894        mut self,
24895    ) -> ProjectLocationCatalogGetConversationalSearchCustomizationConfigCall<'a, C> {
24896        self._scopes.clear();
24897        self
24898    }
24899}
24900
24901/// Get which branch is currently default branch set by CatalogService.SetDefaultBranch method under a specified parent catalog.
24902///
24903/// A builder for the *locations.catalogs.getDefaultBranch* method supported by a *project* resource.
24904/// It is not used directly, but through a [`ProjectMethods`] instance.
24905///
24906/// # Example
24907///
24908/// Instantiate a resource method builder
24909///
24910/// ```test_harness,no_run
24911/// # extern crate hyper;
24912/// # extern crate hyper_rustls;
24913/// # extern crate google_retail2 as retail2;
24914/// # async fn dox() {
24915/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24916///
24917/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24918/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24919/// #     .with_native_roots()
24920/// #     .unwrap()
24921/// #     .https_only()
24922/// #     .enable_http2()
24923/// #     .build();
24924///
24925/// # let executor = hyper_util::rt::TokioExecutor::new();
24926/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24927/// #     secret,
24928/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24929/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24930/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24931/// #     ),
24932/// # ).build().await.unwrap();
24933///
24934/// # let client = hyper_util::client::legacy::Client::builder(
24935/// #     hyper_util::rt::TokioExecutor::new()
24936/// # )
24937/// # .build(
24938/// #     hyper_rustls::HttpsConnectorBuilder::new()
24939/// #         .with_native_roots()
24940/// #         .unwrap()
24941/// #         .https_or_http()
24942/// #         .enable_http2()
24943/// #         .build()
24944/// # );
24945/// # let mut hub = CloudRetail::new(client, auth);
24946/// // You can configure optional parameters by calling the respective setters at will, and
24947/// // execute the final call using `doit()`.
24948/// // Values shown here are possibly random and not representative !
24949/// let result = hub.projects().locations_catalogs_get_default_branch("catalog")
24950///              .doit().await;
24951/// # }
24952/// ```
24953pub struct ProjectLocationCatalogGetDefaultBranchCall<'a, C>
24954where
24955    C: 'a,
24956{
24957    hub: &'a CloudRetail<C>,
24958    _catalog: String,
24959    _delegate: Option<&'a mut dyn common::Delegate>,
24960    _additional_params: HashMap<String, String>,
24961    _scopes: BTreeSet<String>,
24962}
24963
24964impl<'a, C> common::CallBuilder for ProjectLocationCatalogGetDefaultBranchCall<'a, C> {}
24965
24966impl<'a, C> ProjectLocationCatalogGetDefaultBranchCall<'a, C>
24967where
24968    C: common::Connector,
24969{
24970    /// Perform the operation you have build so far.
24971    pub async fn doit(
24972        mut self,
24973    ) -> common::Result<(
24974        common::Response,
24975        GoogleCloudRetailV2GetDefaultBranchResponse,
24976    )> {
24977        use std::borrow::Cow;
24978        use std::io::{Read, Seek};
24979
24980        use common::{url::Params, ToParts};
24981        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24982
24983        let mut dd = common::DefaultDelegate;
24984        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24985        dlg.begin(common::MethodInfo {
24986            id: "retail.projects.locations.catalogs.getDefaultBranch",
24987            http_method: hyper::Method::GET,
24988        });
24989
24990        for &field in ["alt", "catalog"].iter() {
24991            if self._additional_params.contains_key(field) {
24992                dlg.finished(false);
24993                return Err(common::Error::FieldClash(field));
24994            }
24995        }
24996
24997        let mut params = Params::with_capacity(3 + self._additional_params.len());
24998        params.push("catalog", self._catalog);
24999
25000        params.extend(self._additional_params.iter());
25001
25002        params.push("alt", "json");
25003        let mut url = self.hub._base_url.clone() + "v2/{+catalog}:getDefaultBranch";
25004        if self._scopes.is_empty() {
25005            self._scopes
25006                .insert(Scope::CloudPlatform.as_ref().to_string());
25007        }
25008
25009        #[allow(clippy::single_element_loop)]
25010        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
25011            url = params.uri_replacement(url, param_name, find_this, true);
25012        }
25013        {
25014            let to_remove = ["catalog"];
25015            params.remove_params(&to_remove);
25016        }
25017
25018        let url = params.parse_with_url(&url);
25019
25020        loop {
25021            let token = match self
25022                .hub
25023                .auth
25024                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25025                .await
25026            {
25027                Ok(token) => token,
25028                Err(e) => match dlg.token(e) {
25029                    Ok(token) => token,
25030                    Err(e) => {
25031                        dlg.finished(false);
25032                        return Err(common::Error::MissingToken(e));
25033                    }
25034                },
25035            };
25036            let mut req_result = {
25037                let client = &self.hub.client;
25038                dlg.pre_request();
25039                let mut req_builder = hyper::Request::builder()
25040                    .method(hyper::Method::GET)
25041                    .uri(url.as_str())
25042                    .header(USER_AGENT, self.hub._user_agent.clone());
25043
25044                if let Some(token) = token.as_ref() {
25045                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25046                }
25047
25048                let request = req_builder
25049                    .header(CONTENT_LENGTH, 0_u64)
25050                    .body(common::to_body::<String>(None));
25051
25052                client.request(request.unwrap()).await
25053            };
25054
25055            match req_result {
25056                Err(err) => {
25057                    if let common::Retry::After(d) = dlg.http_error(&err) {
25058                        sleep(d).await;
25059                        continue;
25060                    }
25061                    dlg.finished(false);
25062                    return Err(common::Error::HttpError(err));
25063                }
25064                Ok(res) => {
25065                    let (mut parts, body) = res.into_parts();
25066                    let mut body = common::Body::new(body);
25067                    if !parts.status.is_success() {
25068                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25069                        let error = serde_json::from_str(&common::to_string(&bytes));
25070                        let response = common::to_response(parts, bytes.into());
25071
25072                        if let common::Retry::After(d) =
25073                            dlg.http_failure(&response, error.as_ref().ok())
25074                        {
25075                            sleep(d).await;
25076                            continue;
25077                        }
25078
25079                        dlg.finished(false);
25080
25081                        return Err(match error {
25082                            Ok(value) => common::Error::BadRequest(value),
25083                            _ => common::Error::Failure(response),
25084                        });
25085                    }
25086                    let response = {
25087                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25088                        let encoded = common::to_string(&bytes);
25089                        match serde_json::from_str(&encoded) {
25090                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25091                            Err(error) => {
25092                                dlg.response_json_decode_error(&encoded, &error);
25093                                return Err(common::Error::JsonDecodeError(
25094                                    encoded.to_string(),
25095                                    error,
25096                                ));
25097                            }
25098                        }
25099                    };
25100
25101                    dlg.finished(true);
25102                    return Ok(response);
25103                }
25104            }
25105        }
25106    }
25107
25108    /// The parent catalog resource name, such as `projects/*/locations/global/catalogs/default_catalog`.
25109    ///
25110    /// Sets the *catalog* path property to the given value.
25111    ///
25112    /// Even though the property as already been set when instantiating this call,
25113    /// we provide this method for API completeness.
25114    pub fn catalog(mut self, new_value: &str) -> ProjectLocationCatalogGetDefaultBranchCall<'a, C> {
25115        self._catalog = new_value.to_string();
25116        self
25117    }
25118    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25119    /// while executing the actual API request.
25120    ///
25121    /// ````text
25122    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25123    /// ````
25124    ///
25125    /// Sets the *delegate* property to the given value.
25126    pub fn delegate(
25127        mut self,
25128        new_value: &'a mut dyn common::Delegate,
25129    ) -> ProjectLocationCatalogGetDefaultBranchCall<'a, C> {
25130        self._delegate = Some(new_value);
25131        self
25132    }
25133
25134    /// Set any additional parameter of the query string used in the request.
25135    /// It should be used to set parameters which are not yet available through their own
25136    /// setters.
25137    ///
25138    /// Please note that this method must not be used to set any of the known parameters
25139    /// which have their own setter method. If done anyway, the request will fail.
25140    ///
25141    /// # Additional Parameters
25142    ///
25143    /// * *$.xgafv* (query-string) - V1 error format.
25144    /// * *access_token* (query-string) - OAuth access token.
25145    /// * *alt* (query-string) - Data format for response.
25146    /// * *callback* (query-string) - JSONP
25147    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25148    /// * *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.
25149    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25150    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25151    /// * *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.
25152    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25153    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25154    pub fn param<T>(
25155        mut self,
25156        name: T,
25157        value: T,
25158    ) -> ProjectLocationCatalogGetDefaultBranchCall<'a, C>
25159    where
25160        T: AsRef<str>,
25161    {
25162        self._additional_params
25163            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25164        self
25165    }
25166
25167    /// Identifies the authorization scope for the method you are building.
25168    ///
25169    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25170    /// [`Scope::CloudPlatform`].
25171    ///
25172    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25173    /// tokens for more than one scope.
25174    ///
25175    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25176    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25177    /// sufficient, a read-write scope will do as well.
25178    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogGetDefaultBranchCall<'a, C>
25179    where
25180        St: AsRef<str>,
25181    {
25182        self._scopes.insert(String::from(scope.as_ref()));
25183        self
25184    }
25185    /// Identifies the authorization scope(s) for the method you are building.
25186    ///
25187    /// See [`Self::add_scope()`] for details.
25188    pub fn add_scopes<I, St>(
25189        mut self,
25190        scopes: I,
25191    ) -> ProjectLocationCatalogGetDefaultBranchCall<'a, C>
25192    where
25193        I: IntoIterator<Item = St>,
25194        St: AsRef<str>,
25195    {
25196        self._scopes
25197            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25198        self
25199    }
25200
25201    /// Removes all scopes, and no default scope will be used either.
25202    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25203    /// for details).
25204    pub fn clear_scopes(mut self) -> ProjectLocationCatalogGetDefaultBranchCall<'a, C> {
25205        self._scopes.clear();
25206        self
25207    }
25208}
25209
25210/// Manages overal generative question feature state -- enables toggling feature on and off.
25211///
25212/// A builder for the *locations.catalogs.getGenerativeQuestionFeature* method supported by a *project* resource.
25213/// It is not used directly, but through a [`ProjectMethods`] instance.
25214///
25215/// # Example
25216///
25217/// Instantiate a resource method builder
25218///
25219/// ```test_harness,no_run
25220/// # extern crate hyper;
25221/// # extern crate hyper_rustls;
25222/// # extern crate google_retail2 as retail2;
25223/// # async fn dox() {
25224/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25225///
25226/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25227/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25228/// #     .with_native_roots()
25229/// #     .unwrap()
25230/// #     .https_only()
25231/// #     .enable_http2()
25232/// #     .build();
25233///
25234/// # let executor = hyper_util::rt::TokioExecutor::new();
25235/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25236/// #     secret,
25237/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25238/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25239/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25240/// #     ),
25241/// # ).build().await.unwrap();
25242///
25243/// # let client = hyper_util::client::legacy::Client::builder(
25244/// #     hyper_util::rt::TokioExecutor::new()
25245/// # )
25246/// # .build(
25247/// #     hyper_rustls::HttpsConnectorBuilder::new()
25248/// #         .with_native_roots()
25249/// #         .unwrap()
25250/// #         .https_or_http()
25251/// #         .enable_http2()
25252/// #         .build()
25253/// # );
25254/// # let mut hub = CloudRetail::new(client, auth);
25255/// // You can configure optional parameters by calling the respective setters at will, and
25256/// // execute the final call using `doit()`.
25257/// // Values shown here are possibly random and not representative !
25258/// let result = hub.projects().locations_catalogs_get_generative_question_feature("catalog")
25259///              .doit().await;
25260/// # }
25261/// ```
25262pub struct ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C>
25263where
25264    C: 'a,
25265{
25266    hub: &'a CloudRetail<C>,
25267    _catalog: String,
25268    _delegate: Option<&'a mut dyn common::Delegate>,
25269    _additional_params: HashMap<String, String>,
25270    _scopes: BTreeSet<String>,
25271}
25272
25273impl<'a, C> common::CallBuilder for ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C> {}
25274
25275impl<'a, C> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C>
25276where
25277    C: common::Connector,
25278{
25279    /// Perform the operation you have build so far.
25280    pub async fn doit(
25281        mut self,
25282    ) -> common::Result<(
25283        common::Response,
25284        GoogleCloudRetailV2GenerativeQuestionsFeatureConfig,
25285    )> {
25286        use std::borrow::Cow;
25287        use std::io::{Read, Seek};
25288
25289        use common::{url::Params, ToParts};
25290        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25291
25292        let mut dd = common::DefaultDelegate;
25293        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25294        dlg.begin(common::MethodInfo {
25295            id: "retail.projects.locations.catalogs.getGenerativeQuestionFeature",
25296            http_method: hyper::Method::GET,
25297        });
25298
25299        for &field in ["alt", "catalog"].iter() {
25300            if self._additional_params.contains_key(field) {
25301                dlg.finished(false);
25302                return Err(common::Error::FieldClash(field));
25303            }
25304        }
25305
25306        let mut params = Params::with_capacity(3 + self._additional_params.len());
25307        params.push("catalog", self._catalog);
25308
25309        params.extend(self._additional_params.iter());
25310
25311        params.push("alt", "json");
25312        let mut url = self.hub._base_url.clone() + "v2/{+catalog}/generativeQuestionFeature";
25313        if self._scopes.is_empty() {
25314            self._scopes
25315                .insert(Scope::CloudPlatform.as_ref().to_string());
25316        }
25317
25318        #[allow(clippy::single_element_loop)]
25319        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
25320            url = params.uri_replacement(url, param_name, find_this, true);
25321        }
25322        {
25323            let to_remove = ["catalog"];
25324            params.remove_params(&to_remove);
25325        }
25326
25327        let url = params.parse_with_url(&url);
25328
25329        loop {
25330            let token = match self
25331                .hub
25332                .auth
25333                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25334                .await
25335            {
25336                Ok(token) => token,
25337                Err(e) => match dlg.token(e) {
25338                    Ok(token) => token,
25339                    Err(e) => {
25340                        dlg.finished(false);
25341                        return Err(common::Error::MissingToken(e));
25342                    }
25343                },
25344            };
25345            let mut req_result = {
25346                let client = &self.hub.client;
25347                dlg.pre_request();
25348                let mut req_builder = hyper::Request::builder()
25349                    .method(hyper::Method::GET)
25350                    .uri(url.as_str())
25351                    .header(USER_AGENT, self.hub._user_agent.clone());
25352
25353                if let Some(token) = token.as_ref() {
25354                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25355                }
25356
25357                let request = req_builder
25358                    .header(CONTENT_LENGTH, 0_u64)
25359                    .body(common::to_body::<String>(None));
25360
25361                client.request(request.unwrap()).await
25362            };
25363
25364            match req_result {
25365                Err(err) => {
25366                    if let common::Retry::After(d) = dlg.http_error(&err) {
25367                        sleep(d).await;
25368                        continue;
25369                    }
25370                    dlg.finished(false);
25371                    return Err(common::Error::HttpError(err));
25372                }
25373                Ok(res) => {
25374                    let (mut parts, body) = res.into_parts();
25375                    let mut body = common::Body::new(body);
25376                    if !parts.status.is_success() {
25377                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25378                        let error = serde_json::from_str(&common::to_string(&bytes));
25379                        let response = common::to_response(parts, bytes.into());
25380
25381                        if let common::Retry::After(d) =
25382                            dlg.http_failure(&response, error.as_ref().ok())
25383                        {
25384                            sleep(d).await;
25385                            continue;
25386                        }
25387
25388                        dlg.finished(false);
25389
25390                        return Err(match error {
25391                            Ok(value) => common::Error::BadRequest(value),
25392                            _ => common::Error::Failure(response),
25393                        });
25394                    }
25395                    let response = {
25396                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25397                        let encoded = common::to_string(&bytes);
25398                        match serde_json::from_str(&encoded) {
25399                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25400                            Err(error) => {
25401                                dlg.response_json_decode_error(&encoded, &error);
25402                                return Err(common::Error::JsonDecodeError(
25403                                    encoded.to_string(),
25404                                    error,
25405                                ));
25406                            }
25407                        }
25408                    };
25409
25410                    dlg.finished(true);
25411                    return Ok(response);
25412                }
25413            }
25414        }
25415    }
25416
25417    /// Required. Resource name of the parent catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
25418    ///
25419    /// Sets the *catalog* path property to the given value.
25420    ///
25421    /// Even though the property as already been set when instantiating this call,
25422    /// we provide this method for API completeness.
25423    pub fn catalog(
25424        mut self,
25425        new_value: &str,
25426    ) -> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C> {
25427        self._catalog = new_value.to_string();
25428        self
25429    }
25430    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25431    /// while executing the actual API request.
25432    ///
25433    /// ````text
25434    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25435    /// ````
25436    ///
25437    /// Sets the *delegate* property to the given value.
25438    pub fn delegate(
25439        mut self,
25440        new_value: &'a mut dyn common::Delegate,
25441    ) -> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C> {
25442        self._delegate = Some(new_value);
25443        self
25444    }
25445
25446    /// Set any additional parameter of the query string used in the request.
25447    /// It should be used to set parameters which are not yet available through their own
25448    /// setters.
25449    ///
25450    /// Please note that this method must not be used to set any of the known parameters
25451    /// which have their own setter method. If done anyway, the request will fail.
25452    ///
25453    /// # Additional Parameters
25454    ///
25455    /// * *$.xgafv* (query-string) - V1 error format.
25456    /// * *access_token* (query-string) - OAuth access token.
25457    /// * *alt* (query-string) - Data format for response.
25458    /// * *callback* (query-string) - JSONP
25459    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25460    /// * *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.
25461    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25462    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25463    /// * *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.
25464    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25465    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25466    pub fn param<T>(
25467        mut self,
25468        name: T,
25469        value: T,
25470    ) -> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C>
25471    where
25472        T: AsRef<str>,
25473    {
25474        self._additional_params
25475            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25476        self
25477    }
25478
25479    /// Identifies the authorization scope for the method you are building.
25480    ///
25481    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25482    /// [`Scope::CloudPlatform`].
25483    ///
25484    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25485    /// tokens for more than one scope.
25486    ///
25487    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25488    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25489    /// sufficient, a read-write scope will do as well.
25490    pub fn add_scope<St>(
25491        mut self,
25492        scope: St,
25493    ) -> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C>
25494    where
25495        St: AsRef<str>,
25496    {
25497        self._scopes.insert(String::from(scope.as_ref()));
25498        self
25499    }
25500    /// Identifies the authorization scope(s) for the method you are building.
25501    ///
25502    /// See [`Self::add_scope()`] for details.
25503    pub fn add_scopes<I, St>(
25504        mut self,
25505        scopes: I,
25506    ) -> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C>
25507    where
25508        I: IntoIterator<Item = St>,
25509        St: AsRef<str>,
25510    {
25511        self._scopes
25512            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25513        self
25514    }
25515
25516    /// Removes all scopes, and no default scope will be used either.
25517    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25518    /// for details).
25519    pub fn clear_scopes(mut self) -> ProjectLocationCatalogGetGenerativeQuestionFeatureCall<'a, C> {
25520        self._scopes.clear();
25521        self
25522    }
25523}
25524
25525/// Lists all the Catalogs associated with the project.
25526///
25527/// A builder for the *locations.catalogs.list* method supported by a *project* resource.
25528/// It is not used directly, but through a [`ProjectMethods`] instance.
25529///
25530/// # Example
25531///
25532/// Instantiate a resource method builder
25533///
25534/// ```test_harness,no_run
25535/// # extern crate hyper;
25536/// # extern crate hyper_rustls;
25537/// # extern crate google_retail2 as retail2;
25538/// # async fn dox() {
25539/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25540///
25541/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25542/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25543/// #     .with_native_roots()
25544/// #     .unwrap()
25545/// #     .https_only()
25546/// #     .enable_http2()
25547/// #     .build();
25548///
25549/// # let executor = hyper_util::rt::TokioExecutor::new();
25550/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25551/// #     secret,
25552/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25553/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25554/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25555/// #     ),
25556/// # ).build().await.unwrap();
25557///
25558/// # let client = hyper_util::client::legacy::Client::builder(
25559/// #     hyper_util::rt::TokioExecutor::new()
25560/// # )
25561/// # .build(
25562/// #     hyper_rustls::HttpsConnectorBuilder::new()
25563/// #         .with_native_roots()
25564/// #         .unwrap()
25565/// #         .https_or_http()
25566/// #         .enable_http2()
25567/// #         .build()
25568/// # );
25569/// # let mut hub = CloudRetail::new(client, auth);
25570/// // You can configure optional parameters by calling the respective setters at will, and
25571/// // execute the final call using `doit()`.
25572/// // Values shown here are possibly random and not representative !
25573/// let result = hub.projects().locations_catalogs_list("parent")
25574///              .page_token("sit")
25575///              .page_size(-35)
25576///              .doit().await;
25577/// # }
25578/// ```
25579pub struct ProjectLocationCatalogListCall<'a, C>
25580where
25581    C: 'a,
25582{
25583    hub: &'a CloudRetail<C>,
25584    _parent: String,
25585    _page_token: Option<String>,
25586    _page_size: Option<i32>,
25587    _delegate: Option<&'a mut dyn common::Delegate>,
25588    _additional_params: HashMap<String, String>,
25589    _scopes: BTreeSet<String>,
25590}
25591
25592impl<'a, C> common::CallBuilder for ProjectLocationCatalogListCall<'a, C> {}
25593
25594impl<'a, C> ProjectLocationCatalogListCall<'a, C>
25595where
25596    C: common::Connector,
25597{
25598    /// Perform the operation you have build so far.
25599    pub async fn doit(
25600        mut self,
25601    ) -> common::Result<(common::Response, GoogleCloudRetailV2ListCatalogsResponse)> {
25602        use std::borrow::Cow;
25603        use std::io::{Read, Seek};
25604
25605        use common::{url::Params, ToParts};
25606        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25607
25608        let mut dd = common::DefaultDelegate;
25609        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25610        dlg.begin(common::MethodInfo {
25611            id: "retail.projects.locations.catalogs.list",
25612            http_method: hyper::Method::GET,
25613        });
25614
25615        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
25616            if self._additional_params.contains_key(field) {
25617                dlg.finished(false);
25618                return Err(common::Error::FieldClash(field));
25619            }
25620        }
25621
25622        let mut params = Params::with_capacity(5 + self._additional_params.len());
25623        params.push("parent", self._parent);
25624        if let Some(value) = self._page_token.as_ref() {
25625            params.push("pageToken", value);
25626        }
25627        if let Some(value) = self._page_size.as_ref() {
25628            params.push("pageSize", value.to_string());
25629        }
25630
25631        params.extend(self._additional_params.iter());
25632
25633        params.push("alt", "json");
25634        let mut url = self.hub._base_url.clone() + "v2/{+parent}/catalogs";
25635        if self._scopes.is_empty() {
25636            self._scopes
25637                .insert(Scope::CloudPlatform.as_ref().to_string());
25638        }
25639
25640        #[allow(clippy::single_element_loop)]
25641        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
25642            url = params.uri_replacement(url, param_name, find_this, true);
25643        }
25644        {
25645            let to_remove = ["parent"];
25646            params.remove_params(&to_remove);
25647        }
25648
25649        let url = params.parse_with_url(&url);
25650
25651        loop {
25652            let token = match self
25653                .hub
25654                .auth
25655                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25656                .await
25657            {
25658                Ok(token) => token,
25659                Err(e) => match dlg.token(e) {
25660                    Ok(token) => token,
25661                    Err(e) => {
25662                        dlg.finished(false);
25663                        return Err(common::Error::MissingToken(e));
25664                    }
25665                },
25666            };
25667            let mut req_result = {
25668                let client = &self.hub.client;
25669                dlg.pre_request();
25670                let mut req_builder = hyper::Request::builder()
25671                    .method(hyper::Method::GET)
25672                    .uri(url.as_str())
25673                    .header(USER_AGENT, self.hub._user_agent.clone());
25674
25675                if let Some(token) = token.as_ref() {
25676                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25677                }
25678
25679                let request = req_builder
25680                    .header(CONTENT_LENGTH, 0_u64)
25681                    .body(common::to_body::<String>(None));
25682
25683                client.request(request.unwrap()).await
25684            };
25685
25686            match req_result {
25687                Err(err) => {
25688                    if let common::Retry::After(d) = dlg.http_error(&err) {
25689                        sleep(d).await;
25690                        continue;
25691                    }
25692                    dlg.finished(false);
25693                    return Err(common::Error::HttpError(err));
25694                }
25695                Ok(res) => {
25696                    let (mut parts, body) = res.into_parts();
25697                    let mut body = common::Body::new(body);
25698                    if !parts.status.is_success() {
25699                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25700                        let error = serde_json::from_str(&common::to_string(&bytes));
25701                        let response = common::to_response(parts, bytes.into());
25702
25703                        if let common::Retry::After(d) =
25704                            dlg.http_failure(&response, error.as_ref().ok())
25705                        {
25706                            sleep(d).await;
25707                            continue;
25708                        }
25709
25710                        dlg.finished(false);
25711
25712                        return Err(match error {
25713                            Ok(value) => common::Error::BadRequest(value),
25714                            _ => common::Error::Failure(response),
25715                        });
25716                    }
25717                    let response = {
25718                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25719                        let encoded = common::to_string(&bytes);
25720                        match serde_json::from_str(&encoded) {
25721                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25722                            Err(error) => {
25723                                dlg.response_json_decode_error(&encoded, &error);
25724                                return Err(common::Error::JsonDecodeError(
25725                                    encoded.to_string(),
25726                                    error,
25727                                ));
25728                            }
25729                        }
25730                    };
25731
25732                    dlg.finished(true);
25733                    return Ok(response);
25734                }
25735            }
25736        }
25737    }
25738
25739    /// Required. The account resource name with an associated location. If the caller does not have permission to list Catalogs under this location, regardless of whether or not this location exists, a PERMISSION_DENIED error is returned.
25740    ///
25741    /// Sets the *parent* path property to the given value.
25742    ///
25743    /// Even though the property as already been set when instantiating this call,
25744    /// we provide this method for API completeness.
25745    pub fn parent(mut self, new_value: &str) -> ProjectLocationCatalogListCall<'a, C> {
25746        self._parent = new_value.to_string();
25747        self
25748    }
25749    /// A page token ListCatalogsResponse.next_page_token, received from a previous CatalogService.ListCatalogs call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to CatalogService.ListCatalogs must match the call that provided the page token. Otherwise, an INVALID_ARGUMENT error is returned.
25750    ///
25751    /// Sets the *page token* query property to the given value.
25752    pub fn page_token(mut self, new_value: &str) -> ProjectLocationCatalogListCall<'a, C> {
25753        self._page_token = Some(new_value.to_string());
25754        self
25755    }
25756    /// Maximum number of Catalogs to return. If unspecified, defaults to 50. The maximum allowed value is 1000. Values above 1000 will be coerced to 1000. If this field is negative, an INVALID_ARGUMENT is returned.
25757    ///
25758    /// Sets the *page size* query property to the given value.
25759    pub fn page_size(mut self, new_value: i32) -> ProjectLocationCatalogListCall<'a, C> {
25760        self._page_size = Some(new_value);
25761        self
25762    }
25763    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25764    /// while executing the actual API request.
25765    ///
25766    /// ````text
25767    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25768    /// ````
25769    ///
25770    /// Sets the *delegate* property to the given value.
25771    pub fn delegate(
25772        mut self,
25773        new_value: &'a mut dyn common::Delegate,
25774    ) -> ProjectLocationCatalogListCall<'a, C> {
25775        self._delegate = Some(new_value);
25776        self
25777    }
25778
25779    /// Set any additional parameter of the query string used in the request.
25780    /// It should be used to set parameters which are not yet available through their own
25781    /// setters.
25782    ///
25783    /// Please note that this method must not be used to set any of the known parameters
25784    /// which have their own setter method. If done anyway, the request will fail.
25785    ///
25786    /// # Additional Parameters
25787    ///
25788    /// * *$.xgafv* (query-string) - V1 error format.
25789    /// * *access_token* (query-string) - OAuth access token.
25790    /// * *alt* (query-string) - Data format for response.
25791    /// * *callback* (query-string) - JSONP
25792    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25793    /// * *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.
25794    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25795    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25796    /// * *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.
25797    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25798    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25799    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogListCall<'a, C>
25800    where
25801        T: AsRef<str>,
25802    {
25803        self._additional_params
25804            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25805        self
25806    }
25807
25808    /// Identifies the authorization scope for the method you are building.
25809    ///
25810    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25811    /// [`Scope::CloudPlatform`].
25812    ///
25813    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25814    /// tokens for more than one scope.
25815    ///
25816    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25817    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25818    /// sufficient, a read-write scope will do as well.
25819    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogListCall<'a, C>
25820    where
25821        St: AsRef<str>,
25822    {
25823        self._scopes.insert(String::from(scope.as_ref()));
25824        self
25825    }
25826    /// Identifies the authorization scope(s) for the method you are building.
25827    ///
25828    /// See [`Self::add_scope()`] for details.
25829    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogListCall<'a, C>
25830    where
25831        I: IntoIterator<Item = St>,
25832        St: AsRef<str>,
25833    {
25834        self._scopes
25835            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25836        self
25837    }
25838
25839    /// Removes all scopes, and no default scope will be used either.
25840    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25841    /// for details).
25842    pub fn clear_scopes(mut self) -> ProjectLocationCatalogListCall<'a, C> {
25843        self._scopes.clear();
25844        self
25845    }
25846}
25847
25848/// Updates the Catalogs.
25849///
25850/// A builder for the *locations.catalogs.patch* method supported by a *project* resource.
25851/// It is not used directly, but through a [`ProjectMethods`] instance.
25852///
25853/// # Example
25854///
25855/// Instantiate a resource method builder
25856///
25857/// ```test_harness,no_run
25858/// # extern crate hyper;
25859/// # extern crate hyper_rustls;
25860/// # extern crate google_retail2 as retail2;
25861/// use retail2::api::GoogleCloudRetailV2Catalog;
25862/// # async fn dox() {
25863/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25864///
25865/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25866/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25867/// #     .with_native_roots()
25868/// #     .unwrap()
25869/// #     .https_only()
25870/// #     .enable_http2()
25871/// #     .build();
25872///
25873/// # let executor = hyper_util::rt::TokioExecutor::new();
25874/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25875/// #     secret,
25876/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25877/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25878/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25879/// #     ),
25880/// # ).build().await.unwrap();
25881///
25882/// # let client = hyper_util::client::legacy::Client::builder(
25883/// #     hyper_util::rt::TokioExecutor::new()
25884/// # )
25885/// # .build(
25886/// #     hyper_rustls::HttpsConnectorBuilder::new()
25887/// #         .with_native_roots()
25888/// #         .unwrap()
25889/// #         .https_or_http()
25890/// #         .enable_http2()
25891/// #         .build()
25892/// # );
25893/// # let mut hub = CloudRetail::new(client, auth);
25894/// // As the method needs a request, you would usually fill it with the desired information
25895/// // into the respective structure. Some of the parts shown here might not be applicable !
25896/// // Values shown here are possibly random and not representative !
25897/// let mut req = GoogleCloudRetailV2Catalog::default();
25898///
25899/// // You can configure optional parameters by calling the respective setters at will, and
25900/// // execute the final call using `doit()`.
25901/// // Values shown here are possibly random and not representative !
25902/// let result = hub.projects().locations_catalogs_patch(req, "name")
25903///              .update_mask(FieldMask::new::<&str>(&[]))
25904///              .doit().await;
25905/// # }
25906/// ```
25907pub struct ProjectLocationCatalogPatchCall<'a, C>
25908where
25909    C: 'a,
25910{
25911    hub: &'a CloudRetail<C>,
25912    _request: GoogleCloudRetailV2Catalog,
25913    _name: String,
25914    _update_mask: Option<common::FieldMask>,
25915    _delegate: Option<&'a mut dyn common::Delegate>,
25916    _additional_params: HashMap<String, String>,
25917    _scopes: BTreeSet<String>,
25918}
25919
25920impl<'a, C> common::CallBuilder for ProjectLocationCatalogPatchCall<'a, C> {}
25921
25922impl<'a, C> ProjectLocationCatalogPatchCall<'a, C>
25923where
25924    C: common::Connector,
25925{
25926    /// Perform the operation you have build so far.
25927    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudRetailV2Catalog)> {
25928        use std::borrow::Cow;
25929        use std::io::{Read, Seek};
25930
25931        use common::{url::Params, ToParts};
25932        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25933
25934        let mut dd = common::DefaultDelegate;
25935        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25936        dlg.begin(common::MethodInfo {
25937            id: "retail.projects.locations.catalogs.patch",
25938            http_method: hyper::Method::PATCH,
25939        });
25940
25941        for &field in ["alt", "name", "updateMask"].iter() {
25942            if self._additional_params.contains_key(field) {
25943                dlg.finished(false);
25944                return Err(common::Error::FieldClash(field));
25945            }
25946        }
25947
25948        let mut params = Params::with_capacity(5 + self._additional_params.len());
25949        params.push("name", self._name);
25950        if let Some(value) = self._update_mask.as_ref() {
25951            params.push("updateMask", value.to_string());
25952        }
25953
25954        params.extend(self._additional_params.iter());
25955
25956        params.push("alt", "json");
25957        let mut url = self.hub._base_url.clone() + "v2/{+name}";
25958        if self._scopes.is_empty() {
25959            self._scopes
25960                .insert(Scope::CloudPlatform.as_ref().to_string());
25961        }
25962
25963        #[allow(clippy::single_element_loop)]
25964        for &(find_this, param_name) in [("{+name}", "name")].iter() {
25965            url = params.uri_replacement(url, param_name, find_this, true);
25966        }
25967        {
25968            let to_remove = ["name"];
25969            params.remove_params(&to_remove);
25970        }
25971
25972        let url = params.parse_with_url(&url);
25973
25974        let mut json_mime_type = mime::APPLICATION_JSON;
25975        let mut request_value_reader = {
25976            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25977            common::remove_json_null_values(&mut value);
25978            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25979            serde_json::to_writer(&mut dst, &value).unwrap();
25980            dst
25981        };
25982        let request_size = request_value_reader
25983            .seek(std::io::SeekFrom::End(0))
25984            .unwrap();
25985        request_value_reader
25986            .seek(std::io::SeekFrom::Start(0))
25987            .unwrap();
25988
25989        loop {
25990            let token = match self
25991                .hub
25992                .auth
25993                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25994                .await
25995            {
25996                Ok(token) => token,
25997                Err(e) => match dlg.token(e) {
25998                    Ok(token) => token,
25999                    Err(e) => {
26000                        dlg.finished(false);
26001                        return Err(common::Error::MissingToken(e));
26002                    }
26003                },
26004            };
26005            request_value_reader
26006                .seek(std::io::SeekFrom::Start(0))
26007                .unwrap();
26008            let mut req_result = {
26009                let client = &self.hub.client;
26010                dlg.pre_request();
26011                let mut req_builder = hyper::Request::builder()
26012                    .method(hyper::Method::PATCH)
26013                    .uri(url.as_str())
26014                    .header(USER_AGENT, self.hub._user_agent.clone());
26015
26016                if let Some(token) = token.as_ref() {
26017                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26018                }
26019
26020                let request = req_builder
26021                    .header(CONTENT_TYPE, json_mime_type.to_string())
26022                    .header(CONTENT_LENGTH, request_size as u64)
26023                    .body(common::to_body(
26024                        request_value_reader.get_ref().clone().into(),
26025                    ));
26026
26027                client.request(request.unwrap()).await
26028            };
26029
26030            match req_result {
26031                Err(err) => {
26032                    if let common::Retry::After(d) = dlg.http_error(&err) {
26033                        sleep(d).await;
26034                        continue;
26035                    }
26036                    dlg.finished(false);
26037                    return Err(common::Error::HttpError(err));
26038                }
26039                Ok(res) => {
26040                    let (mut parts, body) = res.into_parts();
26041                    let mut body = common::Body::new(body);
26042                    if !parts.status.is_success() {
26043                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26044                        let error = serde_json::from_str(&common::to_string(&bytes));
26045                        let response = common::to_response(parts, bytes.into());
26046
26047                        if let common::Retry::After(d) =
26048                            dlg.http_failure(&response, error.as_ref().ok())
26049                        {
26050                            sleep(d).await;
26051                            continue;
26052                        }
26053
26054                        dlg.finished(false);
26055
26056                        return Err(match error {
26057                            Ok(value) => common::Error::BadRequest(value),
26058                            _ => common::Error::Failure(response),
26059                        });
26060                    }
26061                    let response = {
26062                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26063                        let encoded = common::to_string(&bytes);
26064                        match serde_json::from_str(&encoded) {
26065                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26066                            Err(error) => {
26067                                dlg.response_json_decode_error(&encoded, &error);
26068                                return Err(common::Error::JsonDecodeError(
26069                                    encoded.to_string(),
26070                                    error,
26071                                ));
26072                            }
26073                        }
26074                    };
26075
26076                    dlg.finished(true);
26077                    return Ok(response);
26078                }
26079            }
26080        }
26081    }
26082
26083    ///
26084    /// Sets the *request* property to the given value.
26085    ///
26086    /// Even though the property as already been set when instantiating this call,
26087    /// we provide this method for API completeness.
26088    pub fn request(
26089        mut self,
26090        new_value: GoogleCloudRetailV2Catalog,
26091    ) -> ProjectLocationCatalogPatchCall<'a, C> {
26092        self._request = new_value;
26093        self
26094    }
26095    /// Required. Immutable. The fully qualified resource name of the catalog.
26096    ///
26097    /// Sets the *name* path property to the given value.
26098    ///
26099    /// Even though the property as already been set when instantiating this call,
26100    /// we provide this method for API completeness.
26101    pub fn name(mut self, new_value: &str) -> ProjectLocationCatalogPatchCall<'a, C> {
26102        self._name = new_value.to_string();
26103        self
26104    }
26105    /// Indicates which fields in the provided Catalog to update. If an unsupported or unknown field is provided, an INVALID_ARGUMENT error is returned.
26106    ///
26107    /// Sets the *update mask* query property to the given value.
26108    pub fn update_mask(
26109        mut self,
26110        new_value: common::FieldMask,
26111    ) -> ProjectLocationCatalogPatchCall<'a, C> {
26112        self._update_mask = Some(new_value);
26113        self
26114    }
26115    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26116    /// while executing the actual API request.
26117    ///
26118    /// ````text
26119    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26120    /// ````
26121    ///
26122    /// Sets the *delegate* property to the given value.
26123    pub fn delegate(
26124        mut self,
26125        new_value: &'a mut dyn common::Delegate,
26126    ) -> ProjectLocationCatalogPatchCall<'a, C> {
26127        self._delegate = Some(new_value);
26128        self
26129    }
26130
26131    /// Set any additional parameter of the query string used in the request.
26132    /// It should be used to set parameters which are not yet available through their own
26133    /// setters.
26134    ///
26135    /// Please note that this method must not be used to set any of the known parameters
26136    /// which have their own setter method. If done anyway, the request will fail.
26137    ///
26138    /// # Additional Parameters
26139    ///
26140    /// * *$.xgafv* (query-string) - V1 error format.
26141    /// * *access_token* (query-string) - OAuth access token.
26142    /// * *alt* (query-string) - Data format for response.
26143    /// * *callback* (query-string) - JSONP
26144    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26145    /// * *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.
26146    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26147    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26148    /// * *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.
26149    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26150    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26151    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCatalogPatchCall<'a, C>
26152    where
26153        T: AsRef<str>,
26154    {
26155        self._additional_params
26156            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26157        self
26158    }
26159
26160    /// Identifies the authorization scope for the method you are building.
26161    ///
26162    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26163    /// [`Scope::CloudPlatform`].
26164    ///
26165    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26166    /// tokens for more than one scope.
26167    ///
26168    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26169    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26170    /// sufficient, a read-write scope will do as well.
26171    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogPatchCall<'a, C>
26172    where
26173        St: AsRef<str>,
26174    {
26175        self._scopes.insert(String::from(scope.as_ref()));
26176        self
26177    }
26178    /// Identifies the authorization scope(s) for the method you are building.
26179    ///
26180    /// See [`Self::add_scope()`] for details.
26181    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCatalogPatchCall<'a, C>
26182    where
26183        I: IntoIterator<Item = St>,
26184        St: AsRef<str>,
26185    {
26186        self._scopes
26187            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26188        self
26189    }
26190
26191    /// Removes all scopes, and no default scope will be used either.
26192    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26193    /// for details).
26194    pub fn clear_scopes(mut self) -> ProjectLocationCatalogPatchCall<'a, C> {
26195        self._scopes.clear();
26196        self
26197    }
26198}
26199
26200/// Set a specified branch id as default branch. API methods such as SearchService.Search, ProductService.GetProduct, ProductService.ListProducts will treat requests using "default_branch" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting SearchRequest.branch to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting SearchRequest.branch to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as SearchRequest.branch to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.
26201///
26202/// A builder for the *locations.catalogs.setDefaultBranch* method supported by a *project* resource.
26203/// It is not used directly, but through a [`ProjectMethods`] instance.
26204///
26205/// # Example
26206///
26207/// Instantiate a resource method builder
26208///
26209/// ```test_harness,no_run
26210/// # extern crate hyper;
26211/// # extern crate hyper_rustls;
26212/// # extern crate google_retail2 as retail2;
26213/// use retail2::api::GoogleCloudRetailV2SetDefaultBranchRequest;
26214/// # async fn dox() {
26215/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26216///
26217/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26218/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26219/// #     .with_native_roots()
26220/// #     .unwrap()
26221/// #     .https_only()
26222/// #     .enable_http2()
26223/// #     .build();
26224///
26225/// # let executor = hyper_util::rt::TokioExecutor::new();
26226/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26227/// #     secret,
26228/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26229/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26230/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26231/// #     ),
26232/// # ).build().await.unwrap();
26233///
26234/// # let client = hyper_util::client::legacy::Client::builder(
26235/// #     hyper_util::rt::TokioExecutor::new()
26236/// # )
26237/// # .build(
26238/// #     hyper_rustls::HttpsConnectorBuilder::new()
26239/// #         .with_native_roots()
26240/// #         .unwrap()
26241/// #         .https_or_http()
26242/// #         .enable_http2()
26243/// #         .build()
26244/// # );
26245/// # let mut hub = CloudRetail::new(client, auth);
26246/// // As the method needs a request, you would usually fill it with the desired information
26247/// // into the respective structure. Some of the parts shown here might not be applicable !
26248/// // Values shown here are possibly random and not representative !
26249/// let mut req = GoogleCloudRetailV2SetDefaultBranchRequest::default();
26250///
26251/// // You can configure optional parameters by calling the respective setters at will, and
26252/// // execute the final call using `doit()`.
26253/// // Values shown here are possibly random and not representative !
26254/// let result = hub.projects().locations_catalogs_set_default_branch(req, "catalog")
26255///              .doit().await;
26256/// # }
26257/// ```
26258pub struct ProjectLocationCatalogSetDefaultBranchCall<'a, C>
26259where
26260    C: 'a,
26261{
26262    hub: &'a CloudRetail<C>,
26263    _request: GoogleCloudRetailV2SetDefaultBranchRequest,
26264    _catalog: String,
26265    _delegate: Option<&'a mut dyn common::Delegate>,
26266    _additional_params: HashMap<String, String>,
26267    _scopes: BTreeSet<String>,
26268}
26269
26270impl<'a, C> common::CallBuilder for ProjectLocationCatalogSetDefaultBranchCall<'a, C> {}
26271
26272impl<'a, C> ProjectLocationCatalogSetDefaultBranchCall<'a, C>
26273where
26274    C: common::Connector,
26275{
26276    /// Perform the operation you have build so far.
26277    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
26278        use std::borrow::Cow;
26279        use std::io::{Read, Seek};
26280
26281        use common::{url::Params, ToParts};
26282        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26283
26284        let mut dd = common::DefaultDelegate;
26285        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26286        dlg.begin(common::MethodInfo {
26287            id: "retail.projects.locations.catalogs.setDefaultBranch",
26288            http_method: hyper::Method::POST,
26289        });
26290
26291        for &field in ["alt", "catalog"].iter() {
26292            if self._additional_params.contains_key(field) {
26293                dlg.finished(false);
26294                return Err(common::Error::FieldClash(field));
26295            }
26296        }
26297
26298        let mut params = Params::with_capacity(4 + self._additional_params.len());
26299        params.push("catalog", self._catalog);
26300
26301        params.extend(self._additional_params.iter());
26302
26303        params.push("alt", "json");
26304        let mut url = self.hub._base_url.clone() + "v2/{+catalog}:setDefaultBranch";
26305        if self._scopes.is_empty() {
26306            self._scopes
26307                .insert(Scope::CloudPlatform.as_ref().to_string());
26308        }
26309
26310        #[allow(clippy::single_element_loop)]
26311        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
26312            url = params.uri_replacement(url, param_name, find_this, true);
26313        }
26314        {
26315            let to_remove = ["catalog"];
26316            params.remove_params(&to_remove);
26317        }
26318
26319        let url = params.parse_with_url(&url);
26320
26321        let mut json_mime_type = mime::APPLICATION_JSON;
26322        let mut request_value_reader = {
26323            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26324            common::remove_json_null_values(&mut value);
26325            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26326            serde_json::to_writer(&mut dst, &value).unwrap();
26327            dst
26328        };
26329        let request_size = request_value_reader
26330            .seek(std::io::SeekFrom::End(0))
26331            .unwrap();
26332        request_value_reader
26333            .seek(std::io::SeekFrom::Start(0))
26334            .unwrap();
26335
26336        loop {
26337            let token = match self
26338                .hub
26339                .auth
26340                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26341                .await
26342            {
26343                Ok(token) => token,
26344                Err(e) => match dlg.token(e) {
26345                    Ok(token) => token,
26346                    Err(e) => {
26347                        dlg.finished(false);
26348                        return Err(common::Error::MissingToken(e));
26349                    }
26350                },
26351            };
26352            request_value_reader
26353                .seek(std::io::SeekFrom::Start(0))
26354                .unwrap();
26355            let mut req_result = {
26356                let client = &self.hub.client;
26357                dlg.pre_request();
26358                let mut req_builder = hyper::Request::builder()
26359                    .method(hyper::Method::POST)
26360                    .uri(url.as_str())
26361                    .header(USER_AGENT, self.hub._user_agent.clone());
26362
26363                if let Some(token) = token.as_ref() {
26364                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26365                }
26366
26367                let request = req_builder
26368                    .header(CONTENT_TYPE, json_mime_type.to_string())
26369                    .header(CONTENT_LENGTH, request_size as u64)
26370                    .body(common::to_body(
26371                        request_value_reader.get_ref().clone().into(),
26372                    ));
26373
26374                client.request(request.unwrap()).await
26375            };
26376
26377            match req_result {
26378                Err(err) => {
26379                    if let common::Retry::After(d) = dlg.http_error(&err) {
26380                        sleep(d).await;
26381                        continue;
26382                    }
26383                    dlg.finished(false);
26384                    return Err(common::Error::HttpError(err));
26385                }
26386                Ok(res) => {
26387                    let (mut parts, body) = res.into_parts();
26388                    let mut body = common::Body::new(body);
26389                    if !parts.status.is_success() {
26390                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26391                        let error = serde_json::from_str(&common::to_string(&bytes));
26392                        let response = common::to_response(parts, bytes.into());
26393
26394                        if let common::Retry::After(d) =
26395                            dlg.http_failure(&response, error.as_ref().ok())
26396                        {
26397                            sleep(d).await;
26398                            continue;
26399                        }
26400
26401                        dlg.finished(false);
26402
26403                        return Err(match error {
26404                            Ok(value) => common::Error::BadRequest(value),
26405                            _ => common::Error::Failure(response),
26406                        });
26407                    }
26408                    let response = {
26409                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26410                        let encoded = common::to_string(&bytes);
26411                        match serde_json::from_str(&encoded) {
26412                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26413                            Err(error) => {
26414                                dlg.response_json_decode_error(&encoded, &error);
26415                                return Err(common::Error::JsonDecodeError(
26416                                    encoded.to_string(),
26417                                    error,
26418                                ));
26419                            }
26420                        }
26421                    };
26422
26423                    dlg.finished(true);
26424                    return Ok(response);
26425                }
26426            }
26427        }
26428    }
26429
26430    ///
26431    /// Sets the *request* property to the given value.
26432    ///
26433    /// Even though the property as already been set when instantiating this call,
26434    /// we provide this method for API completeness.
26435    pub fn request(
26436        mut self,
26437        new_value: GoogleCloudRetailV2SetDefaultBranchRequest,
26438    ) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C> {
26439        self._request = new_value;
26440        self
26441    }
26442    /// Full resource name of the catalog, such as `projects/*/locations/global/catalogs/default_catalog`.
26443    ///
26444    /// Sets the *catalog* path property to the given value.
26445    ///
26446    /// Even though the property as already been set when instantiating this call,
26447    /// we provide this method for API completeness.
26448    pub fn catalog(mut self, new_value: &str) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C> {
26449        self._catalog = new_value.to_string();
26450        self
26451    }
26452    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26453    /// while executing the actual API request.
26454    ///
26455    /// ````text
26456    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26457    /// ````
26458    ///
26459    /// Sets the *delegate* property to the given value.
26460    pub fn delegate(
26461        mut self,
26462        new_value: &'a mut dyn common::Delegate,
26463    ) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C> {
26464        self._delegate = Some(new_value);
26465        self
26466    }
26467
26468    /// Set any additional parameter of the query string used in the request.
26469    /// It should be used to set parameters which are not yet available through their own
26470    /// setters.
26471    ///
26472    /// Please note that this method must not be used to set any of the known parameters
26473    /// which have their own setter method. If done anyway, the request will fail.
26474    ///
26475    /// # Additional Parameters
26476    ///
26477    /// * *$.xgafv* (query-string) - V1 error format.
26478    /// * *access_token* (query-string) - OAuth access token.
26479    /// * *alt* (query-string) - Data format for response.
26480    /// * *callback* (query-string) - JSONP
26481    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26482    /// * *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.
26483    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26484    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26485    /// * *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.
26486    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26487    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26488    pub fn param<T>(
26489        mut self,
26490        name: T,
26491        value: T,
26492    ) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C>
26493    where
26494        T: AsRef<str>,
26495    {
26496        self._additional_params
26497            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26498        self
26499    }
26500
26501    /// Identifies the authorization scope for the method you are building.
26502    ///
26503    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26504    /// [`Scope::CloudPlatform`].
26505    ///
26506    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26507    /// tokens for more than one scope.
26508    ///
26509    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26510    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26511    /// sufficient, a read-write scope will do as well.
26512    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C>
26513    where
26514        St: AsRef<str>,
26515    {
26516        self._scopes.insert(String::from(scope.as_ref()));
26517        self
26518    }
26519    /// Identifies the authorization scope(s) for the method you are building.
26520    ///
26521    /// See [`Self::add_scope()`] for details.
26522    pub fn add_scopes<I, St>(
26523        mut self,
26524        scopes: I,
26525    ) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C>
26526    where
26527        I: IntoIterator<Item = St>,
26528        St: AsRef<str>,
26529    {
26530        self._scopes
26531            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26532        self
26533    }
26534
26535    /// Removes all scopes, and no default scope will be used either.
26536    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26537    /// for details).
26538    pub fn clear_scopes(mut self) -> ProjectLocationCatalogSetDefaultBranchCall<'a, C> {
26539        self._scopes.clear();
26540        self
26541    }
26542}
26543
26544/// Updates the AttributesConfig. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.
26545///
26546/// A builder for the *locations.catalogs.updateAttributesConfig* method supported by a *project* resource.
26547/// It is not used directly, but through a [`ProjectMethods`] instance.
26548///
26549/// # Example
26550///
26551/// Instantiate a resource method builder
26552///
26553/// ```test_harness,no_run
26554/// # extern crate hyper;
26555/// # extern crate hyper_rustls;
26556/// # extern crate google_retail2 as retail2;
26557/// use retail2::api::GoogleCloudRetailV2AttributesConfig;
26558/// # async fn dox() {
26559/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26560///
26561/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26562/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26563/// #     .with_native_roots()
26564/// #     .unwrap()
26565/// #     .https_only()
26566/// #     .enable_http2()
26567/// #     .build();
26568///
26569/// # let executor = hyper_util::rt::TokioExecutor::new();
26570/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26571/// #     secret,
26572/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26573/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26574/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26575/// #     ),
26576/// # ).build().await.unwrap();
26577///
26578/// # let client = hyper_util::client::legacy::Client::builder(
26579/// #     hyper_util::rt::TokioExecutor::new()
26580/// # )
26581/// # .build(
26582/// #     hyper_rustls::HttpsConnectorBuilder::new()
26583/// #         .with_native_roots()
26584/// #         .unwrap()
26585/// #         .https_or_http()
26586/// #         .enable_http2()
26587/// #         .build()
26588/// # );
26589/// # let mut hub = CloudRetail::new(client, auth);
26590/// // As the method needs a request, you would usually fill it with the desired information
26591/// // into the respective structure. Some of the parts shown here might not be applicable !
26592/// // Values shown here are possibly random and not representative !
26593/// let mut req = GoogleCloudRetailV2AttributesConfig::default();
26594///
26595/// // You can configure optional parameters by calling the respective setters at will, and
26596/// // execute the final call using `doit()`.
26597/// // Values shown here are possibly random and not representative !
26598/// let result = hub.projects().locations_catalogs_update_attributes_config(req, "name")
26599///              .update_mask(FieldMask::new::<&str>(&[]))
26600///              .doit().await;
26601/// # }
26602/// ```
26603pub struct ProjectLocationCatalogUpdateAttributesConfigCall<'a, C>
26604where
26605    C: 'a,
26606{
26607    hub: &'a CloudRetail<C>,
26608    _request: GoogleCloudRetailV2AttributesConfig,
26609    _name: String,
26610    _update_mask: Option<common::FieldMask>,
26611    _delegate: Option<&'a mut dyn common::Delegate>,
26612    _additional_params: HashMap<String, String>,
26613    _scopes: BTreeSet<String>,
26614}
26615
26616impl<'a, C> common::CallBuilder for ProjectLocationCatalogUpdateAttributesConfigCall<'a, C> {}
26617
26618impl<'a, C> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C>
26619where
26620    C: common::Connector,
26621{
26622    /// Perform the operation you have build so far.
26623    pub async fn doit(
26624        mut self,
26625    ) -> common::Result<(common::Response, GoogleCloudRetailV2AttributesConfig)> {
26626        use std::borrow::Cow;
26627        use std::io::{Read, Seek};
26628
26629        use common::{url::Params, ToParts};
26630        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26631
26632        let mut dd = common::DefaultDelegate;
26633        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26634        dlg.begin(common::MethodInfo {
26635            id: "retail.projects.locations.catalogs.updateAttributesConfig",
26636            http_method: hyper::Method::PATCH,
26637        });
26638
26639        for &field in ["alt", "name", "updateMask"].iter() {
26640            if self._additional_params.contains_key(field) {
26641                dlg.finished(false);
26642                return Err(common::Error::FieldClash(field));
26643            }
26644        }
26645
26646        let mut params = Params::with_capacity(5 + self._additional_params.len());
26647        params.push("name", self._name);
26648        if let Some(value) = self._update_mask.as_ref() {
26649            params.push("updateMask", value.to_string());
26650        }
26651
26652        params.extend(self._additional_params.iter());
26653
26654        params.push("alt", "json");
26655        let mut url = self.hub._base_url.clone() + "v2/{+name}";
26656        if self._scopes.is_empty() {
26657            self._scopes
26658                .insert(Scope::CloudPlatform.as_ref().to_string());
26659        }
26660
26661        #[allow(clippy::single_element_loop)]
26662        for &(find_this, param_name) in [("{+name}", "name")].iter() {
26663            url = params.uri_replacement(url, param_name, find_this, true);
26664        }
26665        {
26666            let to_remove = ["name"];
26667            params.remove_params(&to_remove);
26668        }
26669
26670        let url = params.parse_with_url(&url);
26671
26672        let mut json_mime_type = mime::APPLICATION_JSON;
26673        let mut request_value_reader = {
26674            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26675            common::remove_json_null_values(&mut value);
26676            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26677            serde_json::to_writer(&mut dst, &value).unwrap();
26678            dst
26679        };
26680        let request_size = request_value_reader
26681            .seek(std::io::SeekFrom::End(0))
26682            .unwrap();
26683        request_value_reader
26684            .seek(std::io::SeekFrom::Start(0))
26685            .unwrap();
26686
26687        loop {
26688            let token = match self
26689                .hub
26690                .auth
26691                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26692                .await
26693            {
26694                Ok(token) => token,
26695                Err(e) => match dlg.token(e) {
26696                    Ok(token) => token,
26697                    Err(e) => {
26698                        dlg.finished(false);
26699                        return Err(common::Error::MissingToken(e));
26700                    }
26701                },
26702            };
26703            request_value_reader
26704                .seek(std::io::SeekFrom::Start(0))
26705                .unwrap();
26706            let mut req_result = {
26707                let client = &self.hub.client;
26708                dlg.pre_request();
26709                let mut req_builder = hyper::Request::builder()
26710                    .method(hyper::Method::PATCH)
26711                    .uri(url.as_str())
26712                    .header(USER_AGENT, self.hub._user_agent.clone());
26713
26714                if let Some(token) = token.as_ref() {
26715                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26716                }
26717
26718                let request = req_builder
26719                    .header(CONTENT_TYPE, json_mime_type.to_string())
26720                    .header(CONTENT_LENGTH, request_size as u64)
26721                    .body(common::to_body(
26722                        request_value_reader.get_ref().clone().into(),
26723                    ));
26724
26725                client.request(request.unwrap()).await
26726            };
26727
26728            match req_result {
26729                Err(err) => {
26730                    if let common::Retry::After(d) = dlg.http_error(&err) {
26731                        sleep(d).await;
26732                        continue;
26733                    }
26734                    dlg.finished(false);
26735                    return Err(common::Error::HttpError(err));
26736                }
26737                Ok(res) => {
26738                    let (mut parts, body) = res.into_parts();
26739                    let mut body = common::Body::new(body);
26740                    if !parts.status.is_success() {
26741                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26742                        let error = serde_json::from_str(&common::to_string(&bytes));
26743                        let response = common::to_response(parts, bytes.into());
26744
26745                        if let common::Retry::After(d) =
26746                            dlg.http_failure(&response, error.as_ref().ok())
26747                        {
26748                            sleep(d).await;
26749                            continue;
26750                        }
26751
26752                        dlg.finished(false);
26753
26754                        return Err(match error {
26755                            Ok(value) => common::Error::BadRequest(value),
26756                            _ => common::Error::Failure(response),
26757                        });
26758                    }
26759                    let response = {
26760                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26761                        let encoded = common::to_string(&bytes);
26762                        match serde_json::from_str(&encoded) {
26763                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26764                            Err(error) => {
26765                                dlg.response_json_decode_error(&encoded, &error);
26766                                return Err(common::Error::JsonDecodeError(
26767                                    encoded.to_string(),
26768                                    error,
26769                                ));
26770                            }
26771                        }
26772                    };
26773
26774                    dlg.finished(true);
26775                    return Ok(response);
26776                }
26777            }
26778        }
26779    }
26780
26781    ///
26782    /// Sets the *request* property to the given value.
26783    ///
26784    /// Even though the property as already been set when instantiating this call,
26785    /// we provide this method for API completeness.
26786    pub fn request(
26787        mut self,
26788        new_value: GoogleCloudRetailV2AttributesConfig,
26789    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C> {
26790        self._request = new_value;
26791        self
26792    }
26793    /// Required. Immutable. The fully qualified resource name of the attribute config. Format: `projects/*/locations/*/catalogs/*/attributesConfig`
26794    ///
26795    /// Sets the *name* path property to the given value.
26796    ///
26797    /// Even though the property as already been set when instantiating this call,
26798    /// we provide this method for API completeness.
26799    pub fn name(
26800        mut self,
26801        new_value: &str,
26802    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C> {
26803        self._name = new_value.to_string();
26804        self
26805    }
26806    /// Indicates which fields in the provided AttributesConfig to update. The following is the only supported field: * AttributesConfig.catalog_attributes If not set, all supported fields are updated.
26807    ///
26808    /// Sets the *update mask* query property to the given value.
26809    pub fn update_mask(
26810        mut self,
26811        new_value: common::FieldMask,
26812    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C> {
26813        self._update_mask = Some(new_value);
26814        self
26815    }
26816    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26817    /// while executing the actual API request.
26818    ///
26819    /// ````text
26820    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26821    /// ````
26822    ///
26823    /// Sets the *delegate* property to the given value.
26824    pub fn delegate(
26825        mut self,
26826        new_value: &'a mut dyn common::Delegate,
26827    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C> {
26828        self._delegate = Some(new_value);
26829        self
26830    }
26831
26832    /// Set any additional parameter of the query string used in the request.
26833    /// It should be used to set parameters which are not yet available through their own
26834    /// setters.
26835    ///
26836    /// Please note that this method must not be used to set any of the known parameters
26837    /// which have their own setter method. If done anyway, the request will fail.
26838    ///
26839    /// # Additional Parameters
26840    ///
26841    /// * *$.xgafv* (query-string) - V1 error format.
26842    /// * *access_token* (query-string) - OAuth access token.
26843    /// * *alt* (query-string) - Data format for response.
26844    /// * *callback* (query-string) - JSONP
26845    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26846    /// * *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.
26847    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26848    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26849    /// * *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.
26850    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26851    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26852    pub fn param<T>(
26853        mut self,
26854        name: T,
26855        value: T,
26856    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C>
26857    where
26858        T: AsRef<str>,
26859    {
26860        self._additional_params
26861            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26862        self
26863    }
26864
26865    /// Identifies the authorization scope for the method you are building.
26866    ///
26867    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26868    /// [`Scope::CloudPlatform`].
26869    ///
26870    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26871    /// tokens for more than one scope.
26872    ///
26873    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26874    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26875    /// sufficient, a read-write scope will do as well.
26876    pub fn add_scope<St>(
26877        mut self,
26878        scope: St,
26879    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C>
26880    where
26881        St: AsRef<str>,
26882    {
26883        self._scopes.insert(String::from(scope.as_ref()));
26884        self
26885    }
26886    /// Identifies the authorization scope(s) for the method you are building.
26887    ///
26888    /// See [`Self::add_scope()`] for details.
26889    pub fn add_scopes<I, St>(
26890        mut self,
26891        scopes: I,
26892    ) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C>
26893    where
26894        I: IntoIterator<Item = St>,
26895        St: AsRef<str>,
26896    {
26897        self._scopes
26898            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26899        self
26900    }
26901
26902    /// Removes all scopes, and no default scope will be used either.
26903    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26904    /// for details).
26905    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUpdateAttributesConfigCall<'a, C> {
26906        self._scopes.clear();
26907        self
26908    }
26909}
26910
26911/// Updates the CompletionConfigs.
26912///
26913/// A builder for the *locations.catalogs.updateCompletionConfig* method supported by a *project* resource.
26914/// It is not used directly, but through a [`ProjectMethods`] instance.
26915///
26916/// # Example
26917///
26918/// Instantiate a resource method builder
26919///
26920/// ```test_harness,no_run
26921/// # extern crate hyper;
26922/// # extern crate hyper_rustls;
26923/// # extern crate google_retail2 as retail2;
26924/// use retail2::api::GoogleCloudRetailV2CompletionConfig;
26925/// # async fn dox() {
26926/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26927///
26928/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26929/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26930/// #     .with_native_roots()
26931/// #     .unwrap()
26932/// #     .https_only()
26933/// #     .enable_http2()
26934/// #     .build();
26935///
26936/// # let executor = hyper_util::rt::TokioExecutor::new();
26937/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26938/// #     secret,
26939/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26940/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26941/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26942/// #     ),
26943/// # ).build().await.unwrap();
26944///
26945/// # let client = hyper_util::client::legacy::Client::builder(
26946/// #     hyper_util::rt::TokioExecutor::new()
26947/// # )
26948/// # .build(
26949/// #     hyper_rustls::HttpsConnectorBuilder::new()
26950/// #         .with_native_roots()
26951/// #         .unwrap()
26952/// #         .https_or_http()
26953/// #         .enable_http2()
26954/// #         .build()
26955/// # );
26956/// # let mut hub = CloudRetail::new(client, auth);
26957/// // As the method needs a request, you would usually fill it with the desired information
26958/// // into the respective structure. Some of the parts shown here might not be applicable !
26959/// // Values shown here are possibly random and not representative !
26960/// let mut req = GoogleCloudRetailV2CompletionConfig::default();
26961///
26962/// // You can configure optional parameters by calling the respective setters at will, and
26963/// // execute the final call using `doit()`.
26964/// // Values shown here are possibly random and not representative !
26965/// let result = hub.projects().locations_catalogs_update_completion_config(req, "name")
26966///              .update_mask(FieldMask::new::<&str>(&[]))
26967///              .doit().await;
26968/// # }
26969/// ```
26970pub struct ProjectLocationCatalogUpdateCompletionConfigCall<'a, C>
26971where
26972    C: 'a,
26973{
26974    hub: &'a CloudRetail<C>,
26975    _request: GoogleCloudRetailV2CompletionConfig,
26976    _name: String,
26977    _update_mask: Option<common::FieldMask>,
26978    _delegate: Option<&'a mut dyn common::Delegate>,
26979    _additional_params: HashMap<String, String>,
26980    _scopes: BTreeSet<String>,
26981}
26982
26983impl<'a, C> common::CallBuilder for ProjectLocationCatalogUpdateCompletionConfigCall<'a, C> {}
26984
26985impl<'a, C> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C>
26986where
26987    C: common::Connector,
26988{
26989    /// Perform the operation you have build so far.
26990    pub async fn doit(
26991        mut self,
26992    ) -> common::Result<(common::Response, GoogleCloudRetailV2CompletionConfig)> {
26993        use std::borrow::Cow;
26994        use std::io::{Read, Seek};
26995
26996        use common::{url::Params, ToParts};
26997        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26998
26999        let mut dd = common::DefaultDelegate;
27000        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27001        dlg.begin(common::MethodInfo {
27002            id: "retail.projects.locations.catalogs.updateCompletionConfig",
27003            http_method: hyper::Method::PATCH,
27004        });
27005
27006        for &field in ["alt", "name", "updateMask"].iter() {
27007            if self._additional_params.contains_key(field) {
27008                dlg.finished(false);
27009                return Err(common::Error::FieldClash(field));
27010            }
27011        }
27012
27013        let mut params = Params::with_capacity(5 + self._additional_params.len());
27014        params.push("name", self._name);
27015        if let Some(value) = self._update_mask.as_ref() {
27016            params.push("updateMask", value.to_string());
27017        }
27018
27019        params.extend(self._additional_params.iter());
27020
27021        params.push("alt", "json");
27022        let mut url = self.hub._base_url.clone() + "v2/{+name}";
27023        if self._scopes.is_empty() {
27024            self._scopes
27025                .insert(Scope::CloudPlatform.as_ref().to_string());
27026        }
27027
27028        #[allow(clippy::single_element_loop)]
27029        for &(find_this, param_name) in [("{+name}", "name")].iter() {
27030            url = params.uri_replacement(url, param_name, find_this, true);
27031        }
27032        {
27033            let to_remove = ["name"];
27034            params.remove_params(&to_remove);
27035        }
27036
27037        let url = params.parse_with_url(&url);
27038
27039        let mut json_mime_type = mime::APPLICATION_JSON;
27040        let mut request_value_reader = {
27041            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27042            common::remove_json_null_values(&mut value);
27043            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27044            serde_json::to_writer(&mut dst, &value).unwrap();
27045            dst
27046        };
27047        let request_size = request_value_reader
27048            .seek(std::io::SeekFrom::End(0))
27049            .unwrap();
27050        request_value_reader
27051            .seek(std::io::SeekFrom::Start(0))
27052            .unwrap();
27053
27054        loop {
27055            let token = match self
27056                .hub
27057                .auth
27058                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27059                .await
27060            {
27061                Ok(token) => token,
27062                Err(e) => match dlg.token(e) {
27063                    Ok(token) => token,
27064                    Err(e) => {
27065                        dlg.finished(false);
27066                        return Err(common::Error::MissingToken(e));
27067                    }
27068                },
27069            };
27070            request_value_reader
27071                .seek(std::io::SeekFrom::Start(0))
27072                .unwrap();
27073            let mut req_result = {
27074                let client = &self.hub.client;
27075                dlg.pre_request();
27076                let mut req_builder = hyper::Request::builder()
27077                    .method(hyper::Method::PATCH)
27078                    .uri(url.as_str())
27079                    .header(USER_AGENT, self.hub._user_agent.clone());
27080
27081                if let Some(token) = token.as_ref() {
27082                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27083                }
27084
27085                let request = req_builder
27086                    .header(CONTENT_TYPE, json_mime_type.to_string())
27087                    .header(CONTENT_LENGTH, request_size as u64)
27088                    .body(common::to_body(
27089                        request_value_reader.get_ref().clone().into(),
27090                    ));
27091
27092                client.request(request.unwrap()).await
27093            };
27094
27095            match req_result {
27096                Err(err) => {
27097                    if let common::Retry::After(d) = dlg.http_error(&err) {
27098                        sleep(d).await;
27099                        continue;
27100                    }
27101                    dlg.finished(false);
27102                    return Err(common::Error::HttpError(err));
27103                }
27104                Ok(res) => {
27105                    let (mut parts, body) = res.into_parts();
27106                    let mut body = common::Body::new(body);
27107                    if !parts.status.is_success() {
27108                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27109                        let error = serde_json::from_str(&common::to_string(&bytes));
27110                        let response = common::to_response(parts, bytes.into());
27111
27112                        if let common::Retry::After(d) =
27113                            dlg.http_failure(&response, error.as_ref().ok())
27114                        {
27115                            sleep(d).await;
27116                            continue;
27117                        }
27118
27119                        dlg.finished(false);
27120
27121                        return Err(match error {
27122                            Ok(value) => common::Error::BadRequest(value),
27123                            _ => common::Error::Failure(response),
27124                        });
27125                    }
27126                    let response = {
27127                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27128                        let encoded = common::to_string(&bytes);
27129                        match serde_json::from_str(&encoded) {
27130                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27131                            Err(error) => {
27132                                dlg.response_json_decode_error(&encoded, &error);
27133                                return Err(common::Error::JsonDecodeError(
27134                                    encoded.to_string(),
27135                                    error,
27136                                ));
27137                            }
27138                        }
27139                    };
27140
27141                    dlg.finished(true);
27142                    return Ok(response);
27143                }
27144            }
27145        }
27146    }
27147
27148    ///
27149    /// Sets the *request* property to the given value.
27150    ///
27151    /// Even though the property as already been set when instantiating this call,
27152    /// we provide this method for API completeness.
27153    pub fn request(
27154        mut self,
27155        new_value: GoogleCloudRetailV2CompletionConfig,
27156    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C> {
27157        self._request = new_value;
27158        self
27159    }
27160    /// Required. Immutable. Fully qualified name `projects/*/locations/*/catalogs/*/completionConfig`
27161    ///
27162    /// Sets the *name* path property to the given value.
27163    ///
27164    /// Even though the property as already been set when instantiating this call,
27165    /// we provide this method for API completeness.
27166    pub fn name(
27167        mut self,
27168        new_value: &str,
27169    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C> {
27170        self._name = new_value.to_string();
27171        self
27172    }
27173    /// Indicates which fields in the provided CompletionConfig to update. The following are the only supported fields: * CompletionConfig.matching_order * CompletionConfig.max_suggestions * CompletionConfig.min_prefix_length * CompletionConfig.auto_learning If not set, all supported fields are updated.
27174    ///
27175    /// Sets the *update mask* query property to the given value.
27176    pub fn update_mask(
27177        mut self,
27178        new_value: common::FieldMask,
27179    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C> {
27180        self._update_mask = Some(new_value);
27181        self
27182    }
27183    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27184    /// while executing the actual API request.
27185    ///
27186    /// ````text
27187    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27188    /// ````
27189    ///
27190    /// Sets the *delegate* property to the given value.
27191    pub fn delegate(
27192        mut self,
27193        new_value: &'a mut dyn common::Delegate,
27194    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C> {
27195        self._delegate = Some(new_value);
27196        self
27197    }
27198
27199    /// Set any additional parameter of the query string used in the request.
27200    /// It should be used to set parameters which are not yet available through their own
27201    /// setters.
27202    ///
27203    /// Please note that this method must not be used to set any of the known parameters
27204    /// which have their own setter method. If done anyway, the request will fail.
27205    ///
27206    /// # Additional Parameters
27207    ///
27208    /// * *$.xgafv* (query-string) - V1 error format.
27209    /// * *access_token* (query-string) - OAuth access token.
27210    /// * *alt* (query-string) - Data format for response.
27211    /// * *callback* (query-string) - JSONP
27212    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27213    /// * *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.
27214    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27215    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27216    /// * *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.
27217    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27218    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27219    pub fn param<T>(
27220        mut self,
27221        name: T,
27222        value: T,
27223    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C>
27224    where
27225        T: AsRef<str>,
27226    {
27227        self._additional_params
27228            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27229        self
27230    }
27231
27232    /// Identifies the authorization scope for the method you are building.
27233    ///
27234    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27235    /// [`Scope::CloudPlatform`].
27236    ///
27237    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27238    /// tokens for more than one scope.
27239    ///
27240    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27241    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27242    /// sufficient, a read-write scope will do as well.
27243    pub fn add_scope<St>(
27244        mut self,
27245        scope: St,
27246    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C>
27247    where
27248        St: AsRef<str>,
27249    {
27250        self._scopes.insert(String::from(scope.as_ref()));
27251        self
27252    }
27253    /// Identifies the authorization scope(s) for the method you are building.
27254    ///
27255    /// See [`Self::add_scope()`] for details.
27256    pub fn add_scopes<I, St>(
27257        mut self,
27258        scopes: I,
27259    ) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C>
27260    where
27261        I: IntoIterator<Item = St>,
27262        St: AsRef<str>,
27263    {
27264        self._scopes
27265            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27266        self
27267    }
27268
27269    /// Removes all scopes, and no default scope will be used either.
27270    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27271    /// for details).
27272    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUpdateCompletionConfigCall<'a, C> {
27273        self._scopes.clear();
27274        self
27275    }
27276}
27277
27278/// Updates the conversational search customization config for a given catalog.
27279///
27280/// A builder for the *locations.catalogs.updateConversationalSearchCustomizationConfig* method supported by a *project* resource.
27281/// It is not used directly, but through a [`ProjectMethods`] instance.
27282///
27283/// # Example
27284///
27285/// Instantiate a resource method builder
27286///
27287/// ```test_harness,no_run
27288/// # extern crate hyper;
27289/// # extern crate hyper_rustls;
27290/// # extern crate google_retail2 as retail2;
27291/// use retail2::api::GoogleCloudRetailV2ConversationalSearchCustomizationConfig;
27292/// # async fn dox() {
27293/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27294///
27295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27296/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27297/// #     .with_native_roots()
27298/// #     .unwrap()
27299/// #     .https_only()
27300/// #     .enable_http2()
27301/// #     .build();
27302///
27303/// # let executor = hyper_util::rt::TokioExecutor::new();
27304/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27305/// #     secret,
27306/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27307/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27308/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27309/// #     ),
27310/// # ).build().await.unwrap();
27311///
27312/// # let client = hyper_util::client::legacy::Client::builder(
27313/// #     hyper_util::rt::TokioExecutor::new()
27314/// # )
27315/// # .build(
27316/// #     hyper_rustls::HttpsConnectorBuilder::new()
27317/// #         .with_native_roots()
27318/// #         .unwrap()
27319/// #         .https_or_http()
27320/// #         .enable_http2()
27321/// #         .build()
27322/// # );
27323/// # let mut hub = CloudRetail::new(client, auth);
27324/// // As the method needs a request, you would usually fill it with the desired information
27325/// // into the respective structure. Some of the parts shown here might not be applicable !
27326/// // Values shown here are possibly random and not representative !
27327/// let mut req = GoogleCloudRetailV2ConversationalSearchCustomizationConfig::default();
27328///
27329/// // You can configure optional parameters by calling the respective setters at will, and
27330/// // execute the final call using `doit()`.
27331/// // Values shown here are possibly random and not representative !
27332/// let result = hub.projects().locations_catalogs_update_conversational_search_customization_config(req, "catalog")
27333///              .update_mask(FieldMask::new::<&str>(&[]))
27334///              .doit().await;
27335/// # }
27336/// ```
27337pub struct ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C>
27338where
27339    C: 'a,
27340{
27341    hub: &'a CloudRetail<C>,
27342    _request: GoogleCloudRetailV2ConversationalSearchCustomizationConfig,
27343    _catalog: String,
27344    _update_mask: Option<common::FieldMask>,
27345    _delegate: Option<&'a mut dyn common::Delegate>,
27346    _additional_params: HashMap<String, String>,
27347    _scopes: BTreeSet<String>,
27348}
27349
27350impl<'a, C> common::CallBuilder
27351    for ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C>
27352{
27353}
27354
27355impl<'a, C> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C>
27356where
27357    C: common::Connector,
27358{
27359    /// Perform the operation you have build so far.
27360    pub async fn doit(
27361        mut self,
27362    ) -> common::Result<(
27363        common::Response,
27364        GoogleCloudRetailV2ConversationalSearchCustomizationConfig,
27365    )> {
27366        use std::borrow::Cow;
27367        use std::io::{Read, Seek};
27368
27369        use common::{url::Params, ToParts};
27370        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27371
27372        let mut dd = common::DefaultDelegate;
27373        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27374        dlg.begin(common::MethodInfo {
27375            id: "retail.projects.locations.catalogs.updateConversationalSearchCustomizationConfig",
27376            http_method: hyper::Method::PATCH,
27377        });
27378
27379        for &field in ["alt", "catalog", "updateMask"].iter() {
27380            if self._additional_params.contains_key(field) {
27381                dlg.finished(false);
27382                return Err(common::Error::FieldClash(field));
27383            }
27384        }
27385
27386        let mut params = Params::with_capacity(5 + self._additional_params.len());
27387        params.push("catalog", self._catalog);
27388        if let Some(value) = self._update_mask.as_ref() {
27389            params.push("updateMask", value.to_string());
27390        }
27391
27392        params.extend(self._additional_params.iter());
27393
27394        params.push("alt", "json");
27395        let mut url =
27396            self.hub._base_url.clone() + "v2/{+catalog}/conversationalSearchCustomizationConfig";
27397        if self._scopes.is_empty() {
27398            self._scopes
27399                .insert(Scope::CloudPlatform.as_ref().to_string());
27400        }
27401
27402        #[allow(clippy::single_element_loop)]
27403        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
27404            url = params.uri_replacement(url, param_name, find_this, true);
27405        }
27406        {
27407            let to_remove = ["catalog"];
27408            params.remove_params(&to_remove);
27409        }
27410
27411        let url = params.parse_with_url(&url);
27412
27413        let mut json_mime_type = mime::APPLICATION_JSON;
27414        let mut request_value_reader = {
27415            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27416            common::remove_json_null_values(&mut value);
27417            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27418            serde_json::to_writer(&mut dst, &value).unwrap();
27419            dst
27420        };
27421        let request_size = request_value_reader
27422            .seek(std::io::SeekFrom::End(0))
27423            .unwrap();
27424        request_value_reader
27425            .seek(std::io::SeekFrom::Start(0))
27426            .unwrap();
27427
27428        loop {
27429            let token = match self
27430                .hub
27431                .auth
27432                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27433                .await
27434            {
27435                Ok(token) => token,
27436                Err(e) => match dlg.token(e) {
27437                    Ok(token) => token,
27438                    Err(e) => {
27439                        dlg.finished(false);
27440                        return Err(common::Error::MissingToken(e));
27441                    }
27442                },
27443            };
27444            request_value_reader
27445                .seek(std::io::SeekFrom::Start(0))
27446                .unwrap();
27447            let mut req_result = {
27448                let client = &self.hub.client;
27449                dlg.pre_request();
27450                let mut req_builder = hyper::Request::builder()
27451                    .method(hyper::Method::PATCH)
27452                    .uri(url.as_str())
27453                    .header(USER_AGENT, self.hub._user_agent.clone());
27454
27455                if let Some(token) = token.as_ref() {
27456                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27457                }
27458
27459                let request = req_builder
27460                    .header(CONTENT_TYPE, json_mime_type.to_string())
27461                    .header(CONTENT_LENGTH, request_size as u64)
27462                    .body(common::to_body(
27463                        request_value_reader.get_ref().clone().into(),
27464                    ));
27465
27466                client.request(request.unwrap()).await
27467            };
27468
27469            match req_result {
27470                Err(err) => {
27471                    if let common::Retry::After(d) = dlg.http_error(&err) {
27472                        sleep(d).await;
27473                        continue;
27474                    }
27475                    dlg.finished(false);
27476                    return Err(common::Error::HttpError(err));
27477                }
27478                Ok(res) => {
27479                    let (mut parts, body) = res.into_parts();
27480                    let mut body = common::Body::new(body);
27481                    if !parts.status.is_success() {
27482                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27483                        let error = serde_json::from_str(&common::to_string(&bytes));
27484                        let response = common::to_response(parts, bytes.into());
27485
27486                        if let common::Retry::After(d) =
27487                            dlg.http_failure(&response, error.as_ref().ok())
27488                        {
27489                            sleep(d).await;
27490                            continue;
27491                        }
27492
27493                        dlg.finished(false);
27494
27495                        return Err(match error {
27496                            Ok(value) => common::Error::BadRequest(value),
27497                            _ => common::Error::Failure(response),
27498                        });
27499                    }
27500                    let response = {
27501                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27502                        let encoded = common::to_string(&bytes);
27503                        match serde_json::from_str(&encoded) {
27504                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27505                            Err(error) => {
27506                                dlg.response_json_decode_error(&encoded, &error);
27507                                return Err(common::Error::JsonDecodeError(
27508                                    encoded.to_string(),
27509                                    error,
27510                                ));
27511                            }
27512                        }
27513                    };
27514
27515                    dlg.finished(true);
27516                    return Ok(response);
27517                }
27518            }
27519        }
27520    }
27521
27522    ///
27523    /// Sets the *request* property to the given value.
27524    ///
27525    /// Even though the property as already been set when instantiating this call,
27526    /// we provide this method for API completeness.
27527    pub fn request(
27528        mut self,
27529        new_value: GoogleCloudRetailV2ConversationalSearchCustomizationConfig,
27530    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C> {
27531        self._request = new_value;
27532        self
27533    }
27534    /// Required. Resource name of the catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
27535    ///
27536    /// Sets the *catalog* path property to the given value.
27537    ///
27538    /// Even though the property as already been set when instantiating this call,
27539    /// we provide this method for API completeness.
27540    pub fn catalog(
27541        mut self,
27542        new_value: &str,
27543    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C> {
27544        self._catalog = new_value.to_string();
27545        self
27546    }
27547    /// Optional. Indicates which fields in the provided ConversationalSearchCustomizationConfig to update. If not set or empty, all supported fields are updated.
27548    ///
27549    /// Sets the *update mask* query property to the given value.
27550    pub fn update_mask(
27551        mut self,
27552        new_value: common::FieldMask,
27553    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C> {
27554        self._update_mask = Some(new_value);
27555        self
27556    }
27557    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27558    /// while executing the actual API request.
27559    ///
27560    /// ````text
27561    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27562    /// ````
27563    ///
27564    /// Sets the *delegate* property to the given value.
27565    pub fn delegate(
27566        mut self,
27567        new_value: &'a mut dyn common::Delegate,
27568    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C> {
27569        self._delegate = Some(new_value);
27570        self
27571    }
27572
27573    /// Set any additional parameter of the query string used in the request.
27574    /// It should be used to set parameters which are not yet available through their own
27575    /// setters.
27576    ///
27577    /// Please note that this method must not be used to set any of the known parameters
27578    /// which have their own setter method. If done anyway, the request will fail.
27579    ///
27580    /// # Additional Parameters
27581    ///
27582    /// * *$.xgafv* (query-string) - V1 error format.
27583    /// * *access_token* (query-string) - OAuth access token.
27584    /// * *alt* (query-string) - Data format for response.
27585    /// * *callback* (query-string) - JSONP
27586    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27587    /// * *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.
27588    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27589    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27590    /// * *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.
27591    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27592    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27593    pub fn param<T>(
27594        mut self,
27595        name: T,
27596        value: T,
27597    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C>
27598    where
27599        T: AsRef<str>,
27600    {
27601        self._additional_params
27602            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27603        self
27604    }
27605
27606    /// Identifies the authorization scope for the method you are building.
27607    ///
27608    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27609    /// [`Scope::CloudPlatform`].
27610    ///
27611    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27612    /// tokens for more than one scope.
27613    ///
27614    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27615    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27616    /// sufficient, a read-write scope will do as well.
27617    pub fn add_scope<St>(
27618        mut self,
27619        scope: St,
27620    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C>
27621    where
27622        St: AsRef<str>,
27623    {
27624        self._scopes.insert(String::from(scope.as_ref()));
27625        self
27626    }
27627    /// Identifies the authorization scope(s) for the method you are building.
27628    ///
27629    /// See [`Self::add_scope()`] for details.
27630    pub fn add_scopes<I, St>(
27631        mut self,
27632        scopes: I,
27633    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C>
27634    where
27635        I: IntoIterator<Item = St>,
27636        St: AsRef<str>,
27637    {
27638        self._scopes
27639            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27640        self
27641    }
27642
27643    /// Removes all scopes, and no default scope will be used either.
27644    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27645    /// for details).
27646    pub fn clear_scopes(
27647        mut self,
27648    ) -> ProjectLocationCatalogUpdateConversationalSearchCustomizationConfigCall<'a, C> {
27649        self._scopes.clear();
27650        self
27651    }
27652}
27653
27654/// Allows management of individual questions.
27655///
27656/// A builder for the *locations.catalogs.updateGenerativeQuestion* method supported by a *project* resource.
27657/// It is not used directly, but through a [`ProjectMethods`] instance.
27658///
27659/// # Example
27660///
27661/// Instantiate a resource method builder
27662///
27663/// ```test_harness,no_run
27664/// # extern crate hyper;
27665/// # extern crate hyper_rustls;
27666/// # extern crate google_retail2 as retail2;
27667/// use retail2::api::GoogleCloudRetailV2GenerativeQuestionConfig;
27668/// # async fn dox() {
27669/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27670///
27671/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27672/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27673/// #     .with_native_roots()
27674/// #     .unwrap()
27675/// #     .https_only()
27676/// #     .enable_http2()
27677/// #     .build();
27678///
27679/// # let executor = hyper_util::rt::TokioExecutor::new();
27680/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27681/// #     secret,
27682/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27683/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27684/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27685/// #     ),
27686/// # ).build().await.unwrap();
27687///
27688/// # let client = hyper_util::client::legacy::Client::builder(
27689/// #     hyper_util::rt::TokioExecutor::new()
27690/// # )
27691/// # .build(
27692/// #     hyper_rustls::HttpsConnectorBuilder::new()
27693/// #         .with_native_roots()
27694/// #         .unwrap()
27695/// #         .https_or_http()
27696/// #         .enable_http2()
27697/// #         .build()
27698/// # );
27699/// # let mut hub = CloudRetail::new(client, auth);
27700/// // As the method needs a request, you would usually fill it with the desired information
27701/// // into the respective structure. Some of the parts shown here might not be applicable !
27702/// // Values shown here are possibly random and not representative !
27703/// let mut req = GoogleCloudRetailV2GenerativeQuestionConfig::default();
27704///
27705/// // You can configure optional parameters by calling the respective setters at will, and
27706/// // execute the final call using `doit()`.
27707/// // Values shown here are possibly random and not representative !
27708/// let result = hub.projects().locations_catalogs_update_generative_question(req, "catalog")
27709///              .update_mask(FieldMask::new::<&str>(&[]))
27710///              .doit().await;
27711/// # }
27712/// ```
27713pub struct ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C>
27714where
27715    C: 'a,
27716{
27717    hub: &'a CloudRetail<C>,
27718    _request: GoogleCloudRetailV2GenerativeQuestionConfig,
27719    _catalog: String,
27720    _update_mask: Option<common::FieldMask>,
27721    _delegate: Option<&'a mut dyn common::Delegate>,
27722    _additional_params: HashMap<String, String>,
27723    _scopes: BTreeSet<String>,
27724}
27725
27726impl<'a, C> common::CallBuilder for ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C> {}
27727
27728impl<'a, C> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C>
27729where
27730    C: common::Connector,
27731{
27732    /// Perform the operation you have build so far.
27733    pub async fn doit(
27734        mut self,
27735    ) -> common::Result<(
27736        common::Response,
27737        GoogleCloudRetailV2GenerativeQuestionConfig,
27738    )> {
27739        use std::borrow::Cow;
27740        use std::io::{Read, Seek};
27741
27742        use common::{url::Params, ToParts};
27743        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27744
27745        let mut dd = common::DefaultDelegate;
27746        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27747        dlg.begin(common::MethodInfo {
27748            id: "retail.projects.locations.catalogs.updateGenerativeQuestion",
27749            http_method: hyper::Method::PATCH,
27750        });
27751
27752        for &field in ["alt", "catalog", "updateMask"].iter() {
27753            if self._additional_params.contains_key(field) {
27754                dlg.finished(false);
27755                return Err(common::Error::FieldClash(field));
27756            }
27757        }
27758
27759        let mut params = Params::with_capacity(5 + self._additional_params.len());
27760        params.push("catalog", self._catalog);
27761        if let Some(value) = self._update_mask.as_ref() {
27762            params.push("updateMask", value.to_string());
27763        }
27764
27765        params.extend(self._additional_params.iter());
27766
27767        params.push("alt", "json");
27768        let mut url = self.hub._base_url.clone() + "v2/{+catalog}/generativeQuestion";
27769        if self._scopes.is_empty() {
27770            self._scopes
27771                .insert(Scope::CloudPlatform.as_ref().to_string());
27772        }
27773
27774        #[allow(clippy::single_element_loop)]
27775        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
27776            url = params.uri_replacement(url, param_name, find_this, true);
27777        }
27778        {
27779            let to_remove = ["catalog"];
27780            params.remove_params(&to_remove);
27781        }
27782
27783        let url = params.parse_with_url(&url);
27784
27785        let mut json_mime_type = mime::APPLICATION_JSON;
27786        let mut request_value_reader = {
27787            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27788            common::remove_json_null_values(&mut value);
27789            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27790            serde_json::to_writer(&mut dst, &value).unwrap();
27791            dst
27792        };
27793        let request_size = request_value_reader
27794            .seek(std::io::SeekFrom::End(0))
27795            .unwrap();
27796        request_value_reader
27797            .seek(std::io::SeekFrom::Start(0))
27798            .unwrap();
27799
27800        loop {
27801            let token = match self
27802                .hub
27803                .auth
27804                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27805                .await
27806            {
27807                Ok(token) => token,
27808                Err(e) => match dlg.token(e) {
27809                    Ok(token) => token,
27810                    Err(e) => {
27811                        dlg.finished(false);
27812                        return Err(common::Error::MissingToken(e));
27813                    }
27814                },
27815            };
27816            request_value_reader
27817                .seek(std::io::SeekFrom::Start(0))
27818                .unwrap();
27819            let mut req_result = {
27820                let client = &self.hub.client;
27821                dlg.pre_request();
27822                let mut req_builder = hyper::Request::builder()
27823                    .method(hyper::Method::PATCH)
27824                    .uri(url.as_str())
27825                    .header(USER_AGENT, self.hub._user_agent.clone());
27826
27827                if let Some(token) = token.as_ref() {
27828                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27829                }
27830
27831                let request = req_builder
27832                    .header(CONTENT_TYPE, json_mime_type.to_string())
27833                    .header(CONTENT_LENGTH, request_size as u64)
27834                    .body(common::to_body(
27835                        request_value_reader.get_ref().clone().into(),
27836                    ));
27837
27838                client.request(request.unwrap()).await
27839            };
27840
27841            match req_result {
27842                Err(err) => {
27843                    if let common::Retry::After(d) = dlg.http_error(&err) {
27844                        sleep(d).await;
27845                        continue;
27846                    }
27847                    dlg.finished(false);
27848                    return Err(common::Error::HttpError(err));
27849                }
27850                Ok(res) => {
27851                    let (mut parts, body) = res.into_parts();
27852                    let mut body = common::Body::new(body);
27853                    if !parts.status.is_success() {
27854                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27855                        let error = serde_json::from_str(&common::to_string(&bytes));
27856                        let response = common::to_response(parts, bytes.into());
27857
27858                        if let common::Retry::After(d) =
27859                            dlg.http_failure(&response, error.as_ref().ok())
27860                        {
27861                            sleep(d).await;
27862                            continue;
27863                        }
27864
27865                        dlg.finished(false);
27866
27867                        return Err(match error {
27868                            Ok(value) => common::Error::BadRequest(value),
27869                            _ => common::Error::Failure(response),
27870                        });
27871                    }
27872                    let response = {
27873                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27874                        let encoded = common::to_string(&bytes);
27875                        match serde_json::from_str(&encoded) {
27876                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27877                            Err(error) => {
27878                                dlg.response_json_decode_error(&encoded, &error);
27879                                return Err(common::Error::JsonDecodeError(
27880                                    encoded.to_string(),
27881                                    error,
27882                                ));
27883                            }
27884                        }
27885                    };
27886
27887                    dlg.finished(true);
27888                    return Ok(response);
27889                }
27890            }
27891        }
27892    }
27893
27894    ///
27895    /// Sets the *request* property to the given value.
27896    ///
27897    /// Even though the property as already been set when instantiating this call,
27898    /// we provide this method for API completeness.
27899    pub fn request(
27900        mut self,
27901        new_value: GoogleCloudRetailV2GenerativeQuestionConfig,
27902    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C> {
27903        self._request = new_value;
27904        self
27905    }
27906    /// Required. Resource name of the catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
27907    ///
27908    /// Sets the *catalog* path property to the given value.
27909    ///
27910    /// Even though the property as already been set when instantiating this call,
27911    /// we provide this method for API completeness.
27912    pub fn catalog(
27913        mut self,
27914        new_value: &str,
27915    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C> {
27916        self._catalog = new_value.to_string();
27917        self
27918    }
27919    /// Optional. Indicates which fields in the provided GenerativeQuestionConfig to update. The following are NOT supported: * GenerativeQuestionConfig.frequency If not set or empty, all supported fields are updated.
27920    ///
27921    /// Sets the *update mask* query property to the given value.
27922    pub fn update_mask(
27923        mut self,
27924        new_value: common::FieldMask,
27925    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C> {
27926        self._update_mask = Some(new_value);
27927        self
27928    }
27929    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27930    /// while executing the actual API request.
27931    ///
27932    /// ````text
27933    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27934    /// ````
27935    ///
27936    /// Sets the *delegate* property to the given value.
27937    pub fn delegate(
27938        mut self,
27939        new_value: &'a mut dyn common::Delegate,
27940    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C> {
27941        self._delegate = Some(new_value);
27942        self
27943    }
27944
27945    /// Set any additional parameter of the query string used in the request.
27946    /// It should be used to set parameters which are not yet available through their own
27947    /// setters.
27948    ///
27949    /// Please note that this method must not be used to set any of the known parameters
27950    /// which have their own setter method. If done anyway, the request will fail.
27951    ///
27952    /// # Additional Parameters
27953    ///
27954    /// * *$.xgafv* (query-string) - V1 error format.
27955    /// * *access_token* (query-string) - OAuth access token.
27956    /// * *alt* (query-string) - Data format for response.
27957    /// * *callback* (query-string) - JSONP
27958    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27959    /// * *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.
27960    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27961    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27962    /// * *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.
27963    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27964    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27965    pub fn param<T>(
27966        mut self,
27967        name: T,
27968        value: T,
27969    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C>
27970    where
27971        T: AsRef<str>,
27972    {
27973        self._additional_params
27974            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27975        self
27976    }
27977
27978    /// Identifies the authorization scope for the method you are building.
27979    ///
27980    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27981    /// [`Scope::CloudPlatform`].
27982    ///
27983    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27984    /// tokens for more than one scope.
27985    ///
27986    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27987    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27988    /// sufficient, a read-write scope will do as well.
27989    pub fn add_scope<St>(
27990        mut self,
27991        scope: St,
27992    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C>
27993    where
27994        St: AsRef<str>,
27995    {
27996        self._scopes.insert(String::from(scope.as_ref()));
27997        self
27998    }
27999    /// Identifies the authorization scope(s) for the method you are building.
28000    ///
28001    /// See [`Self::add_scope()`] for details.
28002    pub fn add_scopes<I, St>(
28003        mut self,
28004        scopes: I,
28005    ) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C>
28006    where
28007        I: IntoIterator<Item = St>,
28008        St: AsRef<str>,
28009    {
28010        self._scopes
28011            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28012        self
28013    }
28014
28015    /// Removes all scopes, and no default scope will be used either.
28016    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28017    /// for details).
28018    pub fn clear_scopes(mut self) -> ProjectLocationCatalogUpdateGenerativeQuestionCall<'a, C> {
28019        self._scopes.clear();
28020        self
28021    }
28022}
28023
28024/// Manages overal generative question feature state -- enables toggling feature on and off.
28025///
28026/// A builder for the *locations.catalogs.updateGenerativeQuestionFeature* method supported by a *project* resource.
28027/// It is not used directly, but through a [`ProjectMethods`] instance.
28028///
28029/// # Example
28030///
28031/// Instantiate a resource method builder
28032///
28033/// ```test_harness,no_run
28034/// # extern crate hyper;
28035/// # extern crate hyper_rustls;
28036/// # extern crate google_retail2 as retail2;
28037/// use retail2::api::GoogleCloudRetailV2GenerativeQuestionsFeatureConfig;
28038/// # async fn dox() {
28039/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28040///
28041/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28042/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28043/// #     .with_native_roots()
28044/// #     .unwrap()
28045/// #     .https_only()
28046/// #     .enable_http2()
28047/// #     .build();
28048///
28049/// # let executor = hyper_util::rt::TokioExecutor::new();
28050/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28051/// #     secret,
28052/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28053/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28054/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28055/// #     ),
28056/// # ).build().await.unwrap();
28057///
28058/// # let client = hyper_util::client::legacy::Client::builder(
28059/// #     hyper_util::rt::TokioExecutor::new()
28060/// # )
28061/// # .build(
28062/// #     hyper_rustls::HttpsConnectorBuilder::new()
28063/// #         .with_native_roots()
28064/// #         .unwrap()
28065/// #         .https_or_http()
28066/// #         .enable_http2()
28067/// #         .build()
28068/// # );
28069/// # let mut hub = CloudRetail::new(client, auth);
28070/// // As the method needs a request, you would usually fill it with the desired information
28071/// // into the respective structure. Some of the parts shown here might not be applicable !
28072/// // Values shown here are possibly random and not representative !
28073/// let mut req = GoogleCloudRetailV2GenerativeQuestionsFeatureConfig::default();
28074///
28075/// // You can configure optional parameters by calling the respective setters at will, and
28076/// // execute the final call using `doit()`.
28077/// // Values shown here are possibly random and not representative !
28078/// let result = hub.projects().locations_catalogs_update_generative_question_feature(req, "catalog")
28079///              .update_mask(FieldMask::new::<&str>(&[]))
28080///              .doit().await;
28081/// # }
28082/// ```
28083pub struct ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C>
28084where
28085    C: 'a,
28086{
28087    hub: &'a CloudRetail<C>,
28088    _request: GoogleCloudRetailV2GenerativeQuestionsFeatureConfig,
28089    _catalog: String,
28090    _update_mask: Option<common::FieldMask>,
28091    _delegate: Option<&'a mut dyn common::Delegate>,
28092    _additional_params: HashMap<String, String>,
28093    _scopes: BTreeSet<String>,
28094}
28095
28096impl<'a, C> common::CallBuilder
28097    for ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C>
28098{
28099}
28100
28101impl<'a, C> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C>
28102where
28103    C: common::Connector,
28104{
28105    /// Perform the operation you have build so far.
28106    pub async fn doit(
28107        mut self,
28108    ) -> common::Result<(
28109        common::Response,
28110        GoogleCloudRetailV2GenerativeQuestionsFeatureConfig,
28111    )> {
28112        use std::borrow::Cow;
28113        use std::io::{Read, Seek};
28114
28115        use common::{url::Params, ToParts};
28116        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28117
28118        let mut dd = common::DefaultDelegate;
28119        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28120        dlg.begin(common::MethodInfo {
28121            id: "retail.projects.locations.catalogs.updateGenerativeQuestionFeature",
28122            http_method: hyper::Method::PATCH,
28123        });
28124
28125        for &field in ["alt", "catalog", "updateMask"].iter() {
28126            if self._additional_params.contains_key(field) {
28127                dlg.finished(false);
28128                return Err(common::Error::FieldClash(field));
28129            }
28130        }
28131
28132        let mut params = Params::with_capacity(5 + self._additional_params.len());
28133        params.push("catalog", self._catalog);
28134        if let Some(value) = self._update_mask.as_ref() {
28135            params.push("updateMask", value.to_string());
28136        }
28137
28138        params.extend(self._additional_params.iter());
28139
28140        params.push("alt", "json");
28141        let mut url = self.hub._base_url.clone() + "v2/{+catalog}/generativeQuestionFeature";
28142        if self._scopes.is_empty() {
28143            self._scopes
28144                .insert(Scope::CloudPlatform.as_ref().to_string());
28145        }
28146
28147        #[allow(clippy::single_element_loop)]
28148        for &(find_this, param_name) in [("{+catalog}", "catalog")].iter() {
28149            url = params.uri_replacement(url, param_name, find_this, true);
28150        }
28151        {
28152            let to_remove = ["catalog"];
28153            params.remove_params(&to_remove);
28154        }
28155
28156        let url = params.parse_with_url(&url);
28157
28158        let mut json_mime_type = mime::APPLICATION_JSON;
28159        let mut request_value_reader = {
28160            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28161            common::remove_json_null_values(&mut value);
28162            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28163            serde_json::to_writer(&mut dst, &value).unwrap();
28164            dst
28165        };
28166        let request_size = request_value_reader
28167            .seek(std::io::SeekFrom::End(0))
28168            .unwrap();
28169        request_value_reader
28170            .seek(std::io::SeekFrom::Start(0))
28171            .unwrap();
28172
28173        loop {
28174            let token = match self
28175                .hub
28176                .auth
28177                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28178                .await
28179            {
28180                Ok(token) => token,
28181                Err(e) => match dlg.token(e) {
28182                    Ok(token) => token,
28183                    Err(e) => {
28184                        dlg.finished(false);
28185                        return Err(common::Error::MissingToken(e));
28186                    }
28187                },
28188            };
28189            request_value_reader
28190                .seek(std::io::SeekFrom::Start(0))
28191                .unwrap();
28192            let mut req_result = {
28193                let client = &self.hub.client;
28194                dlg.pre_request();
28195                let mut req_builder = hyper::Request::builder()
28196                    .method(hyper::Method::PATCH)
28197                    .uri(url.as_str())
28198                    .header(USER_AGENT, self.hub._user_agent.clone());
28199
28200                if let Some(token) = token.as_ref() {
28201                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28202                }
28203
28204                let request = req_builder
28205                    .header(CONTENT_TYPE, json_mime_type.to_string())
28206                    .header(CONTENT_LENGTH, request_size as u64)
28207                    .body(common::to_body(
28208                        request_value_reader.get_ref().clone().into(),
28209                    ));
28210
28211                client.request(request.unwrap()).await
28212            };
28213
28214            match req_result {
28215                Err(err) => {
28216                    if let common::Retry::After(d) = dlg.http_error(&err) {
28217                        sleep(d).await;
28218                        continue;
28219                    }
28220                    dlg.finished(false);
28221                    return Err(common::Error::HttpError(err));
28222                }
28223                Ok(res) => {
28224                    let (mut parts, body) = res.into_parts();
28225                    let mut body = common::Body::new(body);
28226                    if !parts.status.is_success() {
28227                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28228                        let error = serde_json::from_str(&common::to_string(&bytes));
28229                        let response = common::to_response(parts, bytes.into());
28230
28231                        if let common::Retry::After(d) =
28232                            dlg.http_failure(&response, error.as_ref().ok())
28233                        {
28234                            sleep(d).await;
28235                            continue;
28236                        }
28237
28238                        dlg.finished(false);
28239
28240                        return Err(match error {
28241                            Ok(value) => common::Error::BadRequest(value),
28242                            _ => common::Error::Failure(response),
28243                        });
28244                    }
28245                    let response = {
28246                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28247                        let encoded = common::to_string(&bytes);
28248                        match serde_json::from_str(&encoded) {
28249                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28250                            Err(error) => {
28251                                dlg.response_json_decode_error(&encoded, &error);
28252                                return Err(common::Error::JsonDecodeError(
28253                                    encoded.to_string(),
28254                                    error,
28255                                ));
28256                            }
28257                        }
28258                    };
28259
28260                    dlg.finished(true);
28261                    return Ok(response);
28262                }
28263            }
28264        }
28265    }
28266
28267    ///
28268    /// Sets the *request* property to the given value.
28269    ///
28270    /// Even though the property as already been set when instantiating this call,
28271    /// we provide this method for API completeness.
28272    pub fn request(
28273        mut self,
28274        new_value: GoogleCloudRetailV2GenerativeQuestionsFeatureConfig,
28275    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C> {
28276        self._request = new_value;
28277        self
28278    }
28279    /// Required. Resource name of the affected catalog. Format: projects/{project}/locations/{location}/catalogs/{catalog}
28280    ///
28281    /// Sets the *catalog* path property to the given value.
28282    ///
28283    /// Even though the property as already been set when instantiating this call,
28284    /// we provide this method for API completeness.
28285    pub fn catalog(
28286        mut self,
28287        new_value: &str,
28288    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C> {
28289        self._catalog = new_value.to_string();
28290        self
28291    }
28292    /// Optional. Indicates which fields in the provided GenerativeQuestionsFeatureConfig to update. If not set or empty, all supported fields are updated.
28293    ///
28294    /// Sets the *update mask* query property to the given value.
28295    pub fn update_mask(
28296        mut self,
28297        new_value: common::FieldMask,
28298    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C> {
28299        self._update_mask = Some(new_value);
28300        self
28301    }
28302    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28303    /// while executing the actual API request.
28304    ///
28305    /// ````text
28306    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28307    /// ````
28308    ///
28309    /// Sets the *delegate* property to the given value.
28310    pub fn delegate(
28311        mut self,
28312        new_value: &'a mut dyn common::Delegate,
28313    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C> {
28314        self._delegate = Some(new_value);
28315        self
28316    }
28317
28318    /// Set any additional parameter of the query string used in the request.
28319    /// It should be used to set parameters which are not yet available through their own
28320    /// setters.
28321    ///
28322    /// Please note that this method must not be used to set any of the known parameters
28323    /// which have their own setter method. If done anyway, the request will fail.
28324    ///
28325    /// # Additional Parameters
28326    ///
28327    /// * *$.xgafv* (query-string) - V1 error format.
28328    /// * *access_token* (query-string) - OAuth access token.
28329    /// * *alt* (query-string) - Data format for response.
28330    /// * *callback* (query-string) - JSONP
28331    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28332    /// * *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.
28333    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28334    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28335    /// * *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.
28336    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28337    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28338    pub fn param<T>(
28339        mut self,
28340        name: T,
28341        value: T,
28342    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C>
28343    where
28344        T: AsRef<str>,
28345    {
28346        self._additional_params
28347            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28348        self
28349    }
28350
28351    /// Identifies the authorization scope for the method you are building.
28352    ///
28353    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28354    /// [`Scope::CloudPlatform`].
28355    ///
28356    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28357    /// tokens for more than one scope.
28358    ///
28359    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28360    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28361    /// sufficient, a read-write scope will do as well.
28362    pub fn add_scope<St>(
28363        mut self,
28364        scope: St,
28365    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C>
28366    where
28367        St: AsRef<str>,
28368    {
28369        self._scopes.insert(String::from(scope.as_ref()));
28370        self
28371    }
28372    /// Identifies the authorization scope(s) for the method you are building.
28373    ///
28374    /// See [`Self::add_scope()`] for details.
28375    pub fn add_scopes<I, St>(
28376        mut self,
28377        scopes: I,
28378    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C>
28379    where
28380        I: IntoIterator<Item = St>,
28381        St: AsRef<str>,
28382    {
28383        self._scopes
28384            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28385        self
28386    }
28387
28388    /// Removes all scopes, and no default scope will be used either.
28389    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28390    /// for details).
28391    pub fn clear_scopes(
28392        mut self,
28393    ) -> ProjectLocationCatalogUpdateGenerativeQuestionFeatureCall<'a, C> {
28394        self._scopes.clear();
28395        self
28396    }
28397}
28398
28399/// 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.
28400///
28401/// A builder for the *locations.operations.get* method supported by a *project* resource.
28402/// It is not used directly, but through a [`ProjectMethods`] instance.
28403///
28404/// # Example
28405///
28406/// Instantiate a resource method builder
28407///
28408/// ```test_harness,no_run
28409/// # extern crate hyper;
28410/// # extern crate hyper_rustls;
28411/// # extern crate google_retail2 as retail2;
28412/// # async fn dox() {
28413/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28414///
28415/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28416/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28417/// #     .with_native_roots()
28418/// #     .unwrap()
28419/// #     .https_only()
28420/// #     .enable_http2()
28421/// #     .build();
28422///
28423/// # let executor = hyper_util::rt::TokioExecutor::new();
28424/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28425/// #     secret,
28426/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28427/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28428/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28429/// #     ),
28430/// # ).build().await.unwrap();
28431///
28432/// # let client = hyper_util::client::legacy::Client::builder(
28433/// #     hyper_util::rt::TokioExecutor::new()
28434/// # )
28435/// # .build(
28436/// #     hyper_rustls::HttpsConnectorBuilder::new()
28437/// #         .with_native_roots()
28438/// #         .unwrap()
28439/// #         .https_or_http()
28440/// #         .enable_http2()
28441/// #         .build()
28442/// # );
28443/// # let mut hub = CloudRetail::new(client, auth);
28444/// // You can configure optional parameters by calling the respective setters at will, and
28445/// // execute the final call using `doit()`.
28446/// // Values shown here are possibly random and not representative !
28447/// let result = hub.projects().locations_operations_get("name")
28448///              .doit().await;
28449/// # }
28450/// ```
28451pub struct ProjectLocationOperationGetCall<'a, C>
28452where
28453    C: 'a,
28454{
28455    hub: &'a CloudRetail<C>,
28456    _name: String,
28457    _delegate: Option<&'a mut dyn common::Delegate>,
28458    _additional_params: HashMap<String, String>,
28459    _scopes: BTreeSet<String>,
28460}
28461
28462impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
28463
28464impl<'a, C> ProjectLocationOperationGetCall<'a, C>
28465where
28466    C: common::Connector,
28467{
28468    /// Perform the operation you have build so far.
28469    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
28470        use std::borrow::Cow;
28471        use std::io::{Read, Seek};
28472
28473        use common::{url::Params, ToParts};
28474        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28475
28476        let mut dd = common::DefaultDelegate;
28477        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28478        dlg.begin(common::MethodInfo {
28479            id: "retail.projects.locations.operations.get",
28480            http_method: hyper::Method::GET,
28481        });
28482
28483        for &field in ["alt", "name"].iter() {
28484            if self._additional_params.contains_key(field) {
28485                dlg.finished(false);
28486                return Err(common::Error::FieldClash(field));
28487            }
28488        }
28489
28490        let mut params = Params::with_capacity(3 + self._additional_params.len());
28491        params.push("name", self._name);
28492
28493        params.extend(self._additional_params.iter());
28494
28495        params.push("alt", "json");
28496        let mut url = self.hub._base_url.clone() + "v2/{+name}";
28497        if self._scopes.is_empty() {
28498            self._scopes
28499                .insert(Scope::CloudPlatform.as_ref().to_string());
28500        }
28501
28502        #[allow(clippy::single_element_loop)]
28503        for &(find_this, param_name) in [("{+name}", "name")].iter() {
28504            url = params.uri_replacement(url, param_name, find_this, true);
28505        }
28506        {
28507            let to_remove = ["name"];
28508            params.remove_params(&to_remove);
28509        }
28510
28511        let url = params.parse_with_url(&url);
28512
28513        loop {
28514            let token = match self
28515                .hub
28516                .auth
28517                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28518                .await
28519            {
28520                Ok(token) => token,
28521                Err(e) => match dlg.token(e) {
28522                    Ok(token) => token,
28523                    Err(e) => {
28524                        dlg.finished(false);
28525                        return Err(common::Error::MissingToken(e));
28526                    }
28527                },
28528            };
28529            let mut req_result = {
28530                let client = &self.hub.client;
28531                dlg.pre_request();
28532                let mut req_builder = hyper::Request::builder()
28533                    .method(hyper::Method::GET)
28534                    .uri(url.as_str())
28535                    .header(USER_AGENT, self.hub._user_agent.clone());
28536
28537                if let Some(token) = token.as_ref() {
28538                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28539                }
28540
28541                let request = req_builder
28542                    .header(CONTENT_LENGTH, 0_u64)
28543                    .body(common::to_body::<String>(None));
28544
28545                client.request(request.unwrap()).await
28546            };
28547
28548            match req_result {
28549                Err(err) => {
28550                    if let common::Retry::After(d) = dlg.http_error(&err) {
28551                        sleep(d).await;
28552                        continue;
28553                    }
28554                    dlg.finished(false);
28555                    return Err(common::Error::HttpError(err));
28556                }
28557                Ok(res) => {
28558                    let (mut parts, body) = res.into_parts();
28559                    let mut body = common::Body::new(body);
28560                    if !parts.status.is_success() {
28561                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28562                        let error = serde_json::from_str(&common::to_string(&bytes));
28563                        let response = common::to_response(parts, bytes.into());
28564
28565                        if let common::Retry::After(d) =
28566                            dlg.http_failure(&response, error.as_ref().ok())
28567                        {
28568                            sleep(d).await;
28569                            continue;
28570                        }
28571
28572                        dlg.finished(false);
28573
28574                        return Err(match error {
28575                            Ok(value) => common::Error::BadRequest(value),
28576                            _ => common::Error::Failure(response),
28577                        });
28578                    }
28579                    let response = {
28580                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28581                        let encoded = common::to_string(&bytes);
28582                        match serde_json::from_str(&encoded) {
28583                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28584                            Err(error) => {
28585                                dlg.response_json_decode_error(&encoded, &error);
28586                                return Err(common::Error::JsonDecodeError(
28587                                    encoded.to_string(),
28588                                    error,
28589                                ));
28590                            }
28591                        }
28592                    };
28593
28594                    dlg.finished(true);
28595                    return Ok(response);
28596                }
28597            }
28598        }
28599    }
28600
28601    /// The name of the operation resource.
28602    ///
28603    /// Sets the *name* path property to the given value.
28604    ///
28605    /// Even though the property as already been set when instantiating this call,
28606    /// we provide this method for API completeness.
28607    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
28608        self._name = new_value.to_string();
28609        self
28610    }
28611    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28612    /// while executing the actual API request.
28613    ///
28614    /// ````text
28615    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28616    /// ````
28617    ///
28618    /// Sets the *delegate* property to the given value.
28619    pub fn delegate(
28620        mut self,
28621        new_value: &'a mut dyn common::Delegate,
28622    ) -> ProjectLocationOperationGetCall<'a, C> {
28623        self._delegate = Some(new_value);
28624        self
28625    }
28626
28627    /// Set any additional parameter of the query string used in the request.
28628    /// It should be used to set parameters which are not yet available through their own
28629    /// setters.
28630    ///
28631    /// Please note that this method must not be used to set any of the known parameters
28632    /// which have their own setter method. If done anyway, the request will fail.
28633    ///
28634    /// # Additional Parameters
28635    ///
28636    /// * *$.xgafv* (query-string) - V1 error format.
28637    /// * *access_token* (query-string) - OAuth access token.
28638    /// * *alt* (query-string) - Data format for response.
28639    /// * *callback* (query-string) - JSONP
28640    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28641    /// * *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.
28642    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28643    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28644    /// * *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.
28645    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28646    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28647    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
28648    where
28649        T: AsRef<str>,
28650    {
28651        self._additional_params
28652            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28653        self
28654    }
28655
28656    /// Identifies the authorization scope for the method you are building.
28657    ///
28658    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28659    /// [`Scope::CloudPlatform`].
28660    ///
28661    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28662    /// tokens for more than one scope.
28663    ///
28664    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28665    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28666    /// sufficient, a read-write scope will do as well.
28667    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
28668    where
28669        St: AsRef<str>,
28670    {
28671        self._scopes.insert(String::from(scope.as_ref()));
28672        self
28673    }
28674    /// Identifies the authorization scope(s) for the method you are building.
28675    ///
28676    /// See [`Self::add_scope()`] for details.
28677    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
28678    where
28679        I: IntoIterator<Item = St>,
28680        St: AsRef<str>,
28681    {
28682        self._scopes
28683            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28684        self
28685    }
28686
28687    /// Removes all scopes, and no default scope will be used either.
28688    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28689    /// for details).
28690    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
28691        self._scopes.clear();
28692        self
28693    }
28694}
28695
28696/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
28697///
28698/// A builder for the *locations.operations.list* method supported by a *project* resource.
28699/// It is not used directly, but through a [`ProjectMethods`] instance.
28700///
28701/// # Example
28702///
28703/// Instantiate a resource method builder
28704///
28705/// ```test_harness,no_run
28706/// # extern crate hyper;
28707/// # extern crate hyper_rustls;
28708/// # extern crate google_retail2 as retail2;
28709/// # async fn dox() {
28710/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28711///
28712/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28713/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28714/// #     .with_native_roots()
28715/// #     .unwrap()
28716/// #     .https_only()
28717/// #     .enable_http2()
28718/// #     .build();
28719///
28720/// # let executor = hyper_util::rt::TokioExecutor::new();
28721/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28722/// #     secret,
28723/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28724/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28725/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28726/// #     ),
28727/// # ).build().await.unwrap();
28728///
28729/// # let client = hyper_util::client::legacy::Client::builder(
28730/// #     hyper_util::rt::TokioExecutor::new()
28731/// # )
28732/// # .build(
28733/// #     hyper_rustls::HttpsConnectorBuilder::new()
28734/// #         .with_native_roots()
28735/// #         .unwrap()
28736/// #         .https_or_http()
28737/// #         .enable_http2()
28738/// #         .build()
28739/// # );
28740/// # let mut hub = CloudRetail::new(client, auth);
28741/// // You can configure optional parameters by calling the respective setters at will, and
28742/// // execute the final call using `doit()`.
28743/// // Values shown here are possibly random and not representative !
28744/// let result = hub.projects().locations_operations_list("name")
28745///              .return_partial_success(true)
28746///              .page_token("et")
28747///              .page_size(-93)
28748///              .filter("no")
28749///              .doit().await;
28750/// # }
28751/// ```
28752pub struct ProjectLocationOperationListCall<'a, C>
28753where
28754    C: 'a,
28755{
28756    hub: &'a CloudRetail<C>,
28757    _name: String,
28758    _return_partial_success: Option<bool>,
28759    _page_token: Option<String>,
28760    _page_size: Option<i32>,
28761    _filter: Option<String>,
28762    _delegate: Option<&'a mut dyn common::Delegate>,
28763    _additional_params: HashMap<String, String>,
28764    _scopes: BTreeSet<String>,
28765}
28766
28767impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
28768
28769impl<'a, C> ProjectLocationOperationListCall<'a, C>
28770where
28771    C: common::Connector,
28772{
28773    /// Perform the operation you have build so far.
28774    pub async fn doit(
28775        mut self,
28776    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
28777        use std::borrow::Cow;
28778        use std::io::{Read, Seek};
28779
28780        use common::{url::Params, ToParts};
28781        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28782
28783        let mut dd = common::DefaultDelegate;
28784        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28785        dlg.begin(common::MethodInfo {
28786            id: "retail.projects.locations.operations.list",
28787            http_method: hyper::Method::GET,
28788        });
28789
28790        for &field in [
28791            "alt",
28792            "name",
28793            "returnPartialSuccess",
28794            "pageToken",
28795            "pageSize",
28796            "filter",
28797        ]
28798        .iter()
28799        {
28800            if self._additional_params.contains_key(field) {
28801                dlg.finished(false);
28802                return Err(common::Error::FieldClash(field));
28803            }
28804        }
28805
28806        let mut params = Params::with_capacity(7 + self._additional_params.len());
28807        params.push("name", self._name);
28808        if let Some(value) = self._return_partial_success.as_ref() {
28809            params.push("returnPartialSuccess", value.to_string());
28810        }
28811        if let Some(value) = self._page_token.as_ref() {
28812            params.push("pageToken", value);
28813        }
28814        if let Some(value) = self._page_size.as_ref() {
28815            params.push("pageSize", value.to_string());
28816        }
28817        if let Some(value) = self._filter.as_ref() {
28818            params.push("filter", value);
28819        }
28820
28821        params.extend(self._additional_params.iter());
28822
28823        params.push("alt", "json");
28824        let mut url = self.hub._base_url.clone() + "v2/{+name}/operations";
28825        if self._scopes.is_empty() {
28826            self._scopes
28827                .insert(Scope::CloudPlatform.as_ref().to_string());
28828        }
28829
28830        #[allow(clippy::single_element_loop)]
28831        for &(find_this, param_name) in [("{+name}", "name")].iter() {
28832            url = params.uri_replacement(url, param_name, find_this, true);
28833        }
28834        {
28835            let to_remove = ["name"];
28836            params.remove_params(&to_remove);
28837        }
28838
28839        let url = params.parse_with_url(&url);
28840
28841        loop {
28842            let token = match self
28843                .hub
28844                .auth
28845                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28846                .await
28847            {
28848                Ok(token) => token,
28849                Err(e) => match dlg.token(e) {
28850                    Ok(token) => token,
28851                    Err(e) => {
28852                        dlg.finished(false);
28853                        return Err(common::Error::MissingToken(e));
28854                    }
28855                },
28856            };
28857            let mut req_result = {
28858                let client = &self.hub.client;
28859                dlg.pre_request();
28860                let mut req_builder = hyper::Request::builder()
28861                    .method(hyper::Method::GET)
28862                    .uri(url.as_str())
28863                    .header(USER_AGENT, self.hub._user_agent.clone());
28864
28865                if let Some(token) = token.as_ref() {
28866                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28867                }
28868
28869                let request = req_builder
28870                    .header(CONTENT_LENGTH, 0_u64)
28871                    .body(common::to_body::<String>(None));
28872
28873                client.request(request.unwrap()).await
28874            };
28875
28876            match req_result {
28877                Err(err) => {
28878                    if let common::Retry::After(d) = dlg.http_error(&err) {
28879                        sleep(d).await;
28880                        continue;
28881                    }
28882                    dlg.finished(false);
28883                    return Err(common::Error::HttpError(err));
28884                }
28885                Ok(res) => {
28886                    let (mut parts, body) = res.into_parts();
28887                    let mut body = common::Body::new(body);
28888                    if !parts.status.is_success() {
28889                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28890                        let error = serde_json::from_str(&common::to_string(&bytes));
28891                        let response = common::to_response(parts, bytes.into());
28892
28893                        if let common::Retry::After(d) =
28894                            dlg.http_failure(&response, error.as_ref().ok())
28895                        {
28896                            sleep(d).await;
28897                            continue;
28898                        }
28899
28900                        dlg.finished(false);
28901
28902                        return Err(match error {
28903                            Ok(value) => common::Error::BadRequest(value),
28904                            _ => common::Error::Failure(response),
28905                        });
28906                    }
28907                    let response = {
28908                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28909                        let encoded = common::to_string(&bytes);
28910                        match serde_json::from_str(&encoded) {
28911                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28912                            Err(error) => {
28913                                dlg.response_json_decode_error(&encoded, &error);
28914                                return Err(common::Error::JsonDecodeError(
28915                                    encoded.to_string(),
28916                                    error,
28917                                ));
28918                            }
28919                        }
28920                    };
28921
28922                    dlg.finished(true);
28923                    return Ok(response);
28924                }
28925            }
28926        }
28927    }
28928
28929    /// The name of the operation's parent resource.
28930    ///
28931    /// Sets the *name* path property to the given value.
28932    ///
28933    /// Even though the property as already been set when instantiating this call,
28934    /// we provide this method for API completeness.
28935    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
28936        self._name = new_value.to_string();
28937        self
28938    }
28939    /// 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.
28940    ///
28941    /// Sets the *return partial success* query property to the given value.
28942    pub fn return_partial_success(
28943        mut self,
28944        new_value: bool,
28945    ) -> ProjectLocationOperationListCall<'a, C> {
28946        self._return_partial_success = Some(new_value);
28947        self
28948    }
28949    /// The standard list page token.
28950    ///
28951    /// Sets the *page token* query property to the given value.
28952    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
28953        self._page_token = Some(new_value.to_string());
28954        self
28955    }
28956    /// The standard list page size.
28957    ///
28958    /// Sets the *page size* query property to the given value.
28959    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
28960        self._page_size = Some(new_value);
28961        self
28962    }
28963    /// The standard list filter.
28964    ///
28965    /// Sets the *filter* query property to the given value.
28966    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
28967        self._filter = Some(new_value.to_string());
28968        self
28969    }
28970    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28971    /// while executing the actual API request.
28972    ///
28973    /// ````text
28974    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28975    /// ````
28976    ///
28977    /// Sets the *delegate* property to the given value.
28978    pub fn delegate(
28979        mut self,
28980        new_value: &'a mut dyn common::Delegate,
28981    ) -> ProjectLocationOperationListCall<'a, C> {
28982        self._delegate = Some(new_value);
28983        self
28984    }
28985
28986    /// Set any additional parameter of the query string used in the request.
28987    /// It should be used to set parameters which are not yet available through their own
28988    /// setters.
28989    ///
28990    /// Please note that this method must not be used to set any of the known parameters
28991    /// which have their own setter method. If done anyway, the request will fail.
28992    ///
28993    /// # Additional Parameters
28994    ///
28995    /// * *$.xgafv* (query-string) - V1 error format.
28996    /// * *access_token* (query-string) - OAuth access token.
28997    /// * *alt* (query-string) - Data format for response.
28998    /// * *callback* (query-string) - JSONP
28999    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29000    /// * *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.
29001    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29002    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29003    /// * *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.
29004    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29005    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29006    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
29007    where
29008        T: AsRef<str>,
29009    {
29010        self._additional_params
29011            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29012        self
29013    }
29014
29015    /// Identifies the authorization scope for the method you are building.
29016    ///
29017    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29018    /// [`Scope::CloudPlatform`].
29019    ///
29020    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29021    /// tokens for more than one scope.
29022    ///
29023    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29024    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29025    /// sufficient, a read-write scope will do as well.
29026    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
29027    where
29028        St: AsRef<str>,
29029    {
29030        self._scopes.insert(String::from(scope.as_ref()));
29031        self
29032    }
29033    /// Identifies the authorization scope(s) for the method you are building.
29034    ///
29035    /// See [`Self::add_scope()`] for details.
29036    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
29037    where
29038        I: IntoIterator<Item = St>,
29039        St: AsRef<str>,
29040    {
29041        self._scopes
29042            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29043        self
29044    }
29045
29046    /// Removes all scopes, and no default scope will be used either.
29047    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29048    /// for details).
29049    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
29050        self._scopes.clear();
29051        self
29052    }
29053}
29054
29055/// 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.
29056///
29057/// A builder for the *operations.get* method supported by a *project* resource.
29058/// It is not used directly, but through a [`ProjectMethods`] instance.
29059///
29060/// # Example
29061///
29062/// Instantiate a resource method builder
29063///
29064/// ```test_harness,no_run
29065/// # extern crate hyper;
29066/// # extern crate hyper_rustls;
29067/// # extern crate google_retail2 as retail2;
29068/// # async fn dox() {
29069/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29070///
29071/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29072/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29073/// #     .with_native_roots()
29074/// #     .unwrap()
29075/// #     .https_only()
29076/// #     .enable_http2()
29077/// #     .build();
29078///
29079/// # let executor = hyper_util::rt::TokioExecutor::new();
29080/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29081/// #     secret,
29082/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29083/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29084/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29085/// #     ),
29086/// # ).build().await.unwrap();
29087///
29088/// # let client = hyper_util::client::legacy::Client::builder(
29089/// #     hyper_util::rt::TokioExecutor::new()
29090/// # )
29091/// # .build(
29092/// #     hyper_rustls::HttpsConnectorBuilder::new()
29093/// #         .with_native_roots()
29094/// #         .unwrap()
29095/// #         .https_or_http()
29096/// #         .enable_http2()
29097/// #         .build()
29098/// # );
29099/// # let mut hub = CloudRetail::new(client, auth);
29100/// // You can configure optional parameters by calling the respective setters at will, and
29101/// // execute the final call using `doit()`.
29102/// // Values shown here are possibly random and not representative !
29103/// let result = hub.projects().operations_get("name")
29104///              .doit().await;
29105/// # }
29106/// ```
29107pub struct ProjectOperationGetCall<'a, C>
29108where
29109    C: 'a,
29110{
29111    hub: &'a CloudRetail<C>,
29112    _name: String,
29113    _delegate: Option<&'a mut dyn common::Delegate>,
29114    _additional_params: HashMap<String, String>,
29115    _scopes: BTreeSet<String>,
29116}
29117
29118impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
29119
29120impl<'a, C> ProjectOperationGetCall<'a, C>
29121where
29122    C: common::Connector,
29123{
29124    /// Perform the operation you have build so far.
29125    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
29126        use std::borrow::Cow;
29127        use std::io::{Read, Seek};
29128
29129        use common::{url::Params, ToParts};
29130        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29131
29132        let mut dd = common::DefaultDelegate;
29133        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29134        dlg.begin(common::MethodInfo {
29135            id: "retail.projects.operations.get",
29136            http_method: hyper::Method::GET,
29137        });
29138
29139        for &field in ["alt", "name"].iter() {
29140            if self._additional_params.contains_key(field) {
29141                dlg.finished(false);
29142                return Err(common::Error::FieldClash(field));
29143            }
29144        }
29145
29146        let mut params = Params::with_capacity(3 + self._additional_params.len());
29147        params.push("name", self._name);
29148
29149        params.extend(self._additional_params.iter());
29150
29151        params.push("alt", "json");
29152        let mut url = self.hub._base_url.clone() + "v2/{+name}";
29153        if self._scopes.is_empty() {
29154            self._scopes
29155                .insert(Scope::CloudPlatform.as_ref().to_string());
29156        }
29157
29158        #[allow(clippy::single_element_loop)]
29159        for &(find_this, param_name) in [("{+name}", "name")].iter() {
29160            url = params.uri_replacement(url, param_name, find_this, true);
29161        }
29162        {
29163            let to_remove = ["name"];
29164            params.remove_params(&to_remove);
29165        }
29166
29167        let url = params.parse_with_url(&url);
29168
29169        loop {
29170            let token = match self
29171                .hub
29172                .auth
29173                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29174                .await
29175            {
29176                Ok(token) => token,
29177                Err(e) => match dlg.token(e) {
29178                    Ok(token) => token,
29179                    Err(e) => {
29180                        dlg.finished(false);
29181                        return Err(common::Error::MissingToken(e));
29182                    }
29183                },
29184            };
29185            let mut req_result = {
29186                let client = &self.hub.client;
29187                dlg.pre_request();
29188                let mut req_builder = hyper::Request::builder()
29189                    .method(hyper::Method::GET)
29190                    .uri(url.as_str())
29191                    .header(USER_AGENT, self.hub._user_agent.clone());
29192
29193                if let Some(token) = token.as_ref() {
29194                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29195                }
29196
29197                let request = req_builder
29198                    .header(CONTENT_LENGTH, 0_u64)
29199                    .body(common::to_body::<String>(None));
29200
29201                client.request(request.unwrap()).await
29202            };
29203
29204            match req_result {
29205                Err(err) => {
29206                    if let common::Retry::After(d) = dlg.http_error(&err) {
29207                        sleep(d).await;
29208                        continue;
29209                    }
29210                    dlg.finished(false);
29211                    return Err(common::Error::HttpError(err));
29212                }
29213                Ok(res) => {
29214                    let (mut parts, body) = res.into_parts();
29215                    let mut body = common::Body::new(body);
29216                    if !parts.status.is_success() {
29217                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29218                        let error = serde_json::from_str(&common::to_string(&bytes));
29219                        let response = common::to_response(parts, bytes.into());
29220
29221                        if let common::Retry::After(d) =
29222                            dlg.http_failure(&response, error.as_ref().ok())
29223                        {
29224                            sleep(d).await;
29225                            continue;
29226                        }
29227
29228                        dlg.finished(false);
29229
29230                        return Err(match error {
29231                            Ok(value) => common::Error::BadRequest(value),
29232                            _ => common::Error::Failure(response),
29233                        });
29234                    }
29235                    let response = {
29236                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29237                        let encoded = common::to_string(&bytes);
29238                        match serde_json::from_str(&encoded) {
29239                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29240                            Err(error) => {
29241                                dlg.response_json_decode_error(&encoded, &error);
29242                                return Err(common::Error::JsonDecodeError(
29243                                    encoded.to_string(),
29244                                    error,
29245                                ));
29246                            }
29247                        }
29248                    };
29249
29250                    dlg.finished(true);
29251                    return Ok(response);
29252                }
29253            }
29254        }
29255    }
29256
29257    /// The name of the operation resource.
29258    ///
29259    /// Sets the *name* path property to the given value.
29260    ///
29261    /// Even though the property as already been set when instantiating this call,
29262    /// we provide this method for API completeness.
29263    pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
29264        self._name = new_value.to_string();
29265        self
29266    }
29267    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29268    /// while executing the actual API request.
29269    ///
29270    /// ````text
29271    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29272    /// ````
29273    ///
29274    /// Sets the *delegate* property to the given value.
29275    pub fn delegate(
29276        mut self,
29277        new_value: &'a mut dyn common::Delegate,
29278    ) -> ProjectOperationGetCall<'a, C> {
29279        self._delegate = Some(new_value);
29280        self
29281    }
29282
29283    /// Set any additional parameter of the query string used in the request.
29284    /// It should be used to set parameters which are not yet available through their own
29285    /// setters.
29286    ///
29287    /// Please note that this method must not be used to set any of the known parameters
29288    /// which have their own setter method. If done anyway, the request will fail.
29289    ///
29290    /// # Additional Parameters
29291    ///
29292    /// * *$.xgafv* (query-string) - V1 error format.
29293    /// * *access_token* (query-string) - OAuth access token.
29294    /// * *alt* (query-string) - Data format for response.
29295    /// * *callback* (query-string) - JSONP
29296    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29297    /// * *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.
29298    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29299    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29300    /// * *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.
29301    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29302    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29303    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
29304    where
29305        T: AsRef<str>,
29306    {
29307        self._additional_params
29308            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29309        self
29310    }
29311
29312    /// Identifies the authorization scope for the method you are building.
29313    ///
29314    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29315    /// [`Scope::CloudPlatform`].
29316    ///
29317    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29318    /// tokens for more than one scope.
29319    ///
29320    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29321    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29322    /// sufficient, a read-write scope will do as well.
29323    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
29324    where
29325        St: AsRef<str>,
29326    {
29327        self._scopes.insert(String::from(scope.as_ref()));
29328        self
29329    }
29330    /// Identifies the authorization scope(s) for the method you are building.
29331    ///
29332    /// See [`Self::add_scope()`] for details.
29333    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
29334    where
29335        I: IntoIterator<Item = St>,
29336        St: AsRef<str>,
29337    {
29338        self._scopes
29339            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29340        self
29341    }
29342
29343    /// Removes all scopes, and no default scope will be used either.
29344    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29345    /// for details).
29346    pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
29347        self._scopes.clear();
29348        self
29349    }
29350}
29351
29352/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
29353///
29354/// A builder for the *operations.list* method supported by a *project* resource.
29355/// It is not used directly, but through a [`ProjectMethods`] instance.
29356///
29357/// # Example
29358///
29359/// Instantiate a resource method builder
29360///
29361/// ```test_harness,no_run
29362/// # extern crate hyper;
29363/// # extern crate hyper_rustls;
29364/// # extern crate google_retail2 as retail2;
29365/// # async fn dox() {
29366/// # use retail2::{CloudRetail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29367///
29368/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29369/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29370/// #     .with_native_roots()
29371/// #     .unwrap()
29372/// #     .https_only()
29373/// #     .enable_http2()
29374/// #     .build();
29375///
29376/// # let executor = hyper_util::rt::TokioExecutor::new();
29377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29378/// #     secret,
29379/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29380/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29381/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29382/// #     ),
29383/// # ).build().await.unwrap();
29384///
29385/// # let client = hyper_util::client::legacy::Client::builder(
29386/// #     hyper_util::rt::TokioExecutor::new()
29387/// # )
29388/// # .build(
29389/// #     hyper_rustls::HttpsConnectorBuilder::new()
29390/// #         .with_native_roots()
29391/// #         .unwrap()
29392/// #         .https_or_http()
29393/// #         .enable_http2()
29394/// #         .build()
29395/// # );
29396/// # let mut hub = CloudRetail::new(client, auth);
29397/// // You can configure optional parameters by calling the respective setters at will, and
29398/// // execute the final call using `doit()`.
29399/// // Values shown here are possibly random and not representative !
29400/// let result = hub.projects().operations_list("name")
29401///              .return_partial_success(false)
29402///              .page_token("no")
29403///              .page_size(-91)
29404///              .filter("At")
29405///              .doit().await;
29406/// # }
29407/// ```
29408pub struct ProjectOperationListCall<'a, C>
29409where
29410    C: 'a,
29411{
29412    hub: &'a CloudRetail<C>,
29413    _name: String,
29414    _return_partial_success: Option<bool>,
29415    _page_token: Option<String>,
29416    _page_size: Option<i32>,
29417    _filter: Option<String>,
29418    _delegate: Option<&'a mut dyn common::Delegate>,
29419    _additional_params: HashMap<String, String>,
29420    _scopes: BTreeSet<String>,
29421}
29422
29423impl<'a, C> common::CallBuilder for ProjectOperationListCall<'a, C> {}
29424
29425impl<'a, C> ProjectOperationListCall<'a, C>
29426where
29427    C: common::Connector,
29428{
29429    /// Perform the operation you have build so far.
29430    pub async fn doit(
29431        mut self,
29432    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
29433        use std::borrow::Cow;
29434        use std::io::{Read, Seek};
29435
29436        use common::{url::Params, ToParts};
29437        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29438
29439        let mut dd = common::DefaultDelegate;
29440        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29441        dlg.begin(common::MethodInfo {
29442            id: "retail.projects.operations.list",
29443            http_method: hyper::Method::GET,
29444        });
29445
29446        for &field in [
29447            "alt",
29448            "name",
29449            "returnPartialSuccess",
29450            "pageToken",
29451            "pageSize",
29452            "filter",
29453        ]
29454        .iter()
29455        {
29456            if self._additional_params.contains_key(field) {
29457                dlg.finished(false);
29458                return Err(common::Error::FieldClash(field));
29459            }
29460        }
29461
29462        let mut params = Params::with_capacity(7 + self._additional_params.len());
29463        params.push("name", self._name);
29464        if let Some(value) = self._return_partial_success.as_ref() {
29465            params.push("returnPartialSuccess", value.to_string());
29466        }
29467        if let Some(value) = self._page_token.as_ref() {
29468            params.push("pageToken", value);
29469        }
29470        if let Some(value) = self._page_size.as_ref() {
29471            params.push("pageSize", value.to_string());
29472        }
29473        if let Some(value) = self._filter.as_ref() {
29474            params.push("filter", value);
29475        }
29476
29477        params.extend(self._additional_params.iter());
29478
29479        params.push("alt", "json");
29480        let mut url = self.hub._base_url.clone() + "v2/{+name}/operations";
29481        if self._scopes.is_empty() {
29482            self._scopes
29483                .insert(Scope::CloudPlatform.as_ref().to_string());
29484        }
29485
29486        #[allow(clippy::single_element_loop)]
29487        for &(find_this, param_name) in [("{+name}", "name")].iter() {
29488            url = params.uri_replacement(url, param_name, find_this, true);
29489        }
29490        {
29491            let to_remove = ["name"];
29492            params.remove_params(&to_remove);
29493        }
29494
29495        let url = params.parse_with_url(&url);
29496
29497        loop {
29498            let token = match self
29499                .hub
29500                .auth
29501                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29502                .await
29503            {
29504                Ok(token) => token,
29505                Err(e) => match dlg.token(e) {
29506                    Ok(token) => token,
29507                    Err(e) => {
29508                        dlg.finished(false);
29509                        return Err(common::Error::MissingToken(e));
29510                    }
29511                },
29512            };
29513            let mut req_result = {
29514                let client = &self.hub.client;
29515                dlg.pre_request();
29516                let mut req_builder = hyper::Request::builder()
29517                    .method(hyper::Method::GET)
29518                    .uri(url.as_str())
29519                    .header(USER_AGENT, self.hub._user_agent.clone());
29520
29521                if let Some(token) = token.as_ref() {
29522                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29523                }
29524
29525                let request = req_builder
29526                    .header(CONTENT_LENGTH, 0_u64)
29527                    .body(common::to_body::<String>(None));
29528
29529                client.request(request.unwrap()).await
29530            };
29531
29532            match req_result {
29533                Err(err) => {
29534                    if let common::Retry::After(d) = dlg.http_error(&err) {
29535                        sleep(d).await;
29536                        continue;
29537                    }
29538                    dlg.finished(false);
29539                    return Err(common::Error::HttpError(err));
29540                }
29541                Ok(res) => {
29542                    let (mut parts, body) = res.into_parts();
29543                    let mut body = common::Body::new(body);
29544                    if !parts.status.is_success() {
29545                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29546                        let error = serde_json::from_str(&common::to_string(&bytes));
29547                        let response = common::to_response(parts, bytes.into());
29548
29549                        if let common::Retry::After(d) =
29550                            dlg.http_failure(&response, error.as_ref().ok())
29551                        {
29552                            sleep(d).await;
29553                            continue;
29554                        }
29555
29556                        dlg.finished(false);
29557
29558                        return Err(match error {
29559                            Ok(value) => common::Error::BadRequest(value),
29560                            _ => common::Error::Failure(response),
29561                        });
29562                    }
29563                    let response = {
29564                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29565                        let encoded = common::to_string(&bytes);
29566                        match serde_json::from_str(&encoded) {
29567                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29568                            Err(error) => {
29569                                dlg.response_json_decode_error(&encoded, &error);
29570                                return Err(common::Error::JsonDecodeError(
29571                                    encoded.to_string(),
29572                                    error,
29573                                ));
29574                            }
29575                        }
29576                    };
29577
29578                    dlg.finished(true);
29579                    return Ok(response);
29580                }
29581            }
29582        }
29583    }
29584
29585    /// The name of the operation's parent resource.
29586    ///
29587    /// Sets the *name* path property to the given value.
29588    ///
29589    /// Even though the property as already been set when instantiating this call,
29590    /// we provide this method for API completeness.
29591    pub fn name(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
29592        self._name = new_value.to_string();
29593        self
29594    }
29595    /// 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.
29596    ///
29597    /// Sets the *return partial success* query property to the given value.
29598    pub fn return_partial_success(mut self, new_value: bool) -> ProjectOperationListCall<'a, C> {
29599        self._return_partial_success = Some(new_value);
29600        self
29601    }
29602    /// The standard list page token.
29603    ///
29604    /// Sets the *page token* query property to the given value.
29605    pub fn page_token(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
29606        self._page_token = Some(new_value.to_string());
29607        self
29608    }
29609    /// The standard list page size.
29610    ///
29611    /// Sets the *page size* query property to the given value.
29612    pub fn page_size(mut self, new_value: i32) -> ProjectOperationListCall<'a, C> {
29613        self._page_size = Some(new_value);
29614        self
29615    }
29616    /// The standard list filter.
29617    ///
29618    /// Sets the *filter* query property to the given value.
29619    pub fn filter(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
29620        self._filter = Some(new_value.to_string());
29621        self
29622    }
29623    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29624    /// while executing the actual API request.
29625    ///
29626    /// ````text
29627    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29628    /// ````
29629    ///
29630    /// Sets the *delegate* property to the given value.
29631    pub fn delegate(
29632        mut self,
29633        new_value: &'a mut dyn common::Delegate,
29634    ) -> ProjectOperationListCall<'a, C> {
29635        self._delegate = Some(new_value);
29636        self
29637    }
29638
29639    /// Set any additional parameter of the query string used in the request.
29640    /// It should be used to set parameters which are not yet available through their own
29641    /// setters.
29642    ///
29643    /// Please note that this method must not be used to set any of the known parameters
29644    /// which have their own setter method. If done anyway, the request will fail.
29645    ///
29646    /// # Additional Parameters
29647    ///
29648    /// * *$.xgafv* (query-string) - V1 error format.
29649    /// * *access_token* (query-string) - OAuth access token.
29650    /// * *alt* (query-string) - Data format for response.
29651    /// * *callback* (query-string) - JSONP
29652    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29653    /// * *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.
29654    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29655    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29656    /// * *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.
29657    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29658    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29659    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationListCall<'a, C>
29660    where
29661        T: AsRef<str>,
29662    {
29663        self._additional_params
29664            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29665        self
29666    }
29667
29668    /// Identifies the authorization scope for the method you are building.
29669    ///
29670    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29671    /// [`Scope::CloudPlatform`].
29672    ///
29673    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29674    /// tokens for more than one scope.
29675    ///
29676    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29677    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29678    /// sufficient, a read-write scope will do as well.
29679    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationListCall<'a, C>
29680    where
29681        St: AsRef<str>,
29682    {
29683        self._scopes.insert(String::from(scope.as_ref()));
29684        self
29685    }
29686    /// Identifies the authorization scope(s) for the method you are building.
29687    ///
29688    /// See [`Self::add_scope()`] for details.
29689    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationListCall<'a, C>
29690    where
29691        I: IntoIterator<Item = St>,
29692        St: AsRef<str>,
29693    {
29694        self._scopes
29695            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29696        self
29697    }
29698
29699    /// Removes all scopes, and no default scope will be used either.
29700    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29701    /// for details).
29702    pub fn clear_scopes(mut self) -> ProjectOperationListCall<'a, C> {
29703        self._scopes.clear();
29704        self
29705    }
29706}