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