Skip to main content

google_cloud_retail_v2/
client.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Vertex AI Search for commerce API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_retail_v2::client::AnalyticsService;
24/// use google_cloud_lro::Poller;
25/// async fn sample(
26/// ) -> anyhow::Result<()> {
27///     let client = AnalyticsService::builder().build().await?;
28///     let response = client.export_analytics_metrics()
29///         /* set fields */
30///         .poller().until_done().await?;
31///     println!("response {:?}", response);
32///     Ok(())
33/// }
34/// ```
35///
36/// # Service Description
37///
38/// Service for managing & accessing retail search business metric.
39/// Retail recommendation business metric is currently not available.
40///
41/// # Configuration
42///
43/// To configure `AnalyticsService` use the `with_*` methods in the type returned
44/// by [builder()][AnalyticsService::builder]. The default configuration should
45/// work for most applications. Common configuration changes include
46///
47/// * [with_endpoint()]: by default this client uses the global default endpoint
48///   (`https://retail.googleapis.com`). Applications using regional
49///   endpoints or running in restricted networks (e.g. a network configured
50//    with [Private Google Access with VPC Service Controls]) may want to
51///   override this default.
52/// * [with_credentials()]: by default this client uses
53///   [Application Default Credentials]. Applications using custom
54///   authentication may need to override this default.
55///
56/// [with_endpoint()]: super::builder::analytics_service::ClientBuilder::with_endpoint
57/// [with_credentials()]: super::builder::analytics_service::ClientBuilder::with_credentials
58/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
59/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
60///
61/// # Pooling and Cloning
62///
63/// `AnalyticsService` holds a connection pool internally, it is advised to
64/// create one and reuse it. You do not need to wrap `AnalyticsService` in
65/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
66/// already uses an `Arc` internally.
67#[derive(Clone, Debug)]
68pub struct AnalyticsService {
69    inner: std::sync::Arc<dyn super::stub::dynamic::AnalyticsService>,
70}
71
72impl AnalyticsService {
73    /// Returns a builder for [AnalyticsService].
74    ///
75    /// ```
76    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
77    /// # use google_cloud_retail_v2::client::AnalyticsService;
78    /// let client = AnalyticsService::builder().build().await?;
79    /// # Ok(()) }
80    /// ```
81    pub fn builder() -> super::builder::analytics_service::ClientBuilder {
82        crate::new_client_builder(super::builder::analytics_service::client::Factory)
83    }
84
85    /// Creates a new client from the provided stub.
86    ///
87    /// The most common case for calling this function is in tests mocking the
88    /// client's behavior.
89    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
90    where
91        T: super::stub::AnalyticsService + 'static,
92    {
93        Self { inner: stub.into() }
94    }
95
96    pub(crate) async fn new(
97        config: gaxi::options::ClientConfig,
98    ) -> crate::ClientBuilderResult<Self> {
99        let inner = Self::build_inner(config).await?;
100        Ok(Self { inner })
101    }
102
103    async fn build_inner(
104        conf: gaxi::options::ClientConfig,
105    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::AnalyticsService>>
106    {
107        if gaxi::options::tracing_enabled(&conf) {
108            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
109        }
110        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
111    }
112
113    async fn build_transport(
114        conf: gaxi::options::ClientConfig,
115    ) -> crate::ClientBuilderResult<impl super::stub::AnalyticsService> {
116        super::transport::AnalyticsService::new(conf).await
117    }
118
119    async fn build_with_tracing(
120        conf: gaxi::options::ClientConfig,
121    ) -> crate::ClientBuilderResult<impl super::stub::AnalyticsService> {
122        Self::build_transport(conf)
123            .await
124            .map(super::tracing::AnalyticsService::new)
125    }
126
127    /// Exports analytics metrics.
128    ///
129    /// `Operation.response` is of type `ExportAnalyticsMetricsResponse`.
130    /// `Operation.metadata` is of type `ExportMetadata`.
131    ///
132    /// # Long running operations
133    ///
134    /// This method is used to start, and/or poll a [long-running Operation].
135    /// The [Working with long-running operations] chapter in the [user guide]
136    /// covers these operations in detail.
137    ///
138    /// [long-running operation]: https://google.aip.dev/151
139    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
140    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
141    ///
142    /// # Example
143    /// ```
144    /// # use google_cloud_retail_v2::client::AnalyticsService;
145    /// use google_cloud_lro::Poller;
146    /// use google_cloud_retail_v2::Result;
147    /// async fn sample(
148    ///    client: &AnalyticsService
149    /// ) -> Result<()> {
150    ///     let response = client.export_analytics_metrics()
151    ///         /* set fields */
152    ///         .poller().until_done().await?;
153    ///     println!("response {:?}", response);
154    ///     Ok(())
155    /// }
156    /// ```
157    pub fn export_analytics_metrics(
158        &self,
159    ) -> super::builder::analytics_service::ExportAnalyticsMetrics {
160        super::builder::analytics_service::ExportAnalyticsMetrics::new(self.inner.clone())
161    }
162
163    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
164    ///
165    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
166    ///
167    /// # Example
168    /// ```
169    /// # use google_cloud_retail_v2::client::AnalyticsService;
170    /// use google_cloud_gax::paginator::ItemPaginator as _;
171    /// use google_cloud_retail_v2::Result;
172    /// async fn sample(
173    ///    client: &AnalyticsService
174    /// ) -> Result<()> {
175    ///     let mut list = client.list_operations()
176    ///         /* set fields */
177    ///         .by_item();
178    ///     while let Some(item) = list.next().await.transpose()? {
179    ///         println!("{:?}", item);
180    ///     }
181    ///     Ok(())
182    /// }
183    /// ```
184    pub fn list_operations(&self) -> super::builder::analytics_service::ListOperations {
185        super::builder::analytics_service::ListOperations::new(self.inner.clone())
186    }
187
188    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
189    ///
190    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
191    ///
192    /// # Example
193    /// ```
194    /// # use google_cloud_retail_v2::client::AnalyticsService;
195    /// use google_cloud_retail_v2::Result;
196    /// async fn sample(
197    ///    client: &AnalyticsService
198    /// ) -> Result<()> {
199    ///     let response = client.get_operation()
200    ///         /* set fields */
201    ///         .send().await?;
202    ///     println!("response {:?}", response);
203    ///     Ok(())
204    /// }
205    /// ```
206    pub fn get_operation(&self) -> super::builder::analytics_service::GetOperation {
207        super::builder::analytics_service::GetOperation::new(self.inner.clone())
208    }
209}
210
211/// Implements a client for the Vertex AI Search for commerce API.
212///
213/// # Example
214/// ```
215/// # use google_cloud_retail_v2::client::CatalogService;
216/// use google_cloud_gax::paginator::ItemPaginator as _;
217/// async fn sample(
218///    parent: &str,
219/// ) -> anyhow::Result<()> {
220///     let client = CatalogService::builder().build().await?;
221///     let mut list = client.list_catalogs()
222///         .set_parent(parent)
223///         .by_item();
224///     while let Some(item) = list.next().await.transpose()? {
225///         println!("{:?}", item);
226///     }
227///     Ok(())
228/// }
229/// ```
230///
231/// # Service Description
232///
233/// Service for managing catalog configuration.
234///
235/// # Configuration
236///
237/// To configure `CatalogService` use the `with_*` methods in the type returned
238/// by [builder()][CatalogService::builder]. The default configuration should
239/// work for most applications. Common configuration changes include
240///
241/// * [with_endpoint()]: by default this client uses the global default endpoint
242///   (`https://retail.googleapis.com`). Applications using regional
243///   endpoints or running in restricted networks (e.g. a network configured
244//    with [Private Google Access with VPC Service Controls]) may want to
245///   override this default.
246/// * [with_credentials()]: by default this client uses
247///   [Application Default Credentials]. Applications using custom
248///   authentication may need to override this default.
249///
250/// [with_endpoint()]: super::builder::catalog_service::ClientBuilder::with_endpoint
251/// [with_credentials()]: super::builder::catalog_service::ClientBuilder::with_credentials
252/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
253/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
254///
255/// # Pooling and Cloning
256///
257/// `CatalogService` holds a connection pool internally, it is advised to
258/// create one and reuse it. You do not need to wrap `CatalogService` in
259/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
260/// already uses an `Arc` internally.
261#[derive(Clone, Debug)]
262pub struct CatalogService {
263    inner: std::sync::Arc<dyn super::stub::dynamic::CatalogService>,
264}
265
266impl CatalogService {
267    /// Returns a builder for [CatalogService].
268    ///
269    /// ```
270    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
271    /// # use google_cloud_retail_v2::client::CatalogService;
272    /// let client = CatalogService::builder().build().await?;
273    /// # Ok(()) }
274    /// ```
275    pub fn builder() -> super::builder::catalog_service::ClientBuilder {
276        crate::new_client_builder(super::builder::catalog_service::client::Factory)
277    }
278
279    /// Creates a new client from the provided stub.
280    ///
281    /// The most common case for calling this function is in tests mocking the
282    /// client's behavior.
283    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
284    where
285        T: super::stub::CatalogService + 'static,
286    {
287        Self { inner: stub.into() }
288    }
289
290    pub(crate) async fn new(
291        config: gaxi::options::ClientConfig,
292    ) -> crate::ClientBuilderResult<Self> {
293        let inner = Self::build_inner(config).await?;
294        Ok(Self { inner })
295    }
296
297    async fn build_inner(
298        conf: gaxi::options::ClientConfig,
299    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CatalogService>> {
300        if gaxi::options::tracing_enabled(&conf) {
301            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
302        }
303        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
304    }
305
306    async fn build_transport(
307        conf: gaxi::options::ClientConfig,
308    ) -> crate::ClientBuilderResult<impl super::stub::CatalogService> {
309        super::transport::CatalogService::new(conf).await
310    }
311
312    async fn build_with_tracing(
313        conf: gaxi::options::ClientConfig,
314    ) -> crate::ClientBuilderResult<impl super::stub::CatalogService> {
315        Self::build_transport(conf)
316            .await
317            .map(super::tracing::CatalogService::new)
318    }
319
320    /// Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with
321    /// the project.
322    ///
323    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
324    ///
325    /// # Example
326    /// ```
327    /// # use google_cloud_retail_v2::client::CatalogService;
328    /// use google_cloud_gax::paginator::ItemPaginator as _;
329    /// use google_cloud_retail_v2::Result;
330    /// async fn sample(
331    ///    client: &CatalogService, parent: &str
332    /// ) -> Result<()> {
333    ///     let mut list = client.list_catalogs()
334    ///         .set_parent(parent)
335    ///         .by_item();
336    ///     while let Some(item) = list.next().await.transpose()? {
337    ///         println!("{:?}", item);
338    ///     }
339    ///     Ok(())
340    /// }
341    /// ```
342    pub fn list_catalogs(&self) -> super::builder::catalog_service::ListCatalogs {
343        super::builder::catalog_service::ListCatalogs::new(self.inner.clone())
344    }
345
346    /// Updates the [Catalog][google.cloud.retail.v2.Catalog]s.
347    ///
348    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
349    ///
350    /// # Example
351    /// ```
352    /// # use google_cloud_retail_v2::client::CatalogService;
353    /// # extern crate wkt as google_cloud_wkt;
354    /// use google_cloud_wkt::FieldMask;
355    /// use google_cloud_retail_v2::model::Catalog;
356    /// use google_cloud_retail_v2::Result;
357    /// async fn sample(
358    ///    client: &CatalogService, project_id: &str, location_id: &str, catalog_id: &str
359    /// ) -> Result<()> {
360    ///     let response = client.update_catalog()
361    ///         .set_catalog(
362    ///             Catalog::new().set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))/* set fields */
363    ///         )
364    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
365    ///         .send().await?;
366    ///     println!("response {:?}", response);
367    ///     Ok(())
368    /// }
369    /// ```
370    pub fn update_catalog(&self) -> super::builder::catalog_service::UpdateCatalog {
371        super::builder::catalog_service::UpdateCatalog::new(self.inner.clone())
372    }
373
374    /// Set a specified branch id as default branch. API methods such as
375    /// [SearchService.Search][google.cloud.retail.v2.SearchService.Search],
376    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct],
377    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]
378    /// will treat requests using "default_branch" to the actual branch id set as
379    /// default.
380    ///
381    /// For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as
382    /// default, setting
383    /// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
384    /// `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent
385    /// to setting
386    /// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
387    /// `projects/*/locations/*/catalogs/*/branches/1`.
388    ///
389    /// Using multiple branches can be useful when developers would like
390    /// to have a staging branch to test and verify for future usage. When it
391    /// becomes ready, developers switch on the staging branch using this API
392    /// while keeping using
393    /// `projects/*/locations/*/catalogs/*/branches/default_branch` as
394    /// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
395    /// route the traffic to this staging branch.
396    ///
397    /// CAUTION: If you have live predict/search traffic, switching the default
398    /// branch could potentially cause outages if the ID space of the new branch
399    /// is very different from the old one.
400    ///
401    /// More specifically:
402    ///
403    /// * PredictionService will only return product IDs from branch {newBranch}.
404    /// * SearchService will only return product IDs from branch {newBranch}
405    ///   (if branch is not explicitly set).
406    /// * UserEventService will only join events with products from branch
407    ///   {newBranch}.
408    ///
409    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
410    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
411    /// [google.cloud.retail.v2.SearchRequest.branch]: crate::model::SearchRequest::branch
412    /// [google.cloud.retail.v2.SearchService.Search]: crate::client::SearchService::search
413    ///
414    /// # Example
415    /// ```
416    /// # use google_cloud_retail_v2::client::CatalogService;
417    /// use google_cloud_retail_v2::Result;
418    /// async fn sample(
419    ///    client: &CatalogService
420    /// ) -> Result<()> {
421    ///     client.set_default_branch()
422    ///         /* set fields */
423    ///         .send().await?;
424    ///     Ok(())
425    /// }
426    /// ```
427    pub fn set_default_branch(&self) -> super::builder::catalog_service::SetDefaultBranch {
428        super::builder::catalog_service::SetDefaultBranch::new(self.inner.clone())
429    }
430
431    /// Get which branch is currently default branch set by
432    /// [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch]
433    /// method under a specified parent catalog.
434    ///
435    /// [google.cloud.retail.v2.CatalogService.SetDefaultBranch]: crate::client::CatalogService::set_default_branch
436    ///
437    /// # Example
438    /// ```
439    /// # use google_cloud_retail_v2::client::CatalogService;
440    /// use google_cloud_retail_v2::Result;
441    /// async fn sample(
442    ///    client: &CatalogService
443    /// ) -> Result<()> {
444    ///     let response = client.get_default_branch()
445    ///         /* set fields */
446    ///         .send().await?;
447    ///     println!("response {:?}", response);
448    ///     Ok(())
449    /// }
450    /// ```
451    pub fn get_default_branch(&self) -> super::builder::catalog_service::GetDefaultBranch {
452        super::builder::catalog_service::GetDefaultBranch::new(self.inner.clone())
453    }
454
455    /// Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig].
456    ///
457    /// [google.cloud.retail.v2.CompletionConfig]: crate::model::CompletionConfig
458    ///
459    /// # Example
460    /// ```
461    /// # use google_cloud_retail_v2::client::CatalogService;
462    /// use google_cloud_retail_v2::Result;
463    /// async fn sample(
464    ///    client: &CatalogService, project_id: &str, location_id: &str, catalog_id: &str
465    /// ) -> Result<()> {
466    ///     let response = client.get_completion_config()
467    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/completionConfig"))
468    ///         .send().await?;
469    ///     println!("response {:?}", response);
470    ///     Ok(())
471    /// }
472    /// ```
473    pub fn get_completion_config(&self) -> super::builder::catalog_service::GetCompletionConfig {
474        super::builder::catalog_service::GetCompletionConfig::new(self.inner.clone())
475    }
476
477    /// Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s.
478    ///
479    /// [google.cloud.retail.v2.CompletionConfig]: crate::model::CompletionConfig
480    ///
481    /// # Example
482    /// ```
483    /// # use google_cloud_retail_v2::client::CatalogService;
484    /// # extern crate wkt as google_cloud_wkt;
485    /// use google_cloud_wkt::FieldMask;
486    /// use google_cloud_retail_v2::model::CompletionConfig;
487    /// use google_cloud_retail_v2::Result;
488    /// async fn sample(
489    ///    client: &CatalogService, project_id: &str, location_id: &str, catalog_id: &str
490    /// ) -> Result<()> {
491    ///     let response = client.update_completion_config()
492    ///         .set_completion_config(
493    ///             CompletionConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/completionConfig"))/* set fields */
494    ///         )
495    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
496    ///         .send().await?;
497    ///     println!("response {:?}", response);
498    ///     Ok(())
499    /// }
500    /// ```
501    pub fn update_completion_config(
502        &self,
503    ) -> super::builder::catalog_service::UpdateCompletionConfig {
504        super::builder::catalog_service::UpdateCompletionConfig::new(self.inner.clone())
505    }
506
507    /// Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
508    ///
509    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
510    ///
511    /// # Example
512    /// ```
513    /// # use google_cloud_retail_v2::client::CatalogService;
514    /// use google_cloud_retail_v2::Result;
515    /// async fn sample(
516    ///    client: &CatalogService, project_id: &str, location_id: &str, catalog_id: &str
517    /// ) -> Result<()> {
518    ///     let response = client.get_attributes_config()
519    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig"))
520    ///         .send().await?;
521    ///     println!("response {:?}", response);
522    ///     Ok(())
523    /// }
524    /// ```
525    pub fn get_attributes_config(&self) -> super::builder::catalog_service::GetAttributesConfig {
526        super::builder::catalog_service::GetAttributesConfig::new(self.inner.clone())
527    }
528
529    /// Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
530    ///
531    /// The catalog attributes in the request will be updated in the catalog, or
532    /// inserted if they do not exist. Existing catalog attributes not included in
533    /// the request will remain unchanged. Attributes that are assigned to
534    /// products, but do not exist at the catalog level, are always included in the
535    /// response. The product attribute is assigned default values for missing
536    /// catalog attribute fields, e.g., searchable and dynamic facetable options.
537    ///
538    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
539    ///
540    /// # Example
541    /// ```
542    /// # use google_cloud_retail_v2::client::CatalogService;
543    /// # extern crate wkt as google_cloud_wkt;
544    /// use google_cloud_wkt::FieldMask;
545    /// use google_cloud_retail_v2::model::AttributesConfig;
546    /// use google_cloud_retail_v2::Result;
547    /// async fn sample(
548    ///    client: &CatalogService, project_id: &str, location_id: &str, catalog_id: &str
549    /// ) -> Result<()> {
550    ///     let response = client.update_attributes_config()
551    ///         .set_attributes_config(
552    ///             AttributesConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig"))/* set fields */
553    ///         )
554    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
555    ///         .send().await?;
556    ///     println!("response {:?}", response);
557    ///     Ok(())
558    /// }
559    /// ```
560    pub fn update_attributes_config(
561        &self,
562    ) -> super::builder::catalog_service::UpdateAttributesConfig {
563        super::builder::catalog_service::UpdateAttributesConfig::new(self.inner.clone())
564    }
565
566    /// Adds the specified
567    /// [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the
568    /// [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
569    ///
570    /// If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add
571    /// already exists, an ALREADY_EXISTS error is returned.
572    ///
573    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
574    /// [google.cloud.retail.v2.CatalogAttribute]: crate::model::CatalogAttribute
575    ///
576    /// # Example
577    /// ```
578    /// # use google_cloud_retail_v2::client::CatalogService;
579    /// use google_cloud_retail_v2::Result;
580    /// async fn sample(
581    ///    client: &CatalogService
582    /// ) -> Result<()> {
583    ///     let response = client.add_catalog_attribute()
584    ///         /* set fields */
585    ///         .send().await?;
586    ///     println!("response {:?}", response);
587    ///     Ok(())
588    /// }
589    /// ```
590    pub fn add_catalog_attribute(&self) -> super::builder::catalog_service::AddCatalogAttribute {
591        super::builder::catalog_service::AddCatalogAttribute::new(self.inner.clone())
592    }
593
594    /// Removes the specified
595    /// [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the
596    /// [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
597    ///
598    /// If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to
599    /// remove does not exist, a NOT_FOUND error is returned.
600    ///
601    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
602    /// [google.cloud.retail.v2.CatalogAttribute]: crate::model::CatalogAttribute
603    ///
604    /// # Example
605    /// ```
606    /// # use google_cloud_retail_v2::client::CatalogService;
607    /// use google_cloud_retail_v2::Result;
608    /// async fn sample(
609    ///    client: &CatalogService
610    /// ) -> Result<()> {
611    ///     let response = client.remove_catalog_attribute()
612    ///         /* set fields */
613    ///         .send().await?;
614    ///     println!("response {:?}", response);
615    ///     Ok(())
616    /// }
617    /// ```
618    pub fn remove_catalog_attribute(
619        &self,
620    ) -> super::builder::catalog_service::RemoveCatalogAttribute {
621        super::builder::catalog_service::RemoveCatalogAttribute::new(self.inner.clone())
622    }
623
624    /// Replaces the specified
625    /// [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the
626    /// [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the
627    /// catalog attribute with the same
628    /// [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key].
629    ///
630    /// If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to
631    /// replace does not exist, a NOT_FOUND error is returned.
632    ///
633    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
634    /// [google.cloud.retail.v2.CatalogAttribute]: crate::model::CatalogAttribute
635    /// [google.cloud.retail.v2.CatalogAttribute.key]: crate::model::CatalogAttribute::key
636    ///
637    /// # Example
638    /// ```
639    /// # use google_cloud_retail_v2::client::CatalogService;
640    /// use google_cloud_retail_v2::Result;
641    /// async fn sample(
642    ///    client: &CatalogService
643    /// ) -> Result<()> {
644    ///     let response = client.replace_catalog_attribute()
645    ///         /* set fields */
646    ///         .send().await?;
647    ///     println!("response {:?}", response);
648    ///     Ok(())
649    /// }
650    /// ```
651    pub fn replace_catalog_attribute(
652        &self,
653    ) -> super::builder::catalog_service::ReplaceCatalogAttribute {
654        super::builder::catalog_service::ReplaceCatalogAttribute::new(self.inner.clone())
655    }
656
657    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
658    ///
659    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
660    ///
661    /// # Example
662    /// ```
663    /// # use google_cloud_retail_v2::client::CatalogService;
664    /// use google_cloud_gax::paginator::ItemPaginator as _;
665    /// use google_cloud_retail_v2::Result;
666    /// async fn sample(
667    ///    client: &CatalogService
668    /// ) -> Result<()> {
669    ///     let mut list = client.list_operations()
670    ///         /* set fields */
671    ///         .by_item();
672    ///     while let Some(item) = list.next().await.transpose()? {
673    ///         println!("{:?}", item);
674    ///     }
675    ///     Ok(())
676    /// }
677    /// ```
678    pub fn list_operations(&self) -> super::builder::catalog_service::ListOperations {
679        super::builder::catalog_service::ListOperations::new(self.inner.clone())
680    }
681
682    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
683    ///
684    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
685    ///
686    /// # Example
687    /// ```
688    /// # use google_cloud_retail_v2::client::CatalogService;
689    /// use google_cloud_retail_v2::Result;
690    /// async fn sample(
691    ///    client: &CatalogService
692    /// ) -> Result<()> {
693    ///     let response = client.get_operation()
694    ///         /* set fields */
695    ///         .send().await?;
696    ///     println!("response {:?}", response);
697    ///     Ok(())
698    /// }
699    /// ```
700    pub fn get_operation(&self) -> super::builder::catalog_service::GetOperation {
701        super::builder::catalog_service::GetOperation::new(self.inner.clone())
702    }
703}
704
705/// Implements a client for the Vertex AI Search for commerce API.
706///
707/// # Example
708/// ```
709/// # use google_cloud_retail_v2::client::CompletionService;
710/// use google_cloud_lro::Poller;
711/// async fn sample(
712/// ) -> anyhow::Result<()> {
713///     let client = CompletionService::builder().build().await?;
714///     let response = client.import_completion_data()
715///         /* set fields */
716///         .poller().until_done().await?;
717///     println!("response {:?}", response);
718///     Ok(())
719/// }
720/// ```
721///
722/// # Service Description
723///
724/// Autocomplete service for retail.
725///
726/// This feature is only available for users who have Retail Search enabled.
727/// Enable Retail Search on Cloud Console before using this feature.
728///
729/// # Configuration
730///
731/// To configure `CompletionService` use the `with_*` methods in the type returned
732/// by [builder()][CompletionService::builder]. The default configuration should
733/// work for most applications. Common configuration changes include
734///
735/// * [with_endpoint()]: by default this client uses the global default endpoint
736///   (`https://retail.googleapis.com`). Applications using regional
737///   endpoints or running in restricted networks (e.g. a network configured
738//    with [Private Google Access with VPC Service Controls]) may want to
739///   override this default.
740/// * [with_credentials()]: by default this client uses
741///   [Application Default Credentials]. Applications using custom
742///   authentication may need to override this default.
743///
744/// [with_endpoint()]: super::builder::completion_service::ClientBuilder::with_endpoint
745/// [with_credentials()]: super::builder::completion_service::ClientBuilder::with_credentials
746/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
747/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
748///
749/// # Pooling and Cloning
750///
751/// `CompletionService` holds a connection pool internally, it is advised to
752/// create one and reuse it. You do not need to wrap `CompletionService` in
753/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
754/// already uses an `Arc` internally.
755#[derive(Clone, Debug)]
756pub struct CompletionService {
757    inner: std::sync::Arc<dyn super::stub::dynamic::CompletionService>,
758}
759
760impl CompletionService {
761    /// Returns a builder for [CompletionService].
762    ///
763    /// ```
764    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
765    /// # use google_cloud_retail_v2::client::CompletionService;
766    /// let client = CompletionService::builder().build().await?;
767    /// # Ok(()) }
768    /// ```
769    pub fn builder() -> super::builder::completion_service::ClientBuilder {
770        crate::new_client_builder(super::builder::completion_service::client::Factory)
771    }
772
773    /// Creates a new client from the provided stub.
774    ///
775    /// The most common case for calling this function is in tests mocking the
776    /// client's behavior.
777    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
778    where
779        T: super::stub::CompletionService + 'static,
780    {
781        Self { inner: stub.into() }
782    }
783
784    pub(crate) async fn new(
785        config: gaxi::options::ClientConfig,
786    ) -> crate::ClientBuilderResult<Self> {
787        let inner = Self::build_inner(config).await?;
788        Ok(Self { inner })
789    }
790
791    async fn build_inner(
792        conf: gaxi::options::ClientConfig,
793    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CompletionService>>
794    {
795        if gaxi::options::tracing_enabled(&conf) {
796            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
797        }
798        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
799    }
800
801    async fn build_transport(
802        conf: gaxi::options::ClientConfig,
803    ) -> crate::ClientBuilderResult<impl super::stub::CompletionService> {
804        super::transport::CompletionService::new(conf).await
805    }
806
807    async fn build_with_tracing(
808        conf: gaxi::options::ClientConfig,
809    ) -> crate::ClientBuilderResult<impl super::stub::CompletionService> {
810        Self::build_transport(conf)
811            .await
812            .map(super::tracing::CompletionService::new)
813    }
814
815    /// Completes the specified prefix with keyword suggestions.
816    ///
817    /// This feature is only available for users who have Retail Search enabled.
818    /// Enable Retail Search on Cloud Console before using this feature.
819    ///
820    /// # Example
821    /// ```
822    /// # use google_cloud_retail_v2::client::CompletionService;
823    /// use google_cloud_retail_v2::Result;
824    /// async fn sample(
825    ///    client: &CompletionService
826    /// ) -> Result<()> {
827    ///     let response = client.complete_query()
828    ///         /* set fields */
829    ///         .send().await?;
830    ///     println!("response {:?}", response);
831    ///     Ok(())
832    /// }
833    /// ```
834    pub fn complete_query(&self) -> super::builder::completion_service::CompleteQuery {
835        super::builder::completion_service::CompleteQuery::new(self.inner.clone())
836    }
837
838    /// Bulk import of processed completion dataset.
839    ///
840    /// Request processing is asynchronous. Partial updating is not supported.
841    ///
842    /// The operation is successfully finished only after the imported suggestions
843    /// are indexed successfully and ready for serving. The process takes hours.
844    ///
845    /// This feature is only available for users who have Retail Search enabled.
846    /// Enable Retail Search on Cloud Console before using this feature.
847    ///
848    /// # Long running operations
849    ///
850    /// This method is used to start, and/or poll a [long-running Operation].
851    /// The [Working with long-running operations] chapter in the [user guide]
852    /// covers these operations in detail.
853    ///
854    /// [long-running operation]: https://google.aip.dev/151
855    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
856    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
857    ///
858    /// # Example
859    /// ```
860    /// # use google_cloud_retail_v2::client::CompletionService;
861    /// use google_cloud_lro::Poller;
862    /// use google_cloud_retail_v2::Result;
863    /// async fn sample(
864    ///    client: &CompletionService
865    /// ) -> Result<()> {
866    ///     let response = client.import_completion_data()
867    ///         /* set fields */
868    ///         .poller().until_done().await?;
869    ///     println!("response {:?}", response);
870    ///     Ok(())
871    /// }
872    /// ```
873    pub fn import_completion_data(
874        &self,
875    ) -> super::builder::completion_service::ImportCompletionData {
876        super::builder::completion_service::ImportCompletionData::new(self.inner.clone())
877    }
878
879    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
880    ///
881    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
882    ///
883    /// # Example
884    /// ```
885    /// # use google_cloud_retail_v2::client::CompletionService;
886    /// use google_cloud_gax::paginator::ItemPaginator as _;
887    /// use google_cloud_retail_v2::Result;
888    /// async fn sample(
889    ///    client: &CompletionService
890    /// ) -> Result<()> {
891    ///     let mut list = client.list_operations()
892    ///         /* set fields */
893    ///         .by_item();
894    ///     while let Some(item) = list.next().await.transpose()? {
895    ///         println!("{:?}", item);
896    ///     }
897    ///     Ok(())
898    /// }
899    /// ```
900    pub fn list_operations(&self) -> super::builder::completion_service::ListOperations {
901        super::builder::completion_service::ListOperations::new(self.inner.clone())
902    }
903
904    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
905    ///
906    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
907    ///
908    /// # Example
909    /// ```
910    /// # use google_cloud_retail_v2::client::CompletionService;
911    /// use google_cloud_retail_v2::Result;
912    /// async fn sample(
913    ///    client: &CompletionService
914    /// ) -> Result<()> {
915    ///     let response = client.get_operation()
916    ///         /* set fields */
917    ///         .send().await?;
918    ///     println!("response {:?}", response);
919    ///     Ok(())
920    /// }
921    /// ```
922    pub fn get_operation(&self) -> super::builder::completion_service::GetOperation {
923        super::builder::completion_service::GetOperation::new(self.inner.clone())
924    }
925}
926
927/// Implements a client for the Vertex AI Search for commerce API.
928///
929/// # Example
930/// ```
931/// # use google_cloud_retail_v2::client::ControlService;
932/// use google_cloud_gax::paginator::ItemPaginator as _;
933/// async fn sample(
934///    project_id: &str,
935///    location_id: &str,
936///    catalog_id: &str,
937/// ) -> anyhow::Result<()> {
938///     let client = ControlService::builder().build().await?;
939///     let mut list = client.list_controls()
940///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
941///         .by_item();
942///     while let Some(item) = list.next().await.transpose()? {
943///         println!("{:?}", item);
944///     }
945///     Ok(())
946/// }
947/// ```
948///
949/// # Service Description
950///
951/// Service for modifying Control.
952///
953/// # Configuration
954///
955/// To configure `ControlService` use the `with_*` methods in the type returned
956/// by [builder()][ControlService::builder]. The default configuration should
957/// work for most applications. Common configuration changes include
958///
959/// * [with_endpoint()]: by default this client uses the global default endpoint
960///   (`https://retail.googleapis.com`). Applications using regional
961///   endpoints or running in restricted networks (e.g. a network configured
962//    with [Private Google Access with VPC Service Controls]) may want to
963///   override this default.
964/// * [with_credentials()]: by default this client uses
965///   [Application Default Credentials]. Applications using custom
966///   authentication may need to override this default.
967///
968/// [with_endpoint()]: super::builder::control_service::ClientBuilder::with_endpoint
969/// [with_credentials()]: super::builder::control_service::ClientBuilder::with_credentials
970/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
971/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
972///
973/// # Pooling and Cloning
974///
975/// `ControlService` holds a connection pool internally, it is advised to
976/// create one and reuse it. You do not need to wrap `ControlService` in
977/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
978/// already uses an `Arc` internally.
979#[derive(Clone, Debug)]
980pub struct ControlService {
981    inner: std::sync::Arc<dyn super::stub::dynamic::ControlService>,
982}
983
984impl ControlService {
985    /// Returns a builder for [ControlService].
986    ///
987    /// ```
988    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
989    /// # use google_cloud_retail_v2::client::ControlService;
990    /// let client = ControlService::builder().build().await?;
991    /// # Ok(()) }
992    /// ```
993    pub fn builder() -> super::builder::control_service::ClientBuilder {
994        crate::new_client_builder(super::builder::control_service::client::Factory)
995    }
996
997    /// Creates a new client from the provided stub.
998    ///
999    /// The most common case for calling this function is in tests mocking the
1000    /// client's behavior.
1001    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1002    where
1003        T: super::stub::ControlService + 'static,
1004    {
1005        Self { inner: stub.into() }
1006    }
1007
1008    pub(crate) async fn new(
1009        config: gaxi::options::ClientConfig,
1010    ) -> crate::ClientBuilderResult<Self> {
1011        let inner = Self::build_inner(config).await?;
1012        Ok(Self { inner })
1013    }
1014
1015    async fn build_inner(
1016        conf: gaxi::options::ClientConfig,
1017    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ControlService>> {
1018        if gaxi::options::tracing_enabled(&conf) {
1019            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1020        }
1021        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1022    }
1023
1024    async fn build_transport(
1025        conf: gaxi::options::ClientConfig,
1026    ) -> crate::ClientBuilderResult<impl super::stub::ControlService> {
1027        super::transport::ControlService::new(conf).await
1028    }
1029
1030    async fn build_with_tracing(
1031        conf: gaxi::options::ClientConfig,
1032    ) -> crate::ClientBuilderResult<impl super::stub::ControlService> {
1033        Self::build_transport(conf)
1034            .await
1035            .map(super::tracing::ControlService::new)
1036    }
1037
1038    /// Creates a Control.
1039    ///
1040    /// If the [Control][google.cloud.retail.v2.Control] to create already exists,
1041    /// an ALREADY_EXISTS error is returned.
1042    ///
1043    /// [google.cloud.retail.v2.Control]: crate::model::Control
1044    ///
1045    /// # Example
1046    /// ```
1047    /// # use google_cloud_retail_v2::client::ControlService;
1048    /// use google_cloud_retail_v2::model::Control;
1049    /// use google_cloud_retail_v2::Result;
1050    /// async fn sample(
1051    ///    client: &ControlService, project_id: &str, location_id: &str, catalog_id: &str
1052    /// ) -> Result<()> {
1053    ///     let response = client.create_control()
1054    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
1055    ///         .set_control_id("control_id_value")
1056    ///         .set_control(
1057    ///             Control::new()/* set fields */
1058    ///         )
1059    ///         .send().await?;
1060    ///     println!("response {:?}", response);
1061    ///     Ok(())
1062    /// }
1063    /// ```
1064    pub fn create_control(&self) -> super::builder::control_service::CreateControl {
1065        super::builder::control_service::CreateControl::new(self.inner.clone())
1066    }
1067
1068    /// Deletes a Control.
1069    ///
1070    /// If the [Control][google.cloud.retail.v2.Control] to delete does not exist,
1071    /// a NOT_FOUND error is returned.
1072    ///
1073    /// [google.cloud.retail.v2.Control]: crate::model::Control
1074    ///
1075    /// # Example
1076    /// ```
1077    /// # use google_cloud_retail_v2::client::ControlService;
1078    /// use google_cloud_retail_v2::Result;
1079    /// async fn sample(
1080    ///    client: &ControlService, project_id: &str, location_id: &str, catalog_id: &str, control_id: &str
1081    /// ) -> Result<()> {
1082    ///     client.delete_control()
1083    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}"))
1084    ///         .send().await?;
1085    ///     Ok(())
1086    /// }
1087    /// ```
1088    pub fn delete_control(&self) -> super::builder::control_service::DeleteControl {
1089        super::builder::control_service::DeleteControl::new(self.inner.clone())
1090    }
1091
1092    /// Updates a Control.
1093    ///
1094    /// [Control][google.cloud.retail.v2.Control] cannot be set to a different
1095    /// oneof field, if so an INVALID_ARGUMENT is returned. If the
1096    /// [Control][google.cloud.retail.v2.Control] to update does not exist, a
1097    /// NOT_FOUND error is returned.
1098    ///
1099    /// [google.cloud.retail.v2.Control]: crate::model::Control
1100    ///
1101    /// # Example
1102    /// ```
1103    /// # use google_cloud_retail_v2::client::ControlService;
1104    /// # extern crate wkt as google_cloud_wkt;
1105    /// use google_cloud_wkt::FieldMask;
1106    /// use google_cloud_retail_v2::model::Control;
1107    /// use google_cloud_retail_v2::Result;
1108    /// async fn sample(
1109    ///    client: &ControlService, project_id: &str, location_id: &str, catalog_id: &str, control_id: &str
1110    /// ) -> Result<()> {
1111    ///     let response = client.update_control()
1112    ///         .set_control(
1113    ///             Control::new().set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}"))/* set fields */
1114    ///         )
1115    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1116    ///         .send().await?;
1117    ///     println!("response {:?}", response);
1118    ///     Ok(())
1119    /// }
1120    /// ```
1121    pub fn update_control(&self) -> super::builder::control_service::UpdateControl {
1122        super::builder::control_service::UpdateControl::new(self.inner.clone())
1123    }
1124
1125    /// Gets a Control.
1126    ///
1127    /// # Example
1128    /// ```
1129    /// # use google_cloud_retail_v2::client::ControlService;
1130    /// use google_cloud_retail_v2::Result;
1131    /// async fn sample(
1132    ///    client: &ControlService, project_id: &str, location_id: &str, catalog_id: &str, control_id: &str
1133    /// ) -> Result<()> {
1134    ///     let response = client.get_control()
1135    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}"))
1136    ///         .send().await?;
1137    ///     println!("response {:?}", response);
1138    ///     Ok(())
1139    /// }
1140    /// ```
1141    pub fn get_control(&self) -> super::builder::control_service::GetControl {
1142        super::builder::control_service::GetControl::new(self.inner.clone())
1143    }
1144
1145    /// Lists all Controls by their parent
1146    /// [Catalog][google.cloud.retail.v2.Catalog].
1147    ///
1148    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
1149    ///
1150    /// # Example
1151    /// ```
1152    /// # use google_cloud_retail_v2::client::ControlService;
1153    /// use google_cloud_gax::paginator::ItemPaginator as _;
1154    /// use google_cloud_retail_v2::Result;
1155    /// async fn sample(
1156    ///    client: &ControlService, project_id: &str, location_id: &str, catalog_id: &str
1157    /// ) -> Result<()> {
1158    ///     let mut list = client.list_controls()
1159    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
1160    ///         .by_item();
1161    ///     while let Some(item) = list.next().await.transpose()? {
1162    ///         println!("{:?}", item);
1163    ///     }
1164    ///     Ok(())
1165    /// }
1166    /// ```
1167    pub fn list_controls(&self) -> super::builder::control_service::ListControls {
1168        super::builder::control_service::ListControls::new(self.inner.clone())
1169    }
1170
1171    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1172    ///
1173    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1174    ///
1175    /// # Example
1176    /// ```
1177    /// # use google_cloud_retail_v2::client::ControlService;
1178    /// use google_cloud_gax::paginator::ItemPaginator as _;
1179    /// use google_cloud_retail_v2::Result;
1180    /// async fn sample(
1181    ///    client: &ControlService
1182    /// ) -> Result<()> {
1183    ///     let mut list = client.list_operations()
1184    ///         /* set fields */
1185    ///         .by_item();
1186    ///     while let Some(item) = list.next().await.transpose()? {
1187    ///         println!("{:?}", item);
1188    ///     }
1189    ///     Ok(())
1190    /// }
1191    /// ```
1192    pub fn list_operations(&self) -> super::builder::control_service::ListOperations {
1193        super::builder::control_service::ListOperations::new(self.inner.clone())
1194    }
1195
1196    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1197    ///
1198    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1199    ///
1200    /// # Example
1201    /// ```
1202    /// # use google_cloud_retail_v2::client::ControlService;
1203    /// use google_cloud_retail_v2::Result;
1204    /// async fn sample(
1205    ///    client: &ControlService
1206    /// ) -> Result<()> {
1207    ///     let response = client.get_operation()
1208    ///         /* set fields */
1209    ///         .send().await?;
1210    ///     println!("response {:?}", response);
1211    ///     Ok(())
1212    /// }
1213    /// ```
1214    pub fn get_operation(&self) -> super::builder::control_service::GetOperation {
1215        super::builder::control_service::GetOperation::new(self.inner.clone())
1216    }
1217}
1218
1219/// Implements a client for the Vertex AI Search for commerce API.
1220///
1221/// # Example
1222/// ```
1223/// # use google_cloud_retail_v2::client::ConversationalSearchService;
1224/// use google_cloud_gax::paginator::ItemPaginator as _;
1225/// async fn sample(
1226/// ) -> anyhow::Result<()> {
1227///     let client = ConversationalSearchService::builder().build().await?;
1228///     let mut list = client.list_operations()
1229///         /* set fields */
1230///         .by_item();
1231///     while let Some(item) = list.next().await.transpose()? {
1232///         println!("{:?}", item);
1233///     }
1234///     Ok(())
1235/// }
1236/// ```
1237///
1238/// # Service Description
1239///
1240/// Service for retail conversational search.
1241///
1242/// This feature is only available for users who have Retail Conversational
1243/// Search enabled. Enable Retail Conversational Search on Cloud Console
1244/// before using this feature.
1245///
1246/// # Configuration
1247///
1248/// To configure `ConversationalSearchService` use the `with_*` methods in the type returned
1249/// by [builder()][ConversationalSearchService::builder]. The default configuration should
1250/// work for most applications. Common configuration changes include
1251///
1252/// * [with_endpoint()]: by default this client uses the global default endpoint
1253///   (`https://retail.googleapis.com`). Applications using regional
1254///   endpoints or running in restricted networks (e.g. a network configured
1255//    with [Private Google Access with VPC Service Controls]) may want to
1256///   override this default.
1257/// * [with_credentials()]: by default this client uses
1258///   [Application Default Credentials]. Applications using custom
1259///   authentication may need to override this default.
1260///
1261/// [with_endpoint()]: super::builder::conversational_search_service::ClientBuilder::with_endpoint
1262/// [with_credentials()]: super::builder::conversational_search_service::ClientBuilder::with_credentials
1263/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1264/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1265///
1266/// # Pooling and Cloning
1267///
1268/// `ConversationalSearchService` holds a connection pool internally, it is advised to
1269/// create one and reuse it. You do not need to wrap `ConversationalSearchService` in
1270/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1271/// already uses an `Arc` internally.
1272#[derive(Clone, Debug)]
1273pub struct ConversationalSearchService {
1274    inner: std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
1275}
1276
1277impl ConversationalSearchService {
1278    /// Returns a builder for [ConversationalSearchService].
1279    ///
1280    /// ```
1281    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1282    /// # use google_cloud_retail_v2::client::ConversationalSearchService;
1283    /// let client = ConversationalSearchService::builder().build().await?;
1284    /// # Ok(()) }
1285    /// ```
1286    pub fn builder() -> super::builder::conversational_search_service::ClientBuilder {
1287        crate::new_client_builder(super::builder::conversational_search_service::client::Factory)
1288    }
1289
1290    /// Creates a new client from the provided stub.
1291    ///
1292    /// The most common case for calling this function is in tests mocking the
1293    /// client's behavior.
1294    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1295    where
1296        T: super::stub::ConversationalSearchService + 'static,
1297    {
1298        Self { inner: stub.into() }
1299    }
1300
1301    pub(crate) async fn new(
1302        config: gaxi::options::ClientConfig,
1303    ) -> crate::ClientBuilderResult<Self> {
1304        let inner = Self::build_inner(config).await?;
1305        Ok(Self { inner })
1306    }
1307
1308    async fn build_inner(
1309        conf: gaxi::options::ClientConfig,
1310    ) -> crate::ClientBuilderResult<
1311        std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
1312    > {
1313        if gaxi::options::tracing_enabled(&conf) {
1314            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1315        }
1316        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1317    }
1318
1319    async fn build_transport(
1320        conf: gaxi::options::ClientConfig,
1321    ) -> crate::ClientBuilderResult<impl super::stub::ConversationalSearchService> {
1322        super::transport::ConversationalSearchService::new(conf).await
1323    }
1324
1325    async fn build_with_tracing(
1326        conf: gaxi::options::ClientConfig,
1327    ) -> crate::ClientBuilderResult<impl super::stub::ConversationalSearchService> {
1328        Self::build_transport(conf)
1329            .await
1330            .map(super::tracing::ConversationalSearchService::new)
1331    }
1332
1333    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1334    ///
1335    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1336    ///
1337    /// # Example
1338    /// ```
1339    /// # use google_cloud_retail_v2::client::ConversationalSearchService;
1340    /// use google_cloud_gax::paginator::ItemPaginator as _;
1341    /// use google_cloud_retail_v2::Result;
1342    /// async fn sample(
1343    ///    client: &ConversationalSearchService
1344    /// ) -> Result<()> {
1345    ///     let mut list = client.list_operations()
1346    ///         /* set fields */
1347    ///         .by_item();
1348    ///     while let Some(item) = list.next().await.transpose()? {
1349    ///         println!("{:?}", item);
1350    ///     }
1351    ///     Ok(())
1352    /// }
1353    /// ```
1354    pub fn list_operations(&self) -> super::builder::conversational_search_service::ListOperations {
1355        super::builder::conversational_search_service::ListOperations::new(self.inner.clone())
1356    }
1357
1358    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1359    ///
1360    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1361    ///
1362    /// # Example
1363    /// ```
1364    /// # use google_cloud_retail_v2::client::ConversationalSearchService;
1365    /// use google_cloud_retail_v2::Result;
1366    /// async fn sample(
1367    ///    client: &ConversationalSearchService
1368    /// ) -> Result<()> {
1369    ///     let response = client.get_operation()
1370    ///         /* set fields */
1371    ///         .send().await?;
1372    ///     println!("response {:?}", response);
1373    ///     Ok(())
1374    /// }
1375    /// ```
1376    pub fn get_operation(&self) -> super::builder::conversational_search_service::GetOperation {
1377        super::builder::conversational_search_service::GetOperation::new(self.inner.clone())
1378    }
1379}
1380
1381/// Implements a client for the Vertex AI Search for commerce API.
1382///
1383/// # Example
1384/// ```
1385/// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1386/// async fn sample(
1387/// ) -> anyhow::Result<()> {
1388///     let client = GenerativeQuestionService::builder().build().await?;
1389///     let response = client.update_generative_questions_feature_config()
1390///         /* set fields */
1391///         .send().await?;
1392///     println!("response {:?}", response);
1393///     Ok(())
1394/// }
1395/// ```
1396///
1397/// # Service Description
1398///
1399/// Service for managing LLM generated questions in search serving.
1400///
1401/// # Configuration
1402///
1403/// To configure `GenerativeQuestionService` use the `with_*` methods in the type returned
1404/// by [builder()][GenerativeQuestionService::builder]. The default configuration should
1405/// work for most applications. Common configuration changes include
1406///
1407/// * [with_endpoint()]: by default this client uses the global default endpoint
1408///   (`https://retail.googleapis.com`). Applications using regional
1409///   endpoints or running in restricted networks (e.g. a network configured
1410//    with [Private Google Access with VPC Service Controls]) may want to
1411///   override this default.
1412/// * [with_credentials()]: by default this client uses
1413///   [Application Default Credentials]. Applications using custom
1414///   authentication may need to override this default.
1415///
1416/// [with_endpoint()]: super::builder::generative_question_service::ClientBuilder::with_endpoint
1417/// [with_credentials()]: super::builder::generative_question_service::ClientBuilder::with_credentials
1418/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1419/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1420///
1421/// # Pooling and Cloning
1422///
1423/// `GenerativeQuestionService` holds a connection pool internally, it is advised to
1424/// create one and reuse it. You do not need to wrap `GenerativeQuestionService` in
1425/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1426/// already uses an `Arc` internally.
1427#[derive(Clone, Debug)]
1428pub struct GenerativeQuestionService {
1429    inner: std::sync::Arc<dyn super::stub::dynamic::GenerativeQuestionService>,
1430}
1431
1432impl GenerativeQuestionService {
1433    /// Returns a builder for [GenerativeQuestionService].
1434    ///
1435    /// ```
1436    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1437    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1438    /// let client = GenerativeQuestionService::builder().build().await?;
1439    /// # Ok(()) }
1440    /// ```
1441    pub fn builder() -> super::builder::generative_question_service::ClientBuilder {
1442        crate::new_client_builder(super::builder::generative_question_service::client::Factory)
1443    }
1444
1445    /// Creates a new client from the provided stub.
1446    ///
1447    /// The most common case for calling this function is in tests mocking the
1448    /// client's behavior.
1449    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1450    where
1451        T: super::stub::GenerativeQuestionService + 'static,
1452    {
1453        Self { inner: stub.into() }
1454    }
1455
1456    pub(crate) async fn new(
1457        config: gaxi::options::ClientConfig,
1458    ) -> crate::ClientBuilderResult<Self> {
1459        let inner = Self::build_inner(config).await?;
1460        Ok(Self { inner })
1461    }
1462
1463    async fn build_inner(
1464        conf: gaxi::options::ClientConfig,
1465    ) -> crate::ClientBuilderResult<
1466        std::sync::Arc<dyn super::stub::dynamic::GenerativeQuestionService>,
1467    > {
1468        if gaxi::options::tracing_enabled(&conf) {
1469            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1470        }
1471        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1472    }
1473
1474    async fn build_transport(
1475        conf: gaxi::options::ClientConfig,
1476    ) -> crate::ClientBuilderResult<impl super::stub::GenerativeQuestionService> {
1477        super::transport::GenerativeQuestionService::new(conf).await
1478    }
1479
1480    async fn build_with_tracing(
1481        conf: gaxi::options::ClientConfig,
1482    ) -> crate::ClientBuilderResult<impl super::stub::GenerativeQuestionService> {
1483        Self::build_transport(conf)
1484            .await
1485            .map(super::tracing::GenerativeQuestionService::new)
1486    }
1487
1488    /// Manages overal generative question feature state -- enables toggling
1489    /// feature on and off.
1490    ///
1491    /// # Example
1492    /// ```
1493    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1494    /// use google_cloud_retail_v2::Result;
1495    /// async fn sample(
1496    ///    client: &GenerativeQuestionService
1497    /// ) -> Result<()> {
1498    ///     let response = client.update_generative_questions_feature_config()
1499    ///         /* set fields */
1500    ///         .send().await?;
1501    ///     println!("response {:?}", response);
1502    ///     Ok(())
1503    /// }
1504    /// ```
1505    pub fn update_generative_questions_feature_config(
1506        &self,
1507    ) -> super::builder::generative_question_service::UpdateGenerativeQuestionsFeatureConfig {
1508        super::builder::generative_question_service::UpdateGenerativeQuestionsFeatureConfig::new(
1509            self.inner.clone(),
1510        )
1511    }
1512
1513    /// Manages overal generative question feature state -- enables toggling
1514    /// feature on and off.
1515    ///
1516    /// # Example
1517    /// ```
1518    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1519    /// use google_cloud_retail_v2::Result;
1520    /// async fn sample(
1521    ///    client: &GenerativeQuestionService
1522    /// ) -> Result<()> {
1523    ///     let response = client.get_generative_questions_feature_config()
1524    ///         /* set fields */
1525    ///         .send().await?;
1526    ///     println!("response {:?}", response);
1527    ///     Ok(())
1528    /// }
1529    /// ```
1530    pub fn get_generative_questions_feature_config(
1531        &self,
1532    ) -> super::builder::generative_question_service::GetGenerativeQuestionsFeatureConfig {
1533        super::builder::generative_question_service::GetGenerativeQuestionsFeatureConfig::new(
1534            self.inner.clone(),
1535        )
1536    }
1537
1538    /// Returns all questions for a given catalog.
1539    ///
1540    /// # Example
1541    /// ```
1542    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1543    /// use google_cloud_retail_v2::Result;
1544    /// async fn sample(
1545    ///    client: &GenerativeQuestionService
1546    /// ) -> Result<()> {
1547    ///     let response = client.list_generative_question_configs()
1548    ///         /* set fields */
1549    ///         .send().await?;
1550    ///     println!("response {:?}", response);
1551    ///     Ok(())
1552    /// }
1553    /// ```
1554    pub fn list_generative_question_configs(
1555        &self,
1556    ) -> super::builder::generative_question_service::ListGenerativeQuestionConfigs {
1557        super::builder::generative_question_service::ListGenerativeQuestionConfigs::new(
1558            self.inner.clone(),
1559        )
1560    }
1561
1562    /// Allows management of individual questions.
1563    ///
1564    /// # Example
1565    /// ```
1566    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1567    /// use google_cloud_retail_v2::Result;
1568    /// async fn sample(
1569    ///    client: &GenerativeQuestionService
1570    /// ) -> Result<()> {
1571    ///     let response = client.update_generative_question_config()
1572    ///         /* set fields */
1573    ///         .send().await?;
1574    ///     println!("response {:?}", response);
1575    ///     Ok(())
1576    /// }
1577    /// ```
1578    pub fn update_generative_question_config(
1579        &self,
1580    ) -> super::builder::generative_question_service::UpdateGenerativeQuestionConfig {
1581        super::builder::generative_question_service::UpdateGenerativeQuestionConfig::new(
1582            self.inner.clone(),
1583        )
1584    }
1585
1586    /// Allows management of multiple questions.
1587    ///
1588    /// # Example
1589    /// ```
1590    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1591    /// use google_cloud_retail_v2::Result;
1592    /// async fn sample(
1593    ///    client: &GenerativeQuestionService
1594    /// ) -> Result<()> {
1595    ///     let response = client.batch_update_generative_question_configs()
1596    ///         /* set fields */
1597    ///         .send().await?;
1598    ///     println!("response {:?}", response);
1599    ///     Ok(())
1600    /// }
1601    /// ```
1602    pub fn batch_update_generative_question_configs(
1603        &self,
1604    ) -> super::builder::generative_question_service::BatchUpdateGenerativeQuestionConfigs {
1605        super::builder::generative_question_service::BatchUpdateGenerativeQuestionConfigs::new(
1606            self.inner.clone(),
1607        )
1608    }
1609
1610    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1611    ///
1612    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1613    ///
1614    /// # Example
1615    /// ```
1616    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1617    /// use google_cloud_gax::paginator::ItemPaginator as _;
1618    /// use google_cloud_retail_v2::Result;
1619    /// async fn sample(
1620    ///    client: &GenerativeQuestionService
1621    /// ) -> Result<()> {
1622    ///     let mut list = client.list_operations()
1623    ///         /* set fields */
1624    ///         .by_item();
1625    ///     while let Some(item) = list.next().await.transpose()? {
1626    ///         println!("{:?}", item);
1627    ///     }
1628    ///     Ok(())
1629    /// }
1630    /// ```
1631    pub fn list_operations(&self) -> super::builder::generative_question_service::ListOperations {
1632        super::builder::generative_question_service::ListOperations::new(self.inner.clone())
1633    }
1634
1635    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1636    ///
1637    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1638    ///
1639    /// # Example
1640    /// ```
1641    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
1642    /// use google_cloud_retail_v2::Result;
1643    /// async fn sample(
1644    ///    client: &GenerativeQuestionService
1645    /// ) -> Result<()> {
1646    ///     let response = client.get_operation()
1647    ///         /* set fields */
1648    ///         .send().await?;
1649    ///     println!("response {:?}", response);
1650    ///     Ok(())
1651    /// }
1652    /// ```
1653    pub fn get_operation(&self) -> super::builder::generative_question_service::GetOperation {
1654        super::builder::generative_question_service::GetOperation::new(self.inner.clone())
1655    }
1656}
1657
1658/// Implements a client for the Vertex AI Search for commerce API.
1659///
1660/// # Example
1661/// ```
1662/// # use google_cloud_retail_v2::client::ModelService;
1663/// use google_cloud_gax::paginator::ItemPaginator as _;
1664/// async fn sample(
1665///    project_id: &str,
1666///    location_id: &str,
1667///    catalog_id: &str,
1668/// ) -> anyhow::Result<()> {
1669///     let client = ModelService::builder().build().await?;
1670///     let mut list = client.list_models()
1671///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
1672///         .by_item();
1673///     while let Some(item) = list.next().await.transpose()? {
1674///         println!("{:?}", item);
1675///     }
1676///     Ok(())
1677/// }
1678/// ```
1679///
1680/// # Service Description
1681///
1682/// Service for performing CRUD operations on models.
1683/// Recommendation models contain all the metadata necessary to generate a set of
1684/// models for the `Predict()` API. A model is queried
1685/// indirectly via a ServingConfig, which associates a model with a
1686/// given Placement (e.g. Frequently Bought Together on Home Page).
1687///
1688/// This service allows you to do the following:
1689///
1690/// * Initiate training of a model.
1691/// * Pause training of an existing model.
1692/// * List all the available models along with their metadata.
1693/// * Control their tuning schedule.
1694///
1695/// # Configuration
1696///
1697/// To configure `ModelService` use the `with_*` methods in the type returned
1698/// by [builder()][ModelService::builder]. The default configuration should
1699/// work for most applications. Common configuration changes include
1700///
1701/// * [with_endpoint()]: by default this client uses the global default endpoint
1702///   (`https://retail.googleapis.com`). Applications using regional
1703///   endpoints or running in restricted networks (e.g. a network configured
1704//    with [Private Google Access with VPC Service Controls]) may want to
1705///   override this default.
1706/// * [with_credentials()]: by default this client uses
1707///   [Application Default Credentials]. Applications using custom
1708///   authentication may need to override this default.
1709///
1710/// [with_endpoint()]: super::builder::model_service::ClientBuilder::with_endpoint
1711/// [with_credentials()]: super::builder::model_service::ClientBuilder::with_credentials
1712/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1713/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1714///
1715/// # Pooling and Cloning
1716///
1717/// `ModelService` holds a connection pool internally, it is advised to
1718/// create one and reuse it. You do not need to wrap `ModelService` in
1719/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1720/// already uses an `Arc` internally.
1721#[derive(Clone, Debug)]
1722pub struct ModelService {
1723    inner: std::sync::Arc<dyn super::stub::dynamic::ModelService>,
1724}
1725
1726impl ModelService {
1727    /// Returns a builder for [ModelService].
1728    ///
1729    /// ```
1730    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1731    /// # use google_cloud_retail_v2::client::ModelService;
1732    /// let client = ModelService::builder().build().await?;
1733    /// # Ok(()) }
1734    /// ```
1735    pub fn builder() -> super::builder::model_service::ClientBuilder {
1736        crate::new_client_builder(super::builder::model_service::client::Factory)
1737    }
1738
1739    /// Creates a new client from the provided stub.
1740    ///
1741    /// The most common case for calling this function is in tests mocking the
1742    /// client's behavior.
1743    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1744    where
1745        T: super::stub::ModelService + 'static,
1746    {
1747        Self { inner: stub.into() }
1748    }
1749
1750    pub(crate) async fn new(
1751        config: gaxi::options::ClientConfig,
1752    ) -> crate::ClientBuilderResult<Self> {
1753        let inner = Self::build_inner(config).await?;
1754        Ok(Self { inner })
1755    }
1756
1757    async fn build_inner(
1758        conf: gaxi::options::ClientConfig,
1759    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ModelService>> {
1760        if gaxi::options::tracing_enabled(&conf) {
1761            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1762        }
1763        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1764    }
1765
1766    async fn build_transport(
1767        conf: gaxi::options::ClientConfig,
1768    ) -> crate::ClientBuilderResult<impl super::stub::ModelService> {
1769        super::transport::ModelService::new(conf).await
1770    }
1771
1772    async fn build_with_tracing(
1773        conf: gaxi::options::ClientConfig,
1774    ) -> crate::ClientBuilderResult<impl super::stub::ModelService> {
1775        Self::build_transport(conf)
1776            .await
1777            .map(super::tracing::ModelService::new)
1778    }
1779
1780    /// Creates a new model.
1781    ///
1782    /// # Long running operations
1783    ///
1784    /// This method is used to start, and/or poll a [long-running Operation].
1785    /// The [Working with long-running operations] chapter in the [user guide]
1786    /// covers these operations in detail.
1787    ///
1788    /// [long-running operation]: https://google.aip.dev/151
1789    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1790    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1791    ///
1792    /// # Example
1793    /// ```
1794    /// # use google_cloud_retail_v2::client::ModelService;
1795    /// use google_cloud_lro::Poller;
1796    /// use google_cloud_retail_v2::model::Model;
1797    /// use google_cloud_retail_v2::Result;
1798    /// async fn sample(
1799    ///    client: &ModelService, project_id: &str, location_id: &str, catalog_id: &str
1800    /// ) -> Result<()> {
1801    ///     let response = client.create_model()
1802    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
1803    ///         .set_model(
1804    ///             Model::new()/* set fields */
1805    ///         )
1806    ///         .poller().until_done().await?;
1807    ///     println!("response {:?}", response);
1808    ///     Ok(())
1809    /// }
1810    /// ```
1811    pub fn create_model(&self) -> super::builder::model_service::CreateModel {
1812        super::builder::model_service::CreateModel::new(self.inner.clone())
1813    }
1814
1815    /// Gets a model.
1816    ///
1817    /// # Example
1818    /// ```
1819    /// # use google_cloud_retail_v2::client::ModelService;
1820    /// use google_cloud_retail_v2::Result;
1821    /// async fn sample(
1822    ///    client: &ModelService, project_id: &str, location_id: &str, catalog_id: &str, model_id: &str
1823    /// ) -> Result<()> {
1824    ///     let response = client.get_model()
1825    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}"))
1826    ///         .send().await?;
1827    ///     println!("response {:?}", response);
1828    ///     Ok(())
1829    /// }
1830    /// ```
1831    pub fn get_model(&self) -> super::builder::model_service::GetModel {
1832        super::builder::model_service::GetModel::new(self.inner.clone())
1833    }
1834
1835    /// Pauses the training of an existing model.
1836    ///
1837    /// # Example
1838    /// ```
1839    /// # use google_cloud_retail_v2::client::ModelService;
1840    /// use google_cloud_retail_v2::Result;
1841    /// async fn sample(
1842    ///    client: &ModelService
1843    /// ) -> Result<()> {
1844    ///     let response = client.pause_model()
1845    ///         /* set fields */
1846    ///         .send().await?;
1847    ///     println!("response {:?}", response);
1848    ///     Ok(())
1849    /// }
1850    /// ```
1851    pub fn pause_model(&self) -> super::builder::model_service::PauseModel {
1852        super::builder::model_service::PauseModel::new(self.inner.clone())
1853    }
1854
1855    /// Resumes the training of an existing model.
1856    ///
1857    /// # Example
1858    /// ```
1859    /// # use google_cloud_retail_v2::client::ModelService;
1860    /// use google_cloud_retail_v2::Result;
1861    /// async fn sample(
1862    ///    client: &ModelService
1863    /// ) -> Result<()> {
1864    ///     let response = client.resume_model()
1865    ///         /* set fields */
1866    ///         .send().await?;
1867    ///     println!("response {:?}", response);
1868    ///     Ok(())
1869    /// }
1870    /// ```
1871    pub fn resume_model(&self) -> super::builder::model_service::ResumeModel {
1872        super::builder::model_service::ResumeModel::new(self.inner.clone())
1873    }
1874
1875    /// Deletes an existing model.
1876    ///
1877    /// # Example
1878    /// ```
1879    /// # use google_cloud_retail_v2::client::ModelService;
1880    /// use google_cloud_retail_v2::Result;
1881    /// async fn sample(
1882    ///    client: &ModelService, project_id: &str, location_id: &str, catalog_id: &str, model_id: &str
1883    /// ) -> Result<()> {
1884    ///     client.delete_model()
1885    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}"))
1886    ///         .send().await?;
1887    ///     Ok(())
1888    /// }
1889    /// ```
1890    pub fn delete_model(&self) -> super::builder::model_service::DeleteModel {
1891        super::builder::model_service::DeleteModel::new(self.inner.clone())
1892    }
1893
1894    /// Lists all the models linked to this event store.
1895    ///
1896    /// # Example
1897    /// ```
1898    /// # use google_cloud_retail_v2::client::ModelService;
1899    /// use google_cloud_gax::paginator::ItemPaginator as _;
1900    /// use google_cloud_retail_v2::Result;
1901    /// async fn sample(
1902    ///    client: &ModelService, project_id: &str, location_id: &str, catalog_id: &str
1903    /// ) -> Result<()> {
1904    ///     let mut list = client.list_models()
1905    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
1906    ///         .by_item();
1907    ///     while let Some(item) = list.next().await.transpose()? {
1908    ///         println!("{:?}", item);
1909    ///     }
1910    ///     Ok(())
1911    /// }
1912    /// ```
1913    pub fn list_models(&self) -> super::builder::model_service::ListModels {
1914        super::builder::model_service::ListModels::new(self.inner.clone())
1915    }
1916
1917    /// Update of model metadata. Only fields that
1918    /// currently can be updated are: `filtering_option` and
1919    /// `periodic_tuning_state`.
1920    /// If other values are provided, this API method ignores them.
1921    ///
1922    /// # Example
1923    /// ```
1924    /// # use google_cloud_retail_v2::client::ModelService;
1925    /// # extern crate wkt as google_cloud_wkt;
1926    /// use google_cloud_wkt::FieldMask;
1927    /// use google_cloud_retail_v2::model::Model;
1928    /// use google_cloud_retail_v2::Result;
1929    /// async fn sample(
1930    ///    client: &ModelService, project_id: &str, location_id: &str, catalog_id: &str, model_id: &str
1931    /// ) -> Result<()> {
1932    ///     let response = client.update_model()
1933    ///         .set_model(
1934    ///             Model::new().set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}"))/* set fields */
1935    ///         )
1936    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1937    ///         .send().await?;
1938    ///     println!("response {:?}", response);
1939    ///     Ok(())
1940    /// }
1941    /// ```
1942    pub fn update_model(&self) -> super::builder::model_service::UpdateModel {
1943        super::builder::model_service::UpdateModel::new(self.inner.clone())
1944    }
1945
1946    /// Tunes an existing model.
1947    ///
1948    /// # Long running operations
1949    ///
1950    /// This method is used to start, and/or poll a [long-running Operation].
1951    /// The [Working with long-running operations] chapter in the [user guide]
1952    /// covers these operations in detail.
1953    ///
1954    /// [long-running operation]: https://google.aip.dev/151
1955    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1956    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1957    ///
1958    /// # Example
1959    /// ```
1960    /// # use google_cloud_retail_v2::client::ModelService;
1961    /// use google_cloud_lro::Poller;
1962    /// use google_cloud_retail_v2::Result;
1963    /// async fn sample(
1964    ///    client: &ModelService
1965    /// ) -> Result<()> {
1966    ///     let response = client.tune_model()
1967    ///         /* set fields */
1968    ///         .poller().until_done().await?;
1969    ///     println!("response {:?}", response);
1970    ///     Ok(())
1971    /// }
1972    /// ```
1973    pub fn tune_model(&self) -> super::builder::model_service::TuneModel {
1974        super::builder::model_service::TuneModel::new(self.inner.clone())
1975    }
1976
1977    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1978    ///
1979    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1980    ///
1981    /// # Example
1982    /// ```
1983    /// # use google_cloud_retail_v2::client::ModelService;
1984    /// use google_cloud_gax::paginator::ItemPaginator as _;
1985    /// use google_cloud_retail_v2::Result;
1986    /// async fn sample(
1987    ///    client: &ModelService
1988    /// ) -> Result<()> {
1989    ///     let mut list = client.list_operations()
1990    ///         /* set fields */
1991    ///         .by_item();
1992    ///     while let Some(item) = list.next().await.transpose()? {
1993    ///         println!("{:?}", item);
1994    ///     }
1995    ///     Ok(())
1996    /// }
1997    /// ```
1998    pub fn list_operations(&self) -> super::builder::model_service::ListOperations {
1999        super::builder::model_service::ListOperations::new(self.inner.clone())
2000    }
2001
2002    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2003    ///
2004    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2005    ///
2006    /// # Example
2007    /// ```
2008    /// # use google_cloud_retail_v2::client::ModelService;
2009    /// use google_cloud_retail_v2::Result;
2010    /// async fn sample(
2011    ///    client: &ModelService
2012    /// ) -> Result<()> {
2013    ///     let response = client.get_operation()
2014    ///         /* set fields */
2015    ///         .send().await?;
2016    ///     println!("response {:?}", response);
2017    ///     Ok(())
2018    /// }
2019    /// ```
2020    pub fn get_operation(&self) -> super::builder::model_service::GetOperation {
2021        super::builder::model_service::GetOperation::new(self.inner.clone())
2022    }
2023}
2024
2025/// Implements a client for the Vertex AI Search for commerce API.
2026///
2027/// # Example
2028/// ```
2029/// # use google_cloud_retail_v2::client::PredictionService;
2030/// async fn sample(
2031/// ) -> anyhow::Result<()> {
2032///     let client = PredictionService::builder().build().await?;
2033///     let response = client.predict()
2034///         /* set fields */
2035///         .send().await?;
2036///     println!("response {:?}", response);
2037///     Ok(())
2038/// }
2039/// ```
2040///
2041/// # Service Description
2042///
2043/// Service for making recommendation prediction.
2044///
2045/// # Configuration
2046///
2047/// To configure `PredictionService` use the `with_*` methods in the type returned
2048/// by [builder()][PredictionService::builder]. The default configuration should
2049/// work for most applications. Common configuration changes include
2050///
2051/// * [with_endpoint()]: by default this client uses the global default endpoint
2052///   (`https://retail.googleapis.com`). Applications using regional
2053///   endpoints or running in restricted networks (e.g. a network configured
2054//    with [Private Google Access with VPC Service Controls]) may want to
2055///   override this default.
2056/// * [with_credentials()]: by default this client uses
2057///   [Application Default Credentials]. Applications using custom
2058///   authentication may need to override this default.
2059///
2060/// [with_endpoint()]: super::builder::prediction_service::ClientBuilder::with_endpoint
2061/// [with_credentials()]: super::builder::prediction_service::ClientBuilder::with_credentials
2062/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2063/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2064///
2065/// # Pooling and Cloning
2066///
2067/// `PredictionService` holds a connection pool internally, it is advised to
2068/// create one and reuse it. You do not need to wrap `PredictionService` in
2069/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2070/// already uses an `Arc` internally.
2071#[derive(Clone, Debug)]
2072pub struct PredictionService {
2073    inner: std::sync::Arc<dyn super::stub::dynamic::PredictionService>,
2074}
2075
2076impl PredictionService {
2077    /// Returns a builder for [PredictionService].
2078    ///
2079    /// ```
2080    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2081    /// # use google_cloud_retail_v2::client::PredictionService;
2082    /// let client = PredictionService::builder().build().await?;
2083    /// # Ok(()) }
2084    /// ```
2085    pub fn builder() -> super::builder::prediction_service::ClientBuilder {
2086        crate::new_client_builder(super::builder::prediction_service::client::Factory)
2087    }
2088
2089    /// Creates a new client from the provided stub.
2090    ///
2091    /// The most common case for calling this function is in tests mocking the
2092    /// client's behavior.
2093    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2094    where
2095        T: super::stub::PredictionService + 'static,
2096    {
2097        Self { inner: stub.into() }
2098    }
2099
2100    pub(crate) async fn new(
2101        config: gaxi::options::ClientConfig,
2102    ) -> crate::ClientBuilderResult<Self> {
2103        let inner = Self::build_inner(config).await?;
2104        Ok(Self { inner })
2105    }
2106
2107    async fn build_inner(
2108        conf: gaxi::options::ClientConfig,
2109    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::PredictionService>>
2110    {
2111        if gaxi::options::tracing_enabled(&conf) {
2112            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2113        }
2114        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2115    }
2116
2117    async fn build_transport(
2118        conf: gaxi::options::ClientConfig,
2119    ) -> crate::ClientBuilderResult<impl super::stub::PredictionService> {
2120        super::transport::PredictionService::new(conf).await
2121    }
2122
2123    async fn build_with_tracing(
2124        conf: gaxi::options::ClientConfig,
2125    ) -> crate::ClientBuilderResult<impl super::stub::PredictionService> {
2126        Self::build_transport(conf)
2127            .await
2128            .map(super::tracing::PredictionService::new)
2129    }
2130
2131    /// Makes a recommendation prediction.
2132    ///
2133    /// # Example
2134    /// ```
2135    /// # use google_cloud_retail_v2::client::PredictionService;
2136    /// use google_cloud_retail_v2::Result;
2137    /// async fn sample(
2138    ///    client: &PredictionService
2139    /// ) -> Result<()> {
2140    ///     let response = client.predict()
2141    ///         /* set fields */
2142    ///         .send().await?;
2143    ///     println!("response {:?}", response);
2144    ///     Ok(())
2145    /// }
2146    /// ```
2147    pub fn predict(&self) -> super::builder::prediction_service::Predict {
2148        super::builder::prediction_service::Predict::new(self.inner.clone())
2149    }
2150
2151    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2152    ///
2153    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2154    ///
2155    /// # Example
2156    /// ```
2157    /// # use google_cloud_retail_v2::client::PredictionService;
2158    /// use google_cloud_gax::paginator::ItemPaginator as _;
2159    /// use google_cloud_retail_v2::Result;
2160    /// async fn sample(
2161    ///    client: &PredictionService
2162    /// ) -> Result<()> {
2163    ///     let mut list = client.list_operations()
2164    ///         /* set fields */
2165    ///         .by_item();
2166    ///     while let Some(item) = list.next().await.transpose()? {
2167    ///         println!("{:?}", item);
2168    ///     }
2169    ///     Ok(())
2170    /// }
2171    /// ```
2172    pub fn list_operations(&self) -> super::builder::prediction_service::ListOperations {
2173        super::builder::prediction_service::ListOperations::new(self.inner.clone())
2174    }
2175
2176    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2177    ///
2178    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2179    ///
2180    /// # Example
2181    /// ```
2182    /// # use google_cloud_retail_v2::client::PredictionService;
2183    /// use google_cloud_retail_v2::Result;
2184    /// async fn sample(
2185    ///    client: &PredictionService
2186    /// ) -> Result<()> {
2187    ///     let response = client.get_operation()
2188    ///         /* set fields */
2189    ///         .send().await?;
2190    ///     println!("response {:?}", response);
2191    ///     Ok(())
2192    /// }
2193    /// ```
2194    pub fn get_operation(&self) -> super::builder::prediction_service::GetOperation {
2195        super::builder::prediction_service::GetOperation::new(self.inner.clone())
2196    }
2197}
2198
2199/// Implements a client for the Vertex AI Search for commerce API.
2200///
2201/// # Example
2202/// ```
2203/// # use google_cloud_retail_v2::client::ProductService;
2204/// use google_cloud_gax::paginator::ItemPaginator as _;
2205/// async fn sample(
2206///    parent: &str,
2207/// ) -> anyhow::Result<()> {
2208///     let client = ProductService::builder().build().await?;
2209///     let mut list = client.list_products()
2210///         .set_parent(parent)
2211///         .by_item();
2212///     while let Some(item) = list.next().await.transpose()? {
2213///         println!("{:?}", item);
2214///     }
2215///     Ok(())
2216/// }
2217/// ```
2218///
2219/// # Service Description
2220///
2221/// Service for ingesting [Product][google.cloud.retail.v2.Product] information
2222/// of the customer's website.
2223///
2224/// [google.cloud.retail.v2.Product]: crate::model::Product
2225///
2226/// # Configuration
2227///
2228/// To configure `ProductService` use the `with_*` methods in the type returned
2229/// by [builder()][ProductService::builder]. The default configuration should
2230/// work for most applications. Common configuration changes include
2231///
2232/// * [with_endpoint()]: by default this client uses the global default endpoint
2233///   (`https://retail.googleapis.com`). Applications using regional
2234///   endpoints or running in restricted networks (e.g. a network configured
2235//    with [Private Google Access with VPC Service Controls]) may want to
2236///   override this default.
2237/// * [with_credentials()]: by default this client uses
2238///   [Application Default Credentials]. Applications using custom
2239///   authentication may need to override this default.
2240///
2241/// [with_endpoint()]: super::builder::product_service::ClientBuilder::with_endpoint
2242/// [with_credentials()]: super::builder::product_service::ClientBuilder::with_credentials
2243/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2244/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2245///
2246/// # Pooling and Cloning
2247///
2248/// `ProductService` holds a connection pool internally, it is advised to
2249/// create one and reuse it. You do not need to wrap `ProductService` in
2250/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2251/// already uses an `Arc` internally.
2252#[derive(Clone, Debug)]
2253pub struct ProductService {
2254    inner: std::sync::Arc<dyn super::stub::dynamic::ProductService>,
2255}
2256
2257impl ProductService {
2258    /// Returns a builder for [ProductService].
2259    ///
2260    /// ```
2261    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2262    /// # use google_cloud_retail_v2::client::ProductService;
2263    /// let client = ProductService::builder().build().await?;
2264    /// # Ok(()) }
2265    /// ```
2266    pub fn builder() -> super::builder::product_service::ClientBuilder {
2267        crate::new_client_builder(super::builder::product_service::client::Factory)
2268    }
2269
2270    /// Creates a new client from the provided stub.
2271    ///
2272    /// The most common case for calling this function is in tests mocking the
2273    /// client's behavior.
2274    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2275    where
2276        T: super::stub::ProductService + 'static,
2277    {
2278        Self { inner: stub.into() }
2279    }
2280
2281    pub(crate) async fn new(
2282        config: gaxi::options::ClientConfig,
2283    ) -> crate::ClientBuilderResult<Self> {
2284        let inner = Self::build_inner(config).await?;
2285        Ok(Self { inner })
2286    }
2287
2288    async fn build_inner(
2289        conf: gaxi::options::ClientConfig,
2290    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ProductService>> {
2291        if gaxi::options::tracing_enabled(&conf) {
2292            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2293        }
2294        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2295    }
2296
2297    async fn build_transport(
2298        conf: gaxi::options::ClientConfig,
2299    ) -> crate::ClientBuilderResult<impl super::stub::ProductService> {
2300        super::transport::ProductService::new(conf).await
2301    }
2302
2303    async fn build_with_tracing(
2304        conf: gaxi::options::ClientConfig,
2305    ) -> crate::ClientBuilderResult<impl super::stub::ProductService> {
2306        Self::build_transport(conf)
2307            .await
2308            .map(super::tracing::ProductService::new)
2309    }
2310
2311    /// Creates a [Product][google.cloud.retail.v2.Product].
2312    ///
2313    /// [google.cloud.retail.v2.Product]: crate::model::Product
2314    ///
2315    /// # Example
2316    /// ```
2317    /// # use google_cloud_retail_v2::client::ProductService;
2318    /// use google_cloud_retail_v2::model::Product;
2319    /// use google_cloud_retail_v2::Result;
2320    /// async fn sample(
2321    ///    client: &ProductService, parent: &str
2322    /// ) -> Result<()> {
2323    ///     let response = client.create_product()
2324    ///         .set_parent(parent)
2325    ///         .set_product_id("product_id_value")
2326    ///         .set_product(
2327    ///             Product::new()/* set fields */
2328    ///         )
2329    ///         .send().await?;
2330    ///     println!("response {:?}", response);
2331    ///     Ok(())
2332    /// }
2333    /// ```
2334    pub fn create_product(&self) -> super::builder::product_service::CreateProduct {
2335        super::builder::product_service::CreateProduct::new(self.inner.clone())
2336    }
2337
2338    /// Gets a [Product][google.cloud.retail.v2.Product].
2339    ///
2340    /// [google.cloud.retail.v2.Product]: crate::model::Product
2341    ///
2342    /// # Example
2343    /// ```
2344    /// # use google_cloud_retail_v2::client::ProductService;
2345    /// use google_cloud_retail_v2::Result;
2346    /// async fn sample(
2347    ///    client: &ProductService, project_id: &str, location_id: &str, catalog_id: &str, branch_id: &str, product_id: &str
2348    /// ) -> Result<()> {
2349    ///     let response = client.get_product()
2350    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/branches/{branch_id}/products/{product_id}"))
2351    ///         .send().await?;
2352    ///     println!("response {:?}", response);
2353    ///     Ok(())
2354    /// }
2355    /// ```
2356    pub fn get_product(&self) -> super::builder::product_service::GetProduct {
2357        super::builder::product_service::GetProduct::new(self.inner.clone())
2358    }
2359
2360    /// Gets a list of [Product][google.cloud.retail.v2.Product]s.
2361    ///
2362    /// [google.cloud.retail.v2.Product]: crate::model::Product
2363    ///
2364    /// # Example
2365    /// ```
2366    /// # use google_cloud_retail_v2::client::ProductService;
2367    /// use google_cloud_gax::paginator::ItemPaginator as _;
2368    /// use google_cloud_retail_v2::Result;
2369    /// async fn sample(
2370    ///    client: &ProductService, parent: &str
2371    /// ) -> Result<()> {
2372    ///     let mut list = client.list_products()
2373    ///         .set_parent(parent)
2374    ///         .by_item();
2375    ///     while let Some(item) = list.next().await.transpose()? {
2376    ///         println!("{:?}", item);
2377    ///     }
2378    ///     Ok(())
2379    /// }
2380    /// ```
2381    pub fn list_products(&self) -> super::builder::product_service::ListProducts {
2382        super::builder::product_service::ListProducts::new(self.inner.clone())
2383    }
2384
2385    /// Updates a [Product][google.cloud.retail.v2.Product].
2386    ///
2387    /// [google.cloud.retail.v2.Product]: crate::model::Product
2388    ///
2389    /// # Example
2390    /// ```
2391    /// # use google_cloud_retail_v2::client::ProductService;
2392    /// # extern crate wkt as google_cloud_wkt;
2393    /// use google_cloud_wkt::FieldMask;
2394    /// use google_cloud_retail_v2::model::Product;
2395    /// use google_cloud_retail_v2::Result;
2396    /// async fn sample(
2397    ///    client: &ProductService, project_id: &str, location_id: &str, catalog_id: &str, branch_id: &str, product_id: &str
2398    /// ) -> Result<()> {
2399    ///     let response = client.update_product()
2400    ///         .set_product(
2401    ///             Product::new().set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/branches/{branch_id}/products/{product_id}"))/* set fields */
2402    ///         )
2403    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2404    ///         .send().await?;
2405    ///     println!("response {:?}", response);
2406    ///     Ok(())
2407    /// }
2408    /// ```
2409    pub fn update_product(&self) -> super::builder::product_service::UpdateProduct {
2410        super::builder::product_service::UpdateProduct::new(self.inner.clone())
2411    }
2412
2413    /// Deletes a [Product][google.cloud.retail.v2.Product].
2414    ///
2415    /// [google.cloud.retail.v2.Product]: crate::model::Product
2416    ///
2417    /// # Example
2418    /// ```
2419    /// # use google_cloud_retail_v2::client::ProductService;
2420    /// use google_cloud_retail_v2::Result;
2421    /// async fn sample(
2422    ///    client: &ProductService, project_id: &str, location_id: &str, catalog_id: &str, branch_id: &str, product_id: &str
2423    /// ) -> Result<()> {
2424    ///     client.delete_product()
2425    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/branches/{branch_id}/products/{product_id}"))
2426    ///         .send().await?;
2427    ///     Ok(())
2428    /// }
2429    /// ```
2430    pub fn delete_product(&self) -> super::builder::product_service::DeleteProduct {
2431        super::builder::product_service::DeleteProduct::new(self.inner.clone())
2432    }
2433
2434    /// Permanently deletes all selected [Product][google.cloud.retail.v2.Product]s
2435    /// under a branch.
2436    ///
2437    /// This process is asynchronous. If the request is valid, the removal will be
2438    /// enqueued and processed offline. Depending on the number of
2439    /// [Product][google.cloud.retail.v2.Product]s, this operation could take hours
2440    /// to complete. Before the operation completes, some
2441    /// [Product][google.cloud.retail.v2.Product]s may still be returned by
2442    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
2443    /// or
2444    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
2445    ///
2446    /// Depending on the number of [Product][google.cloud.retail.v2.Product]s, this
2447    /// operation could take hours to complete. To get a sample of
2448    /// [Product][google.cloud.retail.v2.Product]s that would be deleted, set
2449    /// [PurgeProductsRequest.force][google.cloud.retail.v2.PurgeProductsRequest.force]
2450    /// to false.
2451    ///
2452    /// [google.cloud.retail.v2.Product]: crate::model::Product
2453    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
2454    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
2455    /// [google.cloud.retail.v2.PurgeProductsRequest.force]: crate::model::PurgeProductsRequest::force
2456    ///
2457    /// # Long running operations
2458    ///
2459    /// This method is used to start, and/or poll a [long-running Operation].
2460    /// The [Working with long-running operations] chapter in the [user guide]
2461    /// covers these operations in detail.
2462    ///
2463    /// [long-running operation]: https://google.aip.dev/151
2464    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2465    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2466    ///
2467    /// # Example
2468    /// ```
2469    /// # use google_cloud_retail_v2::client::ProductService;
2470    /// use google_cloud_lro::Poller;
2471    /// use google_cloud_retail_v2::Result;
2472    /// async fn sample(
2473    ///    client: &ProductService
2474    /// ) -> Result<()> {
2475    ///     let response = client.purge_products()
2476    ///         /* set fields */
2477    ///         .poller().until_done().await?;
2478    ///     println!("response {:?}", response);
2479    ///     Ok(())
2480    /// }
2481    /// ```
2482    pub fn purge_products(&self) -> super::builder::product_service::PurgeProducts {
2483        super::builder::product_service::PurgeProducts::new(self.inner.clone())
2484    }
2485
2486    /// Bulk import of multiple [Product][google.cloud.retail.v2.Product]s.
2487    ///
2488    /// Request processing may be synchronous.
2489    /// Non-existing items are created.
2490    ///
2491    /// Note that it is possible for a subset of the
2492    /// [Product][google.cloud.retail.v2.Product]s to be successfully updated.
2493    ///
2494    /// [google.cloud.retail.v2.Product]: crate::model::Product
2495    ///
2496    /// # Long running operations
2497    ///
2498    /// This method is used to start, and/or poll a [long-running Operation].
2499    /// The [Working with long-running operations] chapter in the [user guide]
2500    /// covers these operations in detail.
2501    ///
2502    /// [long-running operation]: https://google.aip.dev/151
2503    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2504    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2505    ///
2506    /// # Example
2507    /// ```
2508    /// # use google_cloud_retail_v2::client::ProductService;
2509    /// use google_cloud_lro::Poller;
2510    /// use google_cloud_retail_v2::Result;
2511    /// async fn sample(
2512    ///    client: &ProductService
2513    /// ) -> Result<()> {
2514    ///     let response = client.import_products()
2515    ///         /* set fields */
2516    ///         .poller().until_done().await?;
2517    ///     println!("response {:?}", response);
2518    ///     Ok(())
2519    /// }
2520    /// ```
2521    pub fn import_products(&self) -> super::builder::product_service::ImportProducts {
2522        super::builder::product_service::ImportProducts::new(self.inner.clone())
2523    }
2524
2525    /// Updates inventory information for a
2526    /// [Product][google.cloud.retail.v2.Product] while respecting the last update
2527    /// timestamps of each inventory field.
2528    ///
2529    /// This process is asynchronous and does not require the
2530    /// [Product][google.cloud.retail.v2.Product] to exist before updating
2531    /// fulfillment information. If the request is valid, the update is enqueued
2532    /// and processed downstream. As a consequence, when a response is returned,
2533    /// updates are not immediately manifested in the
2534    /// [Product][google.cloud.retail.v2.Product] queried by
2535    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
2536    /// or
2537    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
2538    ///
2539    /// When inventory is updated with
2540    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
2541    /// and
2542    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct],
2543    /// the specified inventory field value(s) overwrite any existing value(s)
2544    /// while ignoring the last update time for this field. Furthermore, the last
2545    /// update times for the specified inventory fields are overwritten by the
2546    /// times of the
2547    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
2548    /// or
2549    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct]
2550    /// request.
2551    ///
2552    /// If no inventory fields are set in
2553    /// [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product],
2554    /// then any pre-existing inventory information for this product is used.
2555    ///
2556    /// If no inventory fields are set in
2557    /// [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask],
2558    /// then any existing inventory information is preserved.
2559    ///
2560    /// Pre-existing inventory information can only be updated with
2561    /// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory],
2562    /// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces],
2563    /// and
2564    /// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces].
2565    ///
2566    /// The returned [Operation][google.longrunning.Operation]s is obsolete after
2567    /// one day, and the [GetOperation][google.longrunning.Operations.GetOperation]
2568    /// API returns `NOT_FOUND` afterwards.
2569    ///
2570    /// If conflicting updates are issued, the
2571    /// [Operation][google.longrunning.Operation]s associated with the stale
2572    /// updates are not marked as [done][google.longrunning.Operation.done] until
2573    /// they are obsolete.
2574    ///
2575    /// [google.cloud.retail.v2.CreateProductRequest.product]: crate::model::CreateProductRequest::product
2576    /// [google.cloud.retail.v2.Product]: crate::model::Product
2577    /// [google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]: crate::client::ProductService::add_fulfillment_places
2578    /// [google.cloud.retail.v2.ProductService.CreateProduct]: crate::client::ProductService::create_product
2579    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
2580    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
2581    /// [google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]: crate::client::ProductService::remove_fulfillment_places
2582    /// [google.cloud.retail.v2.ProductService.SetInventory]: crate::client::ProductService::set_inventory
2583    /// [google.cloud.retail.v2.ProductService.UpdateProduct]: crate::client::ProductService::update_product
2584    /// [google.cloud.retail.v2.SetInventoryRequest.set_mask]: crate::model::SetInventoryRequest::set_mask
2585    /// [google.longrunning.Operation]: google_cloud_longrunning::model::Operation
2586    /// [google.longrunning.Operation.done]: google_cloud_longrunning::model::Operation::done
2587    ///
2588    /// # Long running operations
2589    ///
2590    /// This method is used to start, and/or poll a [long-running Operation].
2591    /// The [Working with long-running operations] chapter in the [user guide]
2592    /// covers these operations in detail.
2593    ///
2594    /// [long-running operation]: https://google.aip.dev/151
2595    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2596    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2597    ///
2598    /// # Example
2599    /// ```
2600    /// # use google_cloud_retail_v2::client::ProductService;
2601    /// use google_cloud_lro::Poller;
2602    /// use google_cloud_retail_v2::Result;
2603    /// async fn sample(
2604    ///    client: &ProductService
2605    /// ) -> Result<()> {
2606    ///     let response = client.set_inventory()
2607    ///         /* set fields */
2608    ///         .poller().until_done().await?;
2609    ///     println!("response {:?}", response);
2610    ///     Ok(())
2611    /// }
2612    /// ```
2613    pub fn set_inventory(&self) -> super::builder::product_service::SetInventory {
2614        super::builder::product_service::SetInventory::new(self.inner.clone())
2615    }
2616
2617    /// We recommend that you use the
2618    /// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories]
2619    /// method instead of the
2620    /// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]
2621    /// method.
2622    /// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories]
2623    /// achieves the same results but provides more fine-grained control over
2624    /// ingesting local inventory data.
2625    ///
2626    /// Incrementally adds place IDs to
2627    /// [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids].
2628    ///
2629    /// This process is asynchronous and does not require the
2630    /// [Product][google.cloud.retail.v2.Product] to exist before updating
2631    /// fulfillment information. If the request is valid, the update will be
2632    /// enqueued and processed downstream. As a consequence, when a response is
2633    /// returned, the added place IDs are not immediately manifested in the
2634    /// [Product][google.cloud.retail.v2.Product] queried by
2635    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
2636    /// or
2637    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
2638    ///
2639    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
2640    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
2641    /// API will return NOT_FOUND afterwards.
2642    ///
2643    /// If conflicting updates are issued, the
2644    /// [Operation][google.longrunning.Operation]s associated with the stale
2645    /// updates will not be marked as [done][google.longrunning.Operation.done]
2646    /// until being obsolete.
2647    ///
2648    /// [google.cloud.retail.v2.FulfillmentInfo.place_ids]: crate::model::FulfillmentInfo::place_ids
2649    /// [google.cloud.retail.v2.Product]: crate::model::Product
2650    /// [google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]: crate::client::ProductService::add_fulfillment_places
2651    /// [google.cloud.retail.v2.ProductService.AddLocalInventories]: crate::client::ProductService::add_local_inventories
2652    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
2653    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
2654    /// [google.longrunning.Operation]: google_cloud_longrunning::model::Operation
2655    /// [google.longrunning.Operation.done]: google_cloud_longrunning::model::Operation::done
2656    ///
2657    /// # Long running operations
2658    ///
2659    /// This method is used to start, and/or poll a [long-running Operation].
2660    /// The [Working with long-running operations] chapter in the [user guide]
2661    /// covers these operations in detail.
2662    ///
2663    /// [long-running operation]: https://google.aip.dev/151
2664    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2665    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2666    ///
2667    /// # Example
2668    /// ```
2669    /// # use google_cloud_retail_v2::client::ProductService;
2670    /// use google_cloud_lro::Poller;
2671    /// use google_cloud_retail_v2::Result;
2672    /// async fn sample(
2673    ///    client: &ProductService
2674    /// ) -> Result<()> {
2675    ///     let response = client.add_fulfillment_places()
2676    ///         /* set fields */
2677    ///         .poller().until_done().await?;
2678    ///     println!("response {:?}", response);
2679    ///     Ok(())
2680    /// }
2681    /// ```
2682    pub fn add_fulfillment_places(&self) -> super::builder::product_service::AddFulfillmentPlaces {
2683        super::builder::product_service::AddFulfillmentPlaces::new(self.inner.clone())
2684    }
2685
2686    /// We recommend that you use the
2687    /// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories]
2688    /// method instead of the
2689    /// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]
2690    /// method.
2691    /// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories]
2692    /// achieves the same results but provides more fine-grained control over
2693    /// ingesting local inventory data.
2694    ///
2695    /// Incrementally removes place IDs from a
2696    /// [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids].
2697    ///
2698    /// This process is asynchronous and does not require the
2699    /// [Product][google.cloud.retail.v2.Product] to exist before updating
2700    /// fulfillment information. If the request is valid, the update will be
2701    /// enqueued and processed downstream. As a consequence, when a response is
2702    /// returned, the removed place IDs are not immediately manifested in the
2703    /// [Product][google.cloud.retail.v2.Product] queried by
2704    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
2705    /// or
2706    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
2707    ///
2708    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
2709    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
2710    /// API will return NOT_FOUND afterwards.
2711    ///
2712    /// If conflicting updates are issued, the
2713    /// [Operation][google.longrunning.Operation]s associated with the stale
2714    /// updates will not be marked as [done][google.longrunning.Operation.done]
2715    /// until being obsolete.
2716    ///
2717    /// [google.cloud.retail.v2.FulfillmentInfo.place_ids]: crate::model::FulfillmentInfo::place_ids
2718    /// [google.cloud.retail.v2.Product]: crate::model::Product
2719    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
2720    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
2721    /// [google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]: crate::client::ProductService::remove_fulfillment_places
2722    /// [google.cloud.retail.v2.ProductService.RemoveLocalInventories]: crate::client::ProductService::remove_local_inventories
2723    /// [google.longrunning.Operation]: google_cloud_longrunning::model::Operation
2724    /// [google.longrunning.Operation.done]: google_cloud_longrunning::model::Operation::done
2725    ///
2726    /// # Long running operations
2727    ///
2728    /// This method is used to start, and/or poll a [long-running Operation].
2729    /// The [Working with long-running operations] chapter in the [user guide]
2730    /// covers these operations in detail.
2731    ///
2732    /// [long-running operation]: https://google.aip.dev/151
2733    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2734    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2735    ///
2736    /// # Example
2737    /// ```
2738    /// # use google_cloud_retail_v2::client::ProductService;
2739    /// use google_cloud_lro::Poller;
2740    /// use google_cloud_retail_v2::Result;
2741    /// async fn sample(
2742    ///    client: &ProductService
2743    /// ) -> Result<()> {
2744    ///     let response = client.remove_fulfillment_places()
2745    ///         /* set fields */
2746    ///         .poller().until_done().await?;
2747    ///     println!("response {:?}", response);
2748    ///     Ok(())
2749    /// }
2750    /// ```
2751    pub fn remove_fulfillment_places(
2752        &self,
2753    ) -> super::builder::product_service::RemoveFulfillmentPlaces {
2754        super::builder::product_service::RemoveFulfillmentPlaces::new(self.inner.clone())
2755    }
2756
2757    /// Updates local inventory information for a
2758    /// [Product][google.cloud.retail.v2.Product] at a list of places, while
2759    /// respecting the last update timestamps of each inventory field.
2760    ///
2761    /// This process is asynchronous and does not require the
2762    /// [Product][google.cloud.retail.v2.Product] to exist before updating
2763    /// inventory information. If the request is valid, the update will be enqueued
2764    /// and processed downstream. As a consequence, when a response is returned,
2765    /// updates are not immediately manifested in the
2766    /// [Product][google.cloud.retail.v2.Product] queried by
2767    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
2768    /// or
2769    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
2770    ///
2771    /// Local inventory information can only be modified using this method.
2772    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
2773    /// and
2774    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct]
2775    /// has no effect on local inventories.
2776    ///
2777    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
2778    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
2779    /// API will return NOT_FOUND afterwards.
2780    ///
2781    /// If conflicting updates are issued, the
2782    /// [Operation][google.longrunning.Operation]s associated with the stale
2783    /// updates will not be marked as [done][google.longrunning.Operation.done]
2784    /// until being obsolete.
2785    ///
2786    /// [google.cloud.retail.v2.Product]: crate::model::Product
2787    /// [google.cloud.retail.v2.ProductService.CreateProduct]: crate::client::ProductService::create_product
2788    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
2789    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
2790    /// [google.cloud.retail.v2.ProductService.UpdateProduct]: crate::client::ProductService::update_product
2791    /// [google.longrunning.Operation]: google_cloud_longrunning::model::Operation
2792    /// [google.longrunning.Operation.done]: google_cloud_longrunning::model::Operation::done
2793    ///
2794    /// # Long running operations
2795    ///
2796    /// This method is used to start, and/or poll a [long-running Operation].
2797    /// The [Working with long-running operations] chapter in the [user guide]
2798    /// covers these operations in detail.
2799    ///
2800    /// [long-running operation]: https://google.aip.dev/151
2801    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2802    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2803    ///
2804    /// # Example
2805    /// ```
2806    /// # use google_cloud_retail_v2::client::ProductService;
2807    /// use google_cloud_lro::Poller;
2808    /// use google_cloud_retail_v2::Result;
2809    /// async fn sample(
2810    ///    client: &ProductService
2811    /// ) -> Result<()> {
2812    ///     let response = client.add_local_inventories()
2813    ///         /* set fields */
2814    ///         .poller().until_done().await?;
2815    ///     println!("response {:?}", response);
2816    ///     Ok(())
2817    /// }
2818    /// ```
2819    pub fn add_local_inventories(&self) -> super::builder::product_service::AddLocalInventories {
2820        super::builder::product_service::AddLocalInventories::new(self.inner.clone())
2821    }
2822
2823    /// Remove local inventory information for a
2824    /// [Product][google.cloud.retail.v2.Product] at a list of places at a removal
2825    /// timestamp.
2826    ///
2827    /// This process is asynchronous. If the request is valid, the removal will be
2828    /// enqueued and processed downstream. As a consequence, when a response is
2829    /// returned, removals are not immediately manifested in the
2830    /// [Product][google.cloud.retail.v2.Product] queried by
2831    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
2832    /// or
2833    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
2834    ///
2835    /// Local inventory information can only be removed using this method.
2836    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
2837    /// and
2838    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct]
2839    /// has no effect on local inventories.
2840    ///
2841    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
2842    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
2843    /// API will return NOT_FOUND afterwards.
2844    ///
2845    /// If conflicting updates are issued, the
2846    /// [Operation][google.longrunning.Operation]s associated with the stale
2847    /// updates will not be marked as [done][google.longrunning.Operation.done]
2848    /// until being obsolete.
2849    ///
2850    /// [google.cloud.retail.v2.Product]: crate::model::Product
2851    /// [google.cloud.retail.v2.ProductService.CreateProduct]: crate::client::ProductService::create_product
2852    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
2853    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
2854    /// [google.cloud.retail.v2.ProductService.UpdateProduct]: crate::client::ProductService::update_product
2855    /// [google.longrunning.Operation]: google_cloud_longrunning::model::Operation
2856    /// [google.longrunning.Operation.done]: google_cloud_longrunning::model::Operation::done
2857    ///
2858    /// # Long running operations
2859    ///
2860    /// This method is used to start, and/or poll a [long-running Operation].
2861    /// The [Working with long-running operations] chapter in the [user guide]
2862    /// covers these operations in detail.
2863    ///
2864    /// [long-running operation]: https://google.aip.dev/151
2865    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2866    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2867    ///
2868    /// # Example
2869    /// ```
2870    /// # use google_cloud_retail_v2::client::ProductService;
2871    /// use google_cloud_lro::Poller;
2872    /// use google_cloud_retail_v2::Result;
2873    /// async fn sample(
2874    ///    client: &ProductService
2875    /// ) -> Result<()> {
2876    ///     let response = client.remove_local_inventories()
2877    ///         /* set fields */
2878    ///         .poller().until_done().await?;
2879    ///     println!("response {:?}", response);
2880    ///     Ok(())
2881    /// }
2882    /// ```
2883    pub fn remove_local_inventories(
2884        &self,
2885    ) -> super::builder::product_service::RemoveLocalInventories {
2886        super::builder::product_service::RemoveLocalInventories::new(self.inner.clone())
2887    }
2888
2889    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2890    ///
2891    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2892    ///
2893    /// # Example
2894    /// ```
2895    /// # use google_cloud_retail_v2::client::ProductService;
2896    /// use google_cloud_gax::paginator::ItemPaginator as _;
2897    /// use google_cloud_retail_v2::Result;
2898    /// async fn sample(
2899    ///    client: &ProductService
2900    /// ) -> Result<()> {
2901    ///     let mut list = client.list_operations()
2902    ///         /* set fields */
2903    ///         .by_item();
2904    ///     while let Some(item) = list.next().await.transpose()? {
2905    ///         println!("{:?}", item);
2906    ///     }
2907    ///     Ok(())
2908    /// }
2909    /// ```
2910    pub fn list_operations(&self) -> super::builder::product_service::ListOperations {
2911        super::builder::product_service::ListOperations::new(self.inner.clone())
2912    }
2913
2914    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2915    ///
2916    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2917    ///
2918    /// # Example
2919    /// ```
2920    /// # use google_cloud_retail_v2::client::ProductService;
2921    /// use google_cloud_retail_v2::Result;
2922    /// async fn sample(
2923    ///    client: &ProductService
2924    /// ) -> Result<()> {
2925    ///     let response = client.get_operation()
2926    ///         /* set fields */
2927    ///         .send().await?;
2928    ///     println!("response {:?}", response);
2929    ///     Ok(())
2930    /// }
2931    /// ```
2932    pub fn get_operation(&self) -> super::builder::product_service::GetOperation {
2933        super::builder::product_service::GetOperation::new(self.inner.clone())
2934    }
2935}
2936
2937/// Implements a client for the Vertex AI Search for commerce API.
2938///
2939/// # Example
2940/// ```
2941/// # use google_cloud_retail_v2::client::SearchService;
2942/// use google_cloud_gax::paginator::ItemPaginator as _;
2943/// async fn sample(
2944/// ) -> anyhow::Result<()> {
2945///     let client = SearchService::builder().build().await?;
2946///     let mut list = client.search()
2947///         /* set fields */
2948///         .by_item();
2949///     while let Some(item) = list.next().await.transpose()? {
2950///         println!("{:?}", item);
2951///     }
2952///     Ok(())
2953/// }
2954/// ```
2955///
2956/// # Service Description
2957///
2958/// Service for search.
2959///
2960/// This feature is only available for users who have Retail Search enabled.
2961/// Enable Retail Search on Cloud Console before using this feature.
2962///
2963/// # Configuration
2964///
2965/// To configure `SearchService` use the `with_*` methods in the type returned
2966/// by [builder()][SearchService::builder]. The default configuration should
2967/// work for most applications. Common configuration changes include
2968///
2969/// * [with_endpoint()]: by default this client uses the global default endpoint
2970///   (`https://retail.googleapis.com`). Applications using regional
2971///   endpoints or running in restricted networks (e.g. a network configured
2972//    with [Private Google Access with VPC Service Controls]) may want to
2973///   override this default.
2974/// * [with_credentials()]: by default this client uses
2975///   [Application Default Credentials]. Applications using custom
2976///   authentication may need to override this default.
2977///
2978/// [with_endpoint()]: super::builder::search_service::ClientBuilder::with_endpoint
2979/// [with_credentials()]: super::builder::search_service::ClientBuilder::with_credentials
2980/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2981/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2982///
2983/// # Pooling and Cloning
2984///
2985/// `SearchService` holds a connection pool internally, it is advised to
2986/// create one and reuse it. You do not need to wrap `SearchService` in
2987/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2988/// already uses an `Arc` internally.
2989#[derive(Clone, Debug)]
2990pub struct SearchService {
2991    inner: std::sync::Arc<dyn super::stub::dynamic::SearchService>,
2992}
2993
2994impl SearchService {
2995    /// Returns a builder for [SearchService].
2996    ///
2997    /// ```
2998    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2999    /// # use google_cloud_retail_v2::client::SearchService;
3000    /// let client = SearchService::builder().build().await?;
3001    /// # Ok(()) }
3002    /// ```
3003    pub fn builder() -> super::builder::search_service::ClientBuilder {
3004        crate::new_client_builder(super::builder::search_service::client::Factory)
3005    }
3006
3007    /// Creates a new client from the provided stub.
3008    ///
3009    /// The most common case for calling this function is in tests mocking the
3010    /// client's behavior.
3011    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3012    where
3013        T: super::stub::SearchService + 'static,
3014    {
3015        Self { inner: stub.into() }
3016    }
3017
3018    pub(crate) async fn new(
3019        config: gaxi::options::ClientConfig,
3020    ) -> crate::ClientBuilderResult<Self> {
3021        let inner = Self::build_inner(config).await?;
3022        Ok(Self { inner })
3023    }
3024
3025    async fn build_inner(
3026        conf: gaxi::options::ClientConfig,
3027    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SearchService>> {
3028        if gaxi::options::tracing_enabled(&conf) {
3029            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3030        }
3031        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3032    }
3033
3034    async fn build_transport(
3035        conf: gaxi::options::ClientConfig,
3036    ) -> crate::ClientBuilderResult<impl super::stub::SearchService> {
3037        super::transport::SearchService::new(conf).await
3038    }
3039
3040    async fn build_with_tracing(
3041        conf: gaxi::options::ClientConfig,
3042    ) -> crate::ClientBuilderResult<impl super::stub::SearchService> {
3043        Self::build_transport(conf)
3044            .await
3045            .map(super::tracing::SearchService::new)
3046    }
3047
3048    /// Performs a search.
3049    ///
3050    /// This feature is only available for users who have Retail Search enabled.
3051    /// Enable Retail Search on Cloud Console before using this feature.
3052    ///
3053    /// # Example
3054    /// ```
3055    /// # use google_cloud_retail_v2::client::SearchService;
3056    /// use google_cloud_gax::paginator::ItemPaginator as _;
3057    /// use google_cloud_retail_v2::Result;
3058    /// async fn sample(
3059    ///    client: &SearchService
3060    /// ) -> Result<()> {
3061    ///     let mut list = client.search()
3062    ///         /* set fields */
3063    ///         .by_item();
3064    ///     while let Some(item) = list.next().await.transpose()? {
3065    ///         println!("{:?}", item);
3066    ///     }
3067    ///     Ok(())
3068    /// }
3069    /// ```
3070    pub fn search(&self) -> super::builder::search_service::Search {
3071        super::builder::search_service::Search::new(self.inner.clone())
3072    }
3073
3074    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3075    ///
3076    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3077    ///
3078    /// # Example
3079    /// ```
3080    /// # use google_cloud_retail_v2::client::SearchService;
3081    /// use google_cloud_gax::paginator::ItemPaginator as _;
3082    /// use google_cloud_retail_v2::Result;
3083    /// async fn sample(
3084    ///    client: &SearchService
3085    /// ) -> Result<()> {
3086    ///     let mut list = client.list_operations()
3087    ///         /* set fields */
3088    ///         .by_item();
3089    ///     while let Some(item) = list.next().await.transpose()? {
3090    ///         println!("{:?}", item);
3091    ///     }
3092    ///     Ok(())
3093    /// }
3094    /// ```
3095    pub fn list_operations(&self) -> super::builder::search_service::ListOperations {
3096        super::builder::search_service::ListOperations::new(self.inner.clone())
3097    }
3098
3099    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3100    ///
3101    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3102    ///
3103    /// # Example
3104    /// ```
3105    /// # use google_cloud_retail_v2::client::SearchService;
3106    /// use google_cloud_retail_v2::Result;
3107    /// async fn sample(
3108    ///    client: &SearchService
3109    /// ) -> Result<()> {
3110    ///     let response = client.get_operation()
3111    ///         /* set fields */
3112    ///         .send().await?;
3113    ///     println!("response {:?}", response);
3114    ///     Ok(())
3115    /// }
3116    /// ```
3117    pub fn get_operation(&self) -> super::builder::search_service::GetOperation {
3118        super::builder::search_service::GetOperation::new(self.inner.clone())
3119    }
3120}
3121
3122/// Implements a client for the Vertex AI Search for commerce API.
3123///
3124/// # Example
3125/// ```
3126/// # use google_cloud_retail_v2::client::ServingConfigService;
3127/// use google_cloud_gax::paginator::ItemPaginator as _;
3128/// async fn sample(
3129///    project_id: &str,
3130///    location_id: &str,
3131///    catalog_id: &str,
3132/// ) -> anyhow::Result<()> {
3133///     let client = ServingConfigService::builder().build().await?;
3134///     let mut list = client.list_serving_configs()
3135///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
3136///         .by_item();
3137///     while let Some(item) = list.next().await.transpose()? {
3138///         println!("{:?}", item);
3139///     }
3140///     Ok(())
3141/// }
3142/// ```
3143///
3144/// # Service Description
3145///
3146/// Service for modifying ServingConfig.
3147///
3148/// # Configuration
3149///
3150/// To configure `ServingConfigService` use the `with_*` methods in the type returned
3151/// by [builder()][ServingConfigService::builder]. The default configuration should
3152/// work for most applications. Common configuration changes include
3153///
3154/// * [with_endpoint()]: by default this client uses the global default endpoint
3155///   (`https://retail.googleapis.com`). Applications using regional
3156///   endpoints or running in restricted networks (e.g. a network configured
3157//    with [Private Google Access with VPC Service Controls]) may want to
3158///   override this default.
3159/// * [with_credentials()]: by default this client uses
3160///   [Application Default Credentials]. Applications using custom
3161///   authentication may need to override this default.
3162///
3163/// [with_endpoint()]: super::builder::serving_config_service::ClientBuilder::with_endpoint
3164/// [with_credentials()]: super::builder::serving_config_service::ClientBuilder::with_credentials
3165/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
3166/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
3167///
3168/// # Pooling and Cloning
3169///
3170/// `ServingConfigService` holds a connection pool internally, it is advised to
3171/// create one and reuse it. You do not need to wrap `ServingConfigService` in
3172/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
3173/// already uses an `Arc` internally.
3174#[derive(Clone, Debug)]
3175pub struct ServingConfigService {
3176    inner: std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>,
3177}
3178
3179impl ServingConfigService {
3180    /// Returns a builder for [ServingConfigService].
3181    ///
3182    /// ```
3183    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
3184    /// # use google_cloud_retail_v2::client::ServingConfigService;
3185    /// let client = ServingConfigService::builder().build().await?;
3186    /// # Ok(()) }
3187    /// ```
3188    pub fn builder() -> super::builder::serving_config_service::ClientBuilder {
3189        crate::new_client_builder(super::builder::serving_config_service::client::Factory)
3190    }
3191
3192    /// Creates a new client from the provided stub.
3193    ///
3194    /// The most common case for calling this function is in tests mocking the
3195    /// client's behavior.
3196    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3197    where
3198        T: super::stub::ServingConfigService + 'static,
3199    {
3200        Self { inner: stub.into() }
3201    }
3202
3203    pub(crate) async fn new(
3204        config: gaxi::options::ClientConfig,
3205    ) -> crate::ClientBuilderResult<Self> {
3206        let inner = Self::build_inner(config).await?;
3207        Ok(Self { inner })
3208    }
3209
3210    async fn build_inner(
3211        conf: gaxi::options::ClientConfig,
3212    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>>
3213    {
3214        if gaxi::options::tracing_enabled(&conf) {
3215            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3216        }
3217        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3218    }
3219
3220    async fn build_transport(
3221        conf: gaxi::options::ClientConfig,
3222    ) -> crate::ClientBuilderResult<impl super::stub::ServingConfigService> {
3223        super::transport::ServingConfigService::new(conf).await
3224    }
3225
3226    async fn build_with_tracing(
3227        conf: gaxi::options::ClientConfig,
3228    ) -> crate::ClientBuilderResult<impl super::stub::ServingConfigService> {
3229        Self::build_transport(conf)
3230            .await
3231            .map(super::tracing::ServingConfigService::new)
3232    }
3233
3234    /// Creates a ServingConfig.
3235    ///
3236    /// A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are
3237    /// allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a
3238    /// FAILED_PRECONDITION error is returned.
3239    ///
3240    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
3241    /// [google.cloud.retail.v2.ServingConfig]: crate::model::ServingConfig
3242    ///
3243    /// # Example
3244    /// ```
3245    /// # use google_cloud_retail_v2::client::ServingConfigService;
3246    /// use google_cloud_retail_v2::model::ServingConfig;
3247    /// use google_cloud_retail_v2::Result;
3248    /// async fn sample(
3249    ///    client: &ServingConfigService, project_id: &str, location_id: &str, catalog_id: &str
3250    /// ) -> Result<()> {
3251    ///     let response = client.create_serving_config()
3252    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
3253    ///         .set_serving_config(
3254    ///             ServingConfig::new()/* set fields */
3255    ///         )
3256    ///         .send().await?;
3257    ///     println!("response {:?}", response);
3258    ///     Ok(())
3259    /// }
3260    /// ```
3261    pub fn create_serving_config(
3262        &self,
3263    ) -> super::builder::serving_config_service::CreateServingConfig {
3264        super::builder::serving_config_service::CreateServingConfig::new(self.inner.clone())
3265    }
3266
3267    /// Deletes a ServingConfig.
3268    ///
3269    /// Returns a NotFound error if the ServingConfig does not exist.
3270    ///
3271    /// # Example
3272    /// ```
3273    /// # use google_cloud_retail_v2::client::ServingConfigService;
3274    /// use google_cloud_retail_v2::Result;
3275    /// async fn sample(
3276    ///    client: &ServingConfigService, project_id: &str, location_id: &str, catalog_id: &str, serving_config_id: &str
3277    /// ) -> Result<()> {
3278    ///     client.delete_serving_config()
3279    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}"))
3280    ///         .send().await?;
3281    ///     Ok(())
3282    /// }
3283    /// ```
3284    pub fn delete_serving_config(
3285        &self,
3286    ) -> super::builder::serving_config_service::DeleteServingConfig {
3287        super::builder::serving_config_service::DeleteServingConfig::new(self.inner.clone())
3288    }
3289
3290    /// Updates a ServingConfig.
3291    ///
3292    /// # Example
3293    /// ```
3294    /// # use google_cloud_retail_v2::client::ServingConfigService;
3295    /// # extern crate wkt as google_cloud_wkt;
3296    /// use google_cloud_wkt::FieldMask;
3297    /// use google_cloud_retail_v2::model::ServingConfig;
3298    /// use google_cloud_retail_v2::Result;
3299    /// async fn sample(
3300    ///    client: &ServingConfigService, project_id: &str, location_id: &str, catalog_id: &str, serving_config_id: &str
3301    /// ) -> Result<()> {
3302    ///     let response = client.update_serving_config()
3303    ///         .set_serving_config(
3304    ///             ServingConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}"))/* set fields */
3305    ///         )
3306    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
3307    ///         .send().await?;
3308    ///     println!("response {:?}", response);
3309    ///     Ok(())
3310    /// }
3311    /// ```
3312    pub fn update_serving_config(
3313        &self,
3314    ) -> super::builder::serving_config_service::UpdateServingConfig {
3315        super::builder::serving_config_service::UpdateServingConfig::new(self.inner.clone())
3316    }
3317
3318    /// Gets a ServingConfig.
3319    ///
3320    /// Returns a NotFound error if the ServingConfig does not exist.
3321    ///
3322    /// # Example
3323    /// ```
3324    /// # use google_cloud_retail_v2::client::ServingConfigService;
3325    /// use google_cloud_retail_v2::Result;
3326    /// async fn sample(
3327    ///    client: &ServingConfigService, project_id: &str, location_id: &str, catalog_id: &str, serving_config_id: &str
3328    /// ) -> Result<()> {
3329    ///     let response = client.get_serving_config()
3330    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}"))
3331    ///         .send().await?;
3332    ///     println!("response {:?}", response);
3333    ///     Ok(())
3334    /// }
3335    /// ```
3336    pub fn get_serving_config(&self) -> super::builder::serving_config_service::GetServingConfig {
3337        super::builder::serving_config_service::GetServingConfig::new(self.inner.clone())
3338    }
3339
3340    /// Lists all ServingConfigs linked to this catalog.
3341    ///
3342    /// # Example
3343    /// ```
3344    /// # use google_cloud_retail_v2::client::ServingConfigService;
3345    /// use google_cloud_gax::paginator::ItemPaginator as _;
3346    /// use google_cloud_retail_v2::Result;
3347    /// async fn sample(
3348    ///    client: &ServingConfigService, project_id: &str, location_id: &str, catalog_id: &str
3349    /// ) -> Result<()> {
3350    ///     let mut list = client.list_serving_configs()
3351    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}/catalogs/{catalog_id}"))
3352    ///         .by_item();
3353    ///     while let Some(item) = list.next().await.transpose()? {
3354    ///         println!("{:?}", item);
3355    ///     }
3356    ///     Ok(())
3357    /// }
3358    /// ```
3359    pub fn list_serving_configs(
3360        &self,
3361    ) -> super::builder::serving_config_service::ListServingConfigs {
3362        super::builder::serving_config_service::ListServingConfigs::new(self.inner.clone())
3363    }
3364
3365    /// Enables a Control on the specified ServingConfig.
3366    /// The control is added in the last position of the list of controls
3367    /// it belongs to (e.g. if it's a facet spec control it will be applied
3368    /// in the last position of servingConfig.facetSpecIds)
3369    /// Returns a ALREADY_EXISTS error if the control has already been applied.
3370    /// Returns a FAILED_PRECONDITION error if the addition could exceed maximum
3371    /// number of control allowed for that type of control.
3372    ///
3373    /// # Example
3374    /// ```
3375    /// # use google_cloud_retail_v2::client::ServingConfigService;
3376    /// use google_cloud_retail_v2::Result;
3377    /// async fn sample(
3378    ///    client: &ServingConfigService
3379    /// ) -> Result<()> {
3380    ///     let response = client.add_control()
3381    ///         /* set fields */
3382    ///         .send().await?;
3383    ///     println!("response {:?}", response);
3384    ///     Ok(())
3385    /// }
3386    /// ```
3387    pub fn add_control(&self) -> super::builder::serving_config_service::AddControl {
3388        super::builder::serving_config_service::AddControl::new(self.inner.clone())
3389    }
3390
3391    /// Disables a Control on the specified ServingConfig.
3392    /// The control is removed from the ServingConfig.
3393    /// Returns a NOT_FOUND error if the Control is not enabled for the
3394    /// ServingConfig.
3395    ///
3396    /// # Example
3397    /// ```
3398    /// # use google_cloud_retail_v2::client::ServingConfigService;
3399    /// use google_cloud_retail_v2::Result;
3400    /// async fn sample(
3401    ///    client: &ServingConfigService
3402    /// ) -> Result<()> {
3403    ///     let response = client.remove_control()
3404    ///         /* set fields */
3405    ///         .send().await?;
3406    ///     println!("response {:?}", response);
3407    ///     Ok(())
3408    /// }
3409    /// ```
3410    pub fn remove_control(&self) -> super::builder::serving_config_service::RemoveControl {
3411        super::builder::serving_config_service::RemoveControl::new(self.inner.clone())
3412    }
3413
3414    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3415    ///
3416    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3417    ///
3418    /// # Example
3419    /// ```
3420    /// # use google_cloud_retail_v2::client::ServingConfigService;
3421    /// use google_cloud_gax::paginator::ItemPaginator as _;
3422    /// use google_cloud_retail_v2::Result;
3423    /// async fn sample(
3424    ///    client: &ServingConfigService
3425    /// ) -> Result<()> {
3426    ///     let mut list = client.list_operations()
3427    ///         /* set fields */
3428    ///         .by_item();
3429    ///     while let Some(item) = list.next().await.transpose()? {
3430    ///         println!("{:?}", item);
3431    ///     }
3432    ///     Ok(())
3433    /// }
3434    /// ```
3435    pub fn list_operations(&self) -> super::builder::serving_config_service::ListOperations {
3436        super::builder::serving_config_service::ListOperations::new(self.inner.clone())
3437    }
3438
3439    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3440    ///
3441    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3442    ///
3443    /// # Example
3444    /// ```
3445    /// # use google_cloud_retail_v2::client::ServingConfigService;
3446    /// use google_cloud_retail_v2::Result;
3447    /// async fn sample(
3448    ///    client: &ServingConfigService
3449    /// ) -> Result<()> {
3450    ///     let response = client.get_operation()
3451    ///         /* set fields */
3452    ///         .send().await?;
3453    ///     println!("response {:?}", response);
3454    ///     Ok(())
3455    /// }
3456    /// ```
3457    pub fn get_operation(&self) -> super::builder::serving_config_service::GetOperation {
3458        super::builder::serving_config_service::GetOperation::new(self.inner.clone())
3459    }
3460}
3461
3462/// Implements a client for the Vertex AI Search for commerce API.
3463///
3464/// # Example
3465/// ```
3466/// # use google_cloud_retail_v2::client::UserEventService;
3467/// async fn sample(
3468/// ) -> anyhow::Result<()> {
3469///     let client = UserEventService::builder().build().await?;
3470///     let response = client.write_user_event()
3471///         /* set fields */
3472///         .send().await?;
3473///     println!("response {:?}", response);
3474///     Ok(())
3475/// }
3476/// ```
3477///
3478/// # Service Description
3479///
3480/// Service for ingesting end user actions on the customer website.
3481///
3482/// # Configuration
3483///
3484/// To configure `UserEventService` use the `with_*` methods in the type returned
3485/// by [builder()][UserEventService::builder]. The default configuration should
3486/// work for most applications. Common configuration changes include
3487///
3488/// * [with_endpoint()]: by default this client uses the global default endpoint
3489///   (`https://retail.googleapis.com`). Applications using regional
3490///   endpoints or running in restricted networks (e.g. a network configured
3491//    with [Private Google Access with VPC Service Controls]) may want to
3492///   override this default.
3493/// * [with_credentials()]: by default this client uses
3494///   [Application Default Credentials]. Applications using custom
3495///   authentication may need to override this default.
3496///
3497/// [with_endpoint()]: super::builder::user_event_service::ClientBuilder::with_endpoint
3498/// [with_credentials()]: super::builder::user_event_service::ClientBuilder::with_credentials
3499/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
3500/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
3501///
3502/// # Pooling and Cloning
3503///
3504/// `UserEventService` holds a connection pool internally, it is advised to
3505/// create one and reuse it. You do not need to wrap `UserEventService` in
3506/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
3507/// already uses an `Arc` internally.
3508#[derive(Clone, Debug)]
3509pub struct UserEventService {
3510    inner: std::sync::Arc<dyn super::stub::dynamic::UserEventService>,
3511}
3512
3513impl UserEventService {
3514    /// Returns a builder for [UserEventService].
3515    ///
3516    /// ```
3517    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
3518    /// # use google_cloud_retail_v2::client::UserEventService;
3519    /// let client = UserEventService::builder().build().await?;
3520    /// # Ok(()) }
3521    /// ```
3522    pub fn builder() -> super::builder::user_event_service::ClientBuilder {
3523        crate::new_client_builder(super::builder::user_event_service::client::Factory)
3524    }
3525
3526    /// Creates a new client from the provided stub.
3527    ///
3528    /// The most common case for calling this function is in tests mocking the
3529    /// client's behavior.
3530    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3531    where
3532        T: super::stub::UserEventService + 'static,
3533    {
3534        Self { inner: stub.into() }
3535    }
3536
3537    pub(crate) async fn new(
3538        config: gaxi::options::ClientConfig,
3539    ) -> crate::ClientBuilderResult<Self> {
3540        let inner = Self::build_inner(config).await?;
3541        Ok(Self { inner })
3542    }
3543
3544    async fn build_inner(
3545        conf: gaxi::options::ClientConfig,
3546    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::UserEventService>>
3547    {
3548        if gaxi::options::tracing_enabled(&conf) {
3549            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3550        }
3551        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3552    }
3553
3554    async fn build_transport(
3555        conf: gaxi::options::ClientConfig,
3556    ) -> crate::ClientBuilderResult<impl super::stub::UserEventService> {
3557        super::transport::UserEventService::new(conf).await
3558    }
3559
3560    async fn build_with_tracing(
3561        conf: gaxi::options::ClientConfig,
3562    ) -> crate::ClientBuilderResult<impl super::stub::UserEventService> {
3563        Self::build_transport(conf)
3564            .await
3565            .map(super::tracing::UserEventService::new)
3566    }
3567
3568    /// Writes a single user event.
3569    ///
3570    /// # Example
3571    /// ```
3572    /// # use google_cloud_retail_v2::client::UserEventService;
3573    /// use google_cloud_retail_v2::Result;
3574    /// async fn sample(
3575    ///    client: &UserEventService
3576    /// ) -> Result<()> {
3577    ///     let response = client.write_user_event()
3578    ///         /* set fields */
3579    ///         .send().await?;
3580    ///     println!("response {:?}", response);
3581    ///     Ok(())
3582    /// }
3583    /// ```
3584    pub fn write_user_event(&self) -> super::builder::user_event_service::WriteUserEvent {
3585        super::builder::user_event_service::WriteUserEvent::new(self.inner.clone())
3586    }
3587
3588    /// Writes a single user event from the browser.
3589    ///
3590    /// For larger user event payload over 16 KB, the POST method should be used
3591    /// instead, otherwise a 400 Bad Request error is returned.
3592    ///
3593    /// This method is used only by the Retail API JavaScript pixel and Google Tag
3594    /// Manager. Users should not call this method directly.
3595    ///
3596    /// # Example
3597    /// ```
3598    /// # use google_cloud_retail_v2::client::UserEventService;
3599    /// use google_cloud_retail_v2::Result;
3600    /// async fn sample(
3601    ///    client: &UserEventService
3602    /// ) -> Result<()> {
3603    ///     let response = client.collect_user_event()
3604    ///         /* set fields */
3605    ///         .send().await?;
3606    ///     println!("response {:?}", response);
3607    ///     Ok(())
3608    /// }
3609    /// ```
3610    pub fn collect_user_event(&self) -> super::builder::user_event_service::CollectUserEvent {
3611        super::builder::user_event_service::CollectUserEvent::new(self.inner.clone())
3612    }
3613
3614    /// Deletes permanently all user events specified by the filter provided.
3615    /// Depending on the number of events specified by the filter, this operation
3616    /// could take hours or days to complete. To test a filter, use the list
3617    /// command first.
3618    ///
3619    /// # Long running operations
3620    ///
3621    /// This method is used to start, and/or poll a [long-running Operation].
3622    /// The [Working with long-running operations] chapter in the [user guide]
3623    /// covers these operations in detail.
3624    ///
3625    /// [long-running operation]: https://google.aip.dev/151
3626    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3627    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3628    ///
3629    /// # Example
3630    /// ```
3631    /// # use google_cloud_retail_v2::client::UserEventService;
3632    /// use google_cloud_lro::Poller;
3633    /// use google_cloud_retail_v2::Result;
3634    /// async fn sample(
3635    ///    client: &UserEventService
3636    /// ) -> Result<()> {
3637    ///     let response = client.purge_user_events()
3638    ///         /* set fields */
3639    ///         .poller().until_done().await?;
3640    ///     println!("response {:?}", response);
3641    ///     Ok(())
3642    /// }
3643    /// ```
3644    pub fn purge_user_events(&self) -> super::builder::user_event_service::PurgeUserEvents {
3645        super::builder::user_event_service::PurgeUserEvents::new(self.inner.clone())
3646    }
3647
3648    /// Bulk import of User events. Request processing might be
3649    /// synchronous. Events that already exist are skipped.
3650    /// Use this method for backfilling historical user events.
3651    ///
3652    /// `Operation.response` is of type `ImportResponse`. Note that it is
3653    /// possible for a subset of the items to be successfully inserted.
3654    /// `Operation.metadata` is of type `ImportMetadata`.
3655    ///
3656    /// # Long running operations
3657    ///
3658    /// This method is used to start, and/or poll a [long-running Operation].
3659    /// The [Working with long-running operations] chapter in the [user guide]
3660    /// covers these operations in detail.
3661    ///
3662    /// [long-running operation]: https://google.aip.dev/151
3663    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3664    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3665    ///
3666    /// # Example
3667    /// ```
3668    /// # use google_cloud_retail_v2::client::UserEventService;
3669    /// use google_cloud_lro::Poller;
3670    /// use google_cloud_retail_v2::Result;
3671    /// async fn sample(
3672    ///    client: &UserEventService
3673    /// ) -> Result<()> {
3674    ///     let response = client.import_user_events()
3675    ///         /* set fields */
3676    ///         .poller().until_done().await?;
3677    ///     println!("response {:?}", response);
3678    ///     Ok(())
3679    /// }
3680    /// ```
3681    pub fn import_user_events(&self) -> super::builder::user_event_service::ImportUserEvents {
3682        super::builder::user_event_service::ImportUserEvents::new(self.inner.clone())
3683    }
3684
3685    /// Starts a user-event rejoin operation with latest product catalog. Events
3686    /// are not annotated with detailed product information for products that are
3687    /// missing from the catalog when the user event is ingested. These
3688    /// events are stored as unjoined events with limited usage on training and
3689    /// serving. You can use this method to start a join operation on specified
3690    /// events with the latest version of product catalog. You can also use this
3691    /// method to correct events joined with the wrong product catalog. A rejoin
3692    /// operation can take hours or days to complete.
3693    ///
3694    /// # Long running operations
3695    ///
3696    /// This method is used to start, and/or poll a [long-running Operation].
3697    /// The [Working with long-running operations] chapter in the [user guide]
3698    /// covers these operations in detail.
3699    ///
3700    /// [long-running operation]: https://google.aip.dev/151
3701    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3702    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3703    ///
3704    /// # Example
3705    /// ```
3706    /// # use google_cloud_retail_v2::client::UserEventService;
3707    /// use google_cloud_lro::Poller;
3708    /// use google_cloud_retail_v2::Result;
3709    /// async fn sample(
3710    ///    client: &UserEventService
3711    /// ) -> Result<()> {
3712    ///     let response = client.rejoin_user_events()
3713    ///         /* set fields */
3714    ///         .poller().until_done().await?;
3715    ///     println!("response {:?}", response);
3716    ///     Ok(())
3717    /// }
3718    /// ```
3719    pub fn rejoin_user_events(&self) -> super::builder::user_event_service::RejoinUserEvents {
3720        super::builder::user_event_service::RejoinUserEvents::new(self.inner.clone())
3721    }
3722
3723    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3724    ///
3725    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3726    ///
3727    /// # Example
3728    /// ```
3729    /// # use google_cloud_retail_v2::client::UserEventService;
3730    /// use google_cloud_gax::paginator::ItemPaginator as _;
3731    /// use google_cloud_retail_v2::Result;
3732    /// async fn sample(
3733    ///    client: &UserEventService
3734    /// ) -> Result<()> {
3735    ///     let mut list = client.list_operations()
3736    ///         /* set fields */
3737    ///         .by_item();
3738    ///     while let Some(item) = list.next().await.transpose()? {
3739    ///         println!("{:?}", item);
3740    ///     }
3741    ///     Ok(())
3742    /// }
3743    /// ```
3744    pub fn list_operations(&self) -> super::builder::user_event_service::ListOperations {
3745        super::builder::user_event_service::ListOperations::new(self.inner.clone())
3746    }
3747
3748    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3749    ///
3750    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3751    ///
3752    /// # Example
3753    /// ```
3754    /// # use google_cloud_retail_v2::client::UserEventService;
3755    /// use google_cloud_retail_v2::Result;
3756    /// async fn sample(
3757    ///    client: &UserEventService
3758    /// ) -> Result<()> {
3759    ///     let response = client.get_operation()
3760    ///         /* set fields */
3761    ///         .send().await?;
3762    ///     println!("response {:?}", response);
3763    ///     Ok(())
3764    /// }
3765    /// ```
3766    pub fn get_operation(&self) -> super::builder::user_event_service::GetOperation {
3767        super::builder::user_event_service::GetOperation::new(self.inner.clone())
3768    }
3769}