google_cloud_discoveryengine_v1/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 Discovery Engine API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_discoveryengine_v1::client::AssistantService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// ) -> anyhow::Result<()> {
29/// let client = AssistantService::builder().build().await?;
30/// let mut list = client.list_operations()
31/// /* set fields */
32/// .by_item();
33/// while let Some(item) = list.next().await.transpose()? {
34/// println!("{:?}", item);
35/// }
36/// Ok(())
37/// }
38/// ```
39///
40/// # Service Description
41///
42/// Service for managing Assistant configuration and assisting users.
43///
44/// # Configuration
45///
46/// To configure `AssistantService` use the `with_*` methods in the type returned
47/// by [builder()][AssistantService::builder]. The default configuration should
48/// work for most applications. Common configuration changes include
49///
50/// * [with_endpoint()]: by default this client uses the global default endpoint
51/// (`https://discoveryengine.googleapis.com`). Applications using regional
52/// endpoints or running in restricted networks (e.g. a network configured
53/// with [Private Google Access with VPC Service Controls]) may want to
54/// override this default.
55/// * [with_credentials()]: by default this client uses
56/// [Application Default Credentials]. Applications using custom
57/// authentication may need to override this default.
58///
59/// [with_endpoint()]: super::builder::assistant_service::ClientBuilder::with_endpoint
60/// [with_credentials()]: super::builder::assistant_service::ClientBuilder::with_credentials
61/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
62/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
63///
64/// # Pooling and Cloning
65///
66/// `AssistantService` holds a connection pool internally, it is advised to
67/// create one and reuse it. You do not need to wrap `AssistantService` in
68/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
69/// already uses an `Arc` internally.
70#[cfg(feature = "assistant-service")]
71#[cfg_attr(docsrs, doc(cfg(feature = "assistant-service")))]
72#[derive(Clone, Debug)]
73pub struct AssistantService {
74 inner: std::sync::Arc<dyn super::stub::dynamic::AssistantService>,
75}
76
77#[cfg(feature = "assistant-service")]
78impl AssistantService {
79 /// Returns a builder for [AssistantService].
80 ///
81 /// ```
82 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
83 /// # use google_cloud_discoveryengine_v1::client::AssistantService;
84 /// let client = AssistantService::builder().build().await?;
85 /// # Ok(()) }
86 /// ```
87 pub fn builder() -> super::builder::assistant_service::ClientBuilder {
88 crate::new_client_builder(super::builder::assistant_service::client::Factory)
89 }
90
91 /// Creates a new client from the provided stub.
92 ///
93 /// The most common case for calling this function is in tests mocking the
94 /// client's behavior.
95 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
96 where
97 T: super::stub::AssistantService + 'static,
98 {
99 Self { inner: stub.into() }
100 }
101
102 pub(crate) async fn new(
103 config: gaxi::options::ClientConfig,
104 ) -> crate::ClientBuilderResult<Self> {
105 let inner = Self::build_inner(config).await?;
106 Ok(Self { inner })
107 }
108
109 async fn build_inner(
110 conf: gaxi::options::ClientConfig,
111 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::AssistantService>>
112 {
113 if gaxi::options::tracing_enabled(&conf) {
114 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
115 }
116 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
117 }
118
119 async fn build_transport(
120 conf: gaxi::options::ClientConfig,
121 ) -> crate::ClientBuilderResult<impl super::stub::AssistantService> {
122 super::transport::AssistantService::new(conf).await
123 }
124
125 async fn build_with_tracing(
126 conf: gaxi::options::ClientConfig,
127 ) -> crate::ClientBuilderResult<impl super::stub::AssistantService> {
128 Self::build_transport(conf)
129 .await
130 .map(super::tracing::AssistantService::new)
131 }
132
133 /// Assists the user with a query in a streaming fashion.
134 ///
135 /// # Example
136 /// ```
137 /// # use google_cloud_discoveryengine_v1::client::AssistantService;
138 /// use google_cloud_discoveryengine_v1::Result;
139 /// async fn sample(
140 /// client: &AssistantService
141 /// ) -> Result<()> {
142 /// let mut resp_stream = client.stream_assist()
143 /// /* set fields */
144 /// .send().await?;
145 /// while let Some(response) = resp_stream.next().await {
146 /// let response = response?;
147 /// println!("response {:?}", response);
148 /// }
149 /// Ok(())
150 /// }
151 /// ```
152 pub fn stream_assist(&self) -> super::builder::assistant_service::StreamAssist {
153 super::builder::assistant_service::StreamAssist::new(self.inner.clone())
154 }
155
156 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
157 ///
158 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
159 ///
160 /// # Example
161 /// ```
162 /// # use google_cloud_discoveryengine_v1::client::AssistantService;
163 /// use google_cloud_gax::paginator::ItemPaginator as _;
164 /// use google_cloud_discoveryengine_v1::Result;
165 /// async fn sample(
166 /// client: &AssistantService
167 /// ) -> Result<()> {
168 /// let mut list = client.list_operations()
169 /// /* set fields */
170 /// .by_item();
171 /// while let Some(item) = list.next().await.transpose()? {
172 /// println!("{:?}", item);
173 /// }
174 /// Ok(())
175 /// }
176 /// ```
177 pub fn list_operations(&self) -> super::builder::assistant_service::ListOperations {
178 super::builder::assistant_service::ListOperations::new(self.inner.clone())
179 }
180
181 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
182 ///
183 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
184 ///
185 /// # Example
186 /// ```
187 /// # use google_cloud_discoveryengine_v1::client::AssistantService;
188 /// use google_cloud_discoveryengine_v1::Result;
189 /// async fn sample(
190 /// client: &AssistantService
191 /// ) -> Result<()> {
192 /// let response = client.get_operation()
193 /// /* set fields */
194 /// .send().await?;
195 /// println!("response {:?}", response);
196 /// Ok(())
197 /// }
198 /// ```
199 pub fn get_operation(&self) -> super::builder::assistant_service::GetOperation {
200 super::builder::assistant_service::GetOperation::new(self.inner.clone())
201 }
202
203 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
204 ///
205 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
206 ///
207 /// # Example
208 /// ```
209 /// # use google_cloud_discoveryengine_v1::client::AssistantService;
210 /// use google_cloud_discoveryengine_v1::Result;
211 /// async fn sample(
212 /// client: &AssistantService
213 /// ) -> Result<()> {
214 /// client.cancel_operation()
215 /// /* set fields */
216 /// .send().await?;
217 /// Ok(())
218 /// }
219 /// ```
220 pub fn cancel_operation(&self) -> super::builder::assistant_service::CancelOperation {
221 super::builder::assistant_service::CancelOperation::new(self.inner.clone())
222 }
223}
224
225/// Implements a client for the Discovery Engine API.
226///
227/// # Example
228/// ```
229/// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
230/// async fn sample(
231/// project_id: &str,
232/// location_id: &str,
233/// ) -> anyhow::Result<()> {
234/// let client = CmekConfigService::builder().build().await?;
235/// let response = client.get_cmek_config()
236/// .set_name(format!("projects/{project_id}/locations/{location_id}/cmekConfig"))
237/// .send().await?;
238/// println!("response {:?}", response);
239/// Ok(())
240/// }
241/// ```
242///
243/// # Service Description
244///
245/// Service for managing CMEK related tasks
246///
247/// # Configuration
248///
249/// To configure `CmekConfigService` use the `with_*` methods in the type returned
250/// by [builder()][CmekConfigService::builder]. The default configuration should
251/// work for most applications. Common configuration changes include
252///
253/// * [with_endpoint()]: by default this client uses the global default endpoint
254/// (`https://discoveryengine.googleapis.com`). Applications using regional
255/// endpoints or running in restricted networks (e.g. a network configured
256/// with [Private Google Access with VPC Service Controls]) may want to
257/// override this default.
258/// * [with_credentials()]: by default this client uses
259/// [Application Default Credentials]. Applications using custom
260/// authentication may need to override this default.
261///
262/// [with_endpoint()]: super::builder::cmek_config_service::ClientBuilder::with_endpoint
263/// [with_credentials()]: super::builder::cmek_config_service::ClientBuilder::with_credentials
264/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
265/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
266///
267/// # Pooling and Cloning
268///
269/// `CmekConfigService` holds a connection pool internally, it is advised to
270/// create one and reuse it. You do not need to wrap `CmekConfigService` in
271/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
272/// already uses an `Arc` internally.
273#[cfg(feature = "cmek-config-service")]
274#[cfg_attr(docsrs, doc(cfg(feature = "cmek-config-service")))]
275#[derive(Clone, Debug)]
276pub struct CmekConfigService {
277 inner: std::sync::Arc<dyn super::stub::dynamic::CmekConfigService>,
278}
279
280#[cfg(feature = "cmek-config-service")]
281impl CmekConfigService {
282 /// Returns a builder for [CmekConfigService].
283 ///
284 /// ```
285 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
286 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
287 /// let client = CmekConfigService::builder().build().await?;
288 /// # Ok(()) }
289 /// ```
290 pub fn builder() -> super::builder::cmek_config_service::ClientBuilder {
291 crate::new_client_builder(super::builder::cmek_config_service::client::Factory)
292 }
293
294 /// Creates a new client from the provided stub.
295 ///
296 /// The most common case for calling this function is in tests mocking the
297 /// client's behavior.
298 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
299 where
300 T: super::stub::CmekConfigService + 'static,
301 {
302 Self { inner: stub.into() }
303 }
304
305 pub(crate) async fn new(
306 config: gaxi::options::ClientConfig,
307 ) -> crate::ClientBuilderResult<Self> {
308 let inner = Self::build_inner(config).await?;
309 Ok(Self { inner })
310 }
311
312 async fn build_inner(
313 conf: gaxi::options::ClientConfig,
314 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CmekConfigService>>
315 {
316 if gaxi::options::tracing_enabled(&conf) {
317 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
318 }
319 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
320 }
321
322 async fn build_transport(
323 conf: gaxi::options::ClientConfig,
324 ) -> crate::ClientBuilderResult<impl super::stub::CmekConfigService> {
325 super::transport::CmekConfigService::new(conf).await
326 }
327
328 async fn build_with_tracing(
329 conf: gaxi::options::ClientConfig,
330 ) -> crate::ClientBuilderResult<impl super::stub::CmekConfigService> {
331 Self::build_transport(conf)
332 .await
333 .map(super::tracing::CmekConfigService::new)
334 }
335
336 /// Provisions a CMEK key for use in a location of a customer's project.
337 /// This method will also conduct location validation on the provided
338 /// cmekConfig to make sure the key is valid and can be used in the
339 /// selected location.
340 ///
341 /// # Long running operations
342 ///
343 /// This method is used to start, and/or poll a [long-running Operation].
344 /// The [Working with long-running operations] chapter in the [user guide]
345 /// covers these operations in detail.
346 ///
347 /// [long-running operation]: https://google.aip.dev/151
348 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
349 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
350 ///
351 /// # Example
352 /// ```
353 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
354 /// use google_cloud_lro::Poller;
355 /// use google_cloud_discoveryengine_v1::model::CmekConfig;
356 /// use google_cloud_discoveryengine_v1::Result;
357 /// async fn sample(
358 /// client: &CmekConfigService, project_id: &str, location_id: &str
359 /// ) -> Result<()> {
360 /// let response = client.update_cmek_config()
361 /// .set_config(
362 /// CmekConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/cmekConfig"))/* set fields */
363 /// )
364 /// .poller().until_done().await?;
365 /// println!("response {:?}", response);
366 /// Ok(())
367 /// }
368 /// ```
369 pub fn update_cmek_config(&self) -> super::builder::cmek_config_service::UpdateCmekConfig {
370 super::builder::cmek_config_service::UpdateCmekConfig::new(self.inner.clone())
371 }
372
373 /// Gets the [CmekConfig][google.cloud.discoveryengine.v1.CmekConfig].
374 ///
375 /// [google.cloud.discoveryengine.v1.CmekConfig]: crate::model::CmekConfig
376 ///
377 /// # Example
378 /// ```
379 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
380 /// use google_cloud_discoveryengine_v1::Result;
381 /// async fn sample(
382 /// client: &CmekConfigService, project_id: &str, location_id: &str
383 /// ) -> Result<()> {
384 /// let response = client.get_cmek_config()
385 /// .set_name(format!("projects/{project_id}/locations/{location_id}/cmekConfig"))
386 /// .send().await?;
387 /// println!("response {:?}", response);
388 /// Ok(())
389 /// }
390 /// ```
391 pub fn get_cmek_config(&self) -> super::builder::cmek_config_service::GetCmekConfig {
392 super::builder::cmek_config_service::GetCmekConfig::new(self.inner.clone())
393 }
394
395 /// Lists all the [CmekConfig][google.cloud.discoveryengine.v1.CmekConfig]s
396 /// with the project.
397 ///
398 /// [google.cloud.discoveryengine.v1.CmekConfig]: crate::model::CmekConfig
399 ///
400 /// # Example
401 /// ```
402 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
403 /// use google_cloud_discoveryengine_v1::Result;
404 /// async fn sample(
405 /// client: &CmekConfigService
406 /// ) -> Result<()> {
407 /// let response = client.list_cmek_configs()
408 /// /* set fields */
409 /// .send().await?;
410 /// println!("response {:?}", response);
411 /// Ok(())
412 /// }
413 /// ```
414 pub fn list_cmek_configs(&self) -> super::builder::cmek_config_service::ListCmekConfigs {
415 super::builder::cmek_config_service::ListCmekConfigs::new(self.inner.clone())
416 }
417
418 /// De-provisions a CmekConfig.
419 ///
420 /// # Long running operations
421 ///
422 /// This method is used to start, and/or poll a [long-running Operation].
423 /// The [Working with long-running operations] chapter in the [user guide]
424 /// covers these operations in detail.
425 ///
426 /// [long-running operation]: https://google.aip.dev/151
427 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
428 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
429 ///
430 /// # Example
431 /// ```
432 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
433 /// use google_cloud_lro::Poller;
434 /// use google_cloud_discoveryengine_v1::Result;
435 /// async fn sample(
436 /// client: &CmekConfigService, project_id: &str, location_id: &str
437 /// ) -> Result<()> {
438 /// client.delete_cmek_config()
439 /// .set_name(format!("projects/{project_id}/locations/{location_id}/cmekConfig"))
440 /// .poller().until_done().await?;
441 /// Ok(())
442 /// }
443 /// ```
444 pub fn delete_cmek_config(&self) -> super::builder::cmek_config_service::DeleteCmekConfig {
445 super::builder::cmek_config_service::DeleteCmekConfig::new(self.inner.clone())
446 }
447
448 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
449 ///
450 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
451 ///
452 /// # Example
453 /// ```
454 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
455 /// use google_cloud_gax::paginator::ItemPaginator as _;
456 /// use google_cloud_discoveryengine_v1::Result;
457 /// async fn sample(
458 /// client: &CmekConfigService
459 /// ) -> Result<()> {
460 /// let mut list = client.list_operations()
461 /// /* set fields */
462 /// .by_item();
463 /// while let Some(item) = list.next().await.transpose()? {
464 /// println!("{:?}", item);
465 /// }
466 /// Ok(())
467 /// }
468 /// ```
469 pub fn list_operations(&self) -> super::builder::cmek_config_service::ListOperations {
470 super::builder::cmek_config_service::ListOperations::new(self.inner.clone())
471 }
472
473 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
474 ///
475 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
476 ///
477 /// # Example
478 /// ```
479 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
480 /// use google_cloud_discoveryengine_v1::Result;
481 /// async fn sample(
482 /// client: &CmekConfigService
483 /// ) -> Result<()> {
484 /// let response = client.get_operation()
485 /// /* set fields */
486 /// .send().await?;
487 /// println!("response {:?}", response);
488 /// Ok(())
489 /// }
490 /// ```
491 pub fn get_operation(&self) -> super::builder::cmek_config_service::GetOperation {
492 super::builder::cmek_config_service::GetOperation::new(self.inner.clone())
493 }
494
495 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
496 ///
497 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
498 ///
499 /// # Example
500 /// ```
501 /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
502 /// use google_cloud_discoveryengine_v1::Result;
503 /// async fn sample(
504 /// client: &CmekConfigService
505 /// ) -> Result<()> {
506 /// client.cancel_operation()
507 /// /* set fields */
508 /// .send().await?;
509 /// Ok(())
510 /// }
511 /// ```
512 pub fn cancel_operation(&self) -> super::builder::cmek_config_service::CancelOperation {
513 super::builder::cmek_config_service::CancelOperation::new(self.inner.clone())
514 }
515}
516
517/// Implements a client for the Discovery Engine API.
518///
519/// # Example
520/// ```
521/// # use google_cloud_discoveryengine_v1::client::CompletionService;
522/// use google_cloud_lro::Poller;
523/// async fn sample(
524/// ) -> anyhow::Result<()> {
525/// let client = CompletionService::builder().build().await?;
526/// let response = client.import_completion_suggestions()
527/// /* set fields */
528/// .poller().until_done().await?;
529/// println!("response {:?}", response);
530/// Ok(())
531/// }
532/// ```
533///
534/// # Service Description
535///
536/// Service for Auto-Completion.
537///
538/// # Configuration
539///
540/// To configure `CompletionService` use the `with_*` methods in the type returned
541/// by [builder()][CompletionService::builder]. The default configuration should
542/// work for most applications. Common configuration changes include
543///
544/// * [with_endpoint()]: by default this client uses the global default endpoint
545/// (`https://discoveryengine.googleapis.com`). Applications using regional
546/// endpoints or running in restricted networks (e.g. a network configured
547/// with [Private Google Access with VPC Service Controls]) may want to
548/// override this default.
549/// * [with_credentials()]: by default this client uses
550/// [Application Default Credentials]. Applications using custom
551/// authentication may need to override this default.
552///
553/// [with_endpoint()]: super::builder::completion_service::ClientBuilder::with_endpoint
554/// [with_credentials()]: super::builder::completion_service::ClientBuilder::with_credentials
555/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
556/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
557///
558/// # Pooling and Cloning
559///
560/// `CompletionService` holds a connection pool internally, it is advised to
561/// create one and reuse it. You do not need to wrap `CompletionService` in
562/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
563/// already uses an `Arc` internally.
564#[cfg(feature = "completion-service")]
565#[cfg_attr(docsrs, doc(cfg(feature = "completion-service")))]
566#[derive(Clone, Debug)]
567pub struct CompletionService {
568 inner: std::sync::Arc<dyn super::stub::dynamic::CompletionService>,
569}
570
571#[cfg(feature = "completion-service")]
572impl CompletionService {
573 /// Returns a builder for [CompletionService].
574 ///
575 /// ```
576 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
577 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
578 /// let client = CompletionService::builder().build().await?;
579 /// # Ok(()) }
580 /// ```
581 pub fn builder() -> super::builder::completion_service::ClientBuilder {
582 crate::new_client_builder(super::builder::completion_service::client::Factory)
583 }
584
585 /// Creates a new client from the provided stub.
586 ///
587 /// The most common case for calling this function is in tests mocking the
588 /// client's behavior.
589 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
590 where
591 T: super::stub::CompletionService + 'static,
592 {
593 Self { inner: stub.into() }
594 }
595
596 pub(crate) async fn new(
597 config: gaxi::options::ClientConfig,
598 ) -> crate::ClientBuilderResult<Self> {
599 let inner = Self::build_inner(config).await?;
600 Ok(Self { inner })
601 }
602
603 async fn build_inner(
604 conf: gaxi::options::ClientConfig,
605 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CompletionService>>
606 {
607 if gaxi::options::tracing_enabled(&conf) {
608 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
609 }
610 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
611 }
612
613 async fn build_transport(
614 conf: gaxi::options::ClientConfig,
615 ) -> crate::ClientBuilderResult<impl super::stub::CompletionService> {
616 super::transport::CompletionService::new(conf).await
617 }
618
619 async fn build_with_tracing(
620 conf: gaxi::options::ClientConfig,
621 ) -> crate::ClientBuilderResult<impl super::stub::CompletionService> {
622 Self::build_transport(conf)
623 .await
624 .map(super::tracing::CompletionService::new)
625 }
626
627 /// Completes the specified user input with keyword suggestions.
628 ///
629 /// # Example
630 /// ```
631 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
632 /// use google_cloud_discoveryengine_v1::Result;
633 /// async fn sample(
634 /// client: &CompletionService
635 /// ) -> Result<()> {
636 /// let response = client.complete_query()
637 /// /* set fields */
638 /// .send().await?;
639 /// println!("response {:?}", response);
640 /// Ok(())
641 /// }
642 /// ```
643 pub fn complete_query(&self) -> super::builder::completion_service::CompleteQuery {
644 super::builder::completion_service::CompleteQuery::new(self.inner.clone())
645 }
646
647 /// Imports all
648 /// [SuggestionDenyListEntry][google.cloud.discoveryengine.v1.SuggestionDenyListEntry]
649 /// for a DataStore.
650 ///
651 /// [google.cloud.discoveryengine.v1.SuggestionDenyListEntry]: crate::model::SuggestionDenyListEntry
652 ///
653 /// # Long running operations
654 ///
655 /// This method is used to start, and/or poll a [long-running Operation].
656 /// The [Working with long-running operations] chapter in the [user guide]
657 /// covers these operations in detail.
658 ///
659 /// [long-running operation]: https://google.aip.dev/151
660 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
661 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
662 ///
663 /// # Example
664 /// ```
665 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
666 /// use google_cloud_lro::Poller;
667 /// use google_cloud_discoveryengine_v1::Result;
668 /// async fn sample(
669 /// client: &CompletionService
670 /// ) -> Result<()> {
671 /// let response = client.import_suggestion_deny_list_entries()
672 /// /* set fields */
673 /// .poller().until_done().await?;
674 /// println!("response {:?}", response);
675 /// Ok(())
676 /// }
677 /// ```
678 pub fn import_suggestion_deny_list_entries(
679 &self,
680 ) -> super::builder::completion_service::ImportSuggestionDenyListEntries {
681 super::builder::completion_service::ImportSuggestionDenyListEntries::new(self.inner.clone())
682 }
683
684 /// Permanently deletes all
685 /// [SuggestionDenyListEntry][google.cloud.discoveryengine.v1.SuggestionDenyListEntry]
686 /// for a DataStore.
687 ///
688 /// [google.cloud.discoveryengine.v1.SuggestionDenyListEntry]: crate::model::SuggestionDenyListEntry
689 ///
690 /// # Long running operations
691 ///
692 /// This method is used to start, and/or poll a [long-running Operation].
693 /// The [Working with long-running operations] chapter in the [user guide]
694 /// covers these operations in detail.
695 ///
696 /// [long-running operation]: https://google.aip.dev/151
697 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
698 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
699 ///
700 /// # Example
701 /// ```
702 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
703 /// use google_cloud_lro::Poller;
704 /// use google_cloud_discoveryengine_v1::Result;
705 /// async fn sample(
706 /// client: &CompletionService
707 /// ) -> Result<()> {
708 /// let response = client.purge_suggestion_deny_list_entries()
709 /// /* set fields */
710 /// .poller().until_done().await?;
711 /// println!("response {:?}", response);
712 /// Ok(())
713 /// }
714 /// ```
715 pub fn purge_suggestion_deny_list_entries(
716 &self,
717 ) -> super::builder::completion_service::PurgeSuggestionDenyListEntries {
718 super::builder::completion_service::PurgeSuggestionDenyListEntries::new(self.inner.clone())
719 }
720
721 /// Imports
722 /// [CompletionSuggestion][google.cloud.discoveryengine.v1.CompletionSuggestion]s
723 /// for a DataStore.
724 ///
725 /// [google.cloud.discoveryengine.v1.CompletionSuggestion]: crate::model::CompletionSuggestion
726 ///
727 /// # Long running operations
728 ///
729 /// This method is used to start, and/or poll a [long-running Operation].
730 /// The [Working with long-running operations] chapter in the [user guide]
731 /// covers these operations in detail.
732 ///
733 /// [long-running operation]: https://google.aip.dev/151
734 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
735 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
736 ///
737 /// # Example
738 /// ```
739 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
740 /// use google_cloud_lro::Poller;
741 /// use google_cloud_discoveryengine_v1::Result;
742 /// async fn sample(
743 /// client: &CompletionService
744 /// ) -> Result<()> {
745 /// let response = client.import_completion_suggestions()
746 /// /* set fields */
747 /// .poller().until_done().await?;
748 /// println!("response {:?}", response);
749 /// Ok(())
750 /// }
751 /// ```
752 pub fn import_completion_suggestions(
753 &self,
754 ) -> super::builder::completion_service::ImportCompletionSuggestions {
755 super::builder::completion_service::ImportCompletionSuggestions::new(self.inner.clone())
756 }
757
758 /// Permanently deletes all
759 /// [CompletionSuggestion][google.cloud.discoveryengine.v1.CompletionSuggestion]s
760 /// for a DataStore.
761 ///
762 /// [google.cloud.discoveryengine.v1.CompletionSuggestion]: crate::model::CompletionSuggestion
763 ///
764 /// # Long running operations
765 ///
766 /// This method is used to start, and/or poll a [long-running Operation].
767 /// The [Working with long-running operations] chapter in the [user guide]
768 /// covers these operations in detail.
769 ///
770 /// [long-running operation]: https://google.aip.dev/151
771 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
772 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
773 ///
774 /// # Example
775 /// ```
776 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
777 /// use google_cloud_lro::Poller;
778 /// use google_cloud_discoveryengine_v1::Result;
779 /// async fn sample(
780 /// client: &CompletionService
781 /// ) -> Result<()> {
782 /// let response = client.purge_completion_suggestions()
783 /// /* set fields */
784 /// .poller().until_done().await?;
785 /// println!("response {:?}", response);
786 /// Ok(())
787 /// }
788 /// ```
789 pub fn purge_completion_suggestions(
790 &self,
791 ) -> super::builder::completion_service::PurgeCompletionSuggestions {
792 super::builder::completion_service::PurgeCompletionSuggestions::new(self.inner.clone())
793 }
794
795 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
796 ///
797 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
798 ///
799 /// # Example
800 /// ```
801 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
802 /// use google_cloud_gax::paginator::ItemPaginator as _;
803 /// use google_cloud_discoveryengine_v1::Result;
804 /// async fn sample(
805 /// client: &CompletionService
806 /// ) -> Result<()> {
807 /// let mut list = client.list_operations()
808 /// /* set fields */
809 /// .by_item();
810 /// while let Some(item) = list.next().await.transpose()? {
811 /// println!("{:?}", item);
812 /// }
813 /// Ok(())
814 /// }
815 /// ```
816 pub fn list_operations(&self) -> super::builder::completion_service::ListOperations {
817 super::builder::completion_service::ListOperations::new(self.inner.clone())
818 }
819
820 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
821 ///
822 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
823 ///
824 /// # Example
825 /// ```
826 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
827 /// use google_cloud_discoveryengine_v1::Result;
828 /// async fn sample(
829 /// client: &CompletionService
830 /// ) -> Result<()> {
831 /// let response = client.get_operation()
832 /// /* set fields */
833 /// .send().await?;
834 /// println!("response {:?}", response);
835 /// Ok(())
836 /// }
837 /// ```
838 pub fn get_operation(&self) -> super::builder::completion_service::GetOperation {
839 super::builder::completion_service::GetOperation::new(self.inner.clone())
840 }
841
842 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
843 ///
844 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
845 ///
846 /// # Example
847 /// ```
848 /// # use google_cloud_discoveryengine_v1::client::CompletionService;
849 /// use google_cloud_discoveryengine_v1::Result;
850 /// async fn sample(
851 /// client: &CompletionService
852 /// ) -> Result<()> {
853 /// client.cancel_operation()
854 /// /* set fields */
855 /// .send().await?;
856 /// Ok(())
857 /// }
858 /// ```
859 pub fn cancel_operation(&self) -> super::builder::completion_service::CancelOperation {
860 super::builder::completion_service::CancelOperation::new(self.inner.clone())
861 }
862}
863
864/// Implements a client for the Discovery Engine API.
865///
866/// # Example
867/// ```
868/// # use google_cloud_discoveryengine_v1::client::ControlService;
869/// use google_cloud_gax::paginator::ItemPaginator as _;
870/// async fn sample(
871/// project_id: &str,
872/// location_id: &str,
873/// data_store_id: &str,
874/// ) -> anyhow::Result<()> {
875/// let client = ControlService::builder().build().await?;
876/// let mut list = client.list_controls()
877/// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
878/// .by_item();
879/// while let Some(item) = list.next().await.transpose()? {
880/// println!("{:?}", item);
881/// }
882/// Ok(())
883/// }
884/// ```
885///
886/// # Service Description
887///
888/// Service for performing CRUD operations on Controls.
889/// Controls allow for custom logic to be implemented in the serving path.
890/// Controls need to be attached to a Serving Config to be considered during a
891/// request.
892///
893/// # Configuration
894///
895/// To configure `ControlService` use the `with_*` methods in the type returned
896/// by [builder()][ControlService::builder]. The default configuration should
897/// work for most applications. Common configuration changes include
898///
899/// * [with_endpoint()]: by default this client uses the global default endpoint
900/// (`https://discoveryengine.googleapis.com`). Applications using regional
901/// endpoints or running in restricted networks (e.g. a network configured
902/// with [Private Google Access with VPC Service Controls]) may want to
903/// override this default.
904/// * [with_credentials()]: by default this client uses
905/// [Application Default Credentials]. Applications using custom
906/// authentication may need to override this default.
907///
908/// [with_endpoint()]: super::builder::control_service::ClientBuilder::with_endpoint
909/// [with_credentials()]: super::builder::control_service::ClientBuilder::with_credentials
910/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
911/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
912///
913/// # Pooling and Cloning
914///
915/// `ControlService` holds a connection pool internally, it is advised to
916/// create one and reuse it. You do not need to wrap `ControlService` in
917/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
918/// already uses an `Arc` internally.
919#[cfg(feature = "control-service")]
920#[cfg_attr(docsrs, doc(cfg(feature = "control-service")))]
921#[derive(Clone, Debug)]
922pub struct ControlService {
923 inner: std::sync::Arc<dyn super::stub::dynamic::ControlService>,
924}
925
926#[cfg(feature = "control-service")]
927impl ControlService {
928 /// Returns a builder for [ControlService].
929 ///
930 /// ```
931 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
932 /// # use google_cloud_discoveryengine_v1::client::ControlService;
933 /// let client = ControlService::builder().build().await?;
934 /// # Ok(()) }
935 /// ```
936 pub fn builder() -> super::builder::control_service::ClientBuilder {
937 crate::new_client_builder(super::builder::control_service::client::Factory)
938 }
939
940 /// Creates a new client from the provided stub.
941 ///
942 /// The most common case for calling this function is in tests mocking the
943 /// client's behavior.
944 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
945 where
946 T: super::stub::ControlService + 'static,
947 {
948 Self { inner: stub.into() }
949 }
950
951 pub(crate) async fn new(
952 config: gaxi::options::ClientConfig,
953 ) -> crate::ClientBuilderResult<Self> {
954 let inner = Self::build_inner(config).await?;
955 Ok(Self { inner })
956 }
957
958 async fn build_inner(
959 conf: gaxi::options::ClientConfig,
960 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ControlService>> {
961 if gaxi::options::tracing_enabled(&conf) {
962 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
963 }
964 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
965 }
966
967 async fn build_transport(
968 conf: gaxi::options::ClientConfig,
969 ) -> crate::ClientBuilderResult<impl super::stub::ControlService> {
970 super::transport::ControlService::new(conf).await
971 }
972
973 async fn build_with_tracing(
974 conf: gaxi::options::ClientConfig,
975 ) -> crate::ClientBuilderResult<impl super::stub::ControlService> {
976 Self::build_transport(conf)
977 .await
978 .map(super::tracing::ControlService::new)
979 }
980
981 /// Creates a Control.
982 ///
983 /// By default 1000 controls are allowed for a data store.
984 /// A request can be submitted to adjust this limit.
985 /// If the [Control][google.cloud.discoveryengine.v1.Control] to create already
986 /// exists, an ALREADY_EXISTS error is returned.
987 ///
988 /// [google.cloud.discoveryengine.v1.Control]: crate::model::Control
989 ///
990 /// # Example
991 /// ```
992 /// # use google_cloud_discoveryengine_v1::client::ControlService;
993 /// use google_cloud_discoveryengine_v1::model::Control;
994 /// use google_cloud_discoveryengine_v1::Result;
995 /// async fn sample(
996 /// client: &ControlService, project_id: &str, location_id: &str, data_store_id: &str
997 /// ) -> Result<()> {
998 /// let response = client.create_control()
999 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1000 /// .set_control_id("control_id_value")
1001 /// .set_control(
1002 /// Control::new()/* set fields */
1003 /// )
1004 /// .send().await?;
1005 /// println!("response {:?}", response);
1006 /// Ok(())
1007 /// }
1008 /// ```
1009 pub fn create_control(&self) -> super::builder::control_service::CreateControl {
1010 super::builder::control_service::CreateControl::new(self.inner.clone())
1011 }
1012
1013 /// Deletes a Control.
1014 ///
1015 /// If the [Control][google.cloud.discoveryengine.v1.Control] to delete does
1016 /// not exist, a NOT_FOUND error is returned.
1017 ///
1018 /// [google.cloud.discoveryengine.v1.Control]: crate::model::Control
1019 ///
1020 /// # Example
1021 /// ```
1022 /// # use google_cloud_discoveryengine_v1::client::ControlService;
1023 /// use google_cloud_discoveryengine_v1::Result;
1024 /// async fn sample(
1025 /// client: &ControlService, project_id: &str, location_id: &str, data_store_id: &str, control_id: &str
1026 /// ) -> Result<()> {
1027 /// client.delete_control()
1028 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/controls/{control_id}"))
1029 /// .send().await?;
1030 /// Ok(())
1031 /// }
1032 /// ```
1033 pub fn delete_control(&self) -> super::builder::control_service::DeleteControl {
1034 super::builder::control_service::DeleteControl::new(self.inner.clone())
1035 }
1036
1037 /// Updates a Control.
1038 ///
1039 /// [Control][google.cloud.discoveryengine.v1.Control] action type cannot be
1040 /// changed. If the [Control][google.cloud.discoveryengine.v1.Control] to
1041 /// update does not exist, a NOT_FOUND error is returned.
1042 ///
1043 /// [google.cloud.discoveryengine.v1.Control]: crate::model::Control
1044 ///
1045 /// # Example
1046 /// ```
1047 /// # use google_cloud_discoveryengine_v1::client::ControlService;
1048 /// # extern crate wkt as google_cloud_wkt;
1049 /// use google_cloud_wkt::FieldMask;
1050 /// use google_cloud_discoveryengine_v1::model::Control;
1051 /// use google_cloud_discoveryengine_v1::Result;
1052 /// async fn sample(
1053 /// client: &ControlService, project_id: &str, location_id: &str, data_store_id: &str, control_id: &str
1054 /// ) -> Result<()> {
1055 /// let response = client.update_control()
1056 /// .set_control(
1057 /// Control::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/controls/{control_id}"))/* set fields */
1058 /// )
1059 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1060 /// .send().await?;
1061 /// println!("response {:?}", response);
1062 /// Ok(())
1063 /// }
1064 /// ```
1065 pub fn update_control(&self) -> super::builder::control_service::UpdateControl {
1066 super::builder::control_service::UpdateControl::new(self.inner.clone())
1067 }
1068
1069 /// Gets a Control.
1070 ///
1071 /// # Example
1072 /// ```
1073 /// # use google_cloud_discoveryengine_v1::client::ControlService;
1074 /// use google_cloud_discoveryengine_v1::Result;
1075 /// async fn sample(
1076 /// client: &ControlService, project_id: &str, location_id: &str, data_store_id: &str, control_id: &str
1077 /// ) -> Result<()> {
1078 /// let response = client.get_control()
1079 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/controls/{control_id}"))
1080 /// .send().await?;
1081 /// println!("response {:?}", response);
1082 /// Ok(())
1083 /// }
1084 /// ```
1085 pub fn get_control(&self) -> super::builder::control_service::GetControl {
1086 super::builder::control_service::GetControl::new(self.inner.clone())
1087 }
1088
1089 /// Lists all Controls by their parent
1090 /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
1091 ///
1092 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1093 ///
1094 /// # Example
1095 /// ```
1096 /// # use google_cloud_discoveryengine_v1::client::ControlService;
1097 /// use google_cloud_gax::paginator::ItemPaginator as _;
1098 /// use google_cloud_discoveryengine_v1::Result;
1099 /// async fn sample(
1100 /// client: &ControlService, project_id: &str, location_id: &str, data_store_id: &str
1101 /// ) -> Result<()> {
1102 /// let mut list = client.list_controls()
1103 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1104 /// .by_item();
1105 /// while let Some(item) = list.next().await.transpose()? {
1106 /// println!("{:?}", item);
1107 /// }
1108 /// Ok(())
1109 /// }
1110 /// ```
1111 pub fn list_controls(&self) -> super::builder::control_service::ListControls {
1112 super::builder::control_service::ListControls::new(self.inner.clone())
1113 }
1114
1115 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1116 ///
1117 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1118 ///
1119 /// # Example
1120 /// ```
1121 /// # use google_cloud_discoveryengine_v1::client::ControlService;
1122 /// use google_cloud_gax::paginator::ItemPaginator as _;
1123 /// use google_cloud_discoveryengine_v1::Result;
1124 /// async fn sample(
1125 /// client: &ControlService
1126 /// ) -> Result<()> {
1127 /// let mut list = client.list_operations()
1128 /// /* set fields */
1129 /// .by_item();
1130 /// while let Some(item) = list.next().await.transpose()? {
1131 /// println!("{:?}", item);
1132 /// }
1133 /// Ok(())
1134 /// }
1135 /// ```
1136 pub fn list_operations(&self) -> super::builder::control_service::ListOperations {
1137 super::builder::control_service::ListOperations::new(self.inner.clone())
1138 }
1139
1140 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1141 ///
1142 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1143 ///
1144 /// # Example
1145 /// ```
1146 /// # use google_cloud_discoveryengine_v1::client::ControlService;
1147 /// use google_cloud_discoveryengine_v1::Result;
1148 /// async fn sample(
1149 /// client: &ControlService
1150 /// ) -> Result<()> {
1151 /// let response = client.get_operation()
1152 /// /* set fields */
1153 /// .send().await?;
1154 /// println!("response {:?}", response);
1155 /// Ok(())
1156 /// }
1157 /// ```
1158 pub fn get_operation(&self) -> super::builder::control_service::GetOperation {
1159 super::builder::control_service::GetOperation::new(self.inner.clone())
1160 }
1161
1162 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1163 ///
1164 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1165 ///
1166 /// # Example
1167 /// ```
1168 /// # use google_cloud_discoveryengine_v1::client::ControlService;
1169 /// use google_cloud_discoveryengine_v1::Result;
1170 /// async fn sample(
1171 /// client: &ControlService
1172 /// ) -> Result<()> {
1173 /// client.cancel_operation()
1174 /// /* set fields */
1175 /// .send().await?;
1176 /// Ok(())
1177 /// }
1178 /// ```
1179 pub fn cancel_operation(&self) -> super::builder::control_service::CancelOperation {
1180 super::builder::control_service::CancelOperation::new(self.inner.clone())
1181 }
1182}
1183
1184/// Implements a client for the Discovery Engine API.
1185///
1186/// # Example
1187/// ```
1188/// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1189/// use google_cloud_gax::paginator::ItemPaginator as _;
1190/// async fn sample(
1191/// project_id: &str,
1192/// location_id: &str,
1193/// data_store_id: &str,
1194/// ) -> anyhow::Result<()> {
1195/// let client = ConversationalSearchService::builder().build().await?;
1196/// let mut list = client.list_conversations()
1197/// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1198/// .by_item();
1199/// while let Some(item) = list.next().await.transpose()? {
1200/// println!("{:?}", item);
1201/// }
1202/// Ok(())
1203/// }
1204/// ```
1205///
1206/// # Service Description
1207///
1208/// Service for conversational search.
1209///
1210/// # Configuration
1211///
1212/// To configure `ConversationalSearchService` use the `with_*` methods in the type returned
1213/// by [builder()][ConversationalSearchService::builder]. The default configuration should
1214/// work for most applications. Common configuration changes include
1215///
1216/// * [with_endpoint()]: by default this client uses the global default endpoint
1217/// (`https://discoveryengine.googleapis.com`). Applications using regional
1218/// endpoints or running in restricted networks (e.g. a network configured
1219/// with [Private Google Access with VPC Service Controls]) may want to
1220/// override this default.
1221/// * [with_credentials()]: by default this client uses
1222/// [Application Default Credentials]. Applications using custom
1223/// authentication may need to override this default.
1224///
1225/// [with_endpoint()]: super::builder::conversational_search_service::ClientBuilder::with_endpoint
1226/// [with_credentials()]: super::builder::conversational_search_service::ClientBuilder::with_credentials
1227/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1228/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1229///
1230/// # Pooling and Cloning
1231///
1232/// `ConversationalSearchService` holds a connection pool internally, it is advised to
1233/// create one and reuse it. You do not need to wrap `ConversationalSearchService` in
1234/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1235/// already uses an `Arc` internally.
1236#[cfg(feature = "conversational-search-service")]
1237#[cfg_attr(docsrs, doc(cfg(feature = "conversational-search-service")))]
1238#[derive(Clone, Debug)]
1239pub struct ConversationalSearchService {
1240 inner: std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
1241}
1242
1243#[cfg(feature = "conversational-search-service")]
1244impl ConversationalSearchService {
1245 /// Returns a builder for [ConversationalSearchService].
1246 ///
1247 /// ```
1248 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1249 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1250 /// let client = ConversationalSearchService::builder().build().await?;
1251 /// # Ok(()) }
1252 /// ```
1253 pub fn builder() -> super::builder::conversational_search_service::ClientBuilder {
1254 crate::new_client_builder(super::builder::conversational_search_service::client::Factory)
1255 }
1256
1257 /// Creates a new client from the provided stub.
1258 ///
1259 /// The most common case for calling this function is in tests mocking the
1260 /// client's behavior.
1261 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1262 where
1263 T: super::stub::ConversationalSearchService + 'static,
1264 {
1265 Self { inner: stub.into() }
1266 }
1267
1268 pub(crate) async fn new(
1269 config: gaxi::options::ClientConfig,
1270 ) -> crate::ClientBuilderResult<Self> {
1271 let inner = Self::build_inner(config).await?;
1272 Ok(Self { inner })
1273 }
1274
1275 async fn build_inner(
1276 conf: gaxi::options::ClientConfig,
1277 ) -> crate::ClientBuilderResult<
1278 std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
1279 > {
1280 if gaxi::options::tracing_enabled(&conf) {
1281 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1282 }
1283 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1284 }
1285
1286 async fn build_transport(
1287 conf: gaxi::options::ClientConfig,
1288 ) -> crate::ClientBuilderResult<impl super::stub::ConversationalSearchService> {
1289 super::transport::ConversationalSearchService::new(conf).await
1290 }
1291
1292 async fn build_with_tracing(
1293 conf: gaxi::options::ClientConfig,
1294 ) -> crate::ClientBuilderResult<impl super::stub::ConversationalSearchService> {
1295 Self::build_transport(conf)
1296 .await
1297 .map(super::tracing::ConversationalSearchService::new)
1298 }
1299
1300 /// Converses a conversation.
1301 ///
1302 /// # Example
1303 /// ```
1304 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1305 /// use google_cloud_discoveryengine_v1::Result;
1306 /// async fn sample(
1307 /// client: &ConversationalSearchService
1308 /// ) -> Result<()> {
1309 /// let response = client.converse_conversation()
1310 /// /* set fields */
1311 /// .send().await?;
1312 /// println!("response {:?}", response);
1313 /// Ok(())
1314 /// }
1315 /// ```
1316 pub fn converse_conversation(
1317 &self,
1318 ) -> super::builder::conversational_search_service::ConverseConversation {
1319 super::builder::conversational_search_service::ConverseConversation::new(self.inner.clone())
1320 }
1321
1322 /// Creates a Conversation.
1323 ///
1324 /// If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to
1325 /// create already exists, an ALREADY_EXISTS error is returned.
1326 ///
1327 /// [google.cloud.discoveryengine.v1.Conversation]: crate::model::Conversation
1328 ///
1329 /// # Example
1330 /// ```
1331 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1332 /// use google_cloud_discoveryengine_v1::model::Conversation;
1333 /// use google_cloud_discoveryengine_v1::Result;
1334 /// async fn sample(
1335 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str
1336 /// ) -> Result<()> {
1337 /// let response = client.create_conversation()
1338 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1339 /// .set_conversation(
1340 /// Conversation::new()/* set fields */
1341 /// )
1342 /// .send().await?;
1343 /// println!("response {:?}", response);
1344 /// Ok(())
1345 /// }
1346 /// ```
1347 pub fn create_conversation(
1348 &self,
1349 ) -> super::builder::conversational_search_service::CreateConversation {
1350 super::builder::conversational_search_service::CreateConversation::new(self.inner.clone())
1351 }
1352
1353 /// Deletes a Conversation.
1354 ///
1355 /// If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to
1356 /// delete does not exist, a NOT_FOUND error is returned.
1357 ///
1358 /// [google.cloud.discoveryengine.v1.Conversation]: crate::model::Conversation
1359 ///
1360 /// # Example
1361 /// ```
1362 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1363 /// use google_cloud_discoveryengine_v1::Result;
1364 /// async fn sample(
1365 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str, conversation_id: &str
1366 /// ) -> Result<()> {
1367 /// client.delete_conversation()
1368 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/conversations/{conversation_id}"))
1369 /// .send().await?;
1370 /// Ok(())
1371 /// }
1372 /// ```
1373 pub fn delete_conversation(
1374 &self,
1375 ) -> super::builder::conversational_search_service::DeleteConversation {
1376 super::builder::conversational_search_service::DeleteConversation::new(self.inner.clone())
1377 }
1378
1379 /// Updates a Conversation.
1380 ///
1381 /// [Conversation][google.cloud.discoveryengine.v1.Conversation] action type
1382 /// cannot be changed. If the
1383 /// [Conversation][google.cloud.discoveryengine.v1.Conversation] to update does
1384 /// not exist, a NOT_FOUND error is returned.
1385 ///
1386 /// [google.cloud.discoveryengine.v1.Conversation]: crate::model::Conversation
1387 ///
1388 /// # Example
1389 /// ```
1390 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1391 /// # extern crate wkt as google_cloud_wkt;
1392 /// use google_cloud_wkt::FieldMask;
1393 /// use google_cloud_discoveryengine_v1::model::Conversation;
1394 /// use google_cloud_discoveryengine_v1::Result;
1395 /// async fn sample(
1396 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str, conversation_id: &str
1397 /// ) -> Result<()> {
1398 /// let response = client.update_conversation()
1399 /// .set_conversation(
1400 /// Conversation::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/conversations/{conversation_id}"))/* set fields */
1401 /// )
1402 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1403 /// .send().await?;
1404 /// println!("response {:?}", response);
1405 /// Ok(())
1406 /// }
1407 /// ```
1408 pub fn update_conversation(
1409 &self,
1410 ) -> super::builder::conversational_search_service::UpdateConversation {
1411 super::builder::conversational_search_service::UpdateConversation::new(self.inner.clone())
1412 }
1413
1414 /// Gets a Conversation.
1415 ///
1416 /// # Example
1417 /// ```
1418 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1419 /// use google_cloud_discoveryengine_v1::Result;
1420 /// async fn sample(
1421 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str, conversation_id: &str
1422 /// ) -> Result<()> {
1423 /// let response = client.get_conversation()
1424 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/conversations/{conversation_id}"))
1425 /// .send().await?;
1426 /// println!("response {:?}", response);
1427 /// Ok(())
1428 /// }
1429 /// ```
1430 pub fn get_conversation(
1431 &self,
1432 ) -> super::builder::conversational_search_service::GetConversation {
1433 super::builder::conversational_search_service::GetConversation::new(self.inner.clone())
1434 }
1435
1436 /// Lists all Conversations by their parent
1437 /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
1438 ///
1439 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1440 ///
1441 /// # Example
1442 /// ```
1443 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1444 /// use google_cloud_gax::paginator::ItemPaginator as _;
1445 /// use google_cloud_discoveryengine_v1::Result;
1446 /// async fn sample(
1447 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str
1448 /// ) -> Result<()> {
1449 /// let mut list = client.list_conversations()
1450 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1451 /// .by_item();
1452 /// while let Some(item) = list.next().await.transpose()? {
1453 /// println!("{:?}", item);
1454 /// }
1455 /// Ok(())
1456 /// }
1457 /// ```
1458 pub fn list_conversations(
1459 &self,
1460 ) -> super::builder::conversational_search_service::ListConversations {
1461 super::builder::conversational_search_service::ListConversations::new(self.inner.clone())
1462 }
1463
1464 /// Answer query method.
1465 ///
1466 /// # Example
1467 /// ```
1468 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1469 /// use google_cloud_discoveryengine_v1::Result;
1470 /// async fn sample(
1471 /// client: &ConversationalSearchService
1472 /// ) -> Result<()> {
1473 /// let response = client.answer_query()
1474 /// /* set fields */
1475 /// .send().await?;
1476 /// println!("response {:?}", response);
1477 /// Ok(())
1478 /// }
1479 /// ```
1480 pub fn answer_query(&self) -> super::builder::conversational_search_service::AnswerQuery {
1481 super::builder::conversational_search_service::AnswerQuery::new(self.inner.clone())
1482 }
1483
1484 /// Answer query method (streaming).
1485 ///
1486 /// It takes one
1487 /// [AnswerQueryRequest][google.cloud.discoveryengine.v1.AnswerQueryRequest]
1488 /// and returns multiple
1489 /// [AnswerQueryResponse][google.cloud.discoveryengine.v1.AnswerQueryResponse]
1490 /// messages in a stream.
1491 ///
1492 /// [google.cloud.discoveryengine.v1.AnswerQueryRequest]: crate::model::AnswerQueryRequest
1493 /// [google.cloud.discoveryengine.v1.AnswerQueryResponse]: crate::model::AnswerQueryResponse
1494 ///
1495 /// # Example
1496 /// ```
1497 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1498 /// use google_cloud_discoveryengine_v1::Result;
1499 /// async fn sample(
1500 /// client: &ConversationalSearchService
1501 /// ) -> Result<()> {
1502 /// let mut resp_stream = client.stream_answer_query()
1503 /// /* set fields */
1504 /// .send().await?;
1505 /// while let Some(response) = resp_stream.next().await {
1506 /// let response = response?;
1507 /// println!("response {:?}", response);
1508 /// }
1509 /// Ok(())
1510 /// }
1511 /// ```
1512 pub fn stream_answer_query(
1513 &self,
1514 ) -> super::builder::conversational_search_service::StreamAnswerQuery {
1515 super::builder::conversational_search_service::StreamAnswerQuery::new(self.inner.clone())
1516 }
1517
1518 /// Gets a Answer.
1519 ///
1520 /// # Example
1521 /// ```
1522 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1523 /// use google_cloud_discoveryengine_v1::Result;
1524 /// async fn sample(
1525 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str, session_id: &str, answer_id: &str
1526 /// ) -> Result<()> {
1527 /// let response = client.get_answer()
1528 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/sessions/{session_id}/answers/{answer_id}"))
1529 /// .send().await?;
1530 /// println!("response {:?}", response);
1531 /// Ok(())
1532 /// }
1533 /// ```
1534 pub fn get_answer(&self) -> super::builder::conversational_search_service::GetAnswer {
1535 super::builder::conversational_search_service::GetAnswer::new(self.inner.clone())
1536 }
1537
1538 /// Creates a Session.
1539 ///
1540 /// If the [Session][google.cloud.discoveryengine.v1.Session] to create already
1541 /// exists, an ALREADY_EXISTS error is returned.
1542 ///
1543 /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
1544 ///
1545 /// # Example
1546 /// ```
1547 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1548 /// use google_cloud_discoveryengine_v1::model::Session;
1549 /// use google_cloud_discoveryengine_v1::Result;
1550 /// async fn sample(
1551 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str
1552 /// ) -> Result<()> {
1553 /// let response = client.create_session()
1554 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1555 /// .set_session(
1556 /// Session::new()/* set fields */
1557 /// )
1558 /// .send().await?;
1559 /// println!("response {:?}", response);
1560 /// Ok(())
1561 /// }
1562 /// ```
1563 pub fn create_session(&self) -> super::builder::conversational_search_service::CreateSession {
1564 super::builder::conversational_search_service::CreateSession::new(self.inner.clone())
1565 }
1566
1567 /// Deletes a Session.
1568 ///
1569 /// If the [Session][google.cloud.discoveryengine.v1.Session] to delete does
1570 /// not exist, a NOT_FOUND error is returned.
1571 ///
1572 /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
1573 ///
1574 /// # Example
1575 /// ```
1576 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1577 /// use google_cloud_discoveryengine_v1::Result;
1578 /// async fn sample(
1579 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str, session_id: &str
1580 /// ) -> Result<()> {
1581 /// client.delete_session()
1582 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/sessions/{session_id}"))
1583 /// .send().await?;
1584 /// Ok(())
1585 /// }
1586 /// ```
1587 pub fn delete_session(&self) -> super::builder::conversational_search_service::DeleteSession {
1588 super::builder::conversational_search_service::DeleteSession::new(self.inner.clone())
1589 }
1590
1591 /// Updates a Session.
1592 ///
1593 /// [Session][google.cloud.discoveryengine.v1.Session] action type cannot be
1594 /// changed. If the [Session][google.cloud.discoveryengine.v1.Session] to
1595 /// update does not exist, a NOT_FOUND error is returned.
1596 ///
1597 /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
1598 ///
1599 /// # Example
1600 /// ```
1601 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1602 /// # extern crate wkt as google_cloud_wkt;
1603 /// use google_cloud_wkt::FieldMask;
1604 /// use google_cloud_discoveryengine_v1::model::Session;
1605 /// use google_cloud_discoveryengine_v1::Result;
1606 /// async fn sample(
1607 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str, session_id: &str
1608 /// ) -> Result<()> {
1609 /// let response = client.update_session()
1610 /// .set_session(
1611 /// Session::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/sessions/{session_id}"))/* set fields */
1612 /// )
1613 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1614 /// .send().await?;
1615 /// println!("response {:?}", response);
1616 /// Ok(())
1617 /// }
1618 /// ```
1619 pub fn update_session(&self) -> super::builder::conversational_search_service::UpdateSession {
1620 super::builder::conversational_search_service::UpdateSession::new(self.inner.clone())
1621 }
1622
1623 /// Gets a Session.
1624 ///
1625 /// # Example
1626 /// ```
1627 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1628 /// use google_cloud_discoveryengine_v1::Result;
1629 /// async fn sample(
1630 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str, session_id: &str
1631 /// ) -> Result<()> {
1632 /// let response = client.get_session()
1633 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/sessions/{session_id}"))
1634 /// .send().await?;
1635 /// println!("response {:?}", response);
1636 /// Ok(())
1637 /// }
1638 /// ```
1639 pub fn get_session(&self) -> super::builder::conversational_search_service::GetSession {
1640 super::builder::conversational_search_service::GetSession::new(self.inner.clone())
1641 }
1642
1643 /// Lists all Sessions by their parent
1644 /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
1645 ///
1646 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1647 ///
1648 /// # Example
1649 /// ```
1650 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1651 /// use google_cloud_gax::paginator::ItemPaginator as _;
1652 /// use google_cloud_discoveryengine_v1::Result;
1653 /// async fn sample(
1654 /// client: &ConversationalSearchService, project_id: &str, location_id: &str, data_store_id: &str
1655 /// ) -> Result<()> {
1656 /// let mut list = client.list_sessions()
1657 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1658 /// .by_item();
1659 /// while let Some(item) = list.next().await.transpose()? {
1660 /// println!("{:?}", item);
1661 /// }
1662 /// Ok(())
1663 /// }
1664 /// ```
1665 pub fn list_sessions(&self) -> super::builder::conversational_search_service::ListSessions {
1666 super::builder::conversational_search_service::ListSessions::new(self.inner.clone())
1667 }
1668
1669 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1670 ///
1671 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1672 ///
1673 /// # Example
1674 /// ```
1675 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1676 /// use google_cloud_gax::paginator::ItemPaginator as _;
1677 /// use google_cloud_discoveryengine_v1::Result;
1678 /// async fn sample(
1679 /// client: &ConversationalSearchService
1680 /// ) -> Result<()> {
1681 /// let mut list = client.list_operations()
1682 /// /* set fields */
1683 /// .by_item();
1684 /// while let Some(item) = list.next().await.transpose()? {
1685 /// println!("{:?}", item);
1686 /// }
1687 /// Ok(())
1688 /// }
1689 /// ```
1690 pub fn list_operations(&self) -> super::builder::conversational_search_service::ListOperations {
1691 super::builder::conversational_search_service::ListOperations::new(self.inner.clone())
1692 }
1693
1694 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1695 ///
1696 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1697 ///
1698 /// # Example
1699 /// ```
1700 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1701 /// use google_cloud_discoveryengine_v1::Result;
1702 /// async fn sample(
1703 /// client: &ConversationalSearchService
1704 /// ) -> Result<()> {
1705 /// let response = client.get_operation()
1706 /// /* set fields */
1707 /// .send().await?;
1708 /// println!("response {:?}", response);
1709 /// Ok(())
1710 /// }
1711 /// ```
1712 pub fn get_operation(&self) -> super::builder::conversational_search_service::GetOperation {
1713 super::builder::conversational_search_service::GetOperation::new(self.inner.clone())
1714 }
1715
1716 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1717 ///
1718 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1719 ///
1720 /// # Example
1721 /// ```
1722 /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
1723 /// use google_cloud_discoveryengine_v1::Result;
1724 /// async fn sample(
1725 /// client: &ConversationalSearchService
1726 /// ) -> Result<()> {
1727 /// client.cancel_operation()
1728 /// /* set fields */
1729 /// .send().await?;
1730 /// Ok(())
1731 /// }
1732 /// ```
1733 pub fn cancel_operation(
1734 &self,
1735 ) -> super::builder::conversational_search_service::CancelOperation {
1736 super::builder::conversational_search_service::CancelOperation::new(self.inner.clone())
1737 }
1738}
1739
1740/// Implements a client for the Discovery Engine API.
1741///
1742/// # Example
1743/// ```
1744/// # use google_cloud_discoveryengine_v1::client::DataStoreService;
1745/// use google_cloud_gax::paginator::ItemPaginator as _;
1746/// async fn sample(
1747/// parent: &str,
1748/// ) -> anyhow::Result<()> {
1749/// let client = DataStoreService::builder().build().await?;
1750/// let mut list = client.list_data_stores()
1751/// .set_parent(parent)
1752/// .by_item();
1753/// while let Some(item) = list.next().await.transpose()? {
1754/// println!("{:?}", item);
1755/// }
1756/// Ok(())
1757/// }
1758/// ```
1759///
1760/// # Service Description
1761///
1762/// Service for managing [DataStore][google.cloud.discoveryengine.v1.DataStore]
1763/// configuration.
1764///
1765/// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1766///
1767/// # Configuration
1768///
1769/// To configure `DataStoreService` use the `with_*` methods in the type returned
1770/// by [builder()][DataStoreService::builder]. The default configuration should
1771/// work for most applications. Common configuration changes include
1772///
1773/// * [with_endpoint()]: by default this client uses the global default endpoint
1774/// (`https://discoveryengine.googleapis.com`). Applications using regional
1775/// endpoints or running in restricted networks (e.g. a network configured
1776/// with [Private Google Access with VPC Service Controls]) may want to
1777/// override this default.
1778/// * [with_credentials()]: by default this client uses
1779/// [Application Default Credentials]. Applications using custom
1780/// authentication may need to override this default.
1781///
1782/// [with_endpoint()]: super::builder::data_store_service::ClientBuilder::with_endpoint
1783/// [with_credentials()]: super::builder::data_store_service::ClientBuilder::with_credentials
1784/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1785/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1786///
1787/// # Pooling and Cloning
1788///
1789/// `DataStoreService` holds a connection pool internally, it is advised to
1790/// create one and reuse it. You do not need to wrap `DataStoreService` in
1791/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1792/// already uses an `Arc` internally.
1793#[cfg(feature = "data-store-service")]
1794#[cfg_attr(docsrs, doc(cfg(feature = "data-store-service")))]
1795#[derive(Clone, Debug)]
1796pub struct DataStoreService {
1797 inner: std::sync::Arc<dyn super::stub::dynamic::DataStoreService>,
1798}
1799
1800#[cfg(feature = "data-store-service")]
1801impl DataStoreService {
1802 /// Returns a builder for [DataStoreService].
1803 ///
1804 /// ```
1805 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1806 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
1807 /// let client = DataStoreService::builder().build().await?;
1808 /// # Ok(()) }
1809 /// ```
1810 pub fn builder() -> super::builder::data_store_service::ClientBuilder {
1811 crate::new_client_builder(super::builder::data_store_service::client::Factory)
1812 }
1813
1814 /// Creates a new client from the provided stub.
1815 ///
1816 /// The most common case for calling this function is in tests mocking the
1817 /// client's behavior.
1818 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1819 where
1820 T: super::stub::DataStoreService + 'static,
1821 {
1822 Self { inner: stub.into() }
1823 }
1824
1825 pub(crate) async fn new(
1826 config: gaxi::options::ClientConfig,
1827 ) -> crate::ClientBuilderResult<Self> {
1828 let inner = Self::build_inner(config).await?;
1829 Ok(Self { inner })
1830 }
1831
1832 async fn build_inner(
1833 conf: gaxi::options::ClientConfig,
1834 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::DataStoreService>>
1835 {
1836 if gaxi::options::tracing_enabled(&conf) {
1837 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1838 }
1839 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1840 }
1841
1842 async fn build_transport(
1843 conf: gaxi::options::ClientConfig,
1844 ) -> crate::ClientBuilderResult<impl super::stub::DataStoreService> {
1845 super::transport::DataStoreService::new(conf).await
1846 }
1847
1848 async fn build_with_tracing(
1849 conf: gaxi::options::ClientConfig,
1850 ) -> crate::ClientBuilderResult<impl super::stub::DataStoreService> {
1851 Self::build_transport(conf)
1852 .await
1853 .map(super::tracing::DataStoreService::new)
1854 }
1855
1856 /// Creates a [DataStore][google.cloud.discoveryengine.v1.DataStore].
1857 ///
1858 /// DataStore is for storing
1859 /// [Documents][google.cloud.discoveryengine.v1.Document]. To serve these
1860 /// documents for Search, or Recommendation use case, an
1861 /// [Engine][google.cloud.discoveryengine.v1.Engine] needs to be created
1862 /// separately.
1863 ///
1864 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1865 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
1866 /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
1867 ///
1868 /// # Long running operations
1869 ///
1870 /// This method is used to start, and/or poll a [long-running Operation].
1871 /// The [Working with long-running operations] chapter in the [user guide]
1872 /// covers these operations in detail.
1873 ///
1874 /// [long-running operation]: https://google.aip.dev/151
1875 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1876 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1877 ///
1878 /// # Example
1879 /// ```
1880 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
1881 /// use google_cloud_lro::Poller;
1882 /// use google_cloud_discoveryengine_v1::model::DataStore;
1883 /// use google_cloud_discoveryengine_v1::Result;
1884 /// async fn sample(
1885 /// client: &DataStoreService, parent: &str
1886 /// ) -> Result<()> {
1887 /// let response = client.create_data_store()
1888 /// .set_parent(parent)
1889 /// .set_data_store(
1890 /// DataStore::new()/* set fields */
1891 /// )
1892 /// .poller().until_done().await?;
1893 /// println!("response {:?}", response);
1894 /// Ok(())
1895 /// }
1896 /// ```
1897 pub fn create_data_store(&self) -> super::builder::data_store_service::CreateDataStore {
1898 super::builder::data_store_service::CreateDataStore::new(self.inner.clone())
1899 }
1900
1901 /// Gets a [DataStore][google.cloud.discoveryengine.v1.DataStore].
1902 ///
1903 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1904 ///
1905 /// # Example
1906 /// ```
1907 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
1908 /// use google_cloud_discoveryengine_v1::Result;
1909 /// async fn sample(
1910 /// client: &DataStoreService, project_id: &str, location_id: &str, data_store_id: &str
1911 /// ) -> Result<()> {
1912 /// let response = client.get_data_store()
1913 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1914 /// .send().await?;
1915 /// println!("response {:?}", response);
1916 /// Ok(())
1917 /// }
1918 /// ```
1919 pub fn get_data_store(&self) -> super::builder::data_store_service::GetDataStore {
1920 super::builder::data_store_service::GetDataStore::new(self.inner.clone())
1921 }
1922
1923 /// Lists all the [DataStore][google.cloud.discoveryengine.v1.DataStore]s
1924 /// associated with the project.
1925 ///
1926 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1927 ///
1928 /// # Example
1929 /// ```
1930 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
1931 /// use google_cloud_gax::paginator::ItemPaginator as _;
1932 /// use google_cloud_discoveryengine_v1::Result;
1933 /// async fn sample(
1934 /// client: &DataStoreService, parent: &str
1935 /// ) -> Result<()> {
1936 /// let mut list = client.list_data_stores()
1937 /// .set_parent(parent)
1938 /// .by_item();
1939 /// while let Some(item) = list.next().await.transpose()? {
1940 /// println!("{:?}", item);
1941 /// }
1942 /// Ok(())
1943 /// }
1944 /// ```
1945 pub fn list_data_stores(&self) -> super::builder::data_store_service::ListDataStores {
1946 super::builder::data_store_service::ListDataStores::new(self.inner.clone())
1947 }
1948
1949 /// Deletes a [DataStore][google.cloud.discoveryengine.v1.DataStore].
1950 ///
1951 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1952 ///
1953 /// # Long running operations
1954 ///
1955 /// This method is used to start, and/or poll a [long-running Operation].
1956 /// The [Working with long-running operations] chapter in the [user guide]
1957 /// covers these operations in detail.
1958 ///
1959 /// [long-running operation]: https://google.aip.dev/151
1960 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1961 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1962 ///
1963 /// # Example
1964 /// ```
1965 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
1966 /// use google_cloud_lro::Poller;
1967 /// use google_cloud_discoveryengine_v1::Result;
1968 /// async fn sample(
1969 /// client: &DataStoreService, project_id: &str, location_id: &str, data_store_id: &str
1970 /// ) -> Result<()> {
1971 /// client.delete_data_store()
1972 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
1973 /// .poller().until_done().await?;
1974 /// Ok(())
1975 /// }
1976 /// ```
1977 pub fn delete_data_store(&self) -> super::builder::data_store_service::DeleteDataStore {
1978 super::builder::data_store_service::DeleteDataStore::new(self.inner.clone())
1979 }
1980
1981 /// Updates a [DataStore][google.cloud.discoveryengine.v1.DataStore]
1982 ///
1983 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
1984 ///
1985 /// # Example
1986 /// ```
1987 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
1988 /// # extern crate wkt as google_cloud_wkt;
1989 /// use google_cloud_wkt::FieldMask;
1990 /// use google_cloud_discoveryengine_v1::model::DataStore;
1991 /// use google_cloud_discoveryengine_v1::Result;
1992 /// async fn sample(
1993 /// client: &DataStoreService, project_id: &str, location_id: &str, data_store_id: &str
1994 /// ) -> Result<()> {
1995 /// let response = client.update_data_store()
1996 /// .set_data_store(
1997 /// DataStore::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))/* set fields */
1998 /// )
1999 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2000 /// .send().await?;
2001 /// println!("response {:?}", response);
2002 /// Ok(())
2003 /// }
2004 /// ```
2005 pub fn update_data_store(&self) -> super::builder::data_store_service::UpdateDataStore {
2006 super::builder::data_store_service::UpdateDataStore::new(self.inner.clone())
2007 }
2008
2009 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2010 ///
2011 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2012 ///
2013 /// # Example
2014 /// ```
2015 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
2016 /// use google_cloud_gax::paginator::ItemPaginator as _;
2017 /// use google_cloud_discoveryengine_v1::Result;
2018 /// async fn sample(
2019 /// client: &DataStoreService
2020 /// ) -> Result<()> {
2021 /// let mut list = client.list_operations()
2022 /// /* set fields */
2023 /// .by_item();
2024 /// while let Some(item) = list.next().await.transpose()? {
2025 /// println!("{:?}", item);
2026 /// }
2027 /// Ok(())
2028 /// }
2029 /// ```
2030 pub fn list_operations(&self) -> super::builder::data_store_service::ListOperations {
2031 super::builder::data_store_service::ListOperations::new(self.inner.clone())
2032 }
2033
2034 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2035 ///
2036 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2037 ///
2038 /// # Example
2039 /// ```
2040 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
2041 /// use google_cloud_discoveryengine_v1::Result;
2042 /// async fn sample(
2043 /// client: &DataStoreService
2044 /// ) -> Result<()> {
2045 /// let response = client.get_operation()
2046 /// /* set fields */
2047 /// .send().await?;
2048 /// println!("response {:?}", response);
2049 /// Ok(())
2050 /// }
2051 /// ```
2052 pub fn get_operation(&self) -> super::builder::data_store_service::GetOperation {
2053 super::builder::data_store_service::GetOperation::new(self.inner.clone())
2054 }
2055
2056 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2057 ///
2058 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2059 ///
2060 /// # Example
2061 /// ```
2062 /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
2063 /// use google_cloud_discoveryengine_v1::Result;
2064 /// async fn sample(
2065 /// client: &DataStoreService
2066 /// ) -> Result<()> {
2067 /// client.cancel_operation()
2068 /// /* set fields */
2069 /// .send().await?;
2070 /// Ok(())
2071 /// }
2072 /// ```
2073 pub fn cancel_operation(&self) -> super::builder::data_store_service::CancelOperation {
2074 super::builder::data_store_service::CancelOperation::new(self.inner.clone())
2075 }
2076}
2077
2078/// Implements a client for the Discovery Engine API.
2079///
2080/// # Example
2081/// ```
2082/// # use google_cloud_discoveryengine_v1::client::DocumentService;
2083/// use google_cloud_gax::paginator::ItemPaginator as _;
2084/// async fn sample(
2085/// parent: &str,
2086/// ) -> anyhow::Result<()> {
2087/// let client = DocumentService::builder().build().await?;
2088/// let mut list = client.list_documents()
2089/// .set_parent(parent)
2090/// .by_item();
2091/// while let Some(item) = list.next().await.transpose()? {
2092/// println!("{:?}", item);
2093/// }
2094/// Ok(())
2095/// }
2096/// ```
2097///
2098/// # Service Description
2099///
2100/// Service for ingesting [Document][google.cloud.discoveryengine.v1.Document]
2101/// information of the customer's website.
2102///
2103/// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2104///
2105/// # Configuration
2106///
2107/// To configure `DocumentService` use the `with_*` methods in the type returned
2108/// by [builder()][DocumentService::builder]. The default configuration should
2109/// work for most applications. Common configuration changes include
2110///
2111/// * [with_endpoint()]: by default this client uses the global default endpoint
2112/// (`https://discoveryengine.googleapis.com`). Applications using regional
2113/// endpoints or running in restricted networks (e.g. a network configured
2114/// with [Private Google Access with VPC Service Controls]) may want to
2115/// override this default.
2116/// * [with_credentials()]: by default this client uses
2117/// [Application Default Credentials]. Applications using custom
2118/// authentication may need to override this default.
2119///
2120/// [with_endpoint()]: super::builder::document_service::ClientBuilder::with_endpoint
2121/// [with_credentials()]: super::builder::document_service::ClientBuilder::with_credentials
2122/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2123/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2124///
2125/// # Pooling and Cloning
2126///
2127/// `DocumentService` holds a connection pool internally, it is advised to
2128/// create one and reuse it. You do not need to wrap `DocumentService` in
2129/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2130/// already uses an `Arc` internally.
2131#[cfg(feature = "document-service")]
2132#[cfg_attr(docsrs, doc(cfg(feature = "document-service")))]
2133#[derive(Clone, Debug)]
2134pub struct DocumentService {
2135 inner: std::sync::Arc<dyn super::stub::dynamic::DocumentService>,
2136}
2137
2138#[cfg(feature = "document-service")]
2139impl DocumentService {
2140 /// Returns a builder for [DocumentService].
2141 ///
2142 /// ```
2143 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2144 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2145 /// let client = DocumentService::builder().build().await?;
2146 /// # Ok(()) }
2147 /// ```
2148 pub fn builder() -> super::builder::document_service::ClientBuilder {
2149 crate::new_client_builder(super::builder::document_service::client::Factory)
2150 }
2151
2152 /// Creates a new client from the provided stub.
2153 ///
2154 /// The most common case for calling this function is in tests mocking the
2155 /// client's behavior.
2156 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2157 where
2158 T: super::stub::DocumentService + 'static,
2159 {
2160 Self { inner: stub.into() }
2161 }
2162
2163 pub(crate) async fn new(
2164 config: gaxi::options::ClientConfig,
2165 ) -> crate::ClientBuilderResult<Self> {
2166 let inner = Self::build_inner(config).await?;
2167 Ok(Self { inner })
2168 }
2169
2170 async fn build_inner(
2171 conf: gaxi::options::ClientConfig,
2172 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::DocumentService>> {
2173 if gaxi::options::tracing_enabled(&conf) {
2174 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2175 }
2176 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2177 }
2178
2179 async fn build_transport(
2180 conf: gaxi::options::ClientConfig,
2181 ) -> crate::ClientBuilderResult<impl super::stub::DocumentService> {
2182 super::transport::DocumentService::new(conf).await
2183 }
2184
2185 async fn build_with_tracing(
2186 conf: gaxi::options::ClientConfig,
2187 ) -> crate::ClientBuilderResult<impl super::stub::DocumentService> {
2188 Self::build_transport(conf)
2189 .await
2190 .map(super::tracing::DocumentService::new)
2191 }
2192
2193 /// Gets a [Document][google.cloud.discoveryengine.v1.Document].
2194 ///
2195 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2196 ///
2197 /// # Example
2198 /// ```
2199 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2200 /// use google_cloud_discoveryengine_v1::Result;
2201 /// async fn sample(
2202 /// client: &DocumentService, project_id: &str, location_id: &str, data_store_id: &str, branch_id: &str, document_id: &str
2203 /// ) -> Result<()> {
2204 /// let response = client.get_document()
2205 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}"))
2206 /// .send().await?;
2207 /// println!("response {:?}", response);
2208 /// Ok(())
2209 /// }
2210 /// ```
2211 pub fn get_document(&self) -> super::builder::document_service::GetDocument {
2212 super::builder::document_service::GetDocument::new(self.inner.clone())
2213 }
2214
2215 /// Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.
2216 ///
2217 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2218 ///
2219 /// # Example
2220 /// ```
2221 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2222 /// use google_cloud_gax::paginator::ItemPaginator as _;
2223 /// use google_cloud_discoveryengine_v1::Result;
2224 /// async fn sample(
2225 /// client: &DocumentService, parent: &str
2226 /// ) -> Result<()> {
2227 /// let mut list = client.list_documents()
2228 /// .set_parent(parent)
2229 /// .by_item();
2230 /// while let Some(item) = list.next().await.transpose()? {
2231 /// println!("{:?}", item);
2232 /// }
2233 /// Ok(())
2234 /// }
2235 /// ```
2236 pub fn list_documents(&self) -> super::builder::document_service::ListDocuments {
2237 super::builder::document_service::ListDocuments::new(self.inner.clone())
2238 }
2239
2240 /// Creates a [Document][google.cloud.discoveryengine.v1.Document].
2241 ///
2242 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2243 ///
2244 /// # Example
2245 /// ```
2246 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2247 /// use google_cloud_discoveryengine_v1::model::Document;
2248 /// use google_cloud_discoveryengine_v1::Result;
2249 /// async fn sample(
2250 /// client: &DocumentService, parent: &str
2251 /// ) -> Result<()> {
2252 /// let response = client.create_document()
2253 /// .set_parent(parent)
2254 /// .set_document_id("document_id_value")
2255 /// .set_document(
2256 /// Document::new()/* set fields */
2257 /// )
2258 /// .send().await?;
2259 /// println!("response {:?}", response);
2260 /// Ok(())
2261 /// }
2262 /// ```
2263 pub fn create_document(&self) -> super::builder::document_service::CreateDocument {
2264 super::builder::document_service::CreateDocument::new(self.inner.clone())
2265 }
2266
2267 /// Updates a [Document][google.cloud.discoveryengine.v1.Document].
2268 ///
2269 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2270 ///
2271 /// # Example
2272 /// ```
2273 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2274 /// # extern crate wkt as google_cloud_wkt;
2275 /// use google_cloud_wkt::FieldMask;
2276 /// use google_cloud_discoveryengine_v1::model::Document;
2277 /// use google_cloud_discoveryengine_v1::Result;
2278 /// async fn sample(
2279 /// client: &DocumentService, project_id: &str, location_id: &str, data_store_id: &str, branch_id: &str, document_id: &str
2280 /// ) -> Result<()> {
2281 /// let response = client.update_document()
2282 /// .set_document(
2283 /// Document::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}"))/* set fields */
2284 /// )
2285 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2286 /// .send().await?;
2287 /// println!("response {:?}", response);
2288 /// Ok(())
2289 /// }
2290 /// ```
2291 pub fn update_document(&self) -> super::builder::document_service::UpdateDocument {
2292 super::builder::document_service::UpdateDocument::new(self.inner.clone())
2293 }
2294
2295 /// Deletes a [Document][google.cloud.discoveryengine.v1.Document].
2296 ///
2297 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2298 ///
2299 /// # Example
2300 /// ```
2301 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2302 /// use google_cloud_discoveryengine_v1::Result;
2303 /// async fn sample(
2304 /// client: &DocumentService, project_id: &str, location_id: &str, data_store_id: &str, branch_id: &str, document_id: &str
2305 /// ) -> Result<()> {
2306 /// client.delete_document()
2307 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}"))
2308 /// .send().await?;
2309 /// Ok(())
2310 /// }
2311 /// ```
2312 pub fn delete_document(&self) -> super::builder::document_service::DeleteDocument {
2313 super::builder::document_service::DeleteDocument::new(self.inner.clone())
2314 }
2315
2316 /// Bulk import of multiple
2317 /// [Document][google.cloud.discoveryengine.v1.Document]s. Request processing
2318 /// may be synchronous. Non-existing items are created.
2319 ///
2320 /// Note: It is possible for a subset of the
2321 /// [Document][google.cloud.discoveryengine.v1.Document]s to be successfully
2322 /// updated.
2323 ///
2324 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2325 ///
2326 /// # Long running operations
2327 ///
2328 /// This method is used to start, and/or poll a [long-running Operation].
2329 /// The [Working with long-running operations] chapter in the [user guide]
2330 /// covers these operations in detail.
2331 ///
2332 /// [long-running operation]: https://google.aip.dev/151
2333 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2334 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2335 ///
2336 /// # Example
2337 /// ```
2338 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2339 /// use google_cloud_lro::Poller;
2340 /// use google_cloud_discoveryengine_v1::Result;
2341 /// async fn sample(
2342 /// client: &DocumentService
2343 /// ) -> Result<()> {
2344 /// let response = client.import_documents()
2345 /// /* set fields */
2346 /// .poller().until_done().await?;
2347 /// println!("response {:?}", response);
2348 /// Ok(())
2349 /// }
2350 /// ```
2351 pub fn import_documents(&self) -> super::builder::document_service::ImportDocuments {
2352 super::builder::document_service::ImportDocuments::new(self.inner.clone())
2353 }
2354
2355 /// Permanently deletes all selected
2356 /// [Document][google.cloud.discoveryengine.v1.Document]s in a branch.
2357 ///
2358 /// This process is asynchronous. Depending on the number of
2359 /// [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this
2360 /// operation can take hours to complete. Before the delete operation
2361 /// completes, some [Document][google.cloud.discoveryengine.v1.Document]s might
2362 /// still be returned by
2363 /// [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument]
2364 /// or
2365 /// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments].
2366 ///
2367 /// To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s
2368 /// to be deleted, set
2369 /// [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force]
2370 /// to false.
2371 ///
2372 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2373 /// [google.cloud.discoveryengine.v1.DocumentService.GetDocument]: crate::client::DocumentService::get_document
2374 /// [google.cloud.discoveryengine.v1.DocumentService.ListDocuments]: crate::client::DocumentService::list_documents
2375 /// [google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force]: crate::model::PurgeDocumentsRequest::force
2376 ///
2377 /// # Long running operations
2378 ///
2379 /// This method is used to start, and/or poll a [long-running Operation].
2380 /// The [Working with long-running operations] chapter in the [user guide]
2381 /// covers these operations in detail.
2382 ///
2383 /// [long-running operation]: https://google.aip.dev/151
2384 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2385 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2386 ///
2387 /// # Example
2388 /// ```
2389 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2390 /// use google_cloud_lro::Poller;
2391 /// use google_cloud_discoveryengine_v1::Result;
2392 /// async fn sample(
2393 /// client: &DocumentService
2394 /// ) -> Result<()> {
2395 /// let response = client.purge_documents()
2396 /// /* set fields */
2397 /// .poller().until_done().await?;
2398 /// println!("response {:?}", response);
2399 /// Ok(())
2400 /// }
2401 /// ```
2402 pub fn purge_documents(&self) -> super::builder::document_service::PurgeDocuments {
2403 super::builder::document_service::PurgeDocuments::new(self.inner.clone())
2404 }
2405
2406 /// Gets index freshness metadata for
2407 /// [Document][google.cloud.discoveryengine.v1.Document]s. Supported for
2408 /// website search only.
2409 ///
2410 /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
2411 ///
2412 /// # Example
2413 /// ```
2414 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2415 /// use google_cloud_discoveryengine_v1::Result;
2416 /// async fn sample(
2417 /// client: &DocumentService
2418 /// ) -> Result<()> {
2419 /// let response = client.batch_get_documents_metadata()
2420 /// /* set fields */
2421 /// .send().await?;
2422 /// println!("response {:?}", response);
2423 /// Ok(())
2424 /// }
2425 /// ```
2426 pub fn batch_get_documents_metadata(
2427 &self,
2428 ) -> super::builder::document_service::BatchGetDocumentsMetadata {
2429 super::builder::document_service::BatchGetDocumentsMetadata::new(self.inner.clone())
2430 }
2431
2432 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2433 ///
2434 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2435 ///
2436 /// # Example
2437 /// ```
2438 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2439 /// use google_cloud_gax::paginator::ItemPaginator as _;
2440 /// use google_cloud_discoveryengine_v1::Result;
2441 /// async fn sample(
2442 /// client: &DocumentService
2443 /// ) -> Result<()> {
2444 /// let mut list = client.list_operations()
2445 /// /* set fields */
2446 /// .by_item();
2447 /// while let Some(item) = list.next().await.transpose()? {
2448 /// println!("{:?}", item);
2449 /// }
2450 /// Ok(())
2451 /// }
2452 /// ```
2453 pub fn list_operations(&self) -> super::builder::document_service::ListOperations {
2454 super::builder::document_service::ListOperations::new(self.inner.clone())
2455 }
2456
2457 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2458 ///
2459 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2460 ///
2461 /// # Example
2462 /// ```
2463 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2464 /// use google_cloud_discoveryengine_v1::Result;
2465 /// async fn sample(
2466 /// client: &DocumentService
2467 /// ) -> Result<()> {
2468 /// let response = client.get_operation()
2469 /// /* set fields */
2470 /// .send().await?;
2471 /// println!("response {:?}", response);
2472 /// Ok(())
2473 /// }
2474 /// ```
2475 pub fn get_operation(&self) -> super::builder::document_service::GetOperation {
2476 super::builder::document_service::GetOperation::new(self.inner.clone())
2477 }
2478
2479 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2480 ///
2481 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2482 ///
2483 /// # Example
2484 /// ```
2485 /// # use google_cloud_discoveryengine_v1::client::DocumentService;
2486 /// use google_cloud_discoveryengine_v1::Result;
2487 /// async fn sample(
2488 /// client: &DocumentService
2489 /// ) -> Result<()> {
2490 /// client.cancel_operation()
2491 /// /* set fields */
2492 /// .send().await?;
2493 /// Ok(())
2494 /// }
2495 /// ```
2496 pub fn cancel_operation(&self) -> super::builder::document_service::CancelOperation {
2497 super::builder::document_service::CancelOperation::new(self.inner.clone())
2498 }
2499}
2500
2501/// Implements a client for the Discovery Engine API.
2502///
2503/// # Example
2504/// ```
2505/// # use google_cloud_discoveryengine_v1::client::EngineService;
2506/// use google_cloud_gax::paginator::ItemPaginator as _;
2507/// async fn sample(
2508/// parent: &str,
2509/// ) -> anyhow::Result<()> {
2510/// let client = EngineService::builder().build().await?;
2511/// let mut list = client.list_engines()
2512/// .set_parent(parent)
2513/// .by_item();
2514/// while let Some(item) = list.next().await.transpose()? {
2515/// println!("{:?}", item);
2516/// }
2517/// Ok(())
2518/// }
2519/// ```
2520///
2521/// # Service Description
2522///
2523/// Service for managing [Engine][google.cloud.discoveryengine.v1.Engine]
2524/// configuration.
2525///
2526/// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
2527///
2528/// # Configuration
2529///
2530/// To configure `EngineService` use the `with_*` methods in the type returned
2531/// by [builder()][EngineService::builder]. The default configuration should
2532/// work for most applications. Common configuration changes include
2533///
2534/// * [with_endpoint()]: by default this client uses the global default endpoint
2535/// (`https://discoveryengine.googleapis.com`). Applications using regional
2536/// endpoints or running in restricted networks (e.g. a network configured
2537/// with [Private Google Access with VPC Service Controls]) may want to
2538/// override this default.
2539/// * [with_credentials()]: by default this client uses
2540/// [Application Default Credentials]. Applications using custom
2541/// authentication may need to override this default.
2542///
2543/// [with_endpoint()]: super::builder::engine_service::ClientBuilder::with_endpoint
2544/// [with_credentials()]: super::builder::engine_service::ClientBuilder::with_credentials
2545/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2546/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2547///
2548/// # Pooling and Cloning
2549///
2550/// `EngineService` holds a connection pool internally, it is advised to
2551/// create one and reuse it. You do not need to wrap `EngineService` in
2552/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2553/// already uses an `Arc` internally.
2554#[cfg(feature = "engine-service")]
2555#[cfg_attr(docsrs, doc(cfg(feature = "engine-service")))]
2556#[derive(Clone, Debug)]
2557pub struct EngineService {
2558 inner: std::sync::Arc<dyn super::stub::dynamic::EngineService>,
2559}
2560
2561#[cfg(feature = "engine-service")]
2562impl EngineService {
2563 /// Returns a builder for [EngineService].
2564 ///
2565 /// ```
2566 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2567 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2568 /// let client = EngineService::builder().build().await?;
2569 /// # Ok(()) }
2570 /// ```
2571 pub fn builder() -> super::builder::engine_service::ClientBuilder {
2572 crate::new_client_builder(super::builder::engine_service::client::Factory)
2573 }
2574
2575 /// Creates a new client from the provided stub.
2576 ///
2577 /// The most common case for calling this function is in tests mocking the
2578 /// client's behavior.
2579 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2580 where
2581 T: super::stub::EngineService + 'static,
2582 {
2583 Self { inner: stub.into() }
2584 }
2585
2586 pub(crate) async fn new(
2587 config: gaxi::options::ClientConfig,
2588 ) -> crate::ClientBuilderResult<Self> {
2589 let inner = Self::build_inner(config).await?;
2590 Ok(Self { inner })
2591 }
2592
2593 async fn build_inner(
2594 conf: gaxi::options::ClientConfig,
2595 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::EngineService>> {
2596 if gaxi::options::tracing_enabled(&conf) {
2597 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2598 }
2599 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2600 }
2601
2602 async fn build_transport(
2603 conf: gaxi::options::ClientConfig,
2604 ) -> crate::ClientBuilderResult<impl super::stub::EngineService> {
2605 super::transport::EngineService::new(conf).await
2606 }
2607
2608 async fn build_with_tracing(
2609 conf: gaxi::options::ClientConfig,
2610 ) -> crate::ClientBuilderResult<impl super::stub::EngineService> {
2611 Self::build_transport(conf)
2612 .await
2613 .map(super::tracing::EngineService::new)
2614 }
2615
2616 /// Creates a [Engine][google.cloud.discoveryengine.v1.Engine].
2617 ///
2618 /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
2619 ///
2620 /// # Long running operations
2621 ///
2622 /// This method is used to start, and/or poll a [long-running Operation].
2623 /// The [Working with long-running operations] chapter in the [user guide]
2624 /// covers these operations in detail.
2625 ///
2626 /// [long-running operation]: https://google.aip.dev/151
2627 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2628 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2629 ///
2630 /// # Example
2631 /// ```
2632 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2633 /// use google_cloud_lro::Poller;
2634 /// use google_cloud_discoveryengine_v1::model::Engine;
2635 /// use google_cloud_discoveryengine_v1::Result;
2636 /// async fn sample(
2637 /// client: &EngineService, parent: &str
2638 /// ) -> Result<()> {
2639 /// let response = client.create_engine()
2640 /// .set_parent(parent)
2641 /// .set_engine_id("engine_id_value")
2642 /// .set_engine(
2643 /// Engine::new()/* set fields */
2644 /// )
2645 /// .poller().until_done().await?;
2646 /// println!("response {:?}", response);
2647 /// Ok(())
2648 /// }
2649 /// ```
2650 pub fn create_engine(&self) -> super::builder::engine_service::CreateEngine {
2651 super::builder::engine_service::CreateEngine::new(self.inner.clone())
2652 }
2653
2654 /// Deletes a [Engine][google.cloud.discoveryengine.v1.Engine].
2655 ///
2656 /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
2657 ///
2658 /// # Long running operations
2659 ///
2660 /// This method is used to start, and/or poll a [long-running Operation].
2661 /// The [Working with long-running operations] chapter in the [user guide]
2662 /// covers these operations in detail.
2663 ///
2664 /// [long-running operation]: https://google.aip.dev/151
2665 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2666 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2667 ///
2668 /// # Example
2669 /// ```
2670 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2671 /// use google_cloud_lro::Poller;
2672 /// use google_cloud_discoveryengine_v1::Result;
2673 /// async fn sample(
2674 /// client: &EngineService, project_id: &str, location_id: &str, collection_id: &str, engine_id: &str
2675 /// ) -> Result<()> {
2676 /// client.delete_engine()
2677 /// .set_name(format!("projects/{project_id}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}"))
2678 /// .poller().until_done().await?;
2679 /// Ok(())
2680 /// }
2681 /// ```
2682 pub fn delete_engine(&self) -> super::builder::engine_service::DeleteEngine {
2683 super::builder::engine_service::DeleteEngine::new(self.inner.clone())
2684 }
2685
2686 /// Updates an [Engine][google.cloud.discoveryengine.v1.Engine]
2687 ///
2688 /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
2689 ///
2690 /// # Example
2691 /// ```
2692 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2693 /// # extern crate wkt as google_cloud_wkt;
2694 /// use google_cloud_wkt::FieldMask;
2695 /// use google_cloud_discoveryengine_v1::model::Engine;
2696 /// use google_cloud_discoveryengine_v1::Result;
2697 /// async fn sample(
2698 /// client: &EngineService, project_id: &str, location_id: &str, collection_id: &str, engine_id: &str
2699 /// ) -> Result<()> {
2700 /// let response = client.update_engine()
2701 /// .set_engine(
2702 /// Engine::new().set_name(format!("projects/{project_id}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}"))/* set fields */
2703 /// )
2704 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2705 /// .send().await?;
2706 /// println!("response {:?}", response);
2707 /// Ok(())
2708 /// }
2709 /// ```
2710 pub fn update_engine(&self) -> super::builder::engine_service::UpdateEngine {
2711 super::builder::engine_service::UpdateEngine::new(self.inner.clone())
2712 }
2713
2714 /// Gets a [Engine][google.cloud.discoveryengine.v1.Engine].
2715 ///
2716 /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
2717 ///
2718 /// # Example
2719 /// ```
2720 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2721 /// use google_cloud_discoveryengine_v1::Result;
2722 /// async fn sample(
2723 /// client: &EngineService, project_id: &str, location_id: &str, collection_id: &str, engine_id: &str
2724 /// ) -> Result<()> {
2725 /// let response = client.get_engine()
2726 /// .set_name(format!("projects/{project_id}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}"))
2727 /// .send().await?;
2728 /// println!("response {:?}", response);
2729 /// Ok(())
2730 /// }
2731 /// ```
2732 pub fn get_engine(&self) -> super::builder::engine_service::GetEngine {
2733 super::builder::engine_service::GetEngine::new(self.inner.clone())
2734 }
2735
2736 /// Lists all the [Engine][google.cloud.discoveryengine.v1.Engine]s associated
2737 /// with the project.
2738 ///
2739 /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
2740 ///
2741 /// # Example
2742 /// ```
2743 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2744 /// use google_cloud_gax::paginator::ItemPaginator as _;
2745 /// use google_cloud_discoveryengine_v1::Result;
2746 /// async fn sample(
2747 /// client: &EngineService, parent: &str
2748 /// ) -> Result<()> {
2749 /// let mut list = client.list_engines()
2750 /// .set_parent(parent)
2751 /// .by_item();
2752 /// while let Some(item) = list.next().await.transpose()? {
2753 /// println!("{:?}", item);
2754 /// }
2755 /// Ok(())
2756 /// }
2757 /// ```
2758 pub fn list_engines(&self) -> super::builder::engine_service::ListEngines {
2759 super::builder::engine_service::ListEngines::new(self.inner.clone())
2760 }
2761
2762 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2763 ///
2764 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2765 ///
2766 /// # Example
2767 /// ```
2768 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2769 /// use google_cloud_gax::paginator::ItemPaginator as _;
2770 /// use google_cloud_discoveryengine_v1::Result;
2771 /// async fn sample(
2772 /// client: &EngineService
2773 /// ) -> Result<()> {
2774 /// let mut list = client.list_operations()
2775 /// /* set fields */
2776 /// .by_item();
2777 /// while let Some(item) = list.next().await.transpose()? {
2778 /// println!("{:?}", item);
2779 /// }
2780 /// Ok(())
2781 /// }
2782 /// ```
2783 pub fn list_operations(&self) -> super::builder::engine_service::ListOperations {
2784 super::builder::engine_service::ListOperations::new(self.inner.clone())
2785 }
2786
2787 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2788 ///
2789 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2790 ///
2791 /// # Example
2792 /// ```
2793 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2794 /// use google_cloud_discoveryengine_v1::Result;
2795 /// async fn sample(
2796 /// client: &EngineService
2797 /// ) -> Result<()> {
2798 /// let response = client.get_operation()
2799 /// /* set fields */
2800 /// .send().await?;
2801 /// println!("response {:?}", response);
2802 /// Ok(())
2803 /// }
2804 /// ```
2805 pub fn get_operation(&self) -> super::builder::engine_service::GetOperation {
2806 super::builder::engine_service::GetOperation::new(self.inner.clone())
2807 }
2808
2809 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2810 ///
2811 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2812 ///
2813 /// # Example
2814 /// ```
2815 /// # use google_cloud_discoveryengine_v1::client::EngineService;
2816 /// use google_cloud_discoveryengine_v1::Result;
2817 /// async fn sample(
2818 /// client: &EngineService
2819 /// ) -> Result<()> {
2820 /// client.cancel_operation()
2821 /// /* set fields */
2822 /// .send().await?;
2823 /// Ok(())
2824 /// }
2825 /// ```
2826 pub fn cancel_operation(&self) -> super::builder::engine_service::CancelOperation {
2827 super::builder::engine_service::CancelOperation::new(self.inner.clone())
2828 }
2829}
2830
2831/// Implements a client for the Discovery Engine API.
2832///
2833/// # Example
2834/// ```
2835/// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
2836/// async fn sample(
2837/// ) -> anyhow::Result<()> {
2838/// let client = GroundedGenerationService::builder().build().await?;
2839/// let response = client.generate_grounded_content()
2840/// /* set fields */
2841/// .send().await?;
2842/// println!("response {:?}", response);
2843/// Ok(())
2844/// }
2845/// ```
2846///
2847/// # Service Description
2848///
2849/// Service for grounded generation.
2850///
2851/// # Configuration
2852///
2853/// To configure `GroundedGenerationService` use the `with_*` methods in the type returned
2854/// by [builder()][GroundedGenerationService::builder]. The default configuration should
2855/// work for most applications. Common configuration changes include
2856///
2857/// * [with_endpoint()]: by default this client uses the global default endpoint
2858/// (`https://discoveryengine.googleapis.com`). Applications using regional
2859/// endpoints or running in restricted networks (e.g. a network configured
2860/// with [Private Google Access with VPC Service Controls]) may want to
2861/// override this default.
2862/// * [with_credentials()]: by default this client uses
2863/// [Application Default Credentials]. Applications using custom
2864/// authentication may need to override this default.
2865///
2866/// [with_endpoint()]: super::builder::grounded_generation_service::ClientBuilder::with_endpoint
2867/// [with_credentials()]: super::builder::grounded_generation_service::ClientBuilder::with_credentials
2868/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2869/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2870///
2871/// # Pooling and Cloning
2872///
2873/// `GroundedGenerationService` holds a connection pool internally, it is advised to
2874/// create one and reuse it. You do not need to wrap `GroundedGenerationService` in
2875/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2876/// already uses an `Arc` internally.
2877#[cfg(feature = "grounded-generation-service")]
2878#[cfg_attr(docsrs, doc(cfg(feature = "grounded-generation-service")))]
2879#[derive(Clone, Debug)]
2880pub struct GroundedGenerationService {
2881 inner: std::sync::Arc<dyn super::stub::dynamic::GroundedGenerationService>,
2882}
2883
2884#[cfg(feature = "grounded-generation-service")]
2885impl GroundedGenerationService {
2886 /// Returns a builder for [GroundedGenerationService].
2887 ///
2888 /// ```
2889 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2890 /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
2891 /// let client = GroundedGenerationService::builder().build().await?;
2892 /// # Ok(()) }
2893 /// ```
2894 pub fn builder() -> super::builder::grounded_generation_service::ClientBuilder {
2895 crate::new_client_builder(super::builder::grounded_generation_service::client::Factory)
2896 }
2897
2898 /// Creates a new client from the provided stub.
2899 ///
2900 /// The most common case for calling this function is in tests mocking the
2901 /// client's behavior.
2902 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2903 where
2904 T: super::stub::GroundedGenerationService + 'static,
2905 {
2906 Self { inner: stub.into() }
2907 }
2908
2909 pub(crate) async fn new(
2910 config: gaxi::options::ClientConfig,
2911 ) -> crate::ClientBuilderResult<Self> {
2912 let inner = Self::build_inner(config).await?;
2913 Ok(Self { inner })
2914 }
2915
2916 async fn build_inner(
2917 conf: gaxi::options::ClientConfig,
2918 ) -> crate::ClientBuilderResult<
2919 std::sync::Arc<dyn super::stub::dynamic::GroundedGenerationService>,
2920 > {
2921 if gaxi::options::tracing_enabled(&conf) {
2922 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2923 }
2924 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2925 }
2926
2927 async fn build_transport(
2928 conf: gaxi::options::ClientConfig,
2929 ) -> crate::ClientBuilderResult<impl super::stub::GroundedGenerationService> {
2930 super::transport::GroundedGenerationService::new(conf).await
2931 }
2932
2933 async fn build_with_tracing(
2934 conf: gaxi::options::ClientConfig,
2935 ) -> crate::ClientBuilderResult<impl super::stub::GroundedGenerationService> {
2936 Self::build_transport(conf)
2937 .await
2938 .map(super::tracing::GroundedGenerationService::new)
2939 }
2940
2941 /// Generates grounded content in a streaming fashion.
2942 ///
2943 /// # Example
2944 /// ```
2945 /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
2946 /// # use google_cloud_discoveryengine_v1::model::GenerateGroundedContentRequest;
2947 /// async fn sample(
2948 /// client: &GroundedGenerationService
2949 /// ) -> anyhow::Result<()> {
2950 /// let (sender, mut resp_stream) = client.stream_generate_grounded_content()
2951 /// .build();
2952 ///
2953 /// sender.send(GenerateGroundedContentRequest::default()).await?;
2954 /// drop(sender); // Half-close the stream
2955 ///
2956 /// while let Some(response) = resp_stream.next().await {
2957 /// let response = response?;
2958 /// println!("response {:?}", response);
2959 /// }
2960 /// Ok(())
2961 /// }
2962 /// ```
2963 pub fn stream_generate_grounded_content(
2964 &self,
2965 ) -> super::builder::grounded_generation_service::StreamGenerateGroundedContent {
2966 super::builder::grounded_generation_service::StreamGenerateGroundedContent::new(
2967 self.inner.clone(),
2968 )
2969 }
2970
2971 /// Generates grounded content.
2972 ///
2973 /// # Example
2974 /// ```
2975 /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
2976 /// use google_cloud_discoveryengine_v1::Result;
2977 /// async fn sample(
2978 /// client: &GroundedGenerationService
2979 /// ) -> Result<()> {
2980 /// let response = client.generate_grounded_content()
2981 /// /* set fields */
2982 /// .send().await?;
2983 /// println!("response {:?}", response);
2984 /// Ok(())
2985 /// }
2986 /// ```
2987 pub fn generate_grounded_content(
2988 &self,
2989 ) -> super::builder::grounded_generation_service::GenerateGroundedContent {
2990 super::builder::grounded_generation_service::GenerateGroundedContent::new(
2991 self.inner.clone(),
2992 )
2993 }
2994
2995 /// Performs a grounding check.
2996 ///
2997 /// # Example
2998 /// ```
2999 /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
3000 /// use google_cloud_discoveryengine_v1::Result;
3001 /// async fn sample(
3002 /// client: &GroundedGenerationService
3003 /// ) -> Result<()> {
3004 /// let response = client.check_grounding()
3005 /// /* set fields */
3006 /// .send().await?;
3007 /// println!("response {:?}", response);
3008 /// Ok(())
3009 /// }
3010 /// ```
3011 pub fn check_grounding(&self) -> super::builder::grounded_generation_service::CheckGrounding {
3012 super::builder::grounded_generation_service::CheckGrounding::new(self.inner.clone())
3013 }
3014
3015 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3016 ///
3017 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3018 ///
3019 /// # Example
3020 /// ```
3021 /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
3022 /// use google_cloud_gax::paginator::ItemPaginator as _;
3023 /// use google_cloud_discoveryengine_v1::Result;
3024 /// async fn sample(
3025 /// client: &GroundedGenerationService
3026 /// ) -> Result<()> {
3027 /// let mut list = client.list_operations()
3028 /// /* set fields */
3029 /// .by_item();
3030 /// while let Some(item) = list.next().await.transpose()? {
3031 /// println!("{:?}", item);
3032 /// }
3033 /// Ok(())
3034 /// }
3035 /// ```
3036 pub fn list_operations(&self) -> super::builder::grounded_generation_service::ListOperations {
3037 super::builder::grounded_generation_service::ListOperations::new(self.inner.clone())
3038 }
3039
3040 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3041 ///
3042 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3043 ///
3044 /// # Example
3045 /// ```
3046 /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
3047 /// use google_cloud_discoveryengine_v1::Result;
3048 /// async fn sample(
3049 /// client: &GroundedGenerationService
3050 /// ) -> Result<()> {
3051 /// let response = client.get_operation()
3052 /// /* set fields */
3053 /// .send().await?;
3054 /// println!("response {:?}", response);
3055 /// Ok(())
3056 /// }
3057 /// ```
3058 pub fn get_operation(&self) -> super::builder::grounded_generation_service::GetOperation {
3059 super::builder::grounded_generation_service::GetOperation::new(self.inner.clone())
3060 }
3061
3062 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3063 ///
3064 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3065 ///
3066 /// # Example
3067 /// ```
3068 /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
3069 /// use google_cloud_discoveryengine_v1::Result;
3070 /// async fn sample(
3071 /// client: &GroundedGenerationService
3072 /// ) -> Result<()> {
3073 /// client.cancel_operation()
3074 /// /* set fields */
3075 /// .send().await?;
3076 /// Ok(())
3077 /// }
3078 /// ```
3079 pub fn cancel_operation(&self) -> super::builder::grounded_generation_service::CancelOperation {
3080 super::builder::grounded_generation_service::CancelOperation::new(self.inner.clone())
3081 }
3082}
3083
3084/// Implements a client for the Discovery Engine API.
3085///
3086/// # Example
3087/// ```
3088/// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3089/// use google_cloud_gax::paginator::ItemPaginator as _;
3090/// async fn sample(
3091/// parent: &str,
3092/// ) -> anyhow::Result<()> {
3093/// let client = IdentityMappingStoreService::builder().build().await?;
3094/// let mut list = client.list_identity_mapping_stores()
3095/// .set_parent(parent)
3096/// .by_item();
3097/// while let Some(item) = list.next().await.transpose()? {
3098/// println!("{:?}", item);
3099/// }
3100/// Ok(())
3101/// }
3102/// ```
3103///
3104/// # Service Description
3105///
3106/// Service for managing Identity Mapping Stores.
3107///
3108/// # Configuration
3109///
3110/// To configure `IdentityMappingStoreService` use the `with_*` methods in the type returned
3111/// by [builder()][IdentityMappingStoreService::builder]. The default configuration should
3112/// work for most applications. Common configuration changes include
3113///
3114/// * [with_endpoint()]: by default this client uses the global default endpoint
3115/// (`https://discoveryengine.googleapis.com`). Applications using regional
3116/// endpoints or running in restricted networks (e.g. a network configured
3117/// with [Private Google Access with VPC Service Controls]) may want to
3118/// override this default.
3119/// * [with_credentials()]: by default this client uses
3120/// [Application Default Credentials]. Applications using custom
3121/// authentication may need to override this default.
3122///
3123/// [with_endpoint()]: super::builder::identity_mapping_store_service::ClientBuilder::with_endpoint
3124/// [with_credentials()]: super::builder::identity_mapping_store_service::ClientBuilder::with_credentials
3125/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
3126/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
3127///
3128/// # Pooling and Cloning
3129///
3130/// `IdentityMappingStoreService` holds a connection pool internally, it is advised to
3131/// create one and reuse it. You do not need to wrap `IdentityMappingStoreService` in
3132/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
3133/// already uses an `Arc` internally.
3134#[cfg(feature = "identity-mapping-store-service")]
3135#[cfg_attr(docsrs, doc(cfg(feature = "identity-mapping-store-service")))]
3136#[derive(Clone, Debug)]
3137pub struct IdentityMappingStoreService {
3138 inner: std::sync::Arc<dyn super::stub::dynamic::IdentityMappingStoreService>,
3139}
3140
3141#[cfg(feature = "identity-mapping-store-service")]
3142impl IdentityMappingStoreService {
3143 /// Returns a builder for [IdentityMappingStoreService].
3144 ///
3145 /// ```
3146 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
3147 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3148 /// let client = IdentityMappingStoreService::builder().build().await?;
3149 /// # Ok(()) }
3150 /// ```
3151 pub fn builder() -> super::builder::identity_mapping_store_service::ClientBuilder {
3152 crate::new_client_builder(super::builder::identity_mapping_store_service::client::Factory)
3153 }
3154
3155 /// Creates a new client from the provided stub.
3156 ///
3157 /// The most common case for calling this function is in tests mocking the
3158 /// client's behavior.
3159 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3160 where
3161 T: super::stub::IdentityMappingStoreService + 'static,
3162 {
3163 Self { inner: stub.into() }
3164 }
3165
3166 pub(crate) async fn new(
3167 config: gaxi::options::ClientConfig,
3168 ) -> crate::ClientBuilderResult<Self> {
3169 let inner = Self::build_inner(config).await?;
3170 Ok(Self { inner })
3171 }
3172
3173 async fn build_inner(
3174 conf: gaxi::options::ClientConfig,
3175 ) -> crate::ClientBuilderResult<
3176 std::sync::Arc<dyn super::stub::dynamic::IdentityMappingStoreService>,
3177 > {
3178 if gaxi::options::tracing_enabled(&conf) {
3179 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3180 }
3181 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3182 }
3183
3184 async fn build_transport(
3185 conf: gaxi::options::ClientConfig,
3186 ) -> crate::ClientBuilderResult<impl super::stub::IdentityMappingStoreService> {
3187 super::transport::IdentityMappingStoreService::new(conf).await
3188 }
3189
3190 async fn build_with_tracing(
3191 conf: gaxi::options::ClientConfig,
3192 ) -> crate::ClientBuilderResult<impl super::stub::IdentityMappingStoreService> {
3193 Self::build_transport(conf)
3194 .await
3195 .map(super::tracing::IdentityMappingStoreService::new)
3196 }
3197
3198 /// Creates a new Identity Mapping Store.
3199 ///
3200 /// # Example
3201 /// ```
3202 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3203 /// use google_cloud_discoveryengine_v1::model::IdentityMappingStore;
3204 /// use google_cloud_discoveryengine_v1::Result;
3205 /// async fn sample(
3206 /// client: &IdentityMappingStoreService, parent: &str
3207 /// ) -> Result<()> {
3208 /// let response = client.create_identity_mapping_store()
3209 /// .set_parent(parent)
3210 /// .set_identity_mapping_store(
3211 /// IdentityMappingStore::new()/* set fields */
3212 /// )
3213 /// .send().await?;
3214 /// println!("response {:?}", response);
3215 /// Ok(())
3216 /// }
3217 /// ```
3218 pub fn create_identity_mapping_store(
3219 &self,
3220 ) -> super::builder::identity_mapping_store_service::CreateIdentityMappingStore {
3221 super::builder::identity_mapping_store_service::CreateIdentityMappingStore::new(
3222 self.inner.clone(),
3223 )
3224 }
3225
3226 /// Gets the Identity Mapping Store.
3227 ///
3228 /// # Example
3229 /// ```
3230 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3231 /// use google_cloud_discoveryengine_v1::Result;
3232 /// async fn sample(
3233 /// client: &IdentityMappingStoreService, project_id: &str, location_id: &str, identity_mapping_store_id: &str
3234 /// ) -> Result<()> {
3235 /// let response = client.get_identity_mapping_store()
3236 /// .set_name(format!("projects/{project_id}/locations/{location_id}/identityMappingStores/{identity_mapping_store_id}"))
3237 /// .send().await?;
3238 /// println!("response {:?}", response);
3239 /// Ok(())
3240 /// }
3241 /// ```
3242 pub fn get_identity_mapping_store(
3243 &self,
3244 ) -> super::builder::identity_mapping_store_service::GetIdentityMappingStore {
3245 super::builder::identity_mapping_store_service::GetIdentityMappingStore::new(
3246 self.inner.clone(),
3247 )
3248 }
3249
3250 /// Deletes the Identity Mapping Store.
3251 ///
3252 /// # Long running operations
3253 ///
3254 /// This method is used to start, and/or poll a [long-running Operation].
3255 /// The [Working with long-running operations] chapter in the [user guide]
3256 /// covers these operations in detail.
3257 ///
3258 /// [long-running operation]: https://google.aip.dev/151
3259 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3260 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3261 ///
3262 /// # Example
3263 /// ```
3264 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3265 /// use google_cloud_lro::Poller;
3266 /// use google_cloud_discoveryengine_v1::Result;
3267 /// async fn sample(
3268 /// client: &IdentityMappingStoreService, project_id: &str, location_id: &str, identity_mapping_store_id: &str
3269 /// ) -> Result<()> {
3270 /// client.delete_identity_mapping_store()
3271 /// .set_name(format!("projects/{project_id}/locations/{location_id}/identityMappingStores/{identity_mapping_store_id}"))
3272 /// .poller().until_done().await?;
3273 /// Ok(())
3274 /// }
3275 /// ```
3276 pub fn delete_identity_mapping_store(
3277 &self,
3278 ) -> super::builder::identity_mapping_store_service::DeleteIdentityMappingStore {
3279 super::builder::identity_mapping_store_service::DeleteIdentityMappingStore::new(
3280 self.inner.clone(),
3281 )
3282 }
3283
3284 /// Imports a list of Identity Mapping Entries to an Identity Mapping Store.
3285 ///
3286 /// # Long running operations
3287 ///
3288 /// This method is used to start, and/or poll a [long-running Operation].
3289 /// The [Working with long-running operations] chapter in the [user guide]
3290 /// covers these operations in detail.
3291 ///
3292 /// [long-running operation]: https://google.aip.dev/151
3293 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3294 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3295 ///
3296 /// # Example
3297 /// ```
3298 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3299 /// use google_cloud_lro::Poller;
3300 /// use google_cloud_discoveryengine_v1::Result;
3301 /// async fn sample(
3302 /// client: &IdentityMappingStoreService
3303 /// ) -> Result<()> {
3304 /// let response = client.import_identity_mappings()
3305 /// /* set fields */
3306 /// .poller().until_done().await?;
3307 /// println!("response {:?}", response);
3308 /// Ok(())
3309 /// }
3310 /// ```
3311 pub fn import_identity_mappings(
3312 &self,
3313 ) -> super::builder::identity_mapping_store_service::ImportIdentityMappings {
3314 super::builder::identity_mapping_store_service::ImportIdentityMappings::new(
3315 self.inner.clone(),
3316 )
3317 }
3318
3319 /// Purges specified or all Identity Mapping Entries from an Identity Mapping
3320 /// Store.
3321 ///
3322 /// # Long running operations
3323 ///
3324 /// This method is used to start, and/or poll a [long-running Operation].
3325 /// The [Working with long-running operations] chapter in the [user guide]
3326 /// covers these operations in detail.
3327 ///
3328 /// [long-running operation]: https://google.aip.dev/151
3329 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3330 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3331 ///
3332 /// # Example
3333 /// ```
3334 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3335 /// use google_cloud_lro::Poller;
3336 /// use google_cloud_discoveryengine_v1::Result;
3337 /// async fn sample(
3338 /// client: &IdentityMappingStoreService
3339 /// ) -> Result<()> {
3340 /// client.purge_identity_mappings()
3341 /// /* set fields */
3342 /// .poller().until_done().await?;
3343 /// Ok(())
3344 /// }
3345 /// ```
3346 pub fn purge_identity_mappings(
3347 &self,
3348 ) -> super::builder::identity_mapping_store_service::PurgeIdentityMappings {
3349 super::builder::identity_mapping_store_service::PurgeIdentityMappings::new(
3350 self.inner.clone(),
3351 )
3352 }
3353
3354 /// Lists Identity Mappings in an Identity Mapping Store.
3355 ///
3356 /// # Example
3357 /// ```
3358 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3359 /// use google_cloud_gax::paginator::ItemPaginator as _;
3360 /// use google_cloud_discoveryengine_v1::Result;
3361 /// async fn sample(
3362 /// client: &IdentityMappingStoreService
3363 /// ) -> Result<()> {
3364 /// let mut list = client.list_identity_mappings()
3365 /// /* set fields */
3366 /// .by_item();
3367 /// while let Some(item) = list.next().await.transpose()? {
3368 /// println!("{:?}", item);
3369 /// }
3370 /// Ok(())
3371 /// }
3372 /// ```
3373 pub fn list_identity_mappings(
3374 &self,
3375 ) -> super::builder::identity_mapping_store_service::ListIdentityMappings {
3376 super::builder::identity_mapping_store_service::ListIdentityMappings::new(
3377 self.inner.clone(),
3378 )
3379 }
3380
3381 /// Lists all Identity Mapping Stores.
3382 ///
3383 /// # Example
3384 /// ```
3385 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3386 /// use google_cloud_gax::paginator::ItemPaginator as _;
3387 /// use google_cloud_discoveryengine_v1::Result;
3388 /// async fn sample(
3389 /// client: &IdentityMappingStoreService, parent: &str
3390 /// ) -> Result<()> {
3391 /// let mut list = client.list_identity_mapping_stores()
3392 /// .set_parent(parent)
3393 /// .by_item();
3394 /// while let Some(item) = list.next().await.transpose()? {
3395 /// println!("{:?}", item);
3396 /// }
3397 /// Ok(())
3398 /// }
3399 /// ```
3400 pub fn list_identity_mapping_stores(
3401 &self,
3402 ) -> super::builder::identity_mapping_store_service::ListIdentityMappingStores {
3403 super::builder::identity_mapping_store_service::ListIdentityMappingStores::new(
3404 self.inner.clone(),
3405 )
3406 }
3407
3408 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3409 ///
3410 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3411 ///
3412 /// # Example
3413 /// ```
3414 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3415 /// use google_cloud_gax::paginator::ItemPaginator as _;
3416 /// use google_cloud_discoveryengine_v1::Result;
3417 /// async fn sample(
3418 /// client: &IdentityMappingStoreService
3419 /// ) -> Result<()> {
3420 /// let mut list = client.list_operations()
3421 /// /* set fields */
3422 /// .by_item();
3423 /// while let Some(item) = list.next().await.transpose()? {
3424 /// println!("{:?}", item);
3425 /// }
3426 /// Ok(())
3427 /// }
3428 /// ```
3429 pub fn list_operations(
3430 &self,
3431 ) -> super::builder::identity_mapping_store_service::ListOperations {
3432 super::builder::identity_mapping_store_service::ListOperations::new(self.inner.clone())
3433 }
3434
3435 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3436 ///
3437 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3438 ///
3439 /// # Example
3440 /// ```
3441 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3442 /// use google_cloud_discoveryengine_v1::Result;
3443 /// async fn sample(
3444 /// client: &IdentityMappingStoreService
3445 /// ) -> Result<()> {
3446 /// let response = client.get_operation()
3447 /// /* set fields */
3448 /// .send().await?;
3449 /// println!("response {:?}", response);
3450 /// Ok(())
3451 /// }
3452 /// ```
3453 pub fn get_operation(&self) -> super::builder::identity_mapping_store_service::GetOperation {
3454 super::builder::identity_mapping_store_service::GetOperation::new(self.inner.clone())
3455 }
3456
3457 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3458 ///
3459 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3460 ///
3461 /// # Example
3462 /// ```
3463 /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
3464 /// use google_cloud_discoveryengine_v1::Result;
3465 /// async fn sample(
3466 /// client: &IdentityMappingStoreService
3467 /// ) -> Result<()> {
3468 /// client.cancel_operation()
3469 /// /* set fields */
3470 /// .send().await?;
3471 /// Ok(())
3472 /// }
3473 /// ```
3474 pub fn cancel_operation(
3475 &self,
3476 ) -> super::builder::identity_mapping_store_service::CancelOperation {
3477 super::builder::identity_mapping_store_service::CancelOperation::new(self.inner.clone())
3478 }
3479}
3480
3481/// Implements a client for the Discovery Engine API.
3482///
3483/// # Example
3484/// ```
3485/// # use google_cloud_discoveryengine_v1::client::ProjectService;
3486/// use google_cloud_lro::Poller;
3487/// async fn sample(
3488/// ) -> anyhow::Result<()> {
3489/// let client = ProjectService::builder().build().await?;
3490/// let response = client.provision_project()
3491/// /* set fields */
3492/// .poller().until_done().await?;
3493/// println!("response {:?}", response);
3494/// Ok(())
3495/// }
3496/// ```
3497///
3498/// # Service Description
3499///
3500/// Service for operations on the
3501/// [Project][google.cloud.discoveryengine.v1.Project].
3502///
3503/// [google.cloud.discoveryengine.v1.Project]: crate::model::Project
3504///
3505/// # Configuration
3506///
3507/// To configure `ProjectService` use the `with_*` methods in the type returned
3508/// by [builder()][ProjectService::builder]. The default configuration should
3509/// work for most applications. Common configuration changes include
3510///
3511/// * [with_endpoint()]: by default this client uses the global default endpoint
3512/// (`https://discoveryengine.googleapis.com`). Applications using regional
3513/// endpoints or running in restricted networks (e.g. a network configured
3514/// with [Private Google Access with VPC Service Controls]) may want to
3515/// override this default.
3516/// * [with_credentials()]: by default this client uses
3517/// [Application Default Credentials]. Applications using custom
3518/// authentication may need to override this default.
3519///
3520/// [with_endpoint()]: super::builder::project_service::ClientBuilder::with_endpoint
3521/// [with_credentials()]: super::builder::project_service::ClientBuilder::with_credentials
3522/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
3523/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
3524///
3525/// # Pooling and Cloning
3526///
3527/// `ProjectService` holds a connection pool internally, it is advised to
3528/// create one and reuse it. You do not need to wrap `ProjectService` in
3529/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
3530/// already uses an `Arc` internally.
3531#[cfg(feature = "project-service")]
3532#[cfg_attr(docsrs, doc(cfg(feature = "project-service")))]
3533#[derive(Clone, Debug)]
3534pub struct ProjectService {
3535 inner: std::sync::Arc<dyn super::stub::dynamic::ProjectService>,
3536}
3537
3538#[cfg(feature = "project-service")]
3539impl ProjectService {
3540 /// Returns a builder for [ProjectService].
3541 ///
3542 /// ```
3543 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
3544 /// # use google_cloud_discoveryengine_v1::client::ProjectService;
3545 /// let client = ProjectService::builder().build().await?;
3546 /// # Ok(()) }
3547 /// ```
3548 pub fn builder() -> super::builder::project_service::ClientBuilder {
3549 crate::new_client_builder(super::builder::project_service::client::Factory)
3550 }
3551
3552 /// Creates a new client from the provided stub.
3553 ///
3554 /// The most common case for calling this function is in tests mocking the
3555 /// client's behavior.
3556 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3557 where
3558 T: super::stub::ProjectService + 'static,
3559 {
3560 Self { inner: stub.into() }
3561 }
3562
3563 pub(crate) async fn new(
3564 config: gaxi::options::ClientConfig,
3565 ) -> crate::ClientBuilderResult<Self> {
3566 let inner = Self::build_inner(config).await?;
3567 Ok(Self { inner })
3568 }
3569
3570 async fn build_inner(
3571 conf: gaxi::options::ClientConfig,
3572 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ProjectService>> {
3573 if gaxi::options::tracing_enabled(&conf) {
3574 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3575 }
3576 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3577 }
3578
3579 async fn build_transport(
3580 conf: gaxi::options::ClientConfig,
3581 ) -> crate::ClientBuilderResult<impl super::stub::ProjectService> {
3582 super::transport::ProjectService::new(conf).await
3583 }
3584
3585 async fn build_with_tracing(
3586 conf: gaxi::options::ClientConfig,
3587 ) -> crate::ClientBuilderResult<impl super::stub::ProjectService> {
3588 Self::build_transport(conf)
3589 .await
3590 .map(super::tracing::ProjectService::new)
3591 }
3592
3593 /// Provisions the project resource. During the
3594 /// process, related systems will get prepared and initialized.
3595 ///
3596 /// Caller must read the [Terms for data
3597 /// use](https://cloud.google.com/retail/data-use-terms), and optionally
3598 /// specify in request to provide consent to that service terms.
3599 ///
3600 /// # Long running operations
3601 ///
3602 /// This method is used to start, and/or poll a [long-running Operation].
3603 /// The [Working with long-running operations] chapter in the [user guide]
3604 /// covers these operations in detail.
3605 ///
3606 /// [long-running operation]: https://google.aip.dev/151
3607 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3608 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3609 ///
3610 /// # Example
3611 /// ```
3612 /// # use google_cloud_discoveryengine_v1::client::ProjectService;
3613 /// use google_cloud_lro::Poller;
3614 /// use google_cloud_discoveryengine_v1::Result;
3615 /// async fn sample(
3616 /// client: &ProjectService
3617 /// ) -> Result<()> {
3618 /// let response = client.provision_project()
3619 /// /* set fields */
3620 /// .poller().until_done().await?;
3621 /// println!("response {:?}", response);
3622 /// Ok(())
3623 /// }
3624 /// ```
3625 pub fn provision_project(&self) -> super::builder::project_service::ProvisionProject {
3626 super::builder::project_service::ProvisionProject::new(self.inner.clone())
3627 }
3628
3629 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3630 ///
3631 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3632 ///
3633 /// # Example
3634 /// ```
3635 /// # use google_cloud_discoveryengine_v1::client::ProjectService;
3636 /// use google_cloud_gax::paginator::ItemPaginator as _;
3637 /// use google_cloud_discoveryengine_v1::Result;
3638 /// async fn sample(
3639 /// client: &ProjectService
3640 /// ) -> Result<()> {
3641 /// let mut list = client.list_operations()
3642 /// /* set fields */
3643 /// .by_item();
3644 /// while let Some(item) = list.next().await.transpose()? {
3645 /// println!("{:?}", item);
3646 /// }
3647 /// Ok(())
3648 /// }
3649 /// ```
3650 pub fn list_operations(&self) -> super::builder::project_service::ListOperations {
3651 super::builder::project_service::ListOperations::new(self.inner.clone())
3652 }
3653
3654 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3655 ///
3656 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3657 ///
3658 /// # Example
3659 /// ```
3660 /// # use google_cloud_discoveryengine_v1::client::ProjectService;
3661 /// use google_cloud_discoveryengine_v1::Result;
3662 /// async fn sample(
3663 /// client: &ProjectService
3664 /// ) -> Result<()> {
3665 /// let response = client.get_operation()
3666 /// /* set fields */
3667 /// .send().await?;
3668 /// println!("response {:?}", response);
3669 /// Ok(())
3670 /// }
3671 /// ```
3672 pub fn get_operation(&self) -> super::builder::project_service::GetOperation {
3673 super::builder::project_service::GetOperation::new(self.inner.clone())
3674 }
3675
3676 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3677 ///
3678 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3679 ///
3680 /// # Example
3681 /// ```
3682 /// # use google_cloud_discoveryengine_v1::client::ProjectService;
3683 /// use google_cloud_discoveryengine_v1::Result;
3684 /// async fn sample(
3685 /// client: &ProjectService
3686 /// ) -> Result<()> {
3687 /// client.cancel_operation()
3688 /// /* set fields */
3689 /// .send().await?;
3690 /// Ok(())
3691 /// }
3692 /// ```
3693 pub fn cancel_operation(&self) -> super::builder::project_service::CancelOperation {
3694 super::builder::project_service::CancelOperation::new(self.inner.clone())
3695 }
3696}
3697
3698/// Implements a client for the Discovery Engine API.
3699///
3700/// # Example
3701/// ```
3702/// # use google_cloud_discoveryengine_v1::client::RankService;
3703/// async fn sample(
3704/// ) -> anyhow::Result<()> {
3705/// let client = RankService::builder().build().await?;
3706/// let response = client.rank()
3707/// /* set fields */
3708/// .send().await?;
3709/// println!("response {:?}", response);
3710/// Ok(())
3711/// }
3712/// ```
3713///
3714/// # Service Description
3715///
3716/// Service for ranking text records.
3717///
3718/// # Configuration
3719///
3720/// To configure `RankService` use the `with_*` methods in the type returned
3721/// by [builder()][RankService::builder]. The default configuration should
3722/// work for most applications. Common configuration changes include
3723///
3724/// * [with_endpoint()]: by default this client uses the global default endpoint
3725/// (`https://discoveryengine.googleapis.com`). Applications using regional
3726/// endpoints or running in restricted networks (e.g. a network configured
3727/// with [Private Google Access with VPC Service Controls]) may want to
3728/// override this default.
3729/// * [with_credentials()]: by default this client uses
3730/// [Application Default Credentials]. Applications using custom
3731/// authentication may need to override this default.
3732///
3733/// [with_endpoint()]: super::builder::rank_service::ClientBuilder::with_endpoint
3734/// [with_credentials()]: super::builder::rank_service::ClientBuilder::with_credentials
3735/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
3736/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
3737///
3738/// # Pooling and Cloning
3739///
3740/// `RankService` holds a connection pool internally, it is advised to
3741/// create one and reuse it. You do not need to wrap `RankService` in
3742/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
3743/// already uses an `Arc` internally.
3744#[cfg(feature = "rank-service")]
3745#[cfg_attr(docsrs, doc(cfg(feature = "rank-service")))]
3746#[derive(Clone, Debug)]
3747pub struct RankService {
3748 inner: std::sync::Arc<dyn super::stub::dynamic::RankService>,
3749}
3750
3751#[cfg(feature = "rank-service")]
3752impl RankService {
3753 /// Returns a builder for [RankService].
3754 ///
3755 /// ```
3756 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
3757 /// # use google_cloud_discoveryengine_v1::client::RankService;
3758 /// let client = RankService::builder().build().await?;
3759 /// # Ok(()) }
3760 /// ```
3761 pub fn builder() -> super::builder::rank_service::ClientBuilder {
3762 crate::new_client_builder(super::builder::rank_service::client::Factory)
3763 }
3764
3765 /// Creates a new client from the provided stub.
3766 ///
3767 /// The most common case for calling this function is in tests mocking the
3768 /// client's behavior.
3769 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3770 where
3771 T: super::stub::RankService + 'static,
3772 {
3773 Self { inner: stub.into() }
3774 }
3775
3776 pub(crate) async fn new(
3777 config: gaxi::options::ClientConfig,
3778 ) -> crate::ClientBuilderResult<Self> {
3779 let inner = Self::build_inner(config).await?;
3780 Ok(Self { inner })
3781 }
3782
3783 async fn build_inner(
3784 conf: gaxi::options::ClientConfig,
3785 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::RankService>> {
3786 if gaxi::options::tracing_enabled(&conf) {
3787 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3788 }
3789 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3790 }
3791
3792 async fn build_transport(
3793 conf: gaxi::options::ClientConfig,
3794 ) -> crate::ClientBuilderResult<impl super::stub::RankService> {
3795 super::transport::RankService::new(conf).await
3796 }
3797
3798 async fn build_with_tracing(
3799 conf: gaxi::options::ClientConfig,
3800 ) -> crate::ClientBuilderResult<impl super::stub::RankService> {
3801 Self::build_transport(conf)
3802 .await
3803 .map(super::tracing::RankService::new)
3804 }
3805
3806 /// Ranks a list of text records based on the given input query.
3807 ///
3808 /// # Example
3809 /// ```
3810 /// # use google_cloud_discoveryengine_v1::client::RankService;
3811 /// use google_cloud_discoveryengine_v1::Result;
3812 /// async fn sample(
3813 /// client: &RankService
3814 /// ) -> Result<()> {
3815 /// let response = client.rank()
3816 /// /* set fields */
3817 /// .send().await?;
3818 /// println!("response {:?}", response);
3819 /// Ok(())
3820 /// }
3821 /// ```
3822 pub fn rank(&self) -> super::builder::rank_service::Rank {
3823 super::builder::rank_service::Rank::new(self.inner.clone())
3824 }
3825
3826 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3827 ///
3828 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3829 ///
3830 /// # Example
3831 /// ```
3832 /// # use google_cloud_discoveryengine_v1::client::RankService;
3833 /// use google_cloud_gax::paginator::ItemPaginator as _;
3834 /// use google_cloud_discoveryengine_v1::Result;
3835 /// async fn sample(
3836 /// client: &RankService
3837 /// ) -> Result<()> {
3838 /// let mut list = client.list_operations()
3839 /// /* set fields */
3840 /// .by_item();
3841 /// while let Some(item) = list.next().await.transpose()? {
3842 /// println!("{:?}", item);
3843 /// }
3844 /// Ok(())
3845 /// }
3846 /// ```
3847 pub fn list_operations(&self) -> super::builder::rank_service::ListOperations {
3848 super::builder::rank_service::ListOperations::new(self.inner.clone())
3849 }
3850
3851 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3852 ///
3853 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3854 ///
3855 /// # Example
3856 /// ```
3857 /// # use google_cloud_discoveryengine_v1::client::RankService;
3858 /// use google_cloud_discoveryengine_v1::Result;
3859 /// async fn sample(
3860 /// client: &RankService
3861 /// ) -> Result<()> {
3862 /// let response = client.get_operation()
3863 /// /* set fields */
3864 /// .send().await?;
3865 /// println!("response {:?}", response);
3866 /// Ok(())
3867 /// }
3868 /// ```
3869 pub fn get_operation(&self) -> super::builder::rank_service::GetOperation {
3870 super::builder::rank_service::GetOperation::new(self.inner.clone())
3871 }
3872
3873 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3874 ///
3875 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3876 ///
3877 /// # Example
3878 /// ```
3879 /// # use google_cloud_discoveryengine_v1::client::RankService;
3880 /// use google_cloud_discoveryengine_v1::Result;
3881 /// async fn sample(
3882 /// client: &RankService
3883 /// ) -> Result<()> {
3884 /// client.cancel_operation()
3885 /// /* set fields */
3886 /// .send().await?;
3887 /// Ok(())
3888 /// }
3889 /// ```
3890 pub fn cancel_operation(&self) -> super::builder::rank_service::CancelOperation {
3891 super::builder::rank_service::CancelOperation::new(self.inner.clone())
3892 }
3893}
3894
3895/// Implements a client for the Discovery Engine API.
3896///
3897/// # Example
3898/// ```
3899/// # use google_cloud_discoveryengine_v1::client::RecommendationService;
3900/// async fn sample(
3901/// ) -> anyhow::Result<()> {
3902/// let client = RecommendationService::builder().build().await?;
3903/// let response = client.recommend()
3904/// /* set fields */
3905/// .send().await?;
3906/// println!("response {:?}", response);
3907/// Ok(())
3908/// }
3909/// ```
3910///
3911/// # Service Description
3912///
3913/// Service for making recommendations.
3914///
3915/// # Configuration
3916///
3917/// To configure `RecommendationService` use the `with_*` methods in the type returned
3918/// by [builder()][RecommendationService::builder]. The default configuration should
3919/// work for most applications. Common configuration changes include
3920///
3921/// * [with_endpoint()]: by default this client uses the global default endpoint
3922/// (`https://discoveryengine.googleapis.com`). Applications using regional
3923/// endpoints or running in restricted networks (e.g. a network configured
3924/// with [Private Google Access with VPC Service Controls]) may want to
3925/// override this default.
3926/// * [with_credentials()]: by default this client uses
3927/// [Application Default Credentials]. Applications using custom
3928/// authentication may need to override this default.
3929///
3930/// [with_endpoint()]: super::builder::recommendation_service::ClientBuilder::with_endpoint
3931/// [with_credentials()]: super::builder::recommendation_service::ClientBuilder::with_credentials
3932/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
3933/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
3934///
3935/// # Pooling and Cloning
3936///
3937/// `RecommendationService` holds a connection pool internally, it is advised to
3938/// create one and reuse it. You do not need to wrap `RecommendationService` in
3939/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
3940/// already uses an `Arc` internally.
3941#[cfg(feature = "recommendation-service")]
3942#[cfg_attr(docsrs, doc(cfg(feature = "recommendation-service")))]
3943#[derive(Clone, Debug)]
3944pub struct RecommendationService {
3945 inner: std::sync::Arc<dyn super::stub::dynamic::RecommendationService>,
3946}
3947
3948#[cfg(feature = "recommendation-service")]
3949impl RecommendationService {
3950 /// Returns a builder for [RecommendationService].
3951 ///
3952 /// ```
3953 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
3954 /// # use google_cloud_discoveryengine_v1::client::RecommendationService;
3955 /// let client = RecommendationService::builder().build().await?;
3956 /// # Ok(()) }
3957 /// ```
3958 pub fn builder() -> super::builder::recommendation_service::ClientBuilder {
3959 crate::new_client_builder(super::builder::recommendation_service::client::Factory)
3960 }
3961
3962 /// Creates a new client from the provided stub.
3963 ///
3964 /// The most common case for calling this function is in tests mocking the
3965 /// client's behavior.
3966 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3967 where
3968 T: super::stub::RecommendationService + 'static,
3969 {
3970 Self { inner: stub.into() }
3971 }
3972
3973 pub(crate) async fn new(
3974 config: gaxi::options::ClientConfig,
3975 ) -> crate::ClientBuilderResult<Self> {
3976 let inner = Self::build_inner(config).await?;
3977 Ok(Self { inner })
3978 }
3979
3980 async fn build_inner(
3981 conf: gaxi::options::ClientConfig,
3982 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::RecommendationService>>
3983 {
3984 if gaxi::options::tracing_enabled(&conf) {
3985 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3986 }
3987 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3988 }
3989
3990 async fn build_transport(
3991 conf: gaxi::options::ClientConfig,
3992 ) -> crate::ClientBuilderResult<impl super::stub::RecommendationService> {
3993 super::transport::RecommendationService::new(conf).await
3994 }
3995
3996 async fn build_with_tracing(
3997 conf: gaxi::options::ClientConfig,
3998 ) -> crate::ClientBuilderResult<impl super::stub::RecommendationService> {
3999 Self::build_transport(conf)
4000 .await
4001 .map(super::tracing::RecommendationService::new)
4002 }
4003
4004 /// Makes a recommendation, which requires a contextual user event.
4005 ///
4006 /// # Example
4007 /// ```
4008 /// # use google_cloud_discoveryengine_v1::client::RecommendationService;
4009 /// use google_cloud_discoveryengine_v1::Result;
4010 /// async fn sample(
4011 /// client: &RecommendationService
4012 /// ) -> Result<()> {
4013 /// let response = client.recommend()
4014 /// /* set fields */
4015 /// .send().await?;
4016 /// println!("response {:?}", response);
4017 /// Ok(())
4018 /// }
4019 /// ```
4020 pub fn recommend(&self) -> super::builder::recommendation_service::Recommend {
4021 super::builder::recommendation_service::Recommend::new(self.inner.clone())
4022 }
4023
4024 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4025 ///
4026 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4027 ///
4028 /// # Example
4029 /// ```
4030 /// # use google_cloud_discoveryengine_v1::client::RecommendationService;
4031 /// use google_cloud_gax::paginator::ItemPaginator as _;
4032 /// use google_cloud_discoveryengine_v1::Result;
4033 /// async fn sample(
4034 /// client: &RecommendationService
4035 /// ) -> Result<()> {
4036 /// let mut list = client.list_operations()
4037 /// /* set fields */
4038 /// .by_item();
4039 /// while let Some(item) = list.next().await.transpose()? {
4040 /// println!("{:?}", item);
4041 /// }
4042 /// Ok(())
4043 /// }
4044 /// ```
4045 pub fn list_operations(&self) -> super::builder::recommendation_service::ListOperations {
4046 super::builder::recommendation_service::ListOperations::new(self.inner.clone())
4047 }
4048
4049 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4050 ///
4051 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4052 ///
4053 /// # Example
4054 /// ```
4055 /// # use google_cloud_discoveryengine_v1::client::RecommendationService;
4056 /// use google_cloud_discoveryengine_v1::Result;
4057 /// async fn sample(
4058 /// client: &RecommendationService
4059 /// ) -> Result<()> {
4060 /// let response = client.get_operation()
4061 /// /* set fields */
4062 /// .send().await?;
4063 /// println!("response {:?}", response);
4064 /// Ok(())
4065 /// }
4066 /// ```
4067 pub fn get_operation(&self) -> super::builder::recommendation_service::GetOperation {
4068 super::builder::recommendation_service::GetOperation::new(self.inner.clone())
4069 }
4070
4071 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4072 ///
4073 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4074 ///
4075 /// # Example
4076 /// ```
4077 /// # use google_cloud_discoveryengine_v1::client::RecommendationService;
4078 /// use google_cloud_discoveryengine_v1::Result;
4079 /// async fn sample(
4080 /// client: &RecommendationService
4081 /// ) -> Result<()> {
4082 /// client.cancel_operation()
4083 /// /* set fields */
4084 /// .send().await?;
4085 /// Ok(())
4086 /// }
4087 /// ```
4088 pub fn cancel_operation(&self) -> super::builder::recommendation_service::CancelOperation {
4089 super::builder::recommendation_service::CancelOperation::new(self.inner.clone())
4090 }
4091}
4092
4093/// Implements a client for the Discovery Engine API.
4094///
4095/// # Example
4096/// ```
4097/// # use google_cloud_discoveryengine_v1::client::SchemaService;
4098/// use google_cloud_gax::paginator::ItemPaginator as _;
4099/// async fn sample(
4100/// project_id: &str,
4101/// location_id: &str,
4102/// data_store_id: &str,
4103/// ) -> anyhow::Result<()> {
4104/// let client = SchemaService::builder().build().await?;
4105/// let mut list = client.list_schemas()
4106/// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
4107/// .by_item();
4108/// while let Some(item) = list.next().await.transpose()? {
4109/// println!("{:?}", item);
4110/// }
4111/// Ok(())
4112/// }
4113/// ```
4114///
4115/// # Service Description
4116///
4117/// Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
4118///
4119/// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
4120///
4121/// # Configuration
4122///
4123/// To configure `SchemaService` use the `with_*` methods in the type returned
4124/// by [builder()][SchemaService::builder]. The default configuration should
4125/// work for most applications. Common configuration changes include
4126///
4127/// * [with_endpoint()]: by default this client uses the global default endpoint
4128/// (`https://discoveryengine.googleapis.com`). Applications using regional
4129/// endpoints or running in restricted networks (e.g. a network configured
4130/// with [Private Google Access with VPC Service Controls]) may want to
4131/// override this default.
4132/// * [with_credentials()]: by default this client uses
4133/// [Application Default Credentials]. Applications using custom
4134/// authentication may need to override this default.
4135///
4136/// [with_endpoint()]: super::builder::schema_service::ClientBuilder::with_endpoint
4137/// [with_credentials()]: super::builder::schema_service::ClientBuilder::with_credentials
4138/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
4139/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
4140///
4141/// # Pooling and Cloning
4142///
4143/// `SchemaService` holds a connection pool internally, it is advised to
4144/// create one and reuse it. You do not need to wrap `SchemaService` in
4145/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
4146/// already uses an `Arc` internally.
4147#[cfg(feature = "schema-service")]
4148#[cfg_attr(docsrs, doc(cfg(feature = "schema-service")))]
4149#[derive(Clone, Debug)]
4150pub struct SchemaService {
4151 inner: std::sync::Arc<dyn super::stub::dynamic::SchemaService>,
4152}
4153
4154#[cfg(feature = "schema-service")]
4155impl SchemaService {
4156 /// Returns a builder for [SchemaService].
4157 ///
4158 /// ```
4159 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
4160 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4161 /// let client = SchemaService::builder().build().await?;
4162 /// # Ok(()) }
4163 /// ```
4164 pub fn builder() -> super::builder::schema_service::ClientBuilder {
4165 crate::new_client_builder(super::builder::schema_service::client::Factory)
4166 }
4167
4168 /// Creates a new client from the provided stub.
4169 ///
4170 /// The most common case for calling this function is in tests mocking the
4171 /// client's behavior.
4172 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
4173 where
4174 T: super::stub::SchemaService + 'static,
4175 {
4176 Self { inner: stub.into() }
4177 }
4178
4179 pub(crate) async fn new(
4180 config: gaxi::options::ClientConfig,
4181 ) -> crate::ClientBuilderResult<Self> {
4182 let inner = Self::build_inner(config).await?;
4183 Ok(Self { inner })
4184 }
4185
4186 async fn build_inner(
4187 conf: gaxi::options::ClientConfig,
4188 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SchemaService>> {
4189 if gaxi::options::tracing_enabled(&conf) {
4190 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
4191 }
4192 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
4193 }
4194
4195 async fn build_transport(
4196 conf: gaxi::options::ClientConfig,
4197 ) -> crate::ClientBuilderResult<impl super::stub::SchemaService> {
4198 super::transport::SchemaService::new(conf).await
4199 }
4200
4201 async fn build_with_tracing(
4202 conf: gaxi::options::ClientConfig,
4203 ) -> crate::ClientBuilderResult<impl super::stub::SchemaService> {
4204 Self::build_transport(conf)
4205 .await
4206 .map(super::tracing::SchemaService::new)
4207 }
4208
4209 /// Gets a [Schema][google.cloud.discoveryengine.v1.Schema].
4210 ///
4211 /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
4212 ///
4213 /// # Example
4214 /// ```
4215 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4216 /// use google_cloud_discoveryengine_v1::Result;
4217 /// async fn sample(
4218 /// client: &SchemaService, project_id: &str, location_id: &str, data_store_id: &str, schema_id: &str
4219 /// ) -> Result<()> {
4220 /// let response = client.get_schema()
4221 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/schemas/{schema_id}"))
4222 /// .send().await?;
4223 /// println!("response {:?}", response);
4224 /// Ok(())
4225 /// }
4226 /// ```
4227 pub fn get_schema(&self) -> super::builder::schema_service::GetSchema {
4228 super::builder::schema_service::GetSchema::new(self.inner.clone())
4229 }
4230
4231 /// Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.
4232 ///
4233 /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
4234 ///
4235 /// # Example
4236 /// ```
4237 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4238 /// use google_cloud_gax::paginator::ItemPaginator as _;
4239 /// use google_cloud_discoveryengine_v1::Result;
4240 /// async fn sample(
4241 /// client: &SchemaService, project_id: &str, location_id: &str, data_store_id: &str
4242 /// ) -> Result<()> {
4243 /// let mut list = client.list_schemas()
4244 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
4245 /// .by_item();
4246 /// while let Some(item) = list.next().await.transpose()? {
4247 /// println!("{:?}", item);
4248 /// }
4249 /// Ok(())
4250 /// }
4251 /// ```
4252 pub fn list_schemas(&self) -> super::builder::schema_service::ListSchemas {
4253 super::builder::schema_service::ListSchemas::new(self.inner.clone())
4254 }
4255
4256 /// Creates a [Schema][google.cloud.discoveryengine.v1.Schema].
4257 ///
4258 /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
4259 ///
4260 /// # Long running operations
4261 ///
4262 /// This method is used to start, and/or poll a [long-running Operation].
4263 /// The [Working with long-running operations] chapter in the [user guide]
4264 /// covers these operations in detail.
4265 ///
4266 /// [long-running operation]: https://google.aip.dev/151
4267 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
4268 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
4269 ///
4270 /// # Example
4271 /// ```
4272 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4273 /// use google_cloud_lro::Poller;
4274 /// use google_cloud_discoveryengine_v1::model::Schema;
4275 /// use google_cloud_discoveryengine_v1::Result;
4276 /// async fn sample(
4277 /// client: &SchemaService, project_id: &str, location_id: &str, data_store_id: &str
4278 /// ) -> Result<()> {
4279 /// let response = client.create_schema()
4280 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
4281 /// .set_schema_id("schema_id_value")
4282 /// .set_schema(
4283 /// Schema::new()/* set fields */
4284 /// )
4285 /// .poller().until_done().await?;
4286 /// println!("response {:?}", response);
4287 /// Ok(())
4288 /// }
4289 /// ```
4290 pub fn create_schema(&self) -> super::builder::schema_service::CreateSchema {
4291 super::builder::schema_service::CreateSchema::new(self.inner.clone())
4292 }
4293
4294 /// Updates a [Schema][google.cloud.discoveryengine.v1.Schema].
4295 ///
4296 /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
4297 ///
4298 /// # Long running operations
4299 ///
4300 /// This method is used to start, and/or poll a [long-running Operation].
4301 /// The [Working with long-running operations] chapter in the [user guide]
4302 /// covers these operations in detail.
4303 ///
4304 /// [long-running operation]: https://google.aip.dev/151
4305 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
4306 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
4307 ///
4308 /// # Example
4309 /// ```
4310 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4311 /// use google_cloud_lro::Poller;
4312 /// use google_cloud_discoveryengine_v1::model::Schema;
4313 /// use google_cloud_discoveryengine_v1::Result;
4314 /// async fn sample(
4315 /// client: &SchemaService, project_id: &str, location_id: &str, data_store_id: &str, schema_id: &str
4316 /// ) -> Result<()> {
4317 /// let response = client.update_schema()
4318 /// .set_schema(
4319 /// Schema::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/schemas/{schema_id}"))/* set fields */
4320 /// )
4321 /// .poller().until_done().await?;
4322 /// println!("response {:?}", response);
4323 /// Ok(())
4324 /// }
4325 /// ```
4326 pub fn update_schema(&self) -> super::builder::schema_service::UpdateSchema {
4327 super::builder::schema_service::UpdateSchema::new(self.inner.clone())
4328 }
4329
4330 /// Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].
4331 ///
4332 /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
4333 ///
4334 /// # Long running operations
4335 ///
4336 /// This method is used to start, and/or poll a [long-running Operation].
4337 /// The [Working with long-running operations] chapter in the [user guide]
4338 /// covers these operations in detail.
4339 ///
4340 /// [long-running operation]: https://google.aip.dev/151
4341 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
4342 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
4343 ///
4344 /// # Example
4345 /// ```
4346 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4347 /// use google_cloud_lro::Poller;
4348 /// use google_cloud_discoveryengine_v1::Result;
4349 /// async fn sample(
4350 /// client: &SchemaService, project_id: &str, location_id: &str, data_store_id: &str, schema_id: &str
4351 /// ) -> Result<()> {
4352 /// client.delete_schema()
4353 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/schemas/{schema_id}"))
4354 /// .poller().until_done().await?;
4355 /// Ok(())
4356 /// }
4357 /// ```
4358 pub fn delete_schema(&self) -> super::builder::schema_service::DeleteSchema {
4359 super::builder::schema_service::DeleteSchema::new(self.inner.clone())
4360 }
4361
4362 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4363 ///
4364 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4365 ///
4366 /// # Example
4367 /// ```
4368 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4369 /// use google_cloud_gax::paginator::ItemPaginator as _;
4370 /// use google_cloud_discoveryengine_v1::Result;
4371 /// async fn sample(
4372 /// client: &SchemaService
4373 /// ) -> Result<()> {
4374 /// let mut list = client.list_operations()
4375 /// /* set fields */
4376 /// .by_item();
4377 /// while let Some(item) = list.next().await.transpose()? {
4378 /// println!("{:?}", item);
4379 /// }
4380 /// Ok(())
4381 /// }
4382 /// ```
4383 pub fn list_operations(&self) -> super::builder::schema_service::ListOperations {
4384 super::builder::schema_service::ListOperations::new(self.inner.clone())
4385 }
4386
4387 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4388 ///
4389 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4390 ///
4391 /// # Example
4392 /// ```
4393 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4394 /// use google_cloud_discoveryengine_v1::Result;
4395 /// async fn sample(
4396 /// client: &SchemaService
4397 /// ) -> Result<()> {
4398 /// let response = client.get_operation()
4399 /// /* set fields */
4400 /// .send().await?;
4401 /// println!("response {:?}", response);
4402 /// Ok(())
4403 /// }
4404 /// ```
4405 pub fn get_operation(&self) -> super::builder::schema_service::GetOperation {
4406 super::builder::schema_service::GetOperation::new(self.inner.clone())
4407 }
4408
4409 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4410 ///
4411 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4412 ///
4413 /// # Example
4414 /// ```
4415 /// # use google_cloud_discoveryengine_v1::client::SchemaService;
4416 /// use google_cloud_discoveryengine_v1::Result;
4417 /// async fn sample(
4418 /// client: &SchemaService
4419 /// ) -> Result<()> {
4420 /// client.cancel_operation()
4421 /// /* set fields */
4422 /// .send().await?;
4423 /// Ok(())
4424 /// }
4425 /// ```
4426 pub fn cancel_operation(&self) -> super::builder::schema_service::CancelOperation {
4427 super::builder::schema_service::CancelOperation::new(self.inner.clone())
4428 }
4429}
4430
4431/// Implements a client for the Discovery Engine API.
4432///
4433/// # Example
4434/// ```
4435/// # use google_cloud_discoveryengine_v1::client::SearchService;
4436/// use google_cloud_gax::paginator::ItemPaginator as _;
4437/// async fn sample(
4438/// ) -> anyhow::Result<()> {
4439/// let client = SearchService::builder().build().await?;
4440/// let mut list = client.search()
4441/// /* set fields */
4442/// .by_item();
4443/// while let Some(item) = list.next().await.transpose()? {
4444/// println!("{:?}", item);
4445/// }
4446/// Ok(())
4447/// }
4448/// ```
4449///
4450/// # Service Description
4451///
4452/// Service for search.
4453///
4454/// # Configuration
4455///
4456/// To configure `SearchService` use the `with_*` methods in the type returned
4457/// by [builder()][SearchService::builder]. The default configuration should
4458/// work for most applications. Common configuration changes include
4459///
4460/// * [with_endpoint()]: by default this client uses the global default endpoint
4461/// (`https://discoveryengine.googleapis.com`). Applications using regional
4462/// endpoints or running in restricted networks (e.g. a network configured
4463/// with [Private Google Access with VPC Service Controls]) may want to
4464/// override this default.
4465/// * [with_credentials()]: by default this client uses
4466/// [Application Default Credentials]. Applications using custom
4467/// authentication may need to override this default.
4468///
4469/// [with_endpoint()]: super::builder::search_service::ClientBuilder::with_endpoint
4470/// [with_credentials()]: super::builder::search_service::ClientBuilder::with_credentials
4471/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
4472/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
4473///
4474/// # Pooling and Cloning
4475///
4476/// `SearchService` holds a connection pool internally, it is advised to
4477/// create one and reuse it. You do not need to wrap `SearchService` in
4478/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
4479/// already uses an `Arc` internally.
4480#[cfg(feature = "search-service")]
4481#[cfg_attr(docsrs, doc(cfg(feature = "search-service")))]
4482#[derive(Clone, Debug)]
4483pub struct SearchService {
4484 inner: std::sync::Arc<dyn super::stub::dynamic::SearchService>,
4485}
4486
4487#[cfg(feature = "search-service")]
4488impl SearchService {
4489 /// Returns a builder for [SearchService].
4490 ///
4491 /// ```
4492 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
4493 /// # use google_cloud_discoveryengine_v1::client::SearchService;
4494 /// let client = SearchService::builder().build().await?;
4495 /// # Ok(()) }
4496 /// ```
4497 pub fn builder() -> super::builder::search_service::ClientBuilder {
4498 crate::new_client_builder(super::builder::search_service::client::Factory)
4499 }
4500
4501 /// Creates a new client from the provided stub.
4502 ///
4503 /// The most common case for calling this function is in tests mocking the
4504 /// client's behavior.
4505 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
4506 where
4507 T: super::stub::SearchService + 'static,
4508 {
4509 Self { inner: stub.into() }
4510 }
4511
4512 pub(crate) async fn new(
4513 config: gaxi::options::ClientConfig,
4514 ) -> crate::ClientBuilderResult<Self> {
4515 let inner = Self::build_inner(config).await?;
4516 Ok(Self { inner })
4517 }
4518
4519 async fn build_inner(
4520 conf: gaxi::options::ClientConfig,
4521 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SearchService>> {
4522 if gaxi::options::tracing_enabled(&conf) {
4523 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
4524 }
4525 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
4526 }
4527
4528 async fn build_transport(
4529 conf: gaxi::options::ClientConfig,
4530 ) -> crate::ClientBuilderResult<impl super::stub::SearchService> {
4531 super::transport::SearchService::new(conf).await
4532 }
4533
4534 async fn build_with_tracing(
4535 conf: gaxi::options::ClientConfig,
4536 ) -> crate::ClientBuilderResult<impl super::stub::SearchService> {
4537 Self::build_transport(conf)
4538 .await
4539 .map(super::tracing::SearchService::new)
4540 }
4541
4542 /// Performs a search.
4543 ///
4544 /// # Example
4545 /// ```
4546 /// # use google_cloud_discoveryengine_v1::client::SearchService;
4547 /// use google_cloud_gax::paginator::ItemPaginator as _;
4548 /// use google_cloud_discoveryengine_v1::Result;
4549 /// async fn sample(
4550 /// client: &SearchService
4551 /// ) -> Result<()> {
4552 /// let mut list = client.search()
4553 /// /* set fields */
4554 /// .by_item();
4555 /// while let Some(item) = list.next().await.transpose()? {
4556 /// println!("{:?}", item);
4557 /// }
4558 /// Ok(())
4559 /// }
4560 /// ```
4561 pub fn search(&self) -> super::builder::search_service::Search {
4562 super::builder::search_service::Search::new(self.inner.clone())
4563 }
4564
4565 /// Performs a search. Similar to the
4566 /// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
4567 /// method, but a lite version that allows API key for authentication, where
4568 /// OAuth and IAM checks are not required.
4569 ///
4570 /// Only public website search is supported by this method. If data stores and
4571 /// engines not associated with public website search are specified, a
4572 /// `FAILED_PRECONDITION` error is returned.
4573 ///
4574 /// This method can be used for easy onboarding without having to implement an
4575 /// authentication backend. However, it is strongly recommended to use
4576 /// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
4577 /// instead with required OAuth and IAM checks to provide better data security.
4578 ///
4579 /// [google.cloud.discoveryengine.v1.SearchService.Search]: crate::client::SearchService::search
4580 ///
4581 /// # Example
4582 /// ```
4583 /// # use google_cloud_discoveryengine_v1::client::SearchService;
4584 /// use google_cloud_gax::paginator::ItemPaginator as _;
4585 /// use google_cloud_discoveryengine_v1::Result;
4586 /// async fn sample(
4587 /// client: &SearchService
4588 /// ) -> Result<()> {
4589 /// let mut list = client.search_lite()
4590 /// /* set fields */
4591 /// .by_item();
4592 /// while let Some(item) = list.next().await.transpose()? {
4593 /// println!("{:?}", item);
4594 /// }
4595 /// Ok(())
4596 /// }
4597 /// ```
4598 pub fn search_lite(&self) -> super::builder::search_service::SearchLite {
4599 super::builder::search_service::SearchLite::new(self.inner.clone())
4600 }
4601
4602 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4603 ///
4604 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4605 ///
4606 /// # Example
4607 /// ```
4608 /// # use google_cloud_discoveryengine_v1::client::SearchService;
4609 /// use google_cloud_gax::paginator::ItemPaginator as _;
4610 /// use google_cloud_discoveryengine_v1::Result;
4611 /// async fn sample(
4612 /// client: &SearchService
4613 /// ) -> Result<()> {
4614 /// let mut list = client.list_operations()
4615 /// /* set fields */
4616 /// .by_item();
4617 /// while let Some(item) = list.next().await.transpose()? {
4618 /// println!("{:?}", item);
4619 /// }
4620 /// Ok(())
4621 /// }
4622 /// ```
4623 pub fn list_operations(&self) -> super::builder::search_service::ListOperations {
4624 super::builder::search_service::ListOperations::new(self.inner.clone())
4625 }
4626
4627 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4628 ///
4629 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4630 ///
4631 /// # Example
4632 /// ```
4633 /// # use google_cloud_discoveryengine_v1::client::SearchService;
4634 /// use google_cloud_discoveryengine_v1::Result;
4635 /// async fn sample(
4636 /// client: &SearchService
4637 /// ) -> Result<()> {
4638 /// let response = client.get_operation()
4639 /// /* set fields */
4640 /// .send().await?;
4641 /// println!("response {:?}", response);
4642 /// Ok(())
4643 /// }
4644 /// ```
4645 pub fn get_operation(&self) -> super::builder::search_service::GetOperation {
4646 super::builder::search_service::GetOperation::new(self.inner.clone())
4647 }
4648
4649 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4650 ///
4651 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4652 ///
4653 /// # Example
4654 /// ```
4655 /// # use google_cloud_discoveryengine_v1::client::SearchService;
4656 /// use google_cloud_discoveryengine_v1::Result;
4657 /// async fn sample(
4658 /// client: &SearchService
4659 /// ) -> Result<()> {
4660 /// client.cancel_operation()
4661 /// /* set fields */
4662 /// .send().await?;
4663 /// Ok(())
4664 /// }
4665 /// ```
4666 pub fn cancel_operation(&self) -> super::builder::search_service::CancelOperation {
4667 super::builder::search_service::CancelOperation::new(self.inner.clone())
4668 }
4669}
4670
4671/// Implements a client for the Discovery Engine API.
4672///
4673/// # Example
4674/// ```
4675/// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
4676/// use google_cloud_lro::Poller;
4677/// async fn sample(
4678/// ) -> anyhow::Result<()> {
4679/// let client = SearchTuningService::builder().build().await?;
4680/// let response = client.train_custom_model()
4681/// /* set fields */
4682/// .poller().until_done().await?;
4683/// println!("response {:?}", response);
4684/// Ok(())
4685/// }
4686/// ```
4687///
4688/// # Service Description
4689///
4690/// Service for search tuning.
4691///
4692/// # Configuration
4693///
4694/// To configure `SearchTuningService` use the `with_*` methods in the type returned
4695/// by [builder()][SearchTuningService::builder]. The default configuration should
4696/// work for most applications. Common configuration changes include
4697///
4698/// * [with_endpoint()]: by default this client uses the global default endpoint
4699/// (`https://discoveryengine.googleapis.com`). Applications using regional
4700/// endpoints or running in restricted networks (e.g. a network configured
4701/// with [Private Google Access with VPC Service Controls]) may want to
4702/// override this default.
4703/// * [with_credentials()]: by default this client uses
4704/// [Application Default Credentials]. Applications using custom
4705/// authentication may need to override this default.
4706///
4707/// [with_endpoint()]: super::builder::search_tuning_service::ClientBuilder::with_endpoint
4708/// [with_credentials()]: super::builder::search_tuning_service::ClientBuilder::with_credentials
4709/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
4710/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
4711///
4712/// # Pooling and Cloning
4713///
4714/// `SearchTuningService` holds a connection pool internally, it is advised to
4715/// create one and reuse it. You do not need to wrap `SearchTuningService` in
4716/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
4717/// already uses an `Arc` internally.
4718#[cfg(feature = "search-tuning-service")]
4719#[cfg_attr(docsrs, doc(cfg(feature = "search-tuning-service")))]
4720#[derive(Clone, Debug)]
4721pub struct SearchTuningService {
4722 inner: std::sync::Arc<dyn super::stub::dynamic::SearchTuningService>,
4723}
4724
4725#[cfg(feature = "search-tuning-service")]
4726impl SearchTuningService {
4727 /// Returns a builder for [SearchTuningService].
4728 ///
4729 /// ```
4730 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
4731 /// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
4732 /// let client = SearchTuningService::builder().build().await?;
4733 /// # Ok(()) }
4734 /// ```
4735 pub fn builder() -> super::builder::search_tuning_service::ClientBuilder {
4736 crate::new_client_builder(super::builder::search_tuning_service::client::Factory)
4737 }
4738
4739 /// Creates a new client from the provided stub.
4740 ///
4741 /// The most common case for calling this function is in tests mocking the
4742 /// client's behavior.
4743 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
4744 where
4745 T: super::stub::SearchTuningService + 'static,
4746 {
4747 Self { inner: stub.into() }
4748 }
4749
4750 pub(crate) async fn new(
4751 config: gaxi::options::ClientConfig,
4752 ) -> crate::ClientBuilderResult<Self> {
4753 let inner = Self::build_inner(config).await?;
4754 Ok(Self { inner })
4755 }
4756
4757 async fn build_inner(
4758 conf: gaxi::options::ClientConfig,
4759 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SearchTuningService>>
4760 {
4761 if gaxi::options::tracing_enabled(&conf) {
4762 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
4763 }
4764 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
4765 }
4766
4767 async fn build_transport(
4768 conf: gaxi::options::ClientConfig,
4769 ) -> crate::ClientBuilderResult<impl super::stub::SearchTuningService> {
4770 super::transport::SearchTuningService::new(conf).await
4771 }
4772
4773 async fn build_with_tracing(
4774 conf: gaxi::options::ClientConfig,
4775 ) -> crate::ClientBuilderResult<impl super::stub::SearchTuningService> {
4776 Self::build_transport(conf)
4777 .await
4778 .map(super::tracing::SearchTuningService::new)
4779 }
4780
4781 /// Trains a custom model.
4782 ///
4783 /// # Long running operations
4784 ///
4785 /// This method is used to start, and/or poll a [long-running Operation].
4786 /// The [Working with long-running operations] chapter in the [user guide]
4787 /// covers these operations in detail.
4788 ///
4789 /// [long-running operation]: https://google.aip.dev/151
4790 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
4791 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
4792 ///
4793 /// # Example
4794 /// ```
4795 /// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
4796 /// use google_cloud_lro::Poller;
4797 /// use google_cloud_discoveryengine_v1::Result;
4798 /// async fn sample(
4799 /// client: &SearchTuningService
4800 /// ) -> Result<()> {
4801 /// let response = client.train_custom_model()
4802 /// /* set fields */
4803 /// .poller().until_done().await?;
4804 /// println!("response {:?}", response);
4805 /// Ok(())
4806 /// }
4807 /// ```
4808 pub fn train_custom_model(&self) -> super::builder::search_tuning_service::TrainCustomModel {
4809 super::builder::search_tuning_service::TrainCustomModel::new(self.inner.clone())
4810 }
4811
4812 /// Gets a list of all the custom models.
4813 ///
4814 /// # Example
4815 /// ```
4816 /// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
4817 /// use google_cloud_discoveryengine_v1::Result;
4818 /// async fn sample(
4819 /// client: &SearchTuningService
4820 /// ) -> Result<()> {
4821 /// let response = client.list_custom_models()
4822 /// /* set fields */
4823 /// .send().await?;
4824 /// println!("response {:?}", response);
4825 /// Ok(())
4826 /// }
4827 /// ```
4828 pub fn list_custom_models(&self) -> super::builder::search_tuning_service::ListCustomModels {
4829 super::builder::search_tuning_service::ListCustomModels::new(self.inner.clone())
4830 }
4831
4832 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4833 ///
4834 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4835 ///
4836 /// # Example
4837 /// ```
4838 /// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
4839 /// use google_cloud_gax::paginator::ItemPaginator as _;
4840 /// use google_cloud_discoveryengine_v1::Result;
4841 /// async fn sample(
4842 /// client: &SearchTuningService
4843 /// ) -> Result<()> {
4844 /// let mut list = client.list_operations()
4845 /// /* set fields */
4846 /// .by_item();
4847 /// while let Some(item) = list.next().await.transpose()? {
4848 /// println!("{:?}", item);
4849 /// }
4850 /// Ok(())
4851 /// }
4852 /// ```
4853 pub fn list_operations(&self) -> super::builder::search_tuning_service::ListOperations {
4854 super::builder::search_tuning_service::ListOperations::new(self.inner.clone())
4855 }
4856
4857 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4858 ///
4859 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4860 ///
4861 /// # Example
4862 /// ```
4863 /// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
4864 /// use google_cloud_discoveryengine_v1::Result;
4865 /// async fn sample(
4866 /// client: &SearchTuningService
4867 /// ) -> Result<()> {
4868 /// let response = client.get_operation()
4869 /// /* set fields */
4870 /// .send().await?;
4871 /// println!("response {:?}", response);
4872 /// Ok(())
4873 /// }
4874 /// ```
4875 pub fn get_operation(&self) -> super::builder::search_tuning_service::GetOperation {
4876 super::builder::search_tuning_service::GetOperation::new(self.inner.clone())
4877 }
4878
4879 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
4880 ///
4881 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
4882 ///
4883 /// # Example
4884 /// ```
4885 /// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
4886 /// use google_cloud_discoveryengine_v1::Result;
4887 /// async fn sample(
4888 /// client: &SearchTuningService
4889 /// ) -> Result<()> {
4890 /// client.cancel_operation()
4891 /// /* set fields */
4892 /// .send().await?;
4893 /// Ok(())
4894 /// }
4895 /// ```
4896 pub fn cancel_operation(&self) -> super::builder::search_tuning_service::CancelOperation {
4897 super::builder::search_tuning_service::CancelOperation::new(self.inner.clone())
4898 }
4899}
4900
4901/// Implements a client for the Discovery Engine API.
4902///
4903/// # Example
4904/// ```
4905/// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
4906/// # extern crate wkt as google_cloud_wkt;
4907/// use google_cloud_wkt::FieldMask;
4908/// use google_cloud_discoveryengine_v1::model::ServingConfig;
4909/// async fn sample(
4910/// project_id: &str,
4911/// location_id: &str,
4912/// data_store_id: &str,
4913/// serving_config_id: &str,
4914/// ) -> anyhow::Result<()> {
4915/// let client = ServingConfigService::builder().build().await?;
4916/// let response = client.update_serving_config()
4917/// .set_serving_config(
4918/// ServingConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/servingConfigs/{serving_config_id}"))/* set fields */
4919/// )
4920/// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
4921/// .send().await?;
4922/// println!("response {:?}", response);
4923/// Ok(())
4924/// }
4925/// ```
4926///
4927/// # Service Description
4928///
4929/// Service for operations related to
4930/// [ServingConfig][google.cloud.discoveryengine.v1.ServingConfig].
4931///
4932/// [google.cloud.discoveryengine.v1.ServingConfig]: crate::model::ServingConfig
4933///
4934/// # Configuration
4935///
4936/// To configure `ServingConfigService` use the `with_*` methods in the type returned
4937/// by [builder()][ServingConfigService::builder]. The default configuration should
4938/// work for most applications. Common configuration changes include
4939///
4940/// * [with_endpoint()]: by default this client uses the global default endpoint
4941/// (`https://discoveryengine.googleapis.com`). Applications using regional
4942/// endpoints or running in restricted networks (e.g. a network configured
4943/// with [Private Google Access with VPC Service Controls]) may want to
4944/// override this default.
4945/// * [with_credentials()]: by default this client uses
4946/// [Application Default Credentials]. Applications using custom
4947/// authentication may need to override this default.
4948///
4949/// [with_endpoint()]: super::builder::serving_config_service::ClientBuilder::with_endpoint
4950/// [with_credentials()]: super::builder::serving_config_service::ClientBuilder::with_credentials
4951/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
4952/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
4953///
4954/// # Pooling and Cloning
4955///
4956/// `ServingConfigService` holds a connection pool internally, it is advised to
4957/// create one and reuse it. You do not need to wrap `ServingConfigService` in
4958/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
4959/// already uses an `Arc` internally.
4960#[cfg(feature = "serving-config-service")]
4961#[cfg_attr(docsrs, doc(cfg(feature = "serving-config-service")))]
4962#[derive(Clone, Debug)]
4963pub struct ServingConfigService {
4964 inner: std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>,
4965}
4966
4967#[cfg(feature = "serving-config-service")]
4968impl ServingConfigService {
4969 /// Returns a builder for [ServingConfigService].
4970 ///
4971 /// ```
4972 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
4973 /// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
4974 /// let client = ServingConfigService::builder().build().await?;
4975 /// # Ok(()) }
4976 /// ```
4977 pub fn builder() -> super::builder::serving_config_service::ClientBuilder {
4978 crate::new_client_builder(super::builder::serving_config_service::client::Factory)
4979 }
4980
4981 /// Creates a new client from the provided stub.
4982 ///
4983 /// The most common case for calling this function is in tests mocking the
4984 /// client's behavior.
4985 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
4986 where
4987 T: super::stub::ServingConfigService + 'static,
4988 {
4989 Self { inner: stub.into() }
4990 }
4991
4992 pub(crate) async fn new(
4993 config: gaxi::options::ClientConfig,
4994 ) -> crate::ClientBuilderResult<Self> {
4995 let inner = Self::build_inner(config).await?;
4996 Ok(Self { inner })
4997 }
4998
4999 async fn build_inner(
5000 conf: gaxi::options::ClientConfig,
5001 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>>
5002 {
5003 if gaxi::options::tracing_enabled(&conf) {
5004 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
5005 }
5006 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
5007 }
5008
5009 async fn build_transport(
5010 conf: gaxi::options::ClientConfig,
5011 ) -> crate::ClientBuilderResult<impl super::stub::ServingConfigService> {
5012 super::transport::ServingConfigService::new(conf).await
5013 }
5014
5015 async fn build_with_tracing(
5016 conf: gaxi::options::ClientConfig,
5017 ) -> crate::ClientBuilderResult<impl super::stub::ServingConfigService> {
5018 Self::build_transport(conf)
5019 .await
5020 .map(super::tracing::ServingConfigService::new)
5021 }
5022
5023 /// Updates a ServingConfig.
5024 ///
5025 /// Returns a NOT_FOUND error if the ServingConfig does not exist.
5026 ///
5027 /// # Example
5028 /// ```
5029 /// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
5030 /// # extern crate wkt as google_cloud_wkt;
5031 /// use google_cloud_wkt::FieldMask;
5032 /// use google_cloud_discoveryengine_v1::model::ServingConfig;
5033 /// use google_cloud_discoveryengine_v1::Result;
5034 /// async fn sample(
5035 /// client: &ServingConfigService, project_id: &str, location_id: &str, data_store_id: &str, serving_config_id: &str
5036 /// ) -> Result<()> {
5037 /// let response = client.update_serving_config()
5038 /// .set_serving_config(
5039 /// ServingConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/servingConfigs/{serving_config_id}"))/* set fields */
5040 /// )
5041 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
5042 /// .send().await?;
5043 /// println!("response {:?}", response);
5044 /// Ok(())
5045 /// }
5046 /// ```
5047 pub fn update_serving_config(
5048 &self,
5049 ) -> super::builder::serving_config_service::UpdateServingConfig {
5050 super::builder::serving_config_service::UpdateServingConfig::new(self.inner.clone())
5051 }
5052
5053 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
5054 ///
5055 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
5056 ///
5057 /// # Example
5058 /// ```
5059 /// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
5060 /// use google_cloud_gax::paginator::ItemPaginator as _;
5061 /// use google_cloud_discoveryengine_v1::Result;
5062 /// async fn sample(
5063 /// client: &ServingConfigService
5064 /// ) -> Result<()> {
5065 /// let mut list = client.list_operations()
5066 /// /* set fields */
5067 /// .by_item();
5068 /// while let Some(item) = list.next().await.transpose()? {
5069 /// println!("{:?}", item);
5070 /// }
5071 /// Ok(())
5072 /// }
5073 /// ```
5074 pub fn list_operations(&self) -> super::builder::serving_config_service::ListOperations {
5075 super::builder::serving_config_service::ListOperations::new(self.inner.clone())
5076 }
5077
5078 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
5079 ///
5080 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
5081 ///
5082 /// # Example
5083 /// ```
5084 /// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
5085 /// use google_cloud_discoveryengine_v1::Result;
5086 /// async fn sample(
5087 /// client: &ServingConfigService
5088 /// ) -> Result<()> {
5089 /// let response = client.get_operation()
5090 /// /* set fields */
5091 /// .send().await?;
5092 /// println!("response {:?}", response);
5093 /// Ok(())
5094 /// }
5095 /// ```
5096 pub fn get_operation(&self) -> super::builder::serving_config_service::GetOperation {
5097 super::builder::serving_config_service::GetOperation::new(self.inner.clone())
5098 }
5099
5100 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
5101 ///
5102 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
5103 ///
5104 /// # Example
5105 /// ```
5106 /// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
5107 /// use google_cloud_discoveryengine_v1::Result;
5108 /// async fn sample(
5109 /// client: &ServingConfigService
5110 /// ) -> Result<()> {
5111 /// client.cancel_operation()
5112 /// /* set fields */
5113 /// .send().await?;
5114 /// Ok(())
5115 /// }
5116 /// ```
5117 pub fn cancel_operation(&self) -> super::builder::serving_config_service::CancelOperation {
5118 super::builder::serving_config_service::CancelOperation::new(self.inner.clone())
5119 }
5120}
5121
5122/// Implements a client for the Discovery Engine API.
5123///
5124/// # Example
5125/// ```
5126/// # use google_cloud_discoveryengine_v1::client::SessionService;
5127/// use google_cloud_gax::paginator::ItemPaginator as _;
5128/// async fn sample(
5129/// project_id: &str,
5130/// location_id: &str,
5131/// data_store_id: &str,
5132/// ) -> anyhow::Result<()> {
5133/// let client = SessionService::builder().build().await?;
5134/// let mut list = client.list_sessions()
5135/// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
5136/// .by_item();
5137/// while let Some(item) = list.next().await.transpose()? {
5138/// println!("{:?}", item);
5139/// }
5140/// Ok(())
5141/// }
5142/// ```
5143///
5144/// # Service Description
5145///
5146/// Service for managing Sessions and Session-related resources.
5147///
5148/// # Configuration
5149///
5150/// To configure `SessionService` use the `with_*` methods in the type returned
5151/// by [builder()][SessionService::builder]. The default configuration should
5152/// work for most applications. Common configuration changes include
5153///
5154/// * [with_endpoint()]: by default this client uses the global default endpoint
5155/// (`https://discoveryengine.googleapis.com`). Applications using regional
5156/// endpoints or running in restricted networks (e.g. a network configured
5157/// with [Private Google Access with VPC Service Controls]) may want to
5158/// override this default.
5159/// * [with_credentials()]: by default this client uses
5160/// [Application Default Credentials]. Applications using custom
5161/// authentication may need to override this default.
5162///
5163/// [with_endpoint()]: super::builder::session_service::ClientBuilder::with_endpoint
5164/// [with_credentials()]: super::builder::session_service::ClientBuilder::with_credentials
5165/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
5166/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
5167///
5168/// # Pooling and Cloning
5169///
5170/// `SessionService` holds a connection pool internally, it is advised to
5171/// create one and reuse it. You do not need to wrap `SessionService` in
5172/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
5173/// already uses an `Arc` internally.
5174#[cfg(feature = "session-service")]
5175#[cfg_attr(docsrs, doc(cfg(feature = "session-service")))]
5176#[derive(Clone, Debug)]
5177pub struct SessionService {
5178 inner: std::sync::Arc<dyn super::stub::dynamic::SessionService>,
5179}
5180
5181#[cfg(feature = "session-service")]
5182impl SessionService {
5183 /// Returns a builder for [SessionService].
5184 ///
5185 /// ```
5186 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
5187 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5188 /// let client = SessionService::builder().build().await?;
5189 /// # Ok(()) }
5190 /// ```
5191 pub fn builder() -> super::builder::session_service::ClientBuilder {
5192 crate::new_client_builder(super::builder::session_service::client::Factory)
5193 }
5194
5195 /// Creates a new client from the provided stub.
5196 ///
5197 /// The most common case for calling this function is in tests mocking the
5198 /// client's behavior.
5199 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
5200 where
5201 T: super::stub::SessionService + 'static,
5202 {
5203 Self { inner: stub.into() }
5204 }
5205
5206 pub(crate) async fn new(
5207 config: gaxi::options::ClientConfig,
5208 ) -> crate::ClientBuilderResult<Self> {
5209 let inner = Self::build_inner(config).await?;
5210 Ok(Self { inner })
5211 }
5212
5213 async fn build_inner(
5214 conf: gaxi::options::ClientConfig,
5215 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SessionService>> {
5216 if gaxi::options::tracing_enabled(&conf) {
5217 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
5218 }
5219 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
5220 }
5221
5222 async fn build_transport(
5223 conf: gaxi::options::ClientConfig,
5224 ) -> crate::ClientBuilderResult<impl super::stub::SessionService> {
5225 super::transport::SessionService::new(conf).await
5226 }
5227
5228 async fn build_with_tracing(
5229 conf: gaxi::options::ClientConfig,
5230 ) -> crate::ClientBuilderResult<impl super::stub::SessionService> {
5231 Self::build_transport(conf)
5232 .await
5233 .map(super::tracing::SessionService::new)
5234 }
5235
5236 /// Creates a Session.
5237 ///
5238 /// If the [Session][google.cloud.discoveryengine.v1.Session] to create already
5239 /// exists, an ALREADY_EXISTS error is returned.
5240 ///
5241 /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
5242 ///
5243 /// # Example
5244 /// ```
5245 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5246 /// use google_cloud_discoveryengine_v1::model::Session;
5247 /// use google_cloud_discoveryengine_v1::Result;
5248 /// async fn sample(
5249 /// client: &SessionService, project_id: &str, location_id: &str, data_store_id: &str
5250 /// ) -> Result<()> {
5251 /// let response = client.create_session()
5252 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
5253 /// .set_session(
5254 /// Session::new()/* set fields */
5255 /// )
5256 /// .send().await?;
5257 /// println!("response {:?}", response);
5258 /// Ok(())
5259 /// }
5260 /// ```
5261 pub fn create_session(&self) -> super::builder::session_service::CreateSession {
5262 super::builder::session_service::CreateSession::new(self.inner.clone())
5263 }
5264
5265 /// Deletes a Session.
5266 ///
5267 /// If the [Session][google.cloud.discoveryengine.v1.Session] to delete does
5268 /// not exist, a NOT_FOUND error is returned.
5269 ///
5270 /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
5271 ///
5272 /// # Example
5273 /// ```
5274 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5275 /// use google_cloud_discoveryengine_v1::Result;
5276 /// async fn sample(
5277 /// client: &SessionService, project_id: &str, location_id: &str, data_store_id: &str, session_id: &str
5278 /// ) -> Result<()> {
5279 /// client.delete_session()
5280 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/sessions/{session_id}"))
5281 /// .send().await?;
5282 /// Ok(())
5283 /// }
5284 /// ```
5285 pub fn delete_session(&self) -> super::builder::session_service::DeleteSession {
5286 super::builder::session_service::DeleteSession::new(self.inner.clone())
5287 }
5288
5289 /// Updates a Session.
5290 ///
5291 /// [Session][google.cloud.discoveryengine.v1.Session] action type cannot be
5292 /// changed. If the [Session][google.cloud.discoveryengine.v1.Session] to
5293 /// update does not exist, a NOT_FOUND error is returned.
5294 ///
5295 /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
5296 ///
5297 /// # Example
5298 /// ```
5299 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5300 /// # extern crate wkt as google_cloud_wkt;
5301 /// use google_cloud_wkt::FieldMask;
5302 /// use google_cloud_discoveryengine_v1::model::Session;
5303 /// use google_cloud_discoveryengine_v1::Result;
5304 /// async fn sample(
5305 /// client: &SessionService, project_id: &str, location_id: &str, data_store_id: &str, session_id: &str
5306 /// ) -> Result<()> {
5307 /// let response = client.update_session()
5308 /// .set_session(
5309 /// Session::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/sessions/{session_id}"))/* set fields */
5310 /// )
5311 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
5312 /// .send().await?;
5313 /// println!("response {:?}", response);
5314 /// Ok(())
5315 /// }
5316 /// ```
5317 pub fn update_session(&self) -> super::builder::session_service::UpdateSession {
5318 super::builder::session_service::UpdateSession::new(self.inner.clone())
5319 }
5320
5321 /// Gets a Session.
5322 ///
5323 /// # Example
5324 /// ```
5325 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5326 /// use google_cloud_discoveryengine_v1::Result;
5327 /// async fn sample(
5328 /// client: &SessionService, project_id: &str, location_id: &str, data_store_id: &str, session_id: &str
5329 /// ) -> Result<()> {
5330 /// let response = client.get_session()
5331 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/sessions/{session_id}"))
5332 /// .send().await?;
5333 /// println!("response {:?}", response);
5334 /// Ok(())
5335 /// }
5336 /// ```
5337 pub fn get_session(&self) -> super::builder::session_service::GetSession {
5338 super::builder::session_service::GetSession::new(self.inner.clone())
5339 }
5340
5341 /// Lists all Sessions by their parent
5342 /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
5343 ///
5344 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
5345 ///
5346 /// # Example
5347 /// ```
5348 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5349 /// use google_cloud_gax::paginator::ItemPaginator as _;
5350 /// use google_cloud_discoveryengine_v1::Result;
5351 /// async fn sample(
5352 /// client: &SessionService, project_id: &str, location_id: &str, data_store_id: &str
5353 /// ) -> Result<()> {
5354 /// let mut list = client.list_sessions()
5355 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}"))
5356 /// .by_item();
5357 /// while let Some(item) = list.next().await.transpose()? {
5358 /// println!("{:?}", item);
5359 /// }
5360 /// Ok(())
5361 /// }
5362 /// ```
5363 pub fn list_sessions(&self) -> super::builder::session_service::ListSessions {
5364 super::builder::session_service::ListSessions::new(self.inner.clone())
5365 }
5366
5367 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
5368 ///
5369 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
5370 ///
5371 /// # Example
5372 /// ```
5373 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5374 /// use google_cloud_gax::paginator::ItemPaginator as _;
5375 /// use google_cloud_discoveryengine_v1::Result;
5376 /// async fn sample(
5377 /// client: &SessionService
5378 /// ) -> Result<()> {
5379 /// let mut list = client.list_operations()
5380 /// /* set fields */
5381 /// .by_item();
5382 /// while let Some(item) = list.next().await.transpose()? {
5383 /// println!("{:?}", item);
5384 /// }
5385 /// Ok(())
5386 /// }
5387 /// ```
5388 pub fn list_operations(&self) -> super::builder::session_service::ListOperations {
5389 super::builder::session_service::ListOperations::new(self.inner.clone())
5390 }
5391
5392 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
5393 ///
5394 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
5395 ///
5396 /// # Example
5397 /// ```
5398 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5399 /// use google_cloud_discoveryengine_v1::Result;
5400 /// async fn sample(
5401 /// client: &SessionService
5402 /// ) -> Result<()> {
5403 /// let response = client.get_operation()
5404 /// /* set fields */
5405 /// .send().await?;
5406 /// println!("response {:?}", response);
5407 /// Ok(())
5408 /// }
5409 /// ```
5410 pub fn get_operation(&self) -> super::builder::session_service::GetOperation {
5411 super::builder::session_service::GetOperation::new(self.inner.clone())
5412 }
5413
5414 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
5415 ///
5416 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
5417 ///
5418 /// # Example
5419 /// ```
5420 /// # use google_cloud_discoveryengine_v1::client::SessionService;
5421 /// use google_cloud_discoveryengine_v1::Result;
5422 /// async fn sample(
5423 /// client: &SessionService
5424 /// ) -> Result<()> {
5425 /// client.cancel_operation()
5426 /// /* set fields */
5427 /// .send().await?;
5428 /// Ok(())
5429 /// }
5430 /// ```
5431 pub fn cancel_operation(&self) -> super::builder::session_service::CancelOperation {
5432 super::builder::session_service::CancelOperation::new(self.inner.clone())
5433 }
5434}
5435
5436/// Implements a client for the Discovery Engine API.
5437///
5438/// # Example
5439/// ```
5440/// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5441/// use google_cloud_gax::paginator::ItemPaginator as _;
5442/// async fn sample(
5443/// project_id: &str,
5444/// location_id: &str,
5445/// data_store_id: &str,
5446/// ) -> anyhow::Result<()> {
5447/// let client = SiteSearchEngineService::builder().build().await?;
5448/// let mut list = client.list_target_sites()
5449/// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine"))
5450/// .by_item();
5451/// while let Some(item) = list.next().await.transpose()? {
5452/// println!("{:?}", item);
5453/// }
5454/// Ok(())
5455/// }
5456/// ```
5457///
5458/// # Service Description
5459///
5460/// Service for managing site search related resources.
5461///
5462/// # Configuration
5463///
5464/// To configure `SiteSearchEngineService` use the `with_*` methods in the type returned
5465/// by [builder()][SiteSearchEngineService::builder]. The default configuration should
5466/// work for most applications. Common configuration changes include
5467///
5468/// * [with_endpoint()]: by default this client uses the global default endpoint
5469/// (`https://discoveryengine.googleapis.com`). Applications using regional
5470/// endpoints or running in restricted networks (e.g. a network configured
5471/// with [Private Google Access with VPC Service Controls]) may want to
5472/// override this default.
5473/// * [with_credentials()]: by default this client uses
5474/// [Application Default Credentials]. Applications using custom
5475/// authentication may need to override this default.
5476///
5477/// [with_endpoint()]: super::builder::site_search_engine_service::ClientBuilder::with_endpoint
5478/// [with_credentials()]: super::builder::site_search_engine_service::ClientBuilder::with_credentials
5479/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
5480/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
5481///
5482/// # Pooling and Cloning
5483///
5484/// `SiteSearchEngineService` holds a connection pool internally, it is advised to
5485/// create one and reuse it. You do not need to wrap `SiteSearchEngineService` in
5486/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
5487/// already uses an `Arc` internally.
5488#[cfg(feature = "site-search-engine-service")]
5489#[cfg_attr(docsrs, doc(cfg(feature = "site-search-engine-service")))]
5490#[derive(Clone, Debug)]
5491pub struct SiteSearchEngineService {
5492 inner: std::sync::Arc<dyn super::stub::dynamic::SiteSearchEngineService>,
5493}
5494
5495#[cfg(feature = "site-search-engine-service")]
5496impl SiteSearchEngineService {
5497 /// Returns a builder for [SiteSearchEngineService].
5498 ///
5499 /// ```
5500 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
5501 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5502 /// let client = SiteSearchEngineService::builder().build().await?;
5503 /// # Ok(()) }
5504 /// ```
5505 pub fn builder() -> super::builder::site_search_engine_service::ClientBuilder {
5506 crate::new_client_builder(super::builder::site_search_engine_service::client::Factory)
5507 }
5508
5509 /// Creates a new client from the provided stub.
5510 ///
5511 /// The most common case for calling this function is in tests mocking the
5512 /// client's behavior.
5513 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
5514 where
5515 T: super::stub::SiteSearchEngineService + 'static,
5516 {
5517 Self { inner: stub.into() }
5518 }
5519
5520 pub(crate) async fn new(
5521 config: gaxi::options::ClientConfig,
5522 ) -> crate::ClientBuilderResult<Self> {
5523 let inner = Self::build_inner(config).await?;
5524 Ok(Self { inner })
5525 }
5526
5527 async fn build_inner(
5528 conf: gaxi::options::ClientConfig,
5529 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SiteSearchEngineService>>
5530 {
5531 if gaxi::options::tracing_enabled(&conf) {
5532 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
5533 }
5534 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
5535 }
5536
5537 async fn build_transport(
5538 conf: gaxi::options::ClientConfig,
5539 ) -> crate::ClientBuilderResult<impl super::stub::SiteSearchEngineService> {
5540 super::transport::SiteSearchEngineService::new(conf).await
5541 }
5542
5543 async fn build_with_tracing(
5544 conf: gaxi::options::ClientConfig,
5545 ) -> crate::ClientBuilderResult<impl super::stub::SiteSearchEngineService> {
5546 Self::build_transport(conf)
5547 .await
5548 .map(super::tracing::SiteSearchEngineService::new)
5549 }
5550
5551 /// Gets the
5552 /// [SiteSearchEngine][google.cloud.discoveryengine.v1.SiteSearchEngine].
5553 ///
5554 /// [google.cloud.discoveryengine.v1.SiteSearchEngine]: crate::model::SiteSearchEngine
5555 ///
5556 /// # Example
5557 /// ```
5558 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5559 /// use google_cloud_discoveryengine_v1::Result;
5560 /// async fn sample(
5561 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str
5562 /// ) -> Result<()> {
5563 /// let response = client.get_site_search_engine()
5564 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine"))
5565 /// .send().await?;
5566 /// println!("response {:?}", response);
5567 /// Ok(())
5568 /// }
5569 /// ```
5570 pub fn get_site_search_engine(
5571 &self,
5572 ) -> super::builder::site_search_engine_service::GetSiteSearchEngine {
5573 super::builder::site_search_engine_service::GetSiteSearchEngine::new(self.inner.clone())
5574 }
5575
5576 /// Creates a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
5577 ///
5578 /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
5579 ///
5580 /// # Long running operations
5581 ///
5582 /// This method is used to start, and/or poll a [long-running Operation].
5583 /// The [Working with long-running operations] chapter in the [user guide]
5584 /// covers these operations in detail.
5585 ///
5586 /// [long-running operation]: https://google.aip.dev/151
5587 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5588 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5589 ///
5590 /// # Example
5591 /// ```
5592 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5593 /// use google_cloud_lro::Poller;
5594 /// use google_cloud_discoveryengine_v1::model::TargetSite;
5595 /// use google_cloud_discoveryengine_v1::Result;
5596 /// async fn sample(
5597 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str
5598 /// ) -> Result<()> {
5599 /// let response = client.create_target_site()
5600 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine"))
5601 /// .set_target_site(
5602 /// TargetSite::new()/* set fields */
5603 /// )
5604 /// .poller().until_done().await?;
5605 /// println!("response {:?}", response);
5606 /// Ok(())
5607 /// }
5608 /// ```
5609 pub fn create_target_site(
5610 &self,
5611 ) -> super::builder::site_search_engine_service::CreateTargetSite {
5612 super::builder::site_search_engine_service::CreateTargetSite::new(self.inner.clone())
5613 }
5614
5615 /// Creates [TargetSite][google.cloud.discoveryengine.v1.TargetSite] in a
5616 /// batch.
5617 ///
5618 /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
5619 ///
5620 /// # Long running operations
5621 ///
5622 /// This method is used to start, and/or poll a [long-running Operation].
5623 /// The [Working with long-running operations] chapter in the [user guide]
5624 /// covers these operations in detail.
5625 ///
5626 /// [long-running operation]: https://google.aip.dev/151
5627 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5628 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5629 ///
5630 /// # Example
5631 /// ```
5632 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5633 /// use google_cloud_lro::Poller;
5634 /// use google_cloud_discoveryengine_v1::Result;
5635 /// async fn sample(
5636 /// client: &SiteSearchEngineService
5637 /// ) -> Result<()> {
5638 /// let response = client.batch_create_target_sites()
5639 /// /* set fields */
5640 /// .poller().until_done().await?;
5641 /// println!("response {:?}", response);
5642 /// Ok(())
5643 /// }
5644 /// ```
5645 pub fn batch_create_target_sites(
5646 &self,
5647 ) -> super::builder::site_search_engine_service::BatchCreateTargetSites {
5648 super::builder::site_search_engine_service::BatchCreateTargetSites::new(self.inner.clone())
5649 }
5650
5651 /// Gets a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
5652 ///
5653 /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
5654 ///
5655 /// # Example
5656 /// ```
5657 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5658 /// use google_cloud_discoveryengine_v1::Result;
5659 /// async fn sample(
5660 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str, target_site_id: &str
5661 /// ) -> Result<()> {
5662 /// let response = client.get_target_site()
5663 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine/targetSites/{target_site_id}"))
5664 /// .send().await?;
5665 /// println!("response {:?}", response);
5666 /// Ok(())
5667 /// }
5668 /// ```
5669 pub fn get_target_site(&self) -> super::builder::site_search_engine_service::GetTargetSite {
5670 super::builder::site_search_engine_service::GetTargetSite::new(self.inner.clone())
5671 }
5672
5673 /// Updates a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
5674 ///
5675 /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
5676 ///
5677 /// # Long running operations
5678 ///
5679 /// This method is used to start, and/or poll a [long-running Operation].
5680 /// The [Working with long-running operations] chapter in the [user guide]
5681 /// covers these operations in detail.
5682 ///
5683 /// [long-running operation]: https://google.aip.dev/151
5684 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5685 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5686 ///
5687 /// # Example
5688 /// ```
5689 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5690 /// use google_cloud_lro::Poller;
5691 /// use google_cloud_discoveryengine_v1::model::TargetSite;
5692 /// use google_cloud_discoveryengine_v1::Result;
5693 /// async fn sample(
5694 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str, target_site_id: &str
5695 /// ) -> Result<()> {
5696 /// let response = client.update_target_site()
5697 /// .set_target_site(
5698 /// TargetSite::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine/targetSites/{target_site_id}"))/* set fields */
5699 /// )
5700 /// .poller().until_done().await?;
5701 /// println!("response {:?}", response);
5702 /// Ok(())
5703 /// }
5704 /// ```
5705 pub fn update_target_site(
5706 &self,
5707 ) -> super::builder::site_search_engine_service::UpdateTargetSite {
5708 super::builder::site_search_engine_service::UpdateTargetSite::new(self.inner.clone())
5709 }
5710
5711 /// Deletes a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
5712 ///
5713 /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
5714 ///
5715 /// # Long running operations
5716 ///
5717 /// This method is used to start, and/or poll a [long-running Operation].
5718 /// The [Working with long-running operations] chapter in the [user guide]
5719 /// covers these operations in detail.
5720 ///
5721 /// [long-running operation]: https://google.aip.dev/151
5722 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5723 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5724 ///
5725 /// # Example
5726 /// ```
5727 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5728 /// use google_cloud_lro::Poller;
5729 /// use google_cloud_discoveryengine_v1::Result;
5730 /// async fn sample(
5731 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str, target_site_id: &str
5732 /// ) -> Result<()> {
5733 /// client.delete_target_site()
5734 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine/targetSites/{target_site_id}"))
5735 /// .poller().until_done().await?;
5736 /// Ok(())
5737 /// }
5738 /// ```
5739 pub fn delete_target_site(
5740 &self,
5741 ) -> super::builder::site_search_engine_service::DeleteTargetSite {
5742 super::builder::site_search_engine_service::DeleteTargetSite::new(self.inner.clone())
5743 }
5744
5745 /// Gets a list of [TargetSite][google.cloud.discoveryengine.v1.TargetSite]s.
5746 ///
5747 /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
5748 ///
5749 /// # Example
5750 /// ```
5751 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5752 /// use google_cloud_gax::paginator::ItemPaginator as _;
5753 /// use google_cloud_discoveryengine_v1::Result;
5754 /// async fn sample(
5755 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str
5756 /// ) -> Result<()> {
5757 /// let mut list = client.list_target_sites()
5758 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine"))
5759 /// .by_item();
5760 /// while let Some(item) = list.next().await.transpose()? {
5761 /// println!("{:?}", item);
5762 /// }
5763 /// Ok(())
5764 /// }
5765 /// ```
5766 pub fn list_target_sites(&self) -> super::builder::site_search_engine_service::ListTargetSites {
5767 super::builder::site_search_engine_service::ListTargetSites::new(self.inner.clone())
5768 }
5769
5770 /// Creates a [Sitemap][google.cloud.discoveryengine.v1.Sitemap].
5771 ///
5772 /// [google.cloud.discoveryengine.v1.Sitemap]: crate::model::Sitemap
5773 ///
5774 /// # Long running operations
5775 ///
5776 /// This method is used to start, and/or poll a [long-running Operation].
5777 /// The [Working with long-running operations] chapter in the [user guide]
5778 /// covers these operations in detail.
5779 ///
5780 /// [long-running operation]: https://google.aip.dev/151
5781 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5782 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5783 ///
5784 /// # Example
5785 /// ```
5786 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5787 /// use google_cloud_lro::Poller;
5788 /// use google_cloud_discoveryengine_v1::model::Sitemap;
5789 /// use google_cloud_discoveryengine_v1::Result;
5790 /// async fn sample(
5791 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str
5792 /// ) -> Result<()> {
5793 /// let response = client.create_sitemap()
5794 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine"))
5795 /// .set_sitemap(
5796 /// Sitemap::new()/* set fields */
5797 /// )
5798 /// .poller().until_done().await?;
5799 /// println!("response {:?}", response);
5800 /// Ok(())
5801 /// }
5802 /// ```
5803 pub fn create_sitemap(&self) -> super::builder::site_search_engine_service::CreateSitemap {
5804 super::builder::site_search_engine_service::CreateSitemap::new(self.inner.clone())
5805 }
5806
5807 /// Deletes a [Sitemap][google.cloud.discoveryengine.v1.Sitemap].
5808 ///
5809 /// [google.cloud.discoveryengine.v1.Sitemap]: crate::model::Sitemap
5810 ///
5811 /// # Long running operations
5812 ///
5813 /// This method is used to start, and/or poll a [long-running Operation].
5814 /// The [Working with long-running operations] chapter in the [user guide]
5815 /// covers these operations in detail.
5816 ///
5817 /// [long-running operation]: https://google.aip.dev/151
5818 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5819 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5820 ///
5821 /// # Example
5822 /// ```
5823 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5824 /// use google_cloud_lro::Poller;
5825 /// use google_cloud_discoveryengine_v1::Result;
5826 /// async fn sample(
5827 /// client: &SiteSearchEngineService, project_id: &str, location_id: &str, data_store_id: &str, sitemap_id: &str
5828 /// ) -> Result<()> {
5829 /// client.delete_sitemap()
5830 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataStores/{data_store_id}/siteSearchEngine/sitemaps/{sitemap_id}"))
5831 /// .poller().until_done().await?;
5832 /// Ok(())
5833 /// }
5834 /// ```
5835 pub fn delete_sitemap(&self) -> super::builder::site_search_engine_service::DeleteSitemap {
5836 super::builder::site_search_engine_service::DeleteSitemap::new(self.inner.clone())
5837 }
5838
5839 /// Fetch [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s in a
5840 /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
5841 ///
5842 /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
5843 /// [google.cloud.discoveryengine.v1.Sitemap]: crate::model::Sitemap
5844 ///
5845 /// # Example
5846 /// ```
5847 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5848 /// use google_cloud_discoveryengine_v1::Result;
5849 /// async fn sample(
5850 /// client: &SiteSearchEngineService
5851 /// ) -> Result<()> {
5852 /// let response = client.fetch_sitemaps()
5853 /// /* set fields */
5854 /// .send().await?;
5855 /// println!("response {:?}", response);
5856 /// Ok(())
5857 /// }
5858 /// ```
5859 pub fn fetch_sitemaps(&self) -> super::builder::site_search_engine_service::FetchSitemaps {
5860 super::builder::site_search_engine_service::FetchSitemaps::new(self.inner.clone())
5861 }
5862
5863 /// Upgrade from basic site search to advanced site search.
5864 ///
5865 /// # Long running operations
5866 ///
5867 /// This method is used to start, and/or poll a [long-running Operation].
5868 /// The [Working with long-running operations] chapter in the [user guide]
5869 /// covers these operations in detail.
5870 ///
5871 /// [long-running operation]: https://google.aip.dev/151
5872 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5873 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5874 ///
5875 /// # Example
5876 /// ```
5877 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5878 /// use google_cloud_lro::Poller;
5879 /// use google_cloud_discoveryengine_v1::Result;
5880 /// async fn sample(
5881 /// client: &SiteSearchEngineService
5882 /// ) -> Result<()> {
5883 /// let response = client.enable_advanced_site_search()
5884 /// /* set fields */
5885 /// .poller().until_done().await?;
5886 /// println!("response {:?}", response);
5887 /// Ok(())
5888 /// }
5889 /// ```
5890 pub fn enable_advanced_site_search(
5891 &self,
5892 ) -> super::builder::site_search_engine_service::EnableAdvancedSiteSearch {
5893 super::builder::site_search_engine_service::EnableAdvancedSiteSearch::new(
5894 self.inner.clone(),
5895 )
5896 }
5897
5898 /// Downgrade from advanced site search to basic site search.
5899 ///
5900 /// # Long running operations
5901 ///
5902 /// This method is used to start, and/or poll a [long-running Operation].
5903 /// The [Working with long-running operations] chapter in the [user guide]
5904 /// covers these operations in detail.
5905 ///
5906 /// [long-running operation]: https://google.aip.dev/151
5907 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5908 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5909 ///
5910 /// # Example
5911 /// ```
5912 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5913 /// use google_cloud_lro::Poller;
5914 /// use google_cloud_discoveryengine_v1::Result;
5915 /// async fn sample(
5916 /// client: &SiteSearchEngineService
5917 /// ) -> Result<()> {
5918 /// let response = client.disable_advanced_site_search()
5919 /// /* set fields */
5920 /// .poller().until_done().await?;
5921 /// println!("response {:?}", response);
5922 /// Ok(())
5923 /// }
5924 /// ```
5925 pub fn disable_advanced_site_search(
5926 &self,
5927 ) -> super::builder::site_search_engine_service::DisableAdvancedSiteSearch {
5928 super::builder::site_search_engine_service::DisableAdvancedSiteSearch::new(
5929 self.inner.clone(),
5930 )
5931 }
5932
5933 /// Request on-demand recrawl for a list of URIs.
5934 ///
5935 /// # Long running operations
5936 ///
5937 /// This method is used to start, and/or poll a [long-running Operation].
5938 /// The [Working with long-running operations] chapter in the [user guide]
5939 /// covers these operations in detail.
5940 ///
5941 /// [long-running operation]: https://google.aip.dev/151
5942 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5943 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5944 ///
5945 /// # Example
5946 /// ```
5947 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5948 /// use google_cloud_lro::Poller;
5949 /// use google_cloud_discoveryengine_v1::Result;
5950 /// async fn sample(
5951 /// client: &SiteSearchEngineService
5952 /// ) -> Result<()> {
5953 /// let response = client.recrawl_uris()
5954 /// /* set fields */
5955 /// .poller().until_done().await?;
5956 /// println!("response {:?}", response);
5957 /// Ok(())
5958 /// }
5959 /// ```
5960 pub fn recrawl_uris(&self) -> super::builder::site_search_engine_service::RecrawlUris {
5961 super::builder::site_search_engine_service::RecrawlUris::new(self.inner.clone())
5962 }
5963
5964 /// Verify target sites' ownership and validity.
5965 /// This API sends all the target sites under site search engine for
5966 /// verification.
5967 ///
5968 /// # Long running operations
5969 ///
5970 /// This method is used to start, and/or poll a [long-running Operation].
5971 /// The [Working with long-running operations] chapter in the [user guide]
5972 /// covers these operations in detail.
5973 ///
5974 /// [long-running operation]: https://google.aip.dev/151
5975 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
5976 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
5977 ///
5978 /// # Example
5979 /// ```
5980 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
5981 /// use google_cloud_lro::Poller;
5982 /// use google_cloud_discoveryengine_v1::Result;
5983 /// async fn sample(
5984 /// client: &SiteSearchEngineService
5985 /// ) -> Result<()> {
5986 /// let response = client.batch_verify_target_sites()
5987 /// /* set fields */
5988 /// .poller().until_done().await?;
5989 /// println!("response {:?}", response);
5990 /// Ok(())
5991 /// }
5992 /// ```
5993 pub fn batch_verify_target_sites(
5994 &self,
5995 ) -> super::builder::site_search_engine_service::BatchVerifyTargetSites {
5996 super::builder::site_search_engine_service::BatchVerifyTargetSites::new(self.inner.clone())
5997 }
5998
5999 /// Returns list of target sites with its domain verification status.
6000 /// This method can only be called under data store with BASIC_SITE_SEARCH
6001 /// state at the moment.
6002 ///
6003 /// # Example
6004 /// ```
6005 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
6006 /// use google_cloud_gax::paginator::ItemPaginator as _;
6007 /// use google_cloud_discoveryengine_v1::Result;
6008 /// async fn sample(
6009 /// client: &SiteSearchEngineService
6010 /// ) -> Result<()> {
6011 /// let mut list = client.fetch_domain_verification_status()
6012 /// /* set fields */
6013 /// .by_item();
6014 /// while let Some(item) = list.next().await.transpose()? {
6015 /// println!("{:?}", item);
6016 /// }
6017 /// Ok(())
6018 /// }
6019 /// ```
6020 pub fn fetch_domain_verification_status(
6021 &self,
6022 ) -> super::builder::site_search_engine_service::FetchDomainVerificationStatus {
6023 super::builder::site_search_engine_service::FetchDomainVerificationStatus::new(
6024 self.inner.clone(),
6025 )
6026 }
6027
6028 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6029 ///
6030 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6031 ///
6032 /// # Example
6033 /// ```
6034 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
6035 /// use google_cloud_gax::paginator::ItemPaginator as _;
6036 /// use google_cloud_discoveryengine_v1::Result;
6037 /// async fn sample(
6038 /// client: &SiteSearchEngineService
6039 /// ) -> Result<()> {
6040 /// let mut list = client.list_operations()
6041 /// /* set fields */
6042 /// .by_item();
6043 /// while let Some(item) = list.next().await.transpose()? {
6044 /// println!("{:?}", item);
6045 /// }
6046 /// Ok(())
6047 /// }
6048 /// ```
6049 pub fn list_operations(&self) -> super::builder::site_search_engine_service::ListOperations {
6050 super::builder::site_search_engine_service::ListOperations::new(self.inner.clone())
6051 }
6052
6053 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6054 ///
6055 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6056 ///
6057 /// # Example
6058 /// ```
6059 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
6060 /// use google_cloud_discoveryengine_v1::Result;
6061 /// async fn sample(
6062 /// client: &SiteSearchEngineService
6063 /// ) -> Result<()> {
6064 /// let response = client.get_operation()
6065 /// /* set fields */
6066 /// .send().await?;
6067 /// println!("response {:?}", response);
6068 /// Ok(())
6069 /// }
6070 /// ```
6071 pub fn get_operation(&self) -> super::builder::site_search_engine_service::GetOperation {
6072 super::builder::site_search_engine_service::GetOperation::new(self.inner.clone())
6073 }
6074
6075 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6076 ///
6077 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6078 ///
6079 /// # Example
6080 /// ```
6081 /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
6082 /// use google_cloud_discoveryengine_v1::Result;
6083 /// async fn sample(
6084 /// client: &SiteSearchEngineService
6085 /// ) -> Result<()> {
6086 /// client.cancel_operation()
6087 /// /* set fields */
6088 /// .send().await?;
6089 /// Ok(())
6090 /// }
6091 /// ```
6092 pub fn cancel_operation(&self) -> super::builder::site_search_engine_service::CancelOperation {
6093 super::builder::site_search_engine_service::CancelOperation::new(self.inner.clone())
6094 }
6095}
6096
6097/// Implements a client for the Discovery Engine API.
6098///
6099/// # Example
6100/// ```
6101/// # use google_cloud_discoveryengine_v1::client::UserEventService;
6102/// async fn sample(
6103/// ) -> anyhow::Result<()> {
6104/// let client = UserEventService::builder().build().await?;
6105/// let response = client.write_user_event()
6106/// /* set fields */
6107/// .send().await?;
6108/// println!("response {:?}", response);
6109/// Ok(())
6110/// }
6111/// ```
6112///
6113/// # Service Description
6114///
6115/// Service for ingesting end user actions on a website to Discovery Engine API.
6116///
6117/// # Configuration
6118///
6119/// To configure `UserEventService` use the `with_*` methods in the type returned
6120/// by [builder()][UserEventService::builder]. The default configuration should
6121/// work for most applications. Common configuration changes include
6122///
6123/// * [with_endpoint()]: by default this client uses the global default endpoint
6124/// (`https://discoveryengine.googleapis.com`). Applications using regional
6125/// endpoints or running in restricted networks (e.g. a network configured
6126/// with [Private Google Access with VPC Service Controls]) may want to
6127/// override this default.
6128/// * [with_credentials()]: by default this client uses
6129/// [Application Default Credentials]. Applications using custom
6130/// authentication may need to override this default.
6131///
6132/// [with_endpoint()]: super::builder::user_event_service::ClientBuilder::with_endpoint
6133/// [with_credentials()]: super::builder::user_event_service::ClientBuilder::with_credentials
6134/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
6135/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
6136///
6137/// # Pooling and Cloning
6138///
6139/// `UserEventService` holds a connection pool internally, it is advised to
6140/// create one and reuse it. You do not need to wrap `UserEventService` in
6141/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
6142/// already uses an `Arc` internally.
6143#[cfg(feature = "user-event-service")]
6144#[cfg_attr(docsrs, doc(cfg(feature = "user-event-service")))]
6145#[derive(Clone, Debug)]
6146pub struct UserEventService {
6147 inner: std::sync::Arc<dyn super::stub::dynamic::UserEventService>,
6148}
6149
6150#[cfg(feature = "user-event-service")]
6151impl UserEventService {
6152 /// Returns a builder for [UserEventService].
6153 ///
6154 /// ```
6155 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
6156 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6157 /// let client = UserEventService::builder().build().await?;
6158 /// # Ok(()) }
6159 /// ```
6160 pub fn builder() -> super::builder::user_event_service::ClientBuilder {
6161 crate::new_client_builder(super::builder::user_event_service::client::Factory)
6162 }
6163
6164 /// Creates a new client from the provided stub.
6165 ///
6166 /// The most common case for calling this function is in tests mocking the
6167 /// client's behavior.
6168 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
6169 where
6170 T: super::stub::UserEventService + 'static,
6171 {
6172 Self { inner: stub.into() }
6173 }
6174
6175 pub(crate) async fn new(
6176 config: gaxi::options::ClientConfig,
6177 ) -> crate::ClientBuilderResult<Self> {
6178 let inner = Self::build_inner(config).await?;
6179 Ok(Self { inner })
6180 }
6181
6182 async fn build_inner(
6183 conf: gaxi::options::ClientConfig,
6184 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::UserEventService>>
6185 {
6186 if gaxi::options::tracing_enabled(&conf) {
6187 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
6188 }
6189 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
6190 }
6191
6192 async fn build_transport(
6193 conf: gaxi::options::ClientConfig,
6194 ) -> crate::ClientBuilderResult<impl super::stub::UserEventService> {
6195 super::transport::UserEventService::new(conf).await
6196 }
6197
6198 async fn build_with_tracing(
6199 conf: gaxi::options::ClientConfig,
6200 ) -> crate::ClientBuilderResult<impl super::stub::UserEventService> {
6201 Self::build_transport(conf)
6202 .await
6203 .map(super::tracing::UserEventService::new)
6204 }
6205
6206 /// Writes a single user event.
6207 ///
6208 /// # Example
6209 /// ```
6210 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6211 /// use google_cloud_discoveryengine_v1::Result;
6212 /// async fn sample(
6213 /// client: &UserEventService
6214 /// ) -> Result<()> {
6215 /// let response = client.write_user_event()
6216 /// /* set fields */
6217 /// .send().await?;
6218 /// println!("response {:?}", response);
6219 /// Ok(())
6220 /// }
6221 /// ```
6222 pub fn write_user_event(&self) -> super::builder::user_event_service::WriteUserEvent {
6223 super::builder::user_event_service::WriteUserEvent::new(self.inner.clone())
6224 }
6225
6226 /// Writes a single user event from the browser. This uses a GET request to
6227 /// due to browser restriction of POST-ing to a third-party domain.
6228 ///
6229 /// This method is used only by the Discovery Engine API JavaScript pixel and
6230 /// Google Tag Manager. Users should not call this method directly.
6231 ///
6232 /// # Example
6233 /// ```
6234 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6235 /// use google_cloud_discoveryengine_v1::Result;
6236 /// async fn sample(
6237 /// client: &UserEventService
6238 /// ) -> Result<()> {
6239 /// let response = client.collect_user_event()
6240 /// /* set fields */
6241 /// .send().await?;
6242 /// println!("response {:?}", response);
6243 /// Ok(())
6244 /// }
6245 /// ```
6246 pub fn collect_user_event(&self) -> super::builder::user_event_service::CollectUserEvent {
6247 super::builder::user_event_service::CollectUserEvent::new(self.inner.clone())
6248 }
6249
6250 /// Deletes permanently all user events specified by the filter provided.
6251 /// Depending on the number of events specified by the filter, this operation
6252 /// could take hours or days to complete. To test a filter, use the list
6253 /// command first.
6254 ///
6255 /// # Long running operations
6256 ///
6257 /// This method is used to start, and/or poll a [long-running Operation].
6258 /// The [Working with long-running operations] chapter in the [user guide]
6259 /// covers these operations in detail.
6260 ///
6261 /// [long-running operation]: https://google.aip.dev/151
6262 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
6263 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
6264 ///
6265 /// # Example
6266 /// ```
6267 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6268 /// use google_cloud_lro::Poller;
6269 /// use google_cloud_discoveryengine_v1::Result;
6270 /// async fn sample(
6271 /// client: &UserEventService
6272 /// ) -> Result<()> {
6273 /// let response = client.purge_user_events()
6274 /// /* set fields */
6275 /// .poller().until_done().await?;
6276 /// println!("response {:?}", response);
6277 /// Ok(())
6278 /// }
6279 /// ```
6280 pub fn purge_user_events(&self) -> super::builder::user_event_service::PurgeUserEvents {
6281 super::builder::user_event_service::PurgeUserEvents::new(self.inner.clone())
6282 }
6283
6284 /// Bulk import of user events. Request processing might be
6285 /// synchronous. Events that already exist are skipped.
6286 /// Use this method for backfilling historical user events.
6287 ///
6288 /// Operation.response is of type ImportResponse. Note that it is
6289 /// possible for a subset of the items to be successfully inserted.
6290 /// Operation.metadata is of type ImportMetadata.
6291 ///
6292 /// # Long running operations
6293 ///
6294 /// This method is used to start, and/or poll a [long-running Operation].
6295 /// The [Working with long-running operations] chapter in the [user guide]
6296 /// covers these operations in detail.
6297 ///
6298 /// [long-running operation]: https://google.aip.dev/151
6299 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
6300 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
6301 ///
6302 /// # Example
6303 /// ```
6304 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6305 /// use google_cloud_lro::Poller;
6306 /// use google_cloud_discoveryengine_v1::Result;
6307 /// async fn sample(
6308 /// client: &UserEventService
6309 /// ) -> Result<()> {
6310 /// let response = client.import_user_events()
6311 /// /* set fields */
6312 /// .poller().until_done().await?;
6313 /// println!("response {:?}", response);
6314 /// Ok(())
6315 /// }
6316 /// ```
6317 pub fn import_user_events(&self) -> super::builder::user_event_service::ImportUserEvents {
6318 super::builder::user_event_service::ImportUserEvents::new(self.inner.clone())
6319 }
6320
6321 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6322 ///
6323 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6324 ///
6325 /// # Example
6326 /// ```
6327 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6328 /// use google_cloud_gax::paginator::ItemPaginator as _;
6329 /// use google_cloud_discoveryengine_v1::Result;
6330 /// async fn sample(
6331 /// client: &UserEventService
6332 /// ) -> Result<()> {
6333 /// let mut list = client.list_operations()
6334 /// /* set fields */
6335 /// .by_item();
6336 /// while let Some(item) = list.next().await.transpose()? {
6337 /// println!("{:?}", item);
6338 /// }
6339 /// Ok(())
6340 /// }
6341 /// ```
6342 pub fn list_operations(&self) -> super::builder::user_event_service::ListOperations {
6343 super::builder::user_event_service::ListOperations::new(self.inner.clone())
6344 }
6345
6346 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6347 ///
6348 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6349 ///
6350 /// # Example
6351 /// ```
6352 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6353 /// use google_cloud_discoveryengine_v1::Result;
6354 /// async fn sample(
6355 /// client: &UserEventService
6356 /// ) -> Result<()> {
6357 /// let response = client.get_operation()
6358 /// /* set fields */
6359 /// .send().await?;
6360 /// println!("response {:?}", response);
6361 /// Ok(())
6362 /// }
6363 /// ```
6364 pub fn get_operation(&self) -> super::builder::user_event_service::GetOperation {
6365 super::builder::user_event_service::GetOperation::new(self.inner.clone())
6366 }
6367
6368 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6369 ///
6370 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6371 ///
6372 /// # Example
6373 /// ```
6374 /// # use google_cloud_discoveryengine_v1::client::UserEventService;
6375 /// use google_cloud_discoveryengine_v1::Result;
6376 /// async fn sample(
6377 /// client: &UserEventService
6378 /// ) -> Result<()> {
6379 /// client.cancel_operation()
6380 /// /* set fields */
6381 /// .send().await?;
6382 /// Ok(())
6383 /// }
6384 /// ```
6385 pub fn cancel_operation(&self) -> super::builder::user_event_service::CancelOperation {
6386 super::builder::user_event_service::CancelOperation::new(self.inner.clone())
6387 }
6388}
6389
6390/// Implements a client for the Discovery Engine API.
6391///
6392/// # Example
6393/// ```
6394/// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
6395/// use google_cloud_gax::paginator::ItemPaginator as _;
6396/// async fn sample(
6397/// ) -> anyhow::Result<()> {
6398/// let client = UserLicenseService::builder().build().await?;
6399/// let mut list = client.list_user_licenses()
6400/// /* set fields */
6401/// .by_item();
6402/// while let Some(item) = list.next().await.transpose()? {
6403/// println!("{:?}", item);
6404/// }
6405/// Ok(())
6406/// }
6407/// ```
6408///
6409/// # Service Description
6410///
6411/// Service for managing User Licenses.
6412///
6413/// # Configuration
6414///
6415/// To configure `UserLicenseService` use the `with_*` methods in the type returned
6416/// by [builder()][UserLicenseService::builder]. The default configuration should
6417/// work for most applications. Common configuration changes include
6418///
6419/// * [with_endpoint()]: by default this client uses the global default endpoint
6420/// (`https://discoveryengine.googleapis.com`). Applications using regional
6421/// endpoints or running in restricted networks (e.g. a network configured
6422/// with [Private Google Access with VPC Service Controls]) may want to
6423/// override this default.
6424/// * [with_credentials()]: by default this client uses
6425/// [Application Default Credentials]. Applications using custom
6426/// authentication may need to override this default.
6427///
6428/// [with_endpoint()]: super::builder::user_license_service::ClientBuilder::with_endpoint
6429/// [with_credentials()]: super::builder::user_license_service::ClientBuilder::with_credentials
6430/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
6431/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
6432///
6433/// # Pooling and Cloning
6434///
6435/// `UserLicenseService` holds a connection pool internally, it is advised to
6436/// create one and reuse it. You do not need to wrap `UserLicenseService` in
6437/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
6438/// already uses an `Arc` internally.
6439#[cfg(feature = "user-license-service")]
6440#[cfg_attr(docsrs, doc(cfg(feature = "user-license-service")))]
6441#[derive(Clone, Debug)]
6442pub struct UserLicenseService {
6443 inner: std::sync::Arc<dyn super::stub::dynamic::UserLicenseService>,
6444}
6445
6446#[cfg(feature = "user-license-service")]
6447impl UserLicenseService {
6448 /// Returns a builder for [UserLicenseService].
6449 ///
6450 /// ```
6451 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
6452 /// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
6453 /// let client = UserLicenseService::builder().build().await?;
6454 /// # Ok(()) }
6455 /// ```
6456 pub fn builder() -> super::builder::user_license_service::ClientBuilder {
6457 crate::new_client_builder(super::builder::user_license_service::client::Factory)
6458 }
6459
6460 /// Creates a new client from the provided stub.
6461 ///
6462 /// The most common case for calling this function is in tests mocking the
6463 /// client's behavior.
6464 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
6465 where
6466 T: super::stub::UserLicenseService + 'static,
6467 {
6468 Self { inner: stub.into() }
6469 }
6470
6471 pub(crate) async fn new(
6472 config: gaxi::options::ClientConfig,
6473 ) -> crate::ClientBuilderResult<Self> {
6474 let inner = Self::build_inner(config).await?;
6475 Ok(Self { inner })
6476 }
6477
6478 async fn build_inner(
6479 conf: gaxi::options::ClientConfig,
6480 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::UserLicenseService>>
6481 {
6482 if gaxi::options::tracing_enabled(&conf) {
6483 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
6484 }
6485 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
6486 }
6487
6488 async fn build_transport(
6489 conf: gaxi::options::ClientConfig,
6490 ) -> crate::ClientBuilderResult<impl super::stub::UserLicenseService> {
6491 super::transport::UserLicenseService::new(conf).await
6492 }
6493
6494 async fn build_with_tracing(
6495 conf: gaxi::options::ClientConfig,
6496 ) -> crate::ClientBuilderResult<impl super::stub::UserLicenseService> {
6497 Self::build_transport(conf)
6498 .await
6499 .map(super::tracing::UserLicenseService::new)
6500 }
6501
6502 /// Lists the User Licenses.
6503 ///
6504 /// # Example
6505 /// ```
6506 /// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
6507 /// use google_cloud_gax::paginator::ItemPaginator as _;
6508 /// use google_cloud_discoveryengine_v1::Result;
6509 /// async fn sample(
6510 /// client: &UserLicenseService
6511 /// ) -> Result<()> {
6512 /// let mut list = client.list_user_licenses()
6513 /// /* set fields */
6514 /// .by_item();
6515 /// while let Some(item) = list.next().await.transpose()? {
6516 /// println!("{:?}", item);
6517 /// }
6518 /// Ok(())
6519 /// }
6520 /// ```
6521 pub fn list_user_licenses(&self) -> super::builder::user_license_service::ListUserLicenses {
6522 super::builder::user_license_service::ListUserLicenses::new(self.inner.clone())
6523 }
6524
6525 /// Updates the User License.
6526 /// This method is used for batch assign/unassign licenses to users.
6527 ///
6528 /// # Long running operations
6529 ///
6530 /// This method is used to start, and/or poll a [long-running Operation].
6531 /// The [Working with long-running operations] chapter in the [user guide]
6532 /// covers these operations in detail.
6533 ///
6534 /// [long-running operation]: https://google.aip.dev/151
6535 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
6536 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
6537 ///
6538 /// # Example
6539 /// ```
6540 /// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
6541 /// use google_cloud_lro::Poller;
6542 /// use google_cloud_discoveryengine_v1::Result;
6543 /// async fn sample(
6544 /// client: &UserLicenseService
6545 /// ) -> Result<()> {
6546 /// let response = client.batch_update_user_licenses()
6547 /// /* set fields */
6548 /// .poller().until_done().await?;
6549 /// println!("response {:?}", response);
6550 /// Ok(())
6551 /// }
6552 /// ```
6553 pub fn batch_update_user_licenses(
6554 &self,
6555 ) -> super::builder::user_license_service::BatchUpdateUserLicenses {
6556 super::builder::user_license_service::BatchUpdateUserLicenses::new(self.inner.clone())
6557 }
6558
6559 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6560 ///
6561 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6562 ///
6563 /// # Example
6564 /// ```
6565 /// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
6566 /// use google_cloud_gax::paginator::ItemPaginator as _;
6567 /// use google_cloud_discoveryengine_v1::Result;
6568 /// async fn sample(
6569 /// client: &UserLicenseService
6570 /// ) -> Result<()> {
6571 /// let mut list = client.list_operations()
6572 /// /* set fields */
6573 /// .by_item();
6574 /// while let Some(item) = list.next().await.transpose()? {
6575 /// println!("{:?}", item);
6576 /// }
6577 /// Ok(())
6578 /// }
6579 /// ```
6580 pub fn list_operations(&self) -> super::builder::user_license_service::ListOperations {
6581 super::builder::user_license_service::ListOperations::new(self.inner.clone())
6582 }
6583
6584 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6585 ///
6586 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6587 ///
6588 /// # Example
6589 /// ```
6590 /// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
6591 /// use google_cloud_discoveryengine_v1::Result;
6592 /// async fn sample(
6593 /// client: &UserLicenseService
6594 /// ) -> Result<()> {
6595 /// let response = client.get_operation()
6596 /// /* set fields */
6597 /// .send().await?;
6598 /// println!("response {:?}", response);
6599 /// Ok(())
6600 /// }
6601 /// ```
6602 pub fn get_operation(&self) -> super::builder::user_license_service::GetOperation {
6603 super::builder::user_license_service::GetOperation::new(self.inner.clone())
6604 }
6605
6606 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
6607 ///
6608 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
6609 ///
6610 /// # Example
6611 /// ```
6612 /// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
6613 /// use google_cloud_discoveryengine_v1::Result;
6614 /// async fn sample(
6615 /// client: &UserLicenseService
6616 /// ) -> Result<()> {
6617 /// client.cancel_operation()
6618 /// /* set fields */
6619 /// .send().await?;
6620 /// Ok(())
6621 /// }
6622 /// ```
6623 pub fn cancel_operation(&self) -> super::builder::user_license_service::CancelOperation {
6624 super::builder::user_license_service::CancelOperation::new(self.inner.clone())
6625 }
6626}