Skip to main content

google_cloud_geminidataanalytics_v1/
client.rs

1// Copyright 2026 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 Data Analytics API with Gemini.
22///
23/// # Example
24/// ```
25/// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28///    project_id: &str,
29///    location_id: &str,
30/// ) -> anyhow::Result<()> {
31///     let client = DataAgentService::builder().build().await?;
32///     let mut list = client.list_data_agents()
33///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
34///         .by_item();
35///     while let Some(item) = list.next().await.transpose()? {
36///         println!("{:?}", item);
37///     }
38///     Ok(())
39/// }
40/// ```
41///
42/// # Service Description
43///
44/// Service describing handlers for resources.
45///
46/// # Configuration
47///
48/// To configure `DataAgentService` use the `with_*` methods in the type returned
49/// by [builder()][DataAgentService::builder]. The default configuration should
50/// work for most applications. Common configuration changes include
51///
52/// * [with_endpoint()]: by default this client uses the global default endpoint
53///   (`https://geminidataanalytics.googleapis.com`). Applications using regional
54///   endpoints or running in restricted networks (e.g. a network configured
55///   with [Private Google Access with VPC Service Controls]) may want to
56///   override this default.
57/// * [with_credentials()]: by default this client uses
58///   [Application Default Credentials]. Applications using custom
59///   authentication may need to override this default.
60///
61/// [with_endpoint()]: super::builder::data_agent_service::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::data_agent_service::ClientBuilder::with_credentials
63/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
64/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
65///
66/// # Pooling and Cloning
67///
68/// `DataAgentService` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `DataAgentService` in
70/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
71/// already uses an `Arc` internally.
72#[derive(Clone, Debug)]
73pub struct DataAgentService {
74    inner: std::sync::Arc<dyn super::stub::dynamic::DataAgentService>,
75}
76
77impl DataAgentService {
78    /// Returns a builder for [DataAgentService].
79    ///
80    /// ```
81    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
83    /// let client = DataAgentService::builder().build().await?;
84    /// # Ok(()) }
85    /// ```
86    pub fn builder() -> super::builder::data_agent_service::ClientBuilder {
87        crate::new_client_builder(super::builder::data_agent_service::client::Factory)
88    }
89
90    /// Creates a new client from the provided stub.
91    ///
92    /// The most common case for calling this function is in tests mocking the
93    /// client's behavior.
94    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
95    where
96        T: super::stub::DataAgentService + 'static,
97    {
98        Self { inner: stub.into() }
99    }
100
101    pub(crate) async fn new(
102        config: gaxi::options::ClientConfig,
103    ) -> crate::ClientBuilderResult<Self> {
104        let inner = Self::build_inner(config).await?;
105        Ok(Self { inner })
106    }
107
108    async fn build_inner(
109        conf: gaxi::options::ClientConfig,
110    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::DataAgentService>>
111    {
112        if gaxi::options::tracing_enabled(&conf) {
113            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
114        }
115        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
116    }
117
118    async fn build_transport(
119        conf: gaxi::options::ClientConfig,
120    ) -> crate::ClientBuilderResult<impl super::stub::DataAgentService> {
121        super::transport::DataAgentService::new(conf).await
122    }
123
124    async fn build_with_tracing(
125        conf: gaxi::options::ClientConfig,
126    ) -> crate::ClientBuilderResult<impl super::stub::DataAgentService> {
127        Self::build_transport(conf)
128            .await
129            .map(super::tracing::DataAgentService::new)
130    }
131
132    /// Lists DataAgents in a given project and location.
133    ///
134    /// # Example
135    /// ```
136    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
137    /// use google_cloud_gax::paginator::ItemPaginator as _;
138    /// use google_cloud_geminidataanalytics_v1::Result;
139    /// async fn sample(
140    ///    client: &DataAgentService, project_id: &str, location_id: &str
141    /// ) -> Result<()> {
142    ///     let mut list = client.list_data_agents()
143    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
144    ///         .by_item();
145    ///     while let Some(item) = list.next().await.transpose()? {
146    ///         println!("{:?}", item);
147    ///     }
148    ///     Ok(())
149    /// }
150    /// ```
151    pub fn list_data_agents(&self) -> super::builder::data_agent_service::ListDataAgents {
152        super::builder::data_agent_service::ListDataAgents::new(self.inner.clone())
153    }
154
155    /// Lists DataAgents that are accessible to the caller in a given project and
156    /// location.
157    ///
158    /// # Example
159    /// ```
160    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
161    /// use google_cloud_gax::paginator::ItemPaginator as _;
162    /// use google_cloud_geminidataanalytics_v1::Result;
163    /// async fn sample(
164    ///    client: &DataAgentService, project_id: &str, location_id: &str
165    /// ) -> Result<()> {
166    ///     let mut list = client.list_accessible_data_agents()
167    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
168    ///         .by_item();
169    ///     while let Some(item) = list.next().await.transpose()? {
170    ///         println!("{:?}", item);
171    ///     }
172    ///     Ok(())
173    /// }
174    /// ```
175    pub fn list_accessible_data_agents(
176        &self,
177    ) -> super::builder::data_agent_service::ListAccessibleDataAgents {
178        super::builder::data_agent_service::ListAccessibleDataAgents::new(self.inner.clone())
179    }
180
181    /// Gets details of a single DataAgent.
182    ///
183    /// # Example
184    /// ```
185    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
186    /// use google_cloud_geminidataanalytics_v1::Result;
187    /// async fn sample(
188    ///    client: &DataAgentService, project_id: &str, location_id: &str, data_agent_id: &str
189    /// ) -> Result<()> {
190    ///     let response = client.get_data_agent()
191    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/dataAgents/{data_agent_id}"))
192    ///         .send().await?;
193    ///     println!("response {:?}", response);
194    ///     Ok(())
195    /// }
196    /// ```
197    pub fn get_data_agent(&self) -> super::builder::data_agent_service::GetDataAgent {
198        super::builder::data_agent_service::GetDataAgent::new(self.inner.clone())
199    }
200
201    /// Creates a new DataAgent in a given project and location.
202    ///
203    /// # Long running operations
204    ///
205    /// This method is used to start, and/or poll a [long-running Operation].
206    /// The [Working with long-running operations] chapter in the [user guide]
207    /// covers these operations in detail.
208    ///
209    /// [long-running operation]: https://google.aip.dev/151
210    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
211    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
212    ///
213    /// # Example
214    /// ```
215    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
216    /// use google_cloud_lro::Poller;
217    /// use google_cloud_geminidataanalytics_v1::model::DataAgent;
218    /// use google_cloud_geminidataanalytics_v1::Result;
219    /// async fn sample(
220    ///    client: &DataAgentService, project_id: &str, location_id: &str
221    /// ) -> Result<()> {
222    ///     let response = client.create_data_agent()
223    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
224    ///         .set_data_agent(
225    ///             DataAgent::new()/* set fields */
226    ///         )
227    ///         .poller().until_done().await?;
228    ///     println!("response {:?}", response);
229    ///     Ok(())
230    /// }
231    /// ```
232    pub fn create_data_agent(&self) -> super::builder::data_agent_service::CreateDataAgent {
233        super::builder::data_agent_service::CreateDataAgent::new(self.inner.clone())
234    }
235
236    /// Creates a new DataAgent in a given project and location synchronously.
237    ///
238    /// # Example
239    /// ```
240    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
241    /// use google_cloud_geminidataanalytics_v1::Result;
242    /// async fn sample(
243    ///    client: &DataAgentService
244    /// ) -> Result<()> {
245    ///     let response = client.create_data_agent_sync()
246    ///         /* set fields */
247    ///         .send().await?;
248    ///     println!("response {:?}", response);
249    ///     Ok(())
250    /// }
251    /// ```
252    pub fn create_data_agent_sync(
253        &self,
254    ) -> super::builder::data_agent_service::CreateDataAgentSync {
255        super::builder::data_agent_service::CreateDataAgentSync::new(self.inner.clone())
256    }
257
258    /// Updates the parameters of a single DataAgent.
259    ///
260    /// # Long running operations
261    ///
262    /// This method is used to start, and/or poll a [long-running Operation].
263    /// The [Working with long-running operations] chapter in the [user guide]
264    /// covers these operations in detail.
265    ///
266    /// [long-running operation]: https://google.aip.dev/151
267    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
268    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
269    ///
270    /// # Example
271    /// ```
272    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
273    /// use google_cloud_lro::Poller;
274    /// # extern crate wkt as google_cloud_wkt;
275    /// use google_cloud_wkt::FieldMask;
276    /// use google_cloud_geminidataanalytics_v1::model::DataAgent;
277    /// use google_cloud_geminidataanalytics_v1::Result;
278    /// async fn sample(
279    ///    client: &DataAgentService, project_id: &str, location_id: &str, data_agent_id: &str
280    /// ) -> Result<()> {
281    ///     let response = client.update_data_agent()
282    ///         .set_data_agent(
283    ///             DataAgent::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataAgents/{data_agent_id}"))/* set fields */
284    ///         )
285    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
286    ///         .poller().until_done().await?;
287    ///     println!("response {:?}", response);
288    ///     Ok(())
289    /// }
290    /// ```
291    pub fn update_data_agent(&self) -> super::builder::data_agent_service::UpdateDataAgent {
292        super::builder::data_agent_service::UpdateDataAgent::new(self.inner.clone())
293    }
294
295    /// Updates the parameters of a single DataAgent synchronously.
296    ///
297    /// # Example
298    /// ```
299    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
300    /// use google_cloud_geminidataanalytics_v1::Result;
301    /// async fn sample(
302    ///    client: &DataAgentService
303    /// ) -> Result<()> {
304    ///     let response = client.update_data_agent_sync()
305    ///         /* set fields */
306    ///         .send().await?;
307    ///     println!("response {:?}", response);
308    ///     Ok(())
309    /// }
310    /// ```
311    pub fn update_data_agent_sync(
312        &self,
313    ) -> super::builder::data_agent_service::UpdateDataAgentSync {
314        super::builder::data_agent_service::UpdateDataAgentSync::new(self.inner.clone())
315    }
316
317    /// Deletes a single DataAgent.
318    ///
319    /// # Long running operations
320    ///
321    /// This method is used to start, and/or poll a [long-running Operation].
322    /// The [Working with long-running operations] chapter in the [user guide]
323    /// covers these operations in detail.
324    ///
325    /// [long-running operation]: https://google.aip.dev/151
326    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
327    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
328    ///
329    /// # Example
330    /// ```
331    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
332    /// use google_cloud_lro::Poller;
333    /// use google_cloud_geminidataanalytics_v1::Result;
334    /// async fn sample(
335    ///    client: &DataAgentService, project_id: &str, location_id: &str, data_agent_id: &str
336    /// ) -> Result<()> {
337    ///     client.delete_data_agent()
338    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/dataAgents/{data_agent_id}"))
339    ///         .poller().until_done().await?;
340    ///     Ok(())
341    /// }
342    /// ```
343    pub fn delete_data_agent(&self) -> super::builder::data_agent_service::DeleteDataAgent {
344        super::builder::data_agent_service::DeleteDataAgent::new(self.inner.clone())
345    }
346
347    /// Deletes a single DataAgent synchronously.
348    ///
349    /// # Example
350    /// ```
351    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
352    /// use google_cloud_geminidataanalytics_v1::Result;
353    /// async fn sample(
354    ///    client: &DataAgentService
355    /// ) -> Result<()> {
356    ///     client.delete_data_agent_sync()
357    ///         /* set fields */
358    ///         .send().await?;
359    ///     Ok(())
360    /// }
361    /// ```
362    pub fn delete_data_agent_sync(
363        &self,
364    ) -> super::builder::data_agent_service::DeleteDataAgentSync {
365        super::builder::data_agent_service::DeleteDataAgentSync::new(self.inner.clone())
366    }
367
368    /// Gets the IAM policy for DataAgent
369    ///
370    /// # Example
371    /// ```
372    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
373    /// use google_cloud_geminidataanalytics_v1::Result;
374    /// async fn sample(
375    ///    client: &DataAgentService
376    /// ) -> Result<()> {
377    ///     let response = client.get_iam_policy()
378    ///         /* set fields */
379    ///         .send().await?;
380    ///     println!("response {:?}", response);
381    ///     Ok(())
382    /// }
383    /// ```
384    pub fn get_iam_policy(&self) -> super::builder::data_agent_service::GetIamPolicy {
385        super::builder::data_agent_service::GetIamPolicy::new(self.inner.clone())
386    }
387
388    /// Sets the IAM policy for a DataAgent.
389    ///
390    /// # Example
391    /// ```
392    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
393    /// use google_cloud_geminidataanalytics_v1::Result;
394    /// async fn sample(
395    ///    client: &DataAgentService
396    /// ) -> Result<()> {
397    ///     let response = client.set_iam_policy()
398    ///         /* set fields */
399    ///         .send().await?;
400    ///     println!("response {:?}", response);
401    ///     Ok(())
402    /// }
403    /// ```
404    pub fn set_iam_policy(&self) -> super::builder::data_agent_service::SetIamPolicy {
405        super::builder::data_agent_service::SetIamPolicy::new(self.inner.clone())
406    }
407
408    /// Lists information about the supported locations for this service.
409    ///
410    /// This method lists locations based on the resource scope provided in
411    /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
412    /// **Global locations**: If `name` is empty, the method lists the
413    /// public locations available to all projects. * **Project-specific
414    /// locations**: If `name` follows the format
415    /// `projects/{project}`, the method lists locations visible to that
416    /// specific project. This includes public, private, or other
417    /// project-specific locations enabled for the project.
418    ///
419    /// For gRPC and client library implementations, the resource name is
420    /// passed as the `name` field. For direct service calls, the resource
421    /// name is
422    /// incorporated into the request path based on the specific service
423    /// implementation and version.
424    ///
425    /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
426    ///
427    /// # Example
428    /// ```
429    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
430    /// use google_cloud_gax::paginator::ItemPaginator as _;
431    /// use google_cloud_geminidataanalytics_v1::Result;
432    /// async fn sample(
433    ///    client: &DataAgentService
434    /// ) -> Result<()> {
435    ///     let mut list = client.list_locations()
436    ///         /* set fields */
437    ///         .by_item();
438    ///     while let Some(item) = list.next().await.transpose()? {
439    ///         println!("{:?}", item);
440    ///     }
441    ///     Ok(())
442    /// }
443    /// ```
444    pub fn list_locations(&self) -> super::builder::data_agent_service::ListLocations {
445        super::builder::data_agent_service::ListLocations::new(self.inner.clone())
446    }
447
448    /// Gets information about a location.
449    ///
450    /// # Example
451    /// ```
452    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
453    /// use google_cloud_geminidataanalytics_v1::Result;
454    /// async fn sample(
455    ///    client: &DataAgentService
456    /// ) -> Result<()> {
457    ///     let response = client.get_location()
458    ///         /* set fields */
459    ///         .send().await?;
460    ///     println!("response {:?}", response);
461    ///     Ok(())
462    /// }
463    /// ```
464    pub fn get_location(&self) -> super::builder::data_agent_service::GetLocation {
465        super::builder::data_agent_service::GetLocation::new(self.inner.clone())
466    }
467
468    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
469    ///
470    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
471    ///
472    /// # Example
473    /// ```
474    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
475    /// use google_cloud_gax::paginator::ItemPaginator as _;
476    /// use google_cloud_geminidataanalytics_v1::Result;
477    /// async fn sample(
478    ///    client: &DataAgentService
479    /// ) -> Result<()> {
480    ///     let mut list = client.list_operations()
481    ///         /* set fields */
482    ///         .by_item();
483    ///     while let Some(item) = list.next().await.transpose()? {
484    ///         println!("{:?}", item);
485    ///     }
486    ///     Ok(())
487    /// }
488    /// ```
489    pub fn list_operations(&self) -> super::builder::data_agent_service::ListOperations {
490        super::builder::data_agent_service::ListOperations::new(self.inner.clone())
491    }
492
493    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
494    ///
495    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
496    ///
497    /// # Example
498    /// ```
499    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
500    /// use google_cloud_geminidataanalytics_v1::Result;
501    /// async fn sample(
502    ///    client: &DataAgentService
503    /// ) -> Result<()> {
504    ///     let response = client.get_operation()
505    ///         /* set fields */
506    ///         .send().await?;
507    ///     println!("response {:?}", response);
508    ///     Ok(())
509    /// }
510    /// ```
511    pub fn get_operation(&self) -> super::builder::data_agent_service::GetOperation {
512        super::builder::data_agent_service::GetOperation::new(self.inner.clone())
513    }
514
515    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
516    ///
517    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
518    ///
519    /// # Example
520    /// ```
521    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
522    /// use google_cloud_geminidataanalytics_v1::Result;
523    /// async fn sample(
524    ///    client: &DataAgentService
525    /// ) -> Result<()> {
526    ///     client.delete_operation()
527    ///         /* set fields */
528    ///         .send().await?;
529    ///     Ok(())
530    /// }
531    /// ```
532    pub fn delete_operation(&self) -> super::builder::data_agent_service::DeleteOperation {
533        super::builder::data_agent_service::DeleteOperation::new(self.inner.clone())
534    }
535
536    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
537    ///
538    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
539    ///
540    /// # Example
541    /// ```
542    /// # use google_cloud_geminidataanalytics_v1::client::DataAgentService;
543    /// use google_cloud_geminidataanalytics_v1::Result;
544    /// async fn sample(
545    ///    client: &DataAgentService
546    /// ) -> Result<()> {
547    ///     client.cancel_operation()
548    ///         /* set fields */
549    ///         .send().await?;
550    ///     Ok(())
551    /// }
552    /// ```
553    pub fn cancel_operation(&self) -> super::builder::data_agent_service::CancelOperation {
554        super::builder::data_agent_service::CancelOperation::new(self.inner.clone())
555    }
556}
557
558/// Implements a client for the Data Analytics API with Gemini.
559///
560/// # Example
561/// ```
562/// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
563/// use google_cloud_gax::paginator::ItemPaginator as _;
564/// async fn sample(
565///    project_id: &str,
566///    location_id: &str,
567/// ) -> anyhow::Result<()> {
568///     let client = DataChatService::builder().build().await?;
569///     let mut list = client.list_conversations()
570///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
571///         .by_item();
572///     while let Some(item) = list.next().await.transpose()? {
573///         println!("{:?}", item);
574///     }
575///     Ok(())
576/// }
577/// ```
578///
579/// # Service Description
580///
581/// Service to ask a natural language question on top of BigQuery
582/// and Looker Studio datasources to get back streamed responses of various kinds
583/// to help provide a rich conversational answer.
584///
585/// # Configuration
586///
587/// To configure `DataChatService` use the `with_*` methods in the type returned
588/// by [builder()][DataChatService::builder]. The default configuration should
589/// work for most applications. Common configuration changes include
590///
591/// * [with_endpoint()]: by default this client uses the global default endpoint
592///   (`https://geminidataanalytics.googleapis.com`). Applications using regional
593///   endpoints or running in restricted networks (e.g. a network configured
594///   with [Private Google Access with VPC Service Controls]) may want to
595///   override this default.
596/// * [with_credentials()]: by default this client uses
597///   [Application Default Credentials]. Applications using custom
598///   authentication may need to override this default.
599///
600/// [with_endpoint()]: super::builder::data_chat_service::ClientBuilder::with_endpoint
601/// [with_credentials()]: super::builder::data_chat_service::ClientBuilder::with_credentials
602/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
603/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
604///
605/// # Pooling and Cloning
606///
607/// `DataChatService` holds a connection pool internally, it is advised to
608/// create one and reuse it. You do not need to wrap `DataChatService` in
609/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
610/// already uses an `Arc` internally.
611#[derive(Clone, Debug)]
612pub struct DataChatService {
613    inner: std::sync::Arc<dyn super::stub::dynamic::DataChatService>,
614}
615
616impl DataChatService {
617    /// Returns a builder for [DataChatService].
618    ///
619    /// ```
620    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
621    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
622    /// let client = DataChatService::builder().build().await?;
623    /// # Ok(()) }
624    /// ```
625    pub fn builder() -> super::builder::data_chat_service::ClientBuilder {
626        crate::new_client_builder(super::builder::data_chat_service::client::Factory)
627    }
628
629    /// Creates a new client from the provided stub.
630    ///
631    /// The most common case for calling this function is in tests mocking the
632    /// client's behavior.
633    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
634    where
635        T: super::stub::DataChatService + 'static,
636    {
637        Self { inner: stub.into() }
638    }
639
640    pub(crate) async fn new(
641        config: gaxi::options::ClientConfig,
642    ) -> crate::ClientBuilderResult<Self> {
643        let inner = Self::build_inner(config).await?;
644        Ok(Self { inner })
645    }
646
647    async fn build_inner(
648        conf: gaxi::options::ClientConfig,
649    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::DataChatService>> {
650        if gaxi::options::tracing_enabled(&conf) {
651            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
652        }
653        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
654    }
655
656    async fn build_transport(
657        conf: gaxi::options::ClientConfig,
658    ) -> crate::ClientBuilderResult<impl super::stub::DataChatService> {
659        super::transport::DataChatService::new(conf).await
660    }
661
662    async fn build_with_tracing(
663        conf: gaxi::options::ClientConfig,
664    ) -> crate::ClientBuilderResult<impl super::stub::DataChatService> {
665        Self::build_transport(conf)
666            .await
667            .map(super::tracing::DataChatService::new)
668    }
669
670    /// Creates a new conversation to persist the conversation history. Each
671    /// conversation will have multiple messages associated with it.
672    ///
673    /// # Example
674    /// ```
675    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
676    /// use google_cloud_geminidataanalytics_v1::model::Conversation;
677    /// use google_cloud_geminidataanalytics_v1::Result;
678    /// async fn sample(
679    ///    client: &DataChatService, project_id: &str, location_id: &str
680    /// ) -> Result<()> {
681    ///     let response = client.create_conversation()
682    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
683    ///         .set_conversation_id("conversation_id_value")
684    ///         .set_conversation(
685    ///             Conversation::new()/* set fields */
686    ///         )
687    ///         .send().await?;
688    ///     println!("response {:?}", response);
689    ///     Ok(())
690    /// }
691    /// ```
692    pub fn create_conversation(&self) -> super::builder::data_chat_service::CreateConversation {
693        super::builder::data_chat_service::CreateConversation::new(self.inner.clone())
694    }
695
696    /// Deletes a conversation.
697    ///
698    /// # Example
699    /// ```
700    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
701    /// use google_cloud_geminidataanalytics_v1::Result;
702    /// async fn sample(
703    ///    client: &DataChatService, project_id: &str, location_id: &str, conversation_id: &str
704    /// ) -> Result<()> {
705    ///     client.delete_conversation()
706    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/conversations/{conversation_id}"))
707    ///         .send().await?;
708    ///     Ok(())
709    /// }
710    /// ```
711    pub fn delete_conversation(&self) -> super::builder::data_chat_service::DeleteConversation {
712        super::builder::data_chat_service::DeleteConversation::new(self.inner.clone())
713    }
714
715    /// Gets details of a single conversation by using conversation id and parent.
716    ///
717    /// # Example
718    /// ```
719    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
720    /// use google_cloud_geminidataanalytics_v1::Result;
721    /// async fn sample(
722    ///    client: &DataChatService, project_id: &str, location_id: &str, conversation_id: &str
723    /// ) -> Result<()> {
724    ///     let response = client.get_conversation()
725    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/conversations/{conversation_id}"))
726    ///         .send().await?;
727    ///     println!("response {:?}", response);
728    ///     Ok(())
729    /// }
730    /// ```
731    pub fn get_conversation(&self) -> super::builder::data_chat_service::GetConversation {
732        super::builder::data_chat_service::GetConversation::new(self.inner.clone())
733    }
734
735    /// Lists all conversations for a given parent.
736    ///
737    /// # Example
738    /// ```
739    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
740    /// use google_cloud_gax::paginator::ItemPaginator as _;
741    /// use google_cloud_geminidataanalytics_v1::Result;
742    /// async fn sample(
743    ///    client: &DataChatService, project_id: &str, location_id: &str
744    /// ) -> Result<()> {
745    ///     let mut list = client.list_conversations()
746    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
747    ///         .by_item();
748    ///     while let Some(item) = list.next().await.transpose()? {
749    ///         println!("{:?}", item);
750    ///     }
751    ///     Ok(())
752    /// }
753    /// ```
754    pub fn list_conversations(&self) -> super::builder::data_chat_service::ListConversations {
755        super::builder::data_chat_service::ListConversations::new(self.inner.clone())
756    }
757
758    /// Lists all messages for a given conversation.
759    ///
760    /// # Example
761    /// ```
762    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
763    /// use google_cloud_gax::paginator::ItemPaginator as _;
764    /// use google_cloud_geminidataanalytics_v1::Result;
765    /// async fn sample(
766    ///    client: &DataChatService
767    /// ) -> Result<()> {
768    ///     let mut list = client.list_messages()
769    ///         /* set fields */
770    ///         .by_item();
771    ///     while let Some(item) = list.next().await.transpose()? {
772    ///         println!("{:?}", item);
773    ///     }
774    ///     Ok(())
775    /// }
776    /// ```
777    pub fn list_messages(&self) -> super::builder::data_chat_service::ListMessages {
778        super::builder::data_chat_service::ListMessages::new(self.inner.clone())
779    }
780
781    /// Lists information about the supported locations for this service.
782    ///
783    /// This method lists locations based on the resource scope provided in
784    /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
785    /// **Global locations**: If `name` is empty, the method lists the
786    /// public locations available to all projects. * **Project-specific
787    /// locations**: If `name` follows the format
788    /// `projects/{project}`, the method lists locations visible to that
789    /// specific project. This includes public, private, or other
790    /// project-specific locations enabled for the project.
791    ///
792    /// For gRPC and client library implementations, the resource name is
793    /// passed as the `name` field. For direct service calls, the resource
794    /// name is
795    /// incorporated into the request path based on the specific service
796    /// implementation and version.
797    ///
798    /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
799    ///
800    /// # Example
801    /// ```
802    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
803    /// use google_cloud_gax::paginator::ItemPaginator as _;
804    /// use google_cloud_geminidataanalytics_v1::Result;
805    /// async fn sample(
806    ///    client: &DataChatService
807    /// ) -> Result<()> {
808    ///     let mut list = client.list_locations()
809    ///         /* set fields */
810    ///         .by_item();
811    ///     while let Some(item) = list.next().await.transpose()? {
812    ///         println!("{:?}", item);
813    ///     }
814    ///     Ok(())
815    /// }
816    /// ```
817    pub fn list_locations(&self) -> super::builder::data_chat_service::ListLocations {
818        super::builder::data_chat_service::ListLocations::new(self.inner.clone())
819    }
820
821    /// Gets information about a location.
822    ///
823    /// # Example
824    /// ```
825    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
826    /// use google_cloud_geminidataanalytics_v1::Result;
827    /// async fn sample(
828    ///    client: &DataChatService
829    /// ) -> Result<()> {
830    ///     let response = client.get_location()
831    ///         /* set fields */
832    ///         .send().await?;
833    ///     println!("response {:?}", response);
834    ///     Ok(())
835    /// }
836    /// ```
837    pub fn get_location(&self) -> super::builder::data_chat_service::GetLocation {
838        super::builder::data_chat_service::GetLocation::new(self.inner.clone())
839    }
840
841    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
842    ///
843    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
844    ///
845    /// # Example
846    /// ```
847    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
848    /// use google_cloud_gax::paginator::ItemPaginator as _;
849    /// use google_cloud_geminidataanalytics_v1::Result;
850    /// async fn sample(
851    ///    client: &DataChatService
852    /// ) -> Result<()> {
853    ///     let mut list = client.list_operations()
854    ///         /* set fields */
855    ///         .by_item();
856    ///     while let Some(item) = list.next().await.transpose()? {
857    ///         println!("{:?}", item);
858    ///     }
859    ///     Ok(())
860    /// }
861    /// ```
862    pub fn list_operations(&self) -> super::builder::data_chat_service::ListOperations {
863        super::builder::data_chat_service::ListOperations::new(self.inner.clone())
864    }
865
866    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
867    ///
868    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
869    ///
870    /// # Example
871    /// ```
872    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
873    /// use google_cloud_geminidataanalytics_v1::Result;
874    /// async fn sample(
875    ///    client: &DataChatService
876    /// ) -> Result<()> {
877    ///     let response = client.get_operation()
878    ///         /* set fields */
879    ///         .send().await?;
880    ///     println!("response {:?}", response);
881    ///     Ok(())
882    /// }
883    /// ```
884    pub fn get_operation(&self) -> super::builder::data_chat_service::GetOperation {
885        super::builder::data_chat_service::GetOperation::new(self.inner.clone())
886    }
887
888    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
889    ///
890    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
891    ///
892    /// # Example
893    /// ```
894    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
895    /// use google_cloud_geminidataanalytics_v1::Result;
896    /// async fn sample(
897    ///    client: &DataChatService
898    /// ) -> Result<()> {
899    ///     client.delete_operation()
900    ///         /* set fields */
901    ///         .send().await?;
902    ///     Ok(())
903    /// }
904    /// ```
905    pub fn delete_operation(&self) -> super::builder::data_chat_service::DeleteOperation {
906        super::builder::data_chat_service::DeleteOperation::new(self.inner.clone())
907    }
908
909    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
910    ///
911    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
912    ///
913    /// # Example
914    /// ```
915    /// # use google_cloud_geminidataanalytics_v1::client::DataChatService;
916    /// use google_cloud_geminidataanalytics_v1::Result;
917    /// async fn sample(
918    ///    client: &DataChatService
919    /// ) -> Result<()> {
920    ///     client.cancel_operation()
921    ///         /* set fields */
922    ///         .send().await?;
923    ///     Ok(())
924    /// }
925    /// ```
926    pub fn cancel_operation(&self) -> super::builder::data_chat_service::CancelOperation {
927        super::builder::data_chat_service::CancelOperation::new(self.inner.clone())
928    }
929}