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/// # tokio_test::block_on(async {
24/// # use google_cloud_retail_v2::client::AnalyticsService;
25/// let client = AnalyticsService::builder().build().await?;
26/// // use `client` to make requests to the Vertex AI Search for commerce API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Service for managing & accessing retail search business metric.
33/// Retail recommendation business metric is currently not available.
34///
35/// # Configuration
36///
37/// To configure `AnalyticsService` use the `with_*` methods in the type returned
38/// by [builder()][AnalyticsService::builder]. The default configuration should
39/// work for most applications. Common configuration changes include
40///
41/// * [with_endpoint()]: by default this client uses the global default endpoint
42///   (`https://retail.googleapis.com`). Applications using regional
43///   endpoints or running in restricted networks (e.g. a network configured
44//    with [Private Google Access with VPC Service Controls]) may want to
45///   override this default.
46/// * [with_credentials()]: by default this client uses
47///   [Application Default Credentials]. Applications using custom
48///   authentication may need to override this default.
49///
50/// [with_endpoint()]: super::builder::analytics_service::ClientBuilder::with_endpoint
51/// [with_credentials()]: super::builder::analytics_service::ClientBuilder::credentials
52/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
53/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
54///
55/// # Pooling and Cloning
56///
57/// `AnalyticsService` holds a connection pool internally, it is advised to
58/// create one and the reuse it.  You do not need to wrap `AnalyticsService` in
59/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
60/// already uses an `Arc` internally.
61#[derive(Clone, Debug)]
62pub struct AnalyticsService {
63    inner: std::sync::Arc<dyn super::stub::dynamic::AnalyticsService>,
64}
65
66impl AnalyticsService {
67    /// Returns a builder for [AnalyticsService].
68    ///
69    /// ```
70    /// # tokio_test::block_on(async {
71    /// # use google_cloud_retail_v2::client::AnalyticsService;
72    /// let client = AnalyticsService::builder().build().await?;
73    /// # gax::client_builder::Result::<()>::Ok(()) });
74    /// ```
75    pub fn builder() -> super::builder::analytics_service::ClientBuilder {
76        gax::client_builder::internal::new_builder(
77            super::builder::analytics_service::client::Factory,
78        )
79    }
80
81    /// Creates a new client from the provided stub.
82    ///
83    /// The most common case for calling this function is in tests mocking the
84    /// client's behavior.
85    pub fn from_stub<T>(stub: T) -> Self
86    where
87        T: super::stub::AnalyticsService + 'static,
88    {
89        Self {
90            inner: std::sync::Arc::new(stub),
91        }
92    }
93
94    pub(crate) async fn new(
95        config: gaxi::options::ClientConfig,
96    ) -> gax::client_builder::Result<Self> {
97        let inner = Self::build_inner(config).await?;
98        Ok(Self { inner })
99    }
100
101    async fn build_inner(
102        conf: gaxi::options::ClientConfig,
103    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::AnalyticsService>>
104    {
105        if gaxi::options::tracing_enabled(&conf) {
106            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
107        }
108        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
109    }
110
111    async fn build_transport(
112        conf: gaxi::options::ClientConfig,
113    ) -> gax::client_builder::Result<impl super::stub::AnalyticsService> {
114        super::transport::AnalyticsService::new(conf).await
115    }
116
117    async fn build_with_tracing(
118        conf: gaxi::options::ClientConfig,
119    ) -> gax::client_builder::Result<impl super::stub::AnalyticsService> {
120        Self::build_transport(conf)
121            .await
122            .map(super::tracing::AnalyticsService::new)
123    }
124
125    /// Exports analytics metrics.
126    ///
127    /// `Operation.response` is of type `ExportAnalyticsMetricsResponse`.
128    /// `Operation.metadata` is of type `ExportMetadata`.
129    ///
130    /// # Long running operations
131    ///
132    /// This method is used to start, and/or poll a [long-running Operation].
133    /// The [Working with long-running operations] chapter in the [user guide]
134    /// covers these operations in detail.
135    ///
136    /// [long-running operation]: https://google.aip.dev/151
137    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
138    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
139    pub fn export_analytics_metrics(
140        &self,
141    ) -> super::builder::analytics_service::ExportAnalyticsMetrics {
142        super::builder::analytics_service::ExportAnalyticsMetrics::new(self.inner.clone())
143    }
144
145    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
146    ///
147    /// [google.longrunning.Operations]: longrunning::client::Operations
148    pub fn list_operations(&self) -> super::builder::analytics_service::ListOperations {
149        super::builder::analytics_service::ListOperations::new(self.inner.clone())
150    }
151
152    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
153    ///
154    /// [google.longrunning.Operations]: longrunning::client::Operations
155    pub fn get_operation(&self) -> super::builder::analytics_service::GetOperation {
156        super::builder::analytics_service::GetOperation::new(self.inner.clone())
157    }
158}
159
160/// Implements a client for the Vertex AI Search for commerce API.
161///
162/// # Example
163/// ```
164/// # tokio_test::block_on(async {
165/// # use google_cloud_retail_v2::client::CatalogService;
166/// let client = CatalogService::builder().build().await?;
167/// // use `client` to make requests to the Vertex AI Search for commerce API.
168/// # gax::client_builder::Result::<()>::Ok(()) });
169/// ```
170///
171/// # Service Description
172///
173/// Service for managing catalog configuration.
174///
175/// # Configuration
176///
177/// To configure `CatalogService` use the `with_*` methods in the type returned
178/// by [builder()][CatalogService::builder]. The default configuration should
179/// work for most applications. Common configuration changes include
180///
181/// * [with_endpoint()]: by default this client uses the global default endpoint
182///   (`https://retail.googleapis.com`). Applications using regional
183///   endpoints or running in restricted networks (e.g. a network configured
184//    with [Private Google Access with VPC Service Controls]) may want to
185///   override this default.
186/// * [with_credentials()]: by default this client uses
187///   [Application Default Credentials]. Applications using custom
188///   authentication may need to override this default.
189///
190/// [with_endpoint()]: super::builder::catalog_service::ClientBuilder::with_endpoint
191/// [with_credentials()]: super::builder::catalog_service::ClientBuilder::credentials
192/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
193/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
194///
195/// # Pooling and Cloning
196///
197/// `CatalogService` holds a connection pool internally, it is advised to
198/// create one and the reuse it.  You do not need to wrap `CatalogService` in
199/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
200/// already uses an `Arc` internally.
201#[derive(Clone, Debug)]
202pub struct CatalogService {
203    inner: std::sync::Arc<dyn super::stub::dynamic::CatalogService>,
204}
205
206impl CatalogService {
207    /// Returns a builder for [CatalogService].
208    ///
209    /// ```
210    /// # tokio_test::block_on(async {
211    /// # use google_cloud_retail_v2::client::CatalogService;
212    /// let client = CatalogService::builder().build().await?;
213    /// # gax::client_builder::Result::<()>::Ok(()) });
214    /// ```
215    pub fn builder() -> super::builder::catalog_service::ClientBuilder {
216        gax::client_builder::internal::new_builder(super::builder::catalog_service::client::Factory)
217    }
218
219    /// Creates a new client from the provided stub.
220    ///
221    /// The most common case for calling this function is in tests mocking the
222    /// client's behavior.
223    pub fn from_stub<T>(stub: T) -> Self
224    where
225        T: super::stub::CatalogService + 'static,
226    {
227        Self {
228            inner: std::sync::Arc::new(stub),
229        }
230    }
231
232    pub(crate) async fn new(
233        config: gaxi::options::ClientConfig,
234    ) -> gax::client_builder::Result<Self> {
235        let inner = Self::build_inner(config).await?;
236        Ok(Self { inner })
237    }
238
239    async fn build_inner(
240        conf: gaxi::options::ClientConfig,
241    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::CatalogService>> {
242        if gaxi::options::tracing_enabled(&conf) {
243            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
244        }
245        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
246    }
247
248    async fn build_transport(
249        conf: gaxi::options::ClientConfig,
250    ) -> gax::client_builder::Result<impl super::stub::CatalogService> {
251        super::transport::CatalogService::new(conf).await
252    }
253
254    async fn build_with_tracing(
255        conf: gaxi::options::ClientConfig,
256    ) -> gax::client_builder::Result<impl super::stub::CatalogService> {
257        Self::build_transport(conf)
258            .await
259            .map(super::tracing::CatalogService::new)
260    }
261
262    /// Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with
263    /// the project.
264    ///
265    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
266    pub fn list_catalogs(&self) -> super::builder::catalog_service::ListCatalogs {
267        super::builder::catalog_service::ListCatalogs::new(self.inner.clone())
268    }
269
270    /// Updates the [Catalog][google.cloud.retail.v2.Catalog]s.
271    ///
272    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
273    pub fn update_catalog(&self) -> super::builder::catalog_service::UpdateCatalog {
274        super::builder::catalog_service::UpdateCatalog::new(self.inner.clone())
275    }
276
277    /// Set a specified branch id as default branch. API methods such as
278    /// [SearchService.Search][google.cloud.retail.v2.SearchService.Search],
279    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct],
280    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]
281    /// will treat requests using "default_branch" to the actual branch id set as
282    /// default.
283    ///
284    /// For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as
285    /// default, setting
286    /// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
287    /// `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent
288    /// to setting
289    /// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
290    /// `projects/*/locations/*/catalogs/*/branches/1`.
291    ///
292    /// Using multiple branches can be useful when developers would like
293    /// to have a staging branch to test and verify for future usage. When it
294    /// becomes ready, developers switch on the staging branch using this API
295    /// while keeping using
296    /// `projects/*/locations/*/catalogs/*/branches/default_branch` as
297    /// [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to
298    /// route the traffic to this staging branch.
299    ///
300    /// CAUTION: If you have live predict/search traffic, switching the default
301    /// branch could potentially cause outages if the ID space of the new branch
302    /// is very different from the old one.
303    ///
304    /// More specifically:
305    ///
306    /// * PredictionService will only return product IDs from branch {newBranch}.
307    /// * SearchService will only return product IDs from branch {newBranch}
308    ///   (if branch is not explicitly set).
309    /// * UserEventService will only join events with products from branch
310    ///   {newBranch}.
311    ///
312    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
313    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
314    /// [google.cloud.retail.v2.SearchRequest.branch]: crate::model::SearchRequest::branch
315    /// [google.cloud.retail.v2.SearchService.Search]: crate::client::SearchService::search
316    pub fn set_default_branch(&self) -> super::builder::catalog_service::SetDefaultBranch {
317        super::builder::catalog_service::SetDefaultBranch::new(self.inner.clone())
318    }
319
320    /// Get which branch is currently default branch set by
321    /// [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch]
322    /// method under a specified parent catalog.
323    ///
324    /// [google.cloud.retail.v2.CatalogService.SetDefaultBranch]: crate::client::CatalogService::set_default_branch
325    pub fn get_default_branch(&self) -> super::builder::catalog_service::GetDefaultBranch {
326        super::builder::catalog_service::GetDefaultBranch::new(self.inner.clone())
327    }
328
329    /// Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig].
330    ///
331    /// [google.cloud.retail.v2.CompletionConfig]: crate::model::CompletionConfig
332    pub fn get_completion_config(&self) -> super::builder::catalog_service::GetCompletionConfig {
333        super::builder::catalog_service::GetCompletionConfig::new(self.inner.clone())
334    }
335
336    /// Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s.
337    ///
338    /// [google.cloud.retail.v2.CompletionConfig]: crate::model::CompletionConfig
339    pub fn update_completion_config(
340        &self,
341    ) -> super::builder::catalog_service::UpdateCompletionConfig {
342        super::builder::catalog_service::UpdateCompletionConfig::new(self.inner.clone())
343    }
344
345    /// Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
346    ///
347    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
348    pub fn get_attributes_config(&self) -> super::builder::catalog_service::GetAttributesConfig {
349        super::builder::catalog_service::GetAttributesConfig::new(self.inner.clone())
350    }
351
352    /// Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
353    ///
354    /// The catalog attributes in the request will be updated in the catalog, or
355    /// inserted if they do not exist. Existing catalog attributes not included in
356    /// the request will remain unchanged. Attributes that are assigned to
357    /// products, but do not exist at the catalog level, are always included in the
358    /// response. The product attribute is assigned default values for missing
359    /// catalog attribute fields, e.g., searchable and dynamic facetable options.
360    ///
361    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
362    pub fn update_attributes_config(
363        &self,
364    ) -> super::builder::catalog_service::UpdateAttributesConfig {
365        super::builder::catalog_service::UpdateAttributesConfig::new(self.inner.clone())
366    }
367
368    /// Adds the specified
369    /// [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the
370    /// [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
371    ///
372    /// If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add
373    /// already exists, an ALREADY_EXISTS error is returned.
374    ///
375    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
376    /// [google.cloud.retail.v2.CatalogAttribute]: crate::model::CatalogAttribute
377    pub fn add_catalog_attribute(&self) -> super::builder::catalog_service::AddCatalogAttribute {
378        super::builder::catalog_service::AddCatalogAttribute::new(self.inner.clone())
379    }
380
381    /// Removes the specified
382    /// [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the
383    /// [AttributesConfig][google.cloud.retail.v2.AttributesConfig].
384    ///
385    /// If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to
386    /// remove does not exist, a NOT_FOUND error is returned.
387    ///
388    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
389    /// [google.cloud.retail.v2.CatalogAttribute]: crate::model::CatalogAttribute
390    pub fn remove_catalog_attribute(
391        &self,
392    ) -> super::builder::catalog_service::RemoveCatalogAttribute {
393        super::builder::catalog_service::RemoveCatalogAttribute::new(self.inner.clone())
394    }
395
396    /// Replaces the specified
397    /// [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the
398    /// [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the
399    /// catalog attribute with the same
400    /// [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key].
401    ///
402    /// If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to
403    /// replace does not exist, a NOT_FOUND error is returned.
404    ///
405    /// [google.cloud.retail.v2.AttributesConfig]: crate::model::AttributesConfig
406    /// [google.cloud.retail.v2.CatalogAttribute]: crate::model::CatalogAttribute
407    /// [google.cloud.retail.v2.CatalogAttribute.key]: crate::model::CatalogAttribute::key
408    pub fn replace_catalog_attribute(
409        &self,
410    ) -> super::builder::catalog_service::ReplaceCatalogAttribute {
411        super::builder::catalog_service::ReplaceCatalogAttribute::new(self.inner.clone())
412    }
413
414    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
415    ///
416    /// [google.longrunning.Operations]: longrunning::client::Operations
417    pub fn list_operations(&self) -> super::builder::catalog_service::ListOperations {
418        super::builder::catalog_service::ListOperations::new(self.inner.clone())
419    }
420
421    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
422    ///
423    /// [google.longrunning.Operations]: longrunning::client::Operations
424    pub fn get_operation(&self) -> super::builder::catalog_service::GetOperation {
425        super::builder::catalog_service::GetOperation::new(self.inner.clone())
426    }
427}
428
429/// Implements a client for the Vertex AI Search for commerce API.
430///
431/// # Example
432/// ```
433/// # tokio_test::block_on(async {
434/// # use google_cloud_retail_v2::client::CompletionService;
435/// let client = CompletionService::builder().build().await?;
436/// // use `client` to make requests to the Vertex AI Search for commerce API.
437/// # gax::client_builder::Result::<()>::Ok(()) });
438/// ```
439///
440/// # Service Description
441///
442/// Autocomplete service for retail.
443///
444/// This feature is only available for users who have Retail Search enabled.
445/// Enable Retail Search on Cloud Console before using this feature.
446///
447/// # Configuration
448///
449/// To configure `CompletionService` use the `with_*` methods in the type returned
450/// by [builder()][CompletionService::builder]. The default configuration should
451/// work for most applications. Common configuration changes include
452///
453/// * [with_endpoint()]: by default this client uses the global default endpoint
454///   (`https://retail.googleapis.com`). Applications using regional
455///   endpoints or running in restricted networks (e.g. a network configured
456//    with [Private Google Access with VPC Service Controls]) may want to
457///   override this default.
458/// * [with_credentials()]: by default this client uses
459///   [Application Default Credentials]. Applications using custom
460///   authentication may need to override this default.
461///
462/// [with_endpoint()]: super::builder::completion_service::ClientBuilder::with_endpoint
463/// [with_credentials()]: super::builder::completion_service::ClientBuilder::credentials
464/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
465/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
466///
467/// # Pooling and Cloning
468///
469/// `CompletionService` holds a connection pool internally, it is advised to
470/// create one and the reuse it.  You do not need to wrap `CompletionService` in
471/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
472/// already uses an `Arc` internally.
473#[derive(Clone, Debug)]
474pub struct CompletionService {
475    inner: std::sync::Arc<dyn super::stub::dynamic::CompletionService>,
476}
477
478impl CompletionService {
479    /// Returns a builder for [CompletionService].
480    ///
481    /// ```
482    /// # tokio_test::block_on(async {
483    /// # use google_cloud_retail_v2::client::CompletionService;
484    /// let client = CompletionService::builder().build().await?;
485    /// # gax::client_builder::Result::<()>::Ok(()) });
486    /// ```
487    pub fn builder() -> super::builder::completion_service::ClientBuilder {
488        gax::client_builder::internal::new_builder(
489            super::builder::completion_service::client::Factory,
490        )
491    }
492
493    /// Creates a new client from the provided stub.
494    ///
495    /// The most common case for calling this function is in tests mocking the
496    /// client's behavior.
497    pub fn from_stub<T>(stub: T) -> Self
498    where
499        T: super::stub::CompletionService + 'static,
500    {
501        Self {
502            inner: std::sync::Arc::new(stub),
503        }
504    }
505
506    pub(crate) async fn new(
507        config: gaxi::options::ClientConfig,
508    ) -> gax::client_builder::Result<Self> {
509        let inner = Self::build_inner(config).await?;
510        Ok(Self { inner })
511    }
512
513    async fn build_inner(
514        conf: gaxi::options::ClientConfig,
515    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::CompletionService>>
516    {
517        if gaxi::options::tracing_enabled(&conf) {
518            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
519        }
520        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
521    }
522
523    async fn build_transport(
524        conf: gaxi::options::ClientConfig,
525    ) -> gax::client_builder::Result<impl super::stub::CompletionService> {
526        super::transport::CompletionService::new(conf).await
527    }
528
529    async fn build_with_tracing(
530        conf: gaxi::options::ClientConfig,
531    ) -> gax::client_builder::Result<impl super::stub::CompletionService> {
532        Self::build_transport(conf)
533            .await
534            .map(super::tracing::CompletionService::new)
535    }
536
537    /// Completes the specified prefix with keyword suggestions.
538    ///
539    /// This feature is only available for users who have Retail Search enabled.
540    /// Enable Retail Search on Cloud Console before using this feature.
541    pub fn complete_query(&self) -> super::builder::completion_service::CompleteQuery {
542        super::builder::completion_service::CompleteQuery::new(self.inner.clone())
543    }
544
545    /// Bulk import of processed completion dataset.
546    ///
547    /// Request processing is asynchronous. Partial updating is not supported.
548    ///
549    /// The operation is successfully finished only after the imported suggestions
550    /// are indexed successfully and ready for serving. The process takes hours.
551    ///
552    /// This feature is only available for users who have Retail Search enabled.
553    /// Enable Retail Search on Cloud Console before using this feature.
554    ///
555    /// # Long running operations
556    ///
557    /// This method is used to start, and/or poll a [long-running Operation].
558    /// The [Working with long-running operations] chapter in the [user guide]
559    /// covers these operations in detail.
560    ///
561    /// [long-running operation]: https://google.aip.dev/151
562    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
563    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
564    pub fn import_completion_data(
565        &self,
566    ) -> super::builder::completion_service::ImportCompletionData {
567        super::builder::completion_service::ImportCompletionData::new(self.inner.clone())
568    }
569
570    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
571    ///
572    /// [google.longrunning.Operations]: longrunning::client::Operations
573    pub fn list_operations(&self) -> super::builder::completion_service::ListOperations {
574        super::builder::completion_service::ListOperations::new(self.inner.clone())
575    }
576
577    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
578    ///
579    /// [google.longrunning.Operations]: longrunning::client::Operations
580    pub fn get_operation(&self) -> super::builder::completion_service::GetOperation {
581        super::builder::completion_service::GetOperation::new(self.inner.clone())
582    }
583}
584
585/// Implements a client for the Vertex AI Search for commerce API.
586///
587/// # Example
588/// ```
589/// # tokio_test::block_on(async {
590/// # use google_cloud_retail_v2::client::ControlService;
591/// let client = ControlService::builder().build().await?;
592/// // use `client` to make requests to the Vertex AI Search for commerce API.
593/// # gax::client_builder::Result::<()>::Ok(()) });
594/// ```
595///
596/// # Service Description
597///
598/// Service for modifying Control.
599///
600/// # Configuration
601///
602/// To configure `ControlService` use the `with_*` methods in the type returned
603/// by [builder()][ControlService::builder]. The default configuration should
604/// work for most applications. Common configuration changes include
605///
606/// * [with_endpoint()]: by default this client uses the global default endpoint
607///   (`https://retail.googleapis.com`). Applications using regional
608///   endpoints or running in restricted networks (e.g. a network configured
609//    with [Private Google Access with VPC Service Controls]) may want to
610///   override this default.
611/// * [with_credentials()]: by default this client uses
612///   [Application Default Credentials]. Applications using custom
613///   authentication may need to override this default.
614///
615/// [with_endpoint()]: super::builder::control_service::ClientBuilder::with_endpoint
616/// [with_credentials()]: super::builder::control_service::ClientBuilder::credentials
617/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
618/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
619///
620/// # Pooling and Cloning
621///
622/// `ControlService` holds a connection pool internally, it is advised to
623/// create one and the reuse it.  You do not need to wrap `ControlService` in
624/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
625/// already uses an `Arc` internally.
626#[derive(Clone, Debug)]
627pub struct ControlService {
628    inner: std::sync::Arc<dyn super::stub::dynamic::ControlService>,
629}
630
631impl ControlService {
632    /// Returns a builder for [ControlService].
633    ///
634    /// ```
635    /// # tokio_test::block_on(async {
636    /// # use google_cloud_retail_v2::client::ControlService;
637    /// let client = ControlService::builder().build().await?;
638    /// # gax::client_builder::Result::<()>::Ok(()) });
639    /// ```
640    pub fn builder() -> super::builder::control_service::ClientBuilder {
641        gax::client_builder::internal::new_builder(super::builder::control_service::client::Factory)
642    }
643
644    /// Creates a new client from the provided stub.
645    ///
646    /// The most common case for calling this function is in tests mocking the
647    /// client's behavior.
648    pub fn from_stub<T>(stub: T) -> Self
649    where
650        T: super::stub::ControlService + 'static,
651    {
652        Self {
653            inner: std::sync::Arc::new(stub),
654        }
655    }
656
657    pub(crate) async fn new(
658        config: gaxi::options::ClientConfig,
659    ) -> gax::client_builder::Result<Self> {
660        let inner = Self::build_inner(config).await?;
661        Ok(Self { inner })
662    }
663
664    async fn build_inner(
665        conf: gaxi::options::ClientConfig,
666    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ControlService>> {
667        if gaxi::options::tracing_enabled(&conf) {
668            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
669        }
670        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
671    }
672
673    async fn build_transport(
674        conf: gaxi::options::ClientConfig,
675    ) -> gax::client_builder::Result<impl super::stub::ControlService> {
676        super::transport::ControlService::new(conf).await
677    }
678
679    async fn build_with_tracing(
680        conf: gaxi::options::ClientConfig,
681    ) -> gax::client_builder::Result<impl super::stub::ControlService> {
682        Self::build_transport(conf)
683            .await
684            .map(super::tracing::ControlService::new)
685    }
686
687    /// Creates a Control.
688    ///
689    /// If the [Control][google.cloud.retail.v2.Control] to create already exists,
690    /// an ALREADY_EXISTS error is returned.
691    ///
692    /// [google.cloud.retail.v2.Control]: crate::model::Control
693    pub fn create_control(&self) -> super::builder::control_service::CreateControl {
694        super::builder::control_service::CreateControl::new(self.inner.clone())
695    }
696
697    /// Deletes a Control.
698    ///
699    /// If the [Control][google.cloud.retail.v2.Control] to delete does not exist,
700    /// a NOT_FOUND error is returned.
701    ///
702    /// [google.cloud.retail.v2.Control]: crate::model::Control
703    pub fn delete_control(&self) -> super::builder::control_service::DeleteControl {
704        super::builder::control_service::DeleteControl::new(self.inner.clone())
705    }
706
707    /// Updates a Control.
708    ///
709    /// [Control][google.cloud.retail.v2.Control] cannot be set to a different
710    /// oneof field, if so an INVALID_ARGUMENT is returned. If the
711    /// [Control][google.cloud.retail.v2.Control] to update does not exist, a
712    /// NOT_FOUND error is returned.
713    ///
714    /// [google.cloud.retail.v2.Control]: crate::model::Control
715    pub fn update_control(&self) -> super::builder::control_service::UpdateControl {
716        super::builder::control_service::UpdateControl::new(self.inner.clone())
717    }
718
719    /// Gets a Control.
720    pub fn get_control(&self) -> super::builder::control_service::GetControl {
721        super::builder::control_service::GetControl::new(self.inner.clone())
722    }
723
724    /// Lists all Controls by their parent
725    /// [Catalog][google.cloud.retail.v2.Catalog].
726    ///
727    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
728    pub fn list_controls(&self) -> super::builder::control_service::ListControls {
729        super::builder::control_service::ListControls::new(self.inner.clone())
730    }
731
732    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
733    ///
734    /// [google.longrunning.Operations]: longrunning::client::Operations
735    pub fn list_operations(&self) -> super::builder::control_service::ListOperations {
736        super::builder::control_service::ListOperations::new(self.inner.clone())
737    }
738
739    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
740    ///
741    /// [google.longrunning.Operations]: longrunning::client::Operations
742    pub fn get_operation(&self) -> super::builder::control_service::GetOperation {
743        super::builder::control_service::GetOperation::new(self.inner.clone())
744    }
745}
746
747/// Implements a client for the Vertex AI Search for commerce API.
748///
749/// # Example
750/// ```
751/// # tokio_test::block_on(async {
752/// # use google_cloud_retail_v2::client::ConversationalSearchService;
753/// let client = ConversationalSearchService::builder().build().await?;
754/// // use `client` to make requests to the Vertex AI Search for commerce API.
755/// # gax::client_builder::Result::<()>::Ok(()) });
756/// ```
757///
758/// # Service Description
759///
760/// Service for retail conversational search.
761///
762/// This feature is only available for users who have Retail Conversational
763/// Search enabled. Enable Retail Conversational Search on Cloud Console
764/// before using this feature.
765///
766/// # Configuration
767///
768/// To configure `ConversationalSearchService` use the `with_*` methods in the type returned
769/// by [builder()][ConversationalSearchService::builder]. The default configuration should
770/// work for most applications. Common configuration changes include
771///
772/// * [with_endpoint()]: by default this client uses the global default endpoint
773///   (`https://retail.googleapis.com`). Applications using regional
774///   endpoints or running in restricted networks (e.g. a network configured
775//    with [Private Google Access with VPC Service Controls]) may want to
776///   override this default.
777/// * [with_credentials()]: by default this client uses
778///   [Application Default Credentials]. Applications using custom
779///   authentication may need to override this default.
780///
781/// [with_endpoint()]: super::builder::conversational_search_service::ClientBuilder::with_endpoint
782/// [with_credentials()]: super::builder::conversational_search_service::ClientBuilder::credentials
783/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
784/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
785///
786/// # Pooling and Cloning
787///
788/// `ConversationalSearchService` holds a connection pool internally, it is advised to
789/// create one and the reuse it.  You do not need to wrap `ConversationalSearchService` in
790/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
791/// already uses an `Arc` internally.
792#[derive(Clone, Debug)]
793pub struct ConversationalSearchService {
794    inner: std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
795}
796
797impl ConversationalSearchService {
798    /// Returns a builder for [ConversationalSearchService].
799    ///
800    /// ```
801    /// # tokio_test::block_on(async {
802    /// # use google_cloud_retail_v2::client::ConversationalSearchService;
803    /// let client = ConversationalSearchService::builder().build().await?;
804    /// # gax::client_builder::Result::<()>::Ok(()) });
805    /// ```
806    pub fn builder() -> super::builder::conversational_search_service::ClientBuilder {
807        gax::client_builder::internal::new_builder(
808            super::builder::conversational_search_service::client::Factory,
809        )
810    }
811
812    /// Creates a new client from the provided stub.
813    ///
814    /// The most common case for calling this function is in tests mocking the
815    /// client's behavior.
816    pub fn from_stub<T>(stub: T) -> Self
817    where
818        T: super::stub::ConversationalSearchService + 'static,
819    {
820        Self {
821            inner: std::sync::Arc::new(stub),
822        }
823    }
824
825    pub(crate) async fn new(
826        config: gaxi::options::ClientConfig,
827    ) -> gax::client_builder::Result<Self> {
828        let inner = Self::build_inner(config).await?;
829        Ok(Self { inner })
830    }
831
832    async fn build_inner(
833        conf: gaxi::options::ClientConfig,
834    ) -> gax::client_builder::Result<
835        std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
836    > {
837        if gaxi::options::tracing_enabled(&conf) {
838            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
839        }
840        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
841    }
842
843    async fn build_transport(
844        conf: gaxi::options::ClientConfig,
845    ) -> gax::client_builder::Result<impl super::stub::ConversationalSearchService> {
846        super::transport::ConversationalSearchService::new(conf).await
847    }
848
849    async fn build_with_tracing(
850        conf: gaxi::options::ClientConfig,
851    ) -> gax::client_builder::Result<impl super::stub::ConversationalSearchService> {
852        Self::build_transport(conf)
853            .await
854            .map(super::tracing::ConversationalSearchService::new)
855    }
856
857    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
858    ///
859    /// [google.longrunning.Operations]: longrunning::client::Operations
860    pub fn list_operations(&self) -> super::builder::conversational_search_service::ListOperations {
861        super::builder::conversational_search_service::ListOperations::new(self.inner.clone())
862    }
863
864    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
865    ///
866    /// [google.longrunning.Operations]: longrunning::client::Operations
867    pub fn get_operation(&self) -> super::builder::conversational_search_service::GetOperation {
868        super::builder::conversational_search_service::GetOperation::new(self.inner.clone())
869    }
870}
871
872/// Implements a client for the Vertex AI Search for commerce API.
873///
874/// # Example
875/// ```
876/// # tokio_test::block_on(async {
877/// # use google_cloud_retail_v2::client::GenerativeQuestionService;
878/// let client = GenerativeQuestionService::builder().build().await?;
879/// // use `client` to make requests to the Vertex AI Search for commerce API.
880/// # gax::client_builder::Result::<()>::Ok(()) });
881/// ```
882///
883/// # Service Description
884///
885/// Service for managing LLM generated questions in search serving.
886///
887/// # Configuration
888///
889/// To configure `GenerativeQuestionService` use the `with_*` methods in the type returned
890/// by [builder()][GenerativeQuestionService::builder]. The default configuration should
891/// work for most applications. Common configuration changes include
892///
893/// * [with_endpoint()]: by default this client uses the global default endpoint
894///   (`https://retail.googleapis.com`). Applications using regional
895///   endpoints or running in restricted networks (e.g. a network configured
896//    with [Private Google Access with VPC Service Controls]) may want to
897///   override this default.
898/// * [with_credentials()]: by default this client uses
899///   [Application Default Credentials]. Applications using custom
900///   authentication may need to override this default.
901///
902/// [with_endpoint()]: super::builder::generative_question_service::ClientBuilder::with_endpoint
903/// [with_credentials()]: super::builder::generative_question_service::ClientBuilder::credentials
904/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
905/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
906///
907/// # Pooling and Cloning
908///
909/// `GenerativeQuestionService` holds a connection pool internally, it is advised to
910/// create one and the reuse it.  You do not need to wrap `GenerativeQuestionService` in
911/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
912/// already uses an `Arc` internally.
913#[derive(Clone, Debug)]
914pub struct GenerativeQuestionService {
915    inner: std::sync::Arc<dyn super::stub::dynamic::GenerativeQuestionService>,
916}
917
918impl GenerativeQuestionService {
919    /// Returns a builder for [GenerativeQuestionService].
920    ///
921    /// ```
922    /// # tokio_test::block_on(async {
923    /// # use google_cloud_retail_v2::client::GenerativeQuestionService;
924    /// let client = GenerativeQuestionService::builder().build().await?;
925    /// # gax::client_builder::Result::<()>::Ok(()) });
926    /// ```
927    pub fn builder() -> super::builder::generative_question_service::ClientBuilder {
928        gax::client_builder::internal::new_builder(
929            super::builder::generative_question_service::client::Factory,
930        )
931    }
932
933    /// Creates a new client from the provided stub.
934    ///
935    /// The most common case for calling this function is in tests mocking the
936    /// client's behavior.
937    pub fn from_stub<T>(stub: T) -> Self
938    where
939        T: super::stub::GenerativeQuestionService + 'static,
940    {
941        Self {
942            inner: std::sync::Arc::new(stub),
943        }
944    }
945
946    pub(crate) async fn new(
947        config: gaxi::options::ClientConfig,
948    ) -> gax::client_builder::Result<Self> {
949        let inner = Self::build_inner(config).await?;
950        Ok(Self { inner })
951    }
952
953    async fn build_inner(
954        conf: gaxi::options::ClientConfig,
955    ) -> gax::client_builder::Result<
956        std::sync::Arc<dyn super::stub::dynamic::GenerativeQuestionService>,
957    > {
958        if gaxi::options::tracing_enabled(&conf) {
959            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
960        }
961        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
962    }
963
964    async fn build_transport(
965        conf: gaxi::options::ClientConfig,
966    ) -> gax::client_builder::Result<impl super::stub::GenerativeQuestionService> {
967        super::transport::GenerativeQuestionService::new(conf).await
968    }
969
970    async fn build_with_tracing(
971        conf: gaxi::options::ClientConfig,
972    ) -> gax::client_builder::Result<impl super::stub::GenerativeQuestionService> {
973        Self::build_transport(conf)
974            .await
975            .map(super::tracing::GenerativeQuestionService::new)
976    }
977
978    /// Manages overal generative question feature state -- enables toggling
979    /// feature on and off.
980    pub fn update_generative_questions_feature_config(
981        &self,
982    ) -> super::builder::generative_question_service::UpdateGenerativeQuestionsFeatureConfig {
983        super::builder::generative_question_service::UpdateGenerativeQuestionsFeatureConfig::new(
984            self.inner.clone(),
985        )
986    }
987
988    /// Manages overal generative question feature state -- enables toggling
989    /// feature on and off.
990    pub fn get_generative_questions_feature_config(
991        &self,
992    ) -> super::builder::generative_question_service::GetGenerativeQuestionsFeatureConfig {
993        super::builder::generative_question_service::GetGenerativeQuestionsFeatureConfig::new(
994            self.inner.clone(),
995        )
996    }
997
998    /// Returns all questions for a given catalog.
999    pub fn list_generative_question_configs(
1000        &self,
1001    ) -> super::builder::generative_question_service::ListGenerativeQuestionConfigs {
1002        super::builder::generative_question_service::ListGenerativeQuestionConfigs::new(
1003            self.inner.clone(),
1004        )
1005    }
1006
1007    /// Allows management of individual questions.
1008    pub fn update_generative_question_config(
1009        &self,
1010    ) -> super::builder::generative_question_service::UpdateGenerativeQuestionConfig {
1011        super::builder::generative_question_service::UpdateGenerativeQuestionConfig::new(
1012            self.inner.clone(),
1013        )
1014    }
1015
1016    /// Allows management of multiple questions.
1017    pub fn batch_update_generative_question_configs(
1018        &self,
1019    ) -> super::builder::generative_question_service::BatchUpdateGenerativeQuestionConfigs {
1020        super::builder::generative_question_service::BatchUpdateGenerativeQuestionConfigs::new(
1021            self.inner.clone(),
1022        )
1023    }
1024
1025    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1026    ///
1027    /// [google.longrunning.Operations]: longrunning::client::Operations
1028    pub fn list_operations(&self) -> super::builder::generative_question_service::ListOperations {
1029        super::builder::generative_question_service::ListOperations::new(self.inner.clone())
1030    }
1031
1032    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1033    ///
1034    /// [google.longrunning.Operations]: longrunning::client::Operations
1035    pub fn get_operation(&self) -> super::builder::generative_question_service::GetOperation {
1036        super::builder::generative_question_service::GetOperation::new(self.inner.clone())
1037    }
1038}
1039
1040/// Implements a client for the Vertex AI Search for commerce API.
1041///
1042/// # Example
1043/// ```
1044/// # tokio_test::block_on(async {
1045/// # use google_cloud_retail_v2::client::ModelService;
1046/// let client = ModelService::builder().build().await?;
1047/// // use `client` to make requests to the Vertex AI Search for commerce API.
1048/// # gax::client_builder::Result::<()>::Ok(()) });
1049/// ```
1050///
1051/// # Service Description
1052///
1053/// Service for performing CRUD operations on models.
1054/// Recommendation models contain all the metadata necessary to generate a set of
1055/// models for the `Predict()` API. A model is queried
1056/// indirectly via a ServingConfig, which associates a model with a
1057/// given Placement (e.g. Frequently Bought Together on Home Page).
1058///
1059/// This service allows you to do the following:
1060///
1061/// * Initiate training of a model.
1062/// * Pause training of an existing model.
1063/// * List all the available models along with their metadata.
1064/// * Control their tuning schedule.
1065///
1066/// # Configuration
1067///
1068/// To configure `ModelService` use the `with_*` methods in the type returned
1069/// by [builder()][ModelService::builder]. The default configuration should
1070/// work for most applications. Common configuration changes include
1071///
1072/// * [with_endpoint()]: by default this client uses the global default endpoint
1073///   (`https://retail.googleapis.com`). Applications using regional
1074///   endpoints or running in restricted networks (e.g. a network configured
1075//    with [Private Google Access with VPC Service Controls]) may want to
1076///   override this default.
1077/// * [with_credentials()]: by default this client uses
1078///   [Application Default Credentials]. Applications using custom
1079///   authentication may need to override this default.
1080///
1081/// [with_endpoint()]: super::builder::model_service::ClientBuilder::with_endpoint
1082/// [with_credentials()]: super::builder::model_service::ClientBuilder::credentials
1083/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1084/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1085///
1086/// # Pooling and Cloning
1087///
1088/// `ModelService` holds a connection pool internally, it is advised to
1089/// create one and the reuse it.  You do not need to wrap `ModelService` in
1090/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1091/// already uses an `Arc` internally.
1092#[derive(Clone, Debug)]
1093pub struct ModelService {
1094    inner: std::sync::Arc<dyn super::stub::dynamic::ModelService>,
1095}
1096
1097impl ModelService {
1098    /// Returns a builder for [ModelService].
1099    ///
1100    /// ```
1101    /// # tokio_test::block_on(async {
1102    /// # use google_cloud_retail_v2::client::ModelService;
1103    /// let client = ModelService::builder().build().await?;
1104    /// # gax::client_builder::Result::<()>::Ok(()) });
1105    /// ```
1106    pub fn builder() -> super::builder::model_service::ClientBuilder {
1107        gax::client_builder::internal::new_builder(super::builder::model_service::client::Factory)
1108    }
1109
1110    /// Creates a new client from the provided stub.
1111    ///
1112    /// The most common case for calling this function is in tests mocking the
1113    /// client's behavior.
1114    pub fn from_stub<T>(stub: T) -> Self
1115    where
1116        T: super::stub::ModelService + 'static,
1117    {
1118        Self {
1119            inner: std::sync::Arc::new(stub),
1120        }
1121    }
1122
1123    pub(crate) async fn new(
1124        config: gaxi::options::ClientConfig,
1125    ) -> gax::client_builder::Result<Self> {
1126        let inner = Self::build_inner(config).await?;
1127        Ok(Self { inner })
1128    }
1129
1130    async fn build_inner(
1131        conf: gaxi::options::ClientConfig,
1132    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ModelService>> {
1133        if gaxi::options::tracing_enabled(&conf) {
1134            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1135        }
1136        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1137    }
1138
1139    async fn build_transport(
1140        conf: gaxi::options::ClientConfig,
1141    ) -> gax::client_builder::Result<impl super::stub::ModelService> {
1142        super::transport::ModelService::new(conf).await
1143    }
1144
1145    async fn build_with_tracing(
1146        conf: gaxi::options::ClientConfig,
1147    ) -> gax::client_builder::Result<impl super::stub::ModelService> {
1148        Self::build_transport(conf)
1149            .await
1150            .map(super::tracing::ModelService::new)
1151    }
1152
1153    /// Creates a new model.
1154    ///
1155    /// # Long running operations
1156    ///
1157    /// This method is used to start, and/or poll a [long-running Operation].
1158    /// The [Working with long-running operations] chapter in the [user guide]
1159    /// covers these operations in detail.
1160    ///
1161    /// [long-running operation]: https://google.aip.dev/151
1162    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1163    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1164    pub fn create_model(&self) -> super::builder::model_service::CreateModel {
1165        super::builder::model_service::CreateModel::new(self.inner.clone())
1166    }
1167
1168    /// Gets a model.
1169    pub fn get_model(&self) -> super::builder::model_service::GetModel {
1170        super::builder::model_service::GetModel::new(self.inner.clone())
1171    }
1172
1173    /// Pauses the training of an existing model.
1174    pub fn pause_model(&self) -> super::builder::model_service::PauseModel {
1175        super::builder::model_service::PauseModel::new(self.inner.clone())
1176    }
1177
1178    /// Resumes the training of an existing model.
1179    pub fn resume_model(&self) -> super::builder::model_service::ResumeModel {
1180        super::builder::model_service::ResumeModel::new(self.inner.clone())
1181    }
1182
1183    /// Deletes an existing model.
1184    pub fn delete_model(&self) -> super::builder::model_service::DeleteModel {
1185        super::builder::model_service::DeleteModel::new(self.inner.clone())
1186    }
1187
1188    /// Lists all the models linked to this event store.
1189    pub fn list_models(&self) -> super::builder::model_service::ListModels {
1190        super::builder::model_service::ListModels::new(self.inner.clone())
1191    }
1192
1193    /// Update of model metadata. Only fields that
1194    /// currently can be updated are: `filtering_option` and
1195    /// `periodic_tuning_state`.
1196    /// If other values are provided, this API method ignores them.
1197    pub fn update_model(&self) -> super::builder::model_service::UpdateModel {
1198        super::builder::model_service::UpdateModel::new(self.inner.clone())
1199    }
1200
1201    /// Tunes an existing model.
1202    ///
1203    /// # Long running operations
1204    ///
1205    /// This method is used to start, and/or poll a [long-running Operation].
1206    /// The [Working with long-running operations] chapter in the [user guide]
1207    /// covers these operations in detail.
1208    ///
1209    /// [long-running operation]: https://google.aip.dev/151
1210    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1211    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1212    pub fn tune_model(&self) -> super::builder::model_service::TuneModel {
1213        super::builder::model_service::TuneModel::new(self.inner.clone())
1214    }
1215
1216    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1217    ///
1218    /// [google.longrunning.Operations]: longrunning::client::Operations
1219    pub fn list_operations(&self) -> super::builder::model_service::ListOperations {
1220        super::builder::model_service::ListOperations::new(self.inner.clone())
1221    }
1222
1223    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1224    ///
1225    /// [google.longrunning.Operations]: longrunning::client::Operations
1226    pub fn get_operation(&self) -> super::builder::model_service::GetOperation {
1227        super::builder::model_service::GetOperation::new(self.inner.clone())
1228    }
1229}
1230
1231/// Implements a client for the Vertex AI Search for commerce API.
1232///
1233/// # Example
1234/// ```
1235/// # tokio_test::block_on(async {
1236/// # use google_cloud_retail_v2::client::PredictionService;
1237/// let client = PredictionService::builder().build().await?;
1238/// // use `client` to make requests to the Vertex AI Search for commerce API.
1239/// # gax::client_builder::Result::<()>::Ok(()) });
1240/// ```
1241///
1242/// # Service Description
1243///
1244/// Service for making recommendation prediction.
1245///
1246/// # Configuration
1247///
1248/// To configure `PredictionService` use the `with_*` methods in the type returned
1249/// by [builder()][PredictionService::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::prediction_service::ClientBuilder::with_endpoint
1262/// [with_credentials()]: super::builder::prediction_service::ClientBuilder::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/// `PredictionService` holds a connection pool internally, it is advised to
1269/// create one and the reuse it.  You do not need to wrap `PredictionService` 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 PredictionService {
1274    inner: std::sync::Arc<dyn super::stub::dynamic::PredictionService>,
1275}
1276
1277impl PredictionService {
1278    /// Returns a builder for [PredictionService].
1279    ///
1280    /// ```
1281    /// # tokio_test::block_on(async {
1282    /// # use google_cloud_retail_v2::client::PredictionService;
1283    /// let client = PredictionService::builder().build().await?;
1284    /// # gax::client_builder::Result::<()>::Ok(()) });
1285    /// ```
1286    pub fn builder() -> super::builder::prediction_service::ClientBuilder {
1287        gax::client_builder::internal::new_builder(
1288            super::builder::prediction_service::client::Factory,
1289        )
1290    }
1291
1292    /// Creates a new client from the provided stub.
1293    ///
1294    /// The most common case for calling this function is in tests mocking the
1295    /// client's behavior.
1296    pub fn from_stub<T>(stub: T) -> Self
1297    where
1298        T: super::stub::PredictionService + 'static,
1299    {
1300        Self {
1301            inner: std::sync::Arc::new(stub),
1302        }
1303    }
1304
1305    pub(crate) async fn new(
1306        config: gaxi::options::ClientConfig,
1307    ) -> gax::client_builder::Result<Self> {
1308        let inner = Self::build_inner(config).await?;
1309        Ok(Self { inner })
1310    }
1311
1312    async fn build_inner(
1313        conf: gaxi::options::ClientConfig,
1314    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::PredictionService>>
1315    {
1316        if gaxi::options::tracing_enabled(&conf) {
1317            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1318        }
1319        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1320    }
1321
1322    async fn build_transport(
1323        conf: gaxi::options::ClientConfig,
1324    ) -> gax::client_builder::Result<impl super::stub::PredictionService> {
1325        super::transport::PredictionService::new(conf).await
1326    }
1327
1328    async fn build_with_tracing(
1329        conf: gaxi::options::ClientConfig,
1330    ) -> gax::client_builder::Result<impl super::stub::PredictionService> {
1331        Self::build_transport(conf)
1332            .await
1333            .map(super::tracing::PredictionService::new)
1334    }
1335
1336    /// Makes a recommendation prediction.
1337    pub fn predict(&self) -> super::builder::prediction_service::Predict {
1338        super::builder::prediction_service::Predict::new(self.inner.clone())
1339    }
1340
1341    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1342    ///
1343    /// [google.longrunning.Operations]: longrunning::client::Operations
1344    pub fn list_operations(&self) -> super::builder::prediction_service::ListOperations {
1345        super::builder::prediction_service::ListOperations::new(self.inner.clone())
1346    }
1347
1348    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1349    ///
1350    /// [google.longrunning.Operations]: longrunning::client::Operations
1351    pub fn get_operation(&self) -> super::builder::prediction_service::GetOperation {
1352        super::builder::prediction_service::GetOperation::new(self.inner.clone())
1353    }
1354}
1355
1356/// Implements a client for the Vertex AI Search for commerce API.
1357///
1358/// # Example
1359/// ```
1360/// # tokio_test::block_on(async {
1361/// # use google_cloud_retail_v2::client::ProductService;
1362/// let client = ProductService::builder().build().await?;
1363/// // use `client` to make requests to the Vertex AI Search for commerce API.
1364/// # gax::client_builder::Result::<()>::Ok(()) });
1365/// ```
1366///
1367/// # Service Description
1368///
1369/// Service for ingesting [Product][google.cloud.retail.v2.Product] information
1370/// of the customer's website.
1371///
1372/// [google.cloud.retail.v2.Product]: crate::model::Product
1373///
1374/// # Configuration
1375///
1376/// To configure `ProductService` use the `with_*` methods in the type returned
1377/// by [builder()][ProductService::builder]. The default configuration should
1378/// work for most applications. Common configuration changes include
1379///
1380/// * [with_endpoint()]: by default this client uses the global default endpoint
1381///   (`https://retail.googleapis.com`). Applications using regional
1382///   endpoints or running in restricted networks (e.g. a network configured
1383//    with [Private Google Access with VPC Service Controls]) may want to
1384///   override this default.
1385/// * [with_credentials()]: by default this client uses
1386///   [Application Default Credentials]. Applications using custom
1387///   authentication may need to override this default.
1388///
1389/// [with_endpoint()]: super::builder::product_service::ClientBuilder::with_endpoint
1390/// [with_credentials()]: super::builder::product_service::ClientBuilder::credentials
1391/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1392/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1393///
1394/// # Pooling and Cloning
1395///
1396/// `ProductService` holds a connection pool internally, it is advised to
1397/// create one and the reuse it.  You do not need to wrap `ProductService` in
1398/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1399/// already uses an `Arc` internally.
1400#[derive(Clone, Debug)]
1401pub struct ProductService {
1402    inner: std::sync::Arc<dyn super::stub::dynamic::ProductService>,
1403}
1404
1405impl ProductService {
1406    /// Returns a builder for [ProductService].
1407    ///
1408    /// ```
1409    /// # tokio_test::block_on(async {
1410    /// # use google_cloud_retail_v2::client::ProductService;
1411    /// let client = ProductService::builder().build().await?;
1412    /// # gax::client_builder::Result::<()>::Ok(()) });
1413    /// ```
1414    pub fn builder() -> super::builder::product_service::ClientBuilder {
1415        gax::client_builder::internal::new_builder(super::builder::product_service::client::Factory)
1416    }
1417
1418    /// Creates a new client from the provided stub.
1419    ///
1420    /// The most common case for calling this function is in tests mocking the
1421    /// client's behavior.
1422    pub fn from_stub<T>(stub: T) -> Self
1423    where
1424        T: super::stub::ProductService + 'static,
1425    {
1426        Self {
1427            inner: std::sync::Arc::new(stub),
1428        }
1429    }
1430
1431    pub(crate) async fn new(
1432        config: gaxi::options::ClientConfig,
1433    ) -> gax::client_builder::Result<Self> {
1434        let inner = Self::build_inner(config).await?;
1435        Ok(Self { inner })
1436    }
1437
1438    async fn build_inner(
1439        conf: gaxi::options::ClientConfig,
1440    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ProductService>> {
1441        if gaxi::options::tracing_enabled(&conf) {
1442            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1443        }
1444        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1445    }
1446
1447    async fn build_transport(
1448        conf: gaxi::options::ClientConfig,
1449    ) -> gax::client_builder::Result<impl super::stub::ProductService> {
1450        super::transport::ProductService::new(conf).await
1451    }
1452
1453    async fn build_with_tracing(
1454        conf: gaxi::options::ClientConfig,
1455    ) -> gax::client_builder::Result<impl super::stub::ProductService> {
1456        Self::build_transport(conf)
1457            .await
1458            .map(super::tracing::ProductService::new)
1459    }
1460
1461    /// Creates a [Product][google.cloud.retail.v2.Product].
1462    ///
1463    /// [google.cloud.retail.v2.Product]: crate::model::Product
1464    pub fn create_product(&self) -> super::builder::product_service::CreateProduct {
1465        super::builder::product_service::CreateProduct::new(self.inner.clone())
1466    }
1467
1468    /// Gets a [Product][google.cloud.retail.v2.Product].
1469    ///
1470    /// [google.cloud.retail.v2.Product]: crate::model::Product
1471    pub fn get_product(&self) -> super::builder::product_service::GetProduct {
1472        super::builder::product_service::GetProduct::new(self.inner.clone())
1473    }
1474
1475    /// Gets a list of [Product][google.cloud.retail.v2.Product]s.
1476    ///
1477    /// [google.cloud.retail.v2.Product]: crate::model::Product
1478    pub fn list_products(&self) -> super::builder::product_service::ListProducts {
1479        super::builder::product_service::ListProducts::new(self.inner.clone())
1480    }
1481
1482    /// Updates a [Product][google.cloud.retail.v2.Product].
1483    ///
1484    /// [google.cloud.retail.v2.Product]: crate::model::Product
1485    pub fn update_product(&self) -> super::builder::product_service::UpdateProduct {
1486        super::builder::product_service::UpdateProduct::new(self.inner.clone())
1487    }
1488
1489    /// Deletes a [Product][google.cloud.retail.v2.Product].
1490    ///
1491    /// [google.cloud.retail.v2.Product]: crate::model::Product
1492    pub fn delete_product(&self) -> super::builder::product_service::DeleteProduct {
1493        super::builder::product_service::DeleteProduct::new(self.inner.clone())
1494    }
1495
1496    /// Permanently deletes all selected [Product][google.cloud.retail.v2.Product]s
1497    /// under a branch.
1498    ///
1499    /// This process is asynchronous. If the request is valid, the removal will be
1500    /// enqueued and processed offline. Depending on the number of
1501    /// [Product][google.cloud.retail.v2.Product]s, this operation could take hours
1502    /// to complete. Before the operation completes, some
1503    /// [Product][google.cloud.retail.v2.Product]s may still be returned by
1504    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
1505    /// or
1506    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
1507    ///
1508    /// Depending on the number of [Product][google.cloud.retail.v2.Product]s, this
1509    /// operation could take hours to complete. To get a sample of
1510    /// [Product][google.cloud.retail.v2.Product]s that would be deleted, set
1511    /// [PurgeProductsRequest.force][google.cloud.retail.v2.PurgeProductsRequest.force]
1512    /// to false.
1513    ///
1514    /// [google.cloud.retail.v2.Product]: crate::model::Product
1515    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
1516    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
1517    /// [google.cloud.retail.v2.PurgeProductsRequest.force]: crate::model::PurgeProductsRequest::force
1518    ///
1519    /// # Long running operations
1520    ///
1521    /// This method is used to start, and/or poll a [long-running Operation].
1522    /// The [Working with long-running operations] chapter in the [user guide]
1523    /// covers these operations in detail.
1524    ///
1525    /// [long-running operation]: https://google.aip.dev/151
1526    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1527    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1528    pub fn purge_products(&self) -> super::builder::product_service::PurgeProducts {
1529        super::builder::product_service::PurgeProducts::new(self.inner.clone())
1530    }
1531
1532    /// Bulk import of multiple [Product][google.cloud.retail.v2.Product]s.
1533    ///
1534    /// Request processing may be synchronous.
1535    /// Non-existing items are created.
1536    ///
1537    /// Note that it is possible for a subset of the
1538    /// [Product][google.cloud.retail.v2.Product]s to be successfully updated.
1539    ///
1540    /// [google.cloud.retail.v2.Product]: crate::model::Product
1541    ///
1542    /// # Long running operations
1543    ///
1544    /// This method is used to start, and/or poll a [long-running Operation].
1545    /// The [Working with long-running operations] chapter in the [user guide]
1546    /// covers these operations in detail.
1547    ///
1548    /// [long-running operation]: https://google.aip.dev/151
1549    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1550    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1551    pub fn import_products(&self) -> super::builder::product_service::ImportProducts {
1552        super::builder::product_service::ImportProducts::new(self.inner.clone())
1553    }
1554
1555    /// Updates inventory information for a
1556    /// [Product][google.cloud.retail.v2.Product] while respecting the last update
1557    /// timestamps of each inventory field.
1558    ///
1559    /// This process is asynchronous and does not require the
1560    /// [Product][google.cloud.retail.v2.Product] to exist before updating
1561    /// fulfillment information. If the request is valid, the update is enqueued
1562    /// and processed downstream. As a consequence, when a response is returned,
1563    /// updates are not immediately manifested in the
1564    /// [Product][google.cloud.retail.v2.Product] queried by
1565    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
1566    /// or
1567    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
1568    ///
1569    /// When inventory is updated with
1570    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
1571    /// and
1572    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct],
1573    /// the specified inventory field value(s) overwrite any existing value(s)
1574    /// while ignoring the last update time for this field. Furthermore, the last
1575    /// update times for the specified inventory fields are overwritten by the
1576    /// times of the
1577    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
1578    /// or
1579    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct]
1580    /// request.
1581    ///
1582    /// If no inventory fields are set in
1583    /// [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product],
1584    /// then any pre-existing inventory information for this product is used.
1585    ///
1586    /// If no inventory fields are set in
1587    /// [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask],
1588    /// then any existing inventory information is preserved.
1589    ///
1590    /// Pre-existing inventory information can only be updated with
1591    /// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory],
1592    /// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces],
1593    /// and
1594    /// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces].
1595    ///
1596    /// The returned [Operation][google.longrunning.Operation]s is obsolete after
1597    /// one day, and the [GetOperation][google.longrunning.Operations.GetOperation]
1598    /// API returns `NOT_FOUND` afterwards.
1599    ///
1600    /// If conflicting updates are issued, the
1601    /// [Operation][google.longrunning.Operation]s associated with the stale
1602    /// updates are not marked as [done][google.longrunning.Operation.done] until
1603    /// they are obsolete.
1604    ///
1605    /// [google.cloud.retail.v2.CreateProductRequest.product]: crate::model::CreateProductRequest::product
1606    /// [google.cloud.retail.v2.Product]: crate::model::Product
1607    /// [google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]: crate::client::ProductService::add_fulfillment_places
1608    /// [google.cloud.retail.v2.ProductService.CreateProduct]: crate::client::ProductService::create_product
1609    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
1610    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
1611    /// [google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]: crate::client::ProductService::remove_fulfillment_places
1612    /// [google.cloud.retail.v2.ProductService.SetInventory]: crate::client::ProductService::set_inventory
1613    /// [google.cloud.retail.v2.ProductService.UpdateProduct]: crate::client::ProductService::update_product
1614    /// [google.cloud.retail.v2.SetInventoryRequest.set_mask]: crate::model::SetInventoryRequest::set_mask
1615    /// [google.longrunning.Operation]: longrunning::model::Operation
1616    /// [google.longrunning.Operation.done]: longrunning::model::Operation::done
1617    ///
1618    /// # Long running operations
1619    ///
1620    /// This method is used to start, and/or poll a [long-running Operation].
1621    /// The [Working with long-running operations] chapter in the [user guide]
1622    /// covers these operations in detail.
1623    ///
1624    /// [long-running operation]: https://google.aip.dev/151
1625    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1626    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1627    pub fn set_inventory(&self) -> super::builder::product_service::SetInventory {
1628        super::builder::product_service::SetInventory::new(self.inner.clone())
1629    }
1630
1631    /// We recommend that you use the
1632    /// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories]
1633    /// method instead of the
1634    /// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]
1635    /// method.
1636    /// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories]
1637    /// achieves the same results but provides more fine-grained control over
1638    /// ingesting local inventory data.
1639    ///
1640    /// Incrementally adds place IDs to
1641    /// [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids].
1642    ///
1643    /// This process is asynchronous and does not require the
1644    /// [Product][google.cloud.retail.v2.Product] to exist before updating
1645    /// fulfillment information. If the request is valid, the update will be
1646    /// enqueued and processed downstream. As a consequence, when a response is
1647    /// returned, the added place IDs are not immediately manifested in the
1648    /// [Product][google.cloud.retail.v2.Product] queried by
1649    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
1650    /// or
1651    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
1652    ///
1653    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
1654    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
1655    /// API will return NOT_FOUND afterwards.
1656    ///
1657    /// If conflicting updates are issued, the
1658    /// [Operation][google.longrunning.Operation]s associated with the stale
1659    /// updates will not be marked as [done][google.longrunning.Operation.done]
1660    /// until being obsolete.
1661    ///
1662    /// [google.cloud.retail.v2.FulfillmentInfo.place_ids]: crate::model::FulfillmentInfo::place_ids
1663    /// [google.cloud.retail.v2.Product]: crate::model::Product
1664    /// [google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]: crate::client::ProductService::add_fulfillment_places
1665    /// [google.cloud.retail.v2.ProductService.AddLocalInventories]: crate::client::ProductService::add_local_inventories
1666    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
1667    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
1668    /// [google.longrunning.Operation]: longrunning::model::Operation
1669    /// [google.longrunning.Operation.done]: longrunning::model::Operation::done
1670    ///
1671    /// # Long running operations
1672    ///
1673    /// This method is used to start, and/or poll a [long-running Operation].
1674    /// The [Working with long-running operations] chapter in the [user guide]
1675    /// covers these operations in detail.
1676    ///
1677    /// [long-running operation]: https://google.aip.dev/151
1678    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1679    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1680    pub fn add_fulfillment_places(&self) -> super::builder::product_service::AddFulfillmentPlaces {
1681        super::builder::product_service::AddFulfillmentPlaces::new(self.inner.clone())
1682    }
1683
1684    /// We recommend that you use the
1685    /// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories]
1686    /// method instead of the
1687    /// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]
1688    /// method.
1689    /// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories]
1690    /// achieves the same results but provides more fine-grained control over
1691    /// ingesting local inventory data.
1692    ///
1693    /// Incrementally removes place IDs from a
1694    /// [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids].
1695    ///
1696    /// This process is asynchronous and does not require the
1697    /// [Product][google.cloud.retail.v2.Product] to exist before updating
1698    /// fulfillment information. If the request is valid, the update will be
1699    /// enqueued and processed downstream. As a consequence, when a response is
1700    /// returned, the removed place IDs are not immediately manifested in the
1701    /// [Product][google.cloud.retail.v2.Product] queried by
1702    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
1703    /// or
1704    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
1705    ///
1706    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
1707    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
1708    /// API will return NOT_FOUND afterwards.
1709    ///
1710    /// If conflicting updates are issued, the
1711    /// [Operation][google.longrunning.Operation]s associated with the stale
1712    /// updates will not be marked as [done][google.longrunning.Operation.done]
1713    /// until being obsolete.
1714    ///
1715    /// [google.cloud.retail.v2.FulfillmentInfo.place_ids]: crate::model::FulfillmentInfo::place_ids
1716    /// [google.cloud.retail.v2.Product]: crate::model::Product
1717    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
1718    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
1719    /// [google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]: crate::client::ProductService::remove_fulfillment_places
1720    /// [google.cloud.retail.v2.ProductService.RemoveLocalInventories]: crate::client::ProductService::remove_local_inventories
1721    /// [google.longrunning.Operation]: longrunning::model::Operation
1722    /// [google.longrunning.Operation.done]: longrunning::model::Operation::done
1723    ///
1724    /// # Long running operations
1725    ///
1726    /// This method is used to start, and/or poll a [long-running Operation].
1727    /// The [Working with long-running operations] chapter in the [user guide]
1728    /// covers these operations in detail.
1729    ///
1730    /// [long-running operation]: https://google.aip.dev/151
1731    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1732    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1733    pub fn remove_fulfillment_places(
1734        &self,
1735    ) -> super::builder::product_service::RemoveFulfillmentPlaces {
1736        super::builder::product_service::RemoveFulfillmentPlaces::new(self.inner.clone())
1737    }
1738
1739    /// Updates local inventory information for a
1740    /// [Product][google.cloud.retail.v2.Product] at a list of places, while
1741    /// respecting the last update timestamps of each inventory field.
1742    ///
1743    /// This process is asynchronous and does not require the
1744    /// [Product][google.cloud.retail.v2.Product] to exist before updating
1745    /// inventory information. If the request is valid, the update will be enqueued
1746    /// and processed downstream. As a consequence, when a response is returned,
1747    /// updates are not immediately manifested in the
1748    /// [Product][google.cloud.retail.v2.Product] queried by
1749    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
1750    /// or
1751    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
1752    ///
1753    /// Local inventory information can only be modified using this method.
1754    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
1755    /// and
1756    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct]
1757    /// has no effect on local inventories.
1758    ///
1759    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
1760    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
1761    /// API will return NOT_FOUND afterwards.
1762    ///
1763    /// If conflicting updates are issued, the
1764    /// [Operation][google.longrunning.Operation]s associated with the stale
1765    /// updates will not be marked as [done][google.longrunning.Operation.done]
1766    /// until being obsolete.
1767    ///
1768    /// [google.cloud.retail.v2.Product]: crate::model::Product
1769    /// [google.cloud.retail.v2.ProductService.CreateProduct]: crate::client::ProductService::create_product
1770    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
1771    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
1772    /// [google.cloud.retail.v2.ProductService.UpdateProduct]: crate::client::ProductService::update_product
1773    /// [google.longrunning.Operation]: longrunning::model::Operation
1774    /// [google.longrunning.Operation.done]: longrunning::model::Operation::done
1775    ///
1776    /// # Long running operations
1777    ///
1778    /// This method is used to start, and/or poll a [long-running Operation].
1779    /// The [Working with long-running operations] chapter in the [user guide]
1780    /// covers these operations in detail.
1781    ///
1782    /// [long-running operation]: https://google.aip.dev/151
1783    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1784    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1785    pub fn add_local_inventories(&self) -> super::builder::product_service::AddLocalInventories {
1786        super::builder::product_service::AddLocalInventories::new(self.inner.clone())
1787    }
1788
1789    /// Remove local inventory information for a
1790    /// [Product][google.cloud.retail.v2.Product] at a list of places at a removal
1791    /// timestamp.
1792    ///
1793    /// This process is asynchronous. If the request is valid, the removal will be
1794    /// enqueued and processed downstream. As a consequence, when a response is
1795    /// returned, removals are not immediately manifested in the
1796    /// [Product][google.cloud.retail.v2.Product] queried by
1797    /// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]
1798    /// or
1799    /// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts].
1800    ///
1801    /// Local inventory information can only be removed using this method.
1802    /// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct]
1803    /// and
1804    /// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct]
1805    /// has no effect on local inventories.
1806    ///
1807    /// The returned [Operation][google.longrunning.Operation]s will be obsolete
1808    /// after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation]
1809    /// API will return NOT_FOUND afterwards.
1810    ///
1811    /// If conflicting updates are issued, the
1812    /// [Operation][google.longrunning.Operation]s associated with the stale
1813    /// updates will not be marked as [done][google.longrunning.Operation.done]
1814    /// until being obsolete.
1815    ///
1816    /// [google.cloud.retail.v2.Product]: crate::model::Product
1817    /// [google.cloud.retail.v2.ProductService.CreateProduct]: crate::client::ProductService::create_product
1818    /// [google.cloud.retail.v2.ProductService.GetProduct]: crate::client::ProductService::get_product
1819    /// [google.cloud.retail.v2.ProductService.ListProducts]: crate::client::ProductService::list_products
1820    /// [google.cloud.retail.v2.ProductService.UpdateProduct]: crate::client::ProductService::update_product
1821    /// [google.longrunning.Operation]: longrunning::model::Operation
1822    /// [google.longrunning.Operation.done]: longrunning::model::Operation::done
1823    ///
1824    /// # Long running operations
1825    ///
1826    /// This method is used to start, and/or poll a [long-running Operation].
1827    /// The [Working with long-running operations] chapter in the [user guide]
1828    /// covers these operations in detail.
1829    ///
1830    /// [long-running operation]: https://google.aip.dev/151
1831    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1832    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1833    pub fn remove_local_inventories(
1834        &self,
1835    ) -> super::builder::product_service::RemoveLocalInventories {
1836        super::builder::product_service::RemoveLocalInventories::new(self.inner.clone())
1837    }
1838
1839    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1840    ///
1841    /// [google.longrunning.Operations]: longrunning::client::Operations
1842    pub fn list_operations(&self) -> super::builder::product_service::ListOperations {
1843        super::builder::product_service::ListOperations::new(self.inner.clone())
1844    }
1845
1846    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1847    ///
1848    /// [google.longrunning.Operations]: longrunning::client::Operations
1849    pub fn get_operation(&self) -> super::builder::product_service::GetOperation {
1850        super::builder::product_service::GetOperation::new(self.inner.clone())
1851    }
1852}
1853
1854/// Implements a client for the Vertex AI Search for commerce API.
1855///
1856/// # Example
1857/// ```
1858/// # tokio_test::block_on(async {
1859/// # use google_cloud_retail_v2::client::SearchService;
1860/// let client = SearchService::builder().build().await?;
1861/// // use `client` to make requests to the Vertex AI Search for commerce API.
1862/// # gax::client_builder::Result::<()>::Ok(()) });
1863/// ```
1864///
1865/// # Service Description
1866///
1867/// Service for search.
1868///
1869/// This feature is only available for users who have Retail Search enabled.
1870/// Enable Retail Search on Cloud Console before using this feature.
1871///
1872/// # Configuration
1873///
1874/// To configure `SearchService` use the `with_*` methods in the type returned
1875/// by [builder()][SearchService::builder]. The default configuration should
1876/// work for most applications. Common configuration changes include
1877///
1878/// * [with_endpoint()]: by default this client uses the global default endpoint
1879///   (`https://retail.googleapis.com`). Applications using regional
1880///   endpoints or running in restricted networks (e.g. a network configured
1881//    with [Private Google Access with VPC Service Controls]) may want to
1882///   override this default.
1883/// * [with_credentials()]: by default this client uses
1884///   [Application Default Credentials]. Applications using custom
1885///   authentication may need to override this default.
1886///
1887/// [with_endpoint()]: super::builder::search_service::ClientBuilder::with_endpoint
1888/// [with_credentials()]: super::builder::search_service::ClientBuilder::credentials
1889/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1890/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1891///
1892/// # Pooling and Cloning
1893///
1894/// `SearchService` holds a connection pool internally, it is advised to
1895/// create one and the reuse it.  You do not need to wrap `SearchService` in
1896/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1897/// already uses an `Arc` internally.
1898#[derive(Clone, Debug)]
1899pub struct SearchService {
1900    inner: std::sync::Arc<dyn super::stub::dynamic::SearchService>,
1901}
1902
1903impl SearchService {
1904    /// Returns a builder for [SearchService].
1905    ///
1906    /// ```
1907    /// # tokio_test::block_on(async {
1908    /// # use google_cloud_retail_v2::client::SearchService;
1909    /// let client = SearchService::builder().build().await?;
1910    /// # gax::client_builder::Result::<()>::Ok(()) });
1911    /// ```
1912    pub fn builder() -> super::builder::search_service::ClientBuilder {
1913        gax::client_builder::internal::new_builder(super::builder::search_service::client::Factory)
1914    }
1915
1916    /// Creates a new client from the provided stub.
1917    ///
1918    /// The most common case for calling this function is in tests mocking the
1919    /// client's behavior.
1920    pub fn from_stub<T>(stub: T) -> Self
1921    where
1922        T: super::stub::SearchService + 'static,
1923    {
1924        Self {
1925            inner: std::sync::Arc::new(stub),
1926        }
1927    }
1928
1929    pub(crate) async fn new(
1930        config: gaxi::options::ClientConfig,
1931    ) -> gax::client_builder::Result<Self> {
1932        let inner = Self::build_inner(config).await?;
1933        Ok(Self { inner })
1934    }
1935
1936    async fn build_inner(
1937        conf: gaxi::options::ClientConfig,
1938    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SearchService>> {
1939        if gaxi::options::tracing_enabled(&conf) {
1940            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1941        }
1942        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1943    }
1944
1945    async fn build_transport(
1946        conf: gaxi::options::ClientConfig,
1947    ) -> gax::client_builder::Result<impl super::stub::SearchService> {
1948        super::transport::SearchService::new(conf).await
1949    }
1950
1951    async fn build_with_tracing(
1952        conf: gaxi::options::ClientConfig,
1953    ) -> gax::client_builder::Result<impl super::stub::SearchService> {
1954        Self::build_transport(conf)
1955            .await
1956            .map(super::tracing::SearchService::new)
1957    }
1958
1959    /// Performs a search.
1960    ///
1961    /// This feature is only available for users who have Retail Search enabled.
1962    /// Enable Retail Search on Cloud Console before using this feature.
1963    pub fn search(&self) -> super::builder::search_service::Search {
1964        super::builder::search_service::Search::new(self.inner.clone())
1965    }
1966
1967    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1968    ///
1969    /// [google.longrunning.Operations]: longrunning::client::Operations
1970    pub fn list_operations(&self) -> super::builder::search_service::ListOperations {
1971        super::builder::search_service::ListOperations::new(self.inner.clone())
1972    }
1973
1974    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1975    ///
1976    /// [google.longrunning.Operations]: longrunning::client::Operations
1977    pub fn get_operation(&self) -> super::builder::search_service::GetOperation {
1978        super::builder::search_service::GetOperation::new(self.inner.clone())
1979    }
1980}
1981
1982/// Implements a client for the Vertex AI Search for commerce API.
1983///
1984/// # Example
1985/// ```
1986/// # tokio_test::block_on(async {
1987/// # use google_cloud_retail_v2::client::ServingConfigService;
1988/// let client = ServingConfigService::builder().build().await?;
1989/// // use `client` to make requests to the Vertex AI Search for commerce API.
1990/// # gax::client_builder::Result::<()>::Ok(()) });
1991/// ```
1992///
1993/// # Service Description
1994///
1995/// Service for modifying ServingConfig.
1996///
1997/// # Configuration
1998///
1999/// To configure `ServingConfigService` use the `with_*` methods in the type returned
2000/// by [builder()][ServingConfigService::builder]. The default configuration should
2001/// work for most applications. Common configuration changes include
2002///
2003/// * [with_endpoint()]: by default this client uses the global default endpoint
2004///   (`https://retail.googleapis.com`). Applications using regional
2005///   endpoints or running in restricted networks (e.g. a network configured
2006//    with [Private Google Access with VPC Service Controls]) may want to
2007///   override this default.
2008/// * [with_credentials()]: by default this client uses
2009///   [Application Default Credentials]. Applications using custom
2010///   authentication may need to override this default.
2011///
2012/// [with_endpoint()]: super::builder::serving_config_service::ClientBuilder::with_endpoint
2013/// [with_credentials()]: super::builder::serving_config_service::ClientBuilder::credentials
2014/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2015/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2016///
2017/// # Pooling and Cloning
2018///
2019/// `ServingConfigService` holds a connection pool internally, it is advised to
2020/// create one and the reuse it.  You do not need to wrap `ServingConfigService` in
2021/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2022/// already uses an `Arc` internally.
2023#[derive(Clone, Debug)]
2024pub struct ServingConfigService {
2025    inner: std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>,
2026}
2027
2028impl ServingConfigService {
2029    /// Returns a builder for [ServingConfigService].
2030    ///
2031    /// ```
2032    /// # tokio_test::block_on(async {
2033    /// # use google_cloud_retail_v2::client::ServingConfigService;
2034    /// let client = ServingConfigService::builder().build().await?;
2035    /// # gax::client_builder::Result::<()>::Ok(()) });
2036    /// ```
2037    pub fn builder() -> super::builder::serving_config_service::ClientBuilder {
2038        gax::client_builder::internal::new_builder(
2039            super::builder::serving_config_service::client::Factory,
2040        )
2041    }
2042
2043    /// Creates a new client from the provided stub.
2044    ///
2045    /// The most common case for calling this function is in tests mocking the
2046    /// client's behavior.
2047    pub fn from_stub<T>(stub: T) -> Self
2048    where
2049        T: super::stub::ServingConfigService + 'static,
2050    {
2051        Self {
2052            inner: std::sync::Arc::new(stub),
2053        }
2054    }
2055
2056    pub(crate) async fn new(
2057        config: gaxi::options::ClientConfig,
2058    ) -> gax::client_builder::Result<Self> {
2059        let inner = Self::build_inner(config).await?;
2060        Ok(Self { inner })
2061    }
2062
2063    async fn build_inner(
2064        conf: gaxi::options::ClientConfig,
2065    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>>
2066    {
2067        if gaxi::options::tracing_enabled(&conf) {
2068            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2069        }
2070        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2071    }
2072
2073    async fn build_transport(
2074        conf: gaxi::options::ClientConfig,
2075    ) -> gax::client_builder::Result<impl super::stub::ServingConfigService> {
2076        super::transport::ServingConfigService::new(conf).await
2077    }
2078
2079    async fn build_with_tracing(
2080        conf: gaxi::options::ClientConfig,
2081    ) -> gax::client_builder::Result<impl super::stub::ServingConfigService> {
2082        Self::build_transport(conf)
2083            .await
2084            .map(super::tracing::ServingConfigService::new)
2085    }
2086
2087    /// Creates a ServingConfig.
2088    ///
2089    /// A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are
2090    /// allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a
2091    /// FAILED_PRECONDITION error is returned.
2092    ///
2093    /// [google.cloud.retail.v2.Catalog]: crate::model::Catalog
2094    /// [google.cloud.retail.v2.ServingConfig]: crate::model::ServingConfig
2095    pub fn create_serving_config(
2096        &self,
2097    ) -> super::builder::serving_config_service::CreateServingConfig {
2098        super::builder::serving_config_service::CreateServingConfig::new(self.inner.clone())
2099    }
2100
2101    /// Deletes a ServingConfig.
2102    ///
2103    /// Returns a NotFound error if the ServingConfig does not exist.
2104    pub fn delete_serving_config(
2105        &self,
2106    ) -> super::builder::serving_config_service::DeleteServingConfig {
2107        super::builder::serving_config_service::DeleteServingConfig::new(self.inner.clone())
2108    }
2109
2110    /// Updates a ServingConfig.
2111    pub fn update_serving_config(
2112        &self,
2113    ) -> super::builder::serving_config_service::UpdateServingConfig {
2114        super::builder::serving_config_service::UpdateServingConfig::new(self.inner.clone())
2115    }
2116
2117    /// Gets a ServingConfig.
2118    ///
2119    /// Returns a NotFound error if the ServingConfig does not exist.
2120    pub fn get_serving_config(&self) -> super::builder::serving_config_service::GetServingConfig {
2121        super::builder::serving_config_service::GetServingConfig::new(self.inner.clone())
2122    }
2123
2124    /// Lists all ServingConfigs linked to this catalog.
2125    pub fn list_serving_configs(
2126        &self,
2127    ) -> super::builder::serving_config_service::ListServingConfigs {
2128        super::builder::serving_config_service::ListServingConfigs::new(self.inner.clone())
2129    }
2130
2131    /// Enables a Control on the specified ServingConfig.
2132    /// The control is added in the last position of the list of controls
2133    /// it belongs to (e.g. if it's a facet spec control it will be applied
2134    /// in the last position of servingConfig.facetSpecIds)
2135    /// Returns a ALREADY_EXISTS error if the control has already been applied.
2136    /// Returns a FAILED_PRECONDITION error if the addition could exceed maximum
2137    /// number of control allowed for that type of control.
2138    pub fn add_control(&self) -> super::builder::serving_config_service::AddControl {
2139        super::builder::serving_config_service::AddControl::new(self.inner.clone())
2140    }
2141
2142    /// Disables a Control on the specified ServingConfig.
2143    /// The control is removed from the ServingConfig.
2144    /// Returns a NOT_FOUND error if the Control is not enabled for the
2145    /// ServingConfig.
2146    pub fn remove_control(&self) -> super::builder::serving_config_service::RemoveControl {
2147        super::builder::serving_config_service::RemoveControl::new(self.inner.clone())
2148    }
2149
2150    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2151    ///
2152    /// [google.longrunning.Operations]: longrunning::client::Operations
2153    pub fn list_operations(&self) -> super::builder::serving_config_service::ListOperations {
2154        super::builder::serving_config_service::ListOperations::new(self.inner.clone())
2155    }
2156
2157    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2158    ///
2159    /// [google.longrunning.Operations]: longrunning::client::Operations
2160    pub fn get_operation(&self) -> super::builder::serving_config_service::GetOperation {
2161        super::builder::serving_config_service::GetOperation::new(self.inner.clone())
2162    }
2163}
2164
2165/// Implements a client for the Vertex AI Search for commerce API.
2166///
2167/// # Example
2168/// ```
2169/// # tokio_test::block_on(async {
2170/// # use google_cloud_retail_v2::client::UserEventService;
2171/// let client = UserEventService::builder().build().await?;
2172/// // use `client` to make requests to the Vertex AI Search for commerce API.
2173/// # gax::client_builder::Result::<()>::Ok(()) });
2174/// ```
2175///
2176/// # Service Description
2177///
2178/// Service for ingesting end user actions on the customer website.
2179///
2180/// # Configuration
2181///
2182/// To configure `UserEventService` use the `with_*` methods in the type returned
2183/// by [builder()][UserEventService::builder]. The default configuration should
2184/// work for most applications. Common configuration changes include
2185///
2186/// * [with_endpoint()]: by default this client uses the global default endpoint
2187///   (`https://retail.googleapis.com`). Applications using regional
2188///   endpoints or running in restricted networks (e.g. a network configured
2189//    with [Private Google Access with VPC Service Controls]) may want to
2190///   override this default.
2191/// * [with_credentials()]: by default this client uses
2192///   [Application Default Credentials]. Applications using custom
2193///   authentication may need to override this default.
2194///
2195/// [with_endpoint()]: super::builder::user_event_service::ClientBuilder::with_endpoint
2196/// [with_credentials()]: super::builder::user_event_service::ClientBuilder::credentials
2197/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2198/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2199///
2200/// # Pooling and Cloning
2201///
2202/// `UserEventService` holds a connection pool internally, it is advised to
2203/// create one and the reuse it.  You do not need to wrap `UserEventService` in
2204/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2205/// already uses an `Arc` internally.
2206#[derive(Clone, Debug)]
2207pub struct UserEventService {
2208    inner: std::sync::Arc<dyn super::stub::dynamic::UserEventService>,
2209}
2210
2211impl UserEventService {
2212    /// Returns a builder for [UserEventService].
2213    ///
2214    /// ```
2215    /// # tokio_test::block_on(async {
2216    /// # use google_cloud_retail_v2::client::UserEventService;
2217    /// let client = UserEventService::builder().build().await?;
2218    /// # gax::client_builder::Result::<()>::Ok(()) });
2219    /// ```
2220    pub fn builder() -> super::builder::user_event_service::ClientBuilder {
2221        gax::client_builder::internal::new_builder(
2222            super::builder::user_event_service::client::Factory,
2223        )
2224    }
2225
2226    /// Creates a new client from the provided stub.
2227    ///
2228    /// The most common case for calling this function is in tests mocking the
2229    /// client's behavior.
2230    pub fn from_stub<T>(stub: T) -> Self
2231    where
2232        T: super::stub::UserEventService + 'static,
2233    {
2234        Self {
2235            inner: std::sync::Arc::new(stub),
2236        }
2237    }
2238
2239    pub(crate) async fn new(
2240        config: gaxi::options::ClientConfig,
2241    ) -> gax::client_builder::Result<Self> {
2242        let inner = Self::build_inner(config).await?;
2243        Ok(Self { inner })
2244    }
2245
2246    async fn build_inner(
2247        conf: gaxi::options::ClientConfig,
2248    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::UserEventService>>
2249    {
2250        if gaxi::options::tracing_enabled(&conf) {
2251            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2252        }
2253        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2254    }
2255
2256    async fn build_transport(
2257        conf: gaxi::options::ClientConfig,
2258    ) -> gax::client_builder::Result<impl super::stub::UserEventService> {
2259        super::transport::UserEventService::new(conf).await
2260    }
2261
2262    async fn build_with_tracing(
2263        conf: gaxi::options::ClientConfig,
2264    ) -> gax::client_builder::Result<impl super::stub::UserEventService> {
2265        Self::build_transport(conf)
2266            .await
2267            .map(super::tracing::UserEventService::new)
2268    }
2269
2270    /// Writes a single user event.
2271    pub fn write_user_event(&self) -> super::builder::user_event_service::WriteUserEvent {
2272        super::builder::user_event_service::WriteUserEvent::new(self.inner.clone())
2273    }
2274
2275    /// Writes a single user event from the browser.
2276    ///
2277    /// For larger user event payload over 16 KB, the POST method should be used
2278    /// instead, otherwise a 400 Bad Request error is returned.
2279    ///
2280    /// This method is used only by the Retail API JavaScript pixel and Google Tag
2281    /// Manager. Users should not call this method directly.
2282    pub fn collect_user_event(&self) -> super::builder::user_event_service::CollectUserEvent {
2283        super::builder::user_event_service::CollectUserEvent::new(self.inner.clone())
2284    }
2285
2286    /// Deletes permanently all user events specified by the filter provided.
2287    /// Depending on the number of events specified by the filter, this operation
2288    /// could take hours or days to complete. To test a filter, use the list
2289    /// command first.
2290    ///
2291    /// # Long running operations
2292    ///
2293    /// This method is used to start, and/or poll a [long-running Operation].
2294    /// The [Working with long-running operations] chapter in the [user guide]
2295    /// covers these operations in detail.
2296    ///
2297    /// [long-running operation]: https://google.aip.dev/151
2298    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2299    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2300    pub fn purge_user_events(&self) -> super::builder::user_event_service::PurgeUserEvents {
2301        super::builder::user_event_service::PurgeUserEvents::new(self.inner.clone())
2302    }
2303
2304    /// Bulk import of User events. Request processing might be
2305    /// synchronous. Events that already exist are skipped.
2306    /// Use this method for backfilling historical user events.
2307    ///
2308    /// `Operation.response` is of type `ImportResponse`. Note that it is
2309    /// possible for a subset of the items to be successfully inserted.
2310    /// `Operation.metadata` is of type `ImportMetadata`.
2311    ///
2312    /// # Long running operations
2313    ///
2314    /// This method is used to start, and/or poll a [long-running Operation].
2315    /// The [Working with long-running operations] chapter in the [user guide]
2316    /// covers these operations in detail.
2317    ///
2318    /// [long-running operation]: https://google.aip.dev/151
2319    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2320    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2321    pub fn import_user_events(&self) -> super::builder::user_event_service::ImportUserEvents {
2322        super::builder::user_event_service::ImportUserEvents::new(self.inner.clone())
2323    }
2324
2325    /// Starts a user-event rejoin operation with latest product catalog. Events
2326    /// are not annotated with detailed product information for products that are
2327    /// missing from the catalog when the user event is ingested. These
2328    /// events are stored as unjoined events with limited usage on training and
2329    /// serving. You can use this method to start a join operation on specified
2330    /// events with the latest version of product catalog. You can also use this
2331    /// method to correct events joined with the wrong product catalog. A rejoin
2332    /// operation can take hours or days to complete.
2333    ///
2334    /// # Long running operations
2335    ///
2336    /// This method is used to start, and/or poll a [long-running Operation].
2337    /// The [Working with long-running operations] chapter in the [user guide]
2338    /// covers these operations in detail.
2339    ///
2340    /// [long-running operation]: https://google.aip.dev/151
2341    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2342    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2343    pub fn rejoin_user_events(&self) -> super::builder::user_event_service::RejoinUserEvents {
2344        super::builder::user_event_service::RejoinUserEvents::new(self.inner.clone())
2345    }
2346
2347    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2348    ///
2349    /// [google.longrunning.Operations]: longrunning::client::Operations
2350    pub fn list_operations(&self) -> super::builder::user_event_service::ListOperations {
2351        super::builder::user_event_service::ListOperations::new(self.inner.clone())
2352    }
2353
2354    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2355    ///
2356    /// [google.longrunning.Operations]: longrunning::client::Operations
2357    pub fn get_operation(&self) -> super::builder::user_event_service::GetOperation {
2358        super::builder::user_event_service::GetOperation::new(self.inner.clone())
2359    }
2360}