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