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