google_cloud_datafusion_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::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Cloud Data Fusion API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_datafusion_v1::client::DataFusion;
25/// let client = DataFusion::builder().build().await?;
26/// // use `client` to make requests to the Cloud Data Fusion API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Service for creating and managing Data Fusion instances.
33/// Data Fusion enables ETL developers to build code-free, data integration
34/// pipelines via a point-and-click UI.
35///
36/// # Configuration
37///
38/// To configure `DataFusion` use the `with_*` methods in the type returned
39/// by [builder()][DataFusion::builder]. The default configuration should
40/// work for most applications. Common configuration changes include
41///
42/// * [with_endpoint()]: by default this client uses the global default endpoint
43/// (`https://datafusion.googleapis.com`). Applications using regional
44/// endpoints or running in restricted networks (e.g. a network configured
45// with [Private Google Access with VPC Service Controls]) may want to
46/// override this default.
47/// * [with_credentials()]: by default this client uses
48/// [Application Default Credentials]. Applications using custom
49/// authentication may need to override this default.
50///
51/// [with_endpoint()]: super::builder::data_fusion::ClientBuilder::with_endpoint
52/// [with_credentials()]: super::builder::data_fusion::ClientBuilder::credentials
53/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
54/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
55///
56/// # Pooling and Cloning
57///
58/// `DataFusion` holds a connection pool internally, it is advised to
59/// create one and the reuse it. You do not need to wrap `DataFusion` in
60/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
61/// already uses an `Arc` internally.
62#[derive(Clone, Debug)]
63pub struct DataFusion {
64 inner: std::sync::Arc<dyn super::stub::dynamic::DataFusion>,
65}
66
67impl DataFusion {
68 /// Returns a builder for [DataFusion].
69 ///
70 /// ```
71 /// # tokio_test::block_on(async {
72 /// # use google_cloud_datafusion_v1::client::DataFusion;
73 /// let client = DataFusion::builder().build().await?;
74 /// # gax::client_builder::Result::<()>::Ok(()) });
75 /// ```
76 pub fn builder() -> super::builder::data_fusion::ClientBuilder {
77 gax::client_builder::internal::new_builder(super::builder::data_fusion::client::Factory)
78 }
79
80 /// Creates a new client from the provided stub.
81 ///
82 /// The most common case for calling this function is in tests mocking the
83 /// client's behavior.
84 pub fn from_stub<T>(stub: T) -> Self
85 where
86 T: super::stub::DataFusion + 'static,
87 {
88 Self {
89 inner: std::sync::Arc::new(stub),
90 }
91 }
92
93 pub(crate) async fn new(
94 config: gaxi::options::ClientConfig,
95 ) -> gax::client_builder::Result<Self> {
96 let inner = Self::build_inner(config).await?;
97 Ok(Self { inner })
98 }
99
100 async fn build_inner(
101 conf: gaxi::options::ClientConfig,
102 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::DataFusion>> {
103 if gaxi::options::tracing_enabled(&conf) {
104 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
105 }
106 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
107 }
108
109 async fn build_transport(
110 conf: gaxi::options::ClientConfig,
111 ) -> gax::client_builder::Result<impl super::stub::DataFusion> {
112 super::transport::DataFusion::new(conf).await
113 }
114
115 async fn build_with_tracing(
116 conf: gaxi::options::ClientConfig,
117 ) -> gax::client_builder::Result<impl super::stub::DataFusion> {
118 Self::build_transport(conf)
119 .await
120 .map(super::tracing::DataFusion::new)
121 }
122
123 /// Lists possible versions for Data Fusion instances in the specified project
124 /// and location.
125 pub fn list_available_versions(&self) -> super::builder::data_fusion::ListAvailableVersions {
126 super::builder::data_fusion::ListAvailableVersions::new(self.inner.clone())
127 }
128
129 /// Lists Data Fusion instances in the specified project and location.
130 pub fn list_instances(&self) -> super::builder::data_fusion::ListInstances {
131 super::builder::data_fusion::ListInstances::new(self.inner.clone())
132 }
133
134 /// Gets details of a single Data Fusion instance.
135 pub fn get_instance(&self) -> super::builder::data_fusion::GetInstance {
136 super::builder::data_fusion::GetInstance::new(self.inner.clone())
137 }
138
139 /// Creates a new Data Fusion instance in the specified project and location.
140 ///
141 /// # Long running operations
142 ///
143 /// This method is used to start, and/or poll a [long-running Operation].
144 /// The [Working with long-running operations] chapter in the [user guide]
145 /// covers these operations in detail.
146 ///
147 /// [long-running operation]: https://google.aip.dev/151
148 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
149 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
150 pub fn create_instance(&self) -> super::builder::data_fusion::CreateInstance {
151 super::builder::data_fusion::CreateInstance::new(self.inner.clone())
152 }
153
154 /// Deletes a single Date Fusion instance.
155 ///
156 /// # Long running operations
157 ///
158 /// This method is used to start, and/or poll a [long-running Operation].
159 /// The [Working with long-running operations] chapter in the [user guide]
160 /// covers these operations in detail.
161 ///
162 /// [long-running operation]: https://google.aip.dev/151
163 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
164 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
165 pub fn delete_instance(&self) -> super::builder::data_fusion::DeleteInstance {
166 super::builder::data_fusion::DeleteInstance::new(self.inner.clone())
167 }
168
169 /// Updates a single Data Fusion instance.
170 ///
171 /// # Long running operations
172 ///
173 /// This method is used to start, and/or poll a [long-running Operation].
174 /// The [Working with long-running operations] chapter in the [user guide]
175 /// covers these operations in detail.
176 ///
177 /// [long-running operation]: https://google.aip.dev/151
178 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
179 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
180 pub fn update_instance(&self) -> super::builder::data_fusion::UpdateInstance {
181 super::builder::data_fusion::UpdateInstance::new(self.inner.clone())
182 }
183
184 /// Restart a single Data Fusion instance.
185 /// At the end of an operation instance is fully restarted.
186 ///
187 /// # Long running operations
188 ///
189 /// This method is used to start, and/or poll a [long-running Operation].
190 /// The [Working with long-running operations] chapter in the [user guide]
191 /// covers these operations in detail.
192 ///
193 /// [long-running operation]: https://google.aip.dev/151
194 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
195 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
196 pub fn restart_instance(&self) -> super::builder::data_fusion::RestartInstance {
197 super::builder::data_fusion::RestartInstance::new(self.inner.clone())
198 }
199
200 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
201 ///
202 /// [google.longrunning.Operations]: longrunning::client::Operations
203 pub fn list_operations(&self) -> super::builder::data_fusion::ListOperations {
204 super::builder::data_fusion::ListOperations::new(self.inner.clone())
205 }
206
207 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
208 ///
209 /// [google.longrunning.Operations]: longrunning::client::Operations
210 pub fn get_operation(&self) -> super::builder::data_fusion::GetOperation {
211 super::builder::data_fusion::GetOperation::new(self.inner.clone())
212 }
213
214 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
215 ///
216 /// [google.longrunning.Operations]: longrunning::client::Operations
217 pub fn delete_operation(&self) -> super::builder::data_fusion::DeleteOperation {
218 super::builder::data_fusion::DeleteOperation::new(self.inner.clone())
219 }
220
221 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
222 ///
223 /// [google.longrunning.Operations]: longrunning::client::Operations
224 pub fn cancel_operation(&self) -> super::builder::data_fusion::CancelOperation {
225 super::builder::data_fusion::CancelOperation::new(self.inner.clone())
226 }
227}