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