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/// # use google_cloud_datafusion_v1::client::DataFusion;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
26/// let client = DataFusion::builder().build().await?;
27/// let parent = "parent_value";
28/// let mut list = client.list_instances()
29/// .set_parent(parent)
30/// .by_item();
31/// while let Some(item) = list.next().await.transpose()? {
32/// println!("{:?}", item);
33/// }
34/// # Ok(()) }
35/// ```
36///
37/// # Service Description
38///
39/// Service for creating and managing Data Fusion instances.
40/// Data Fusion enables ETL developers to build code-free, data integration
41/// pipelines via a point-and-click UI.
42///
43/// # Configuration
44///
45/// To configure `DataFusion` use the `with_*` methods in the type returned
46/// by [builder()][DataFusion::builder]. The default configuration should
47/// work for most applications. Common configuration changes include
48///
49/// * [with_endpoint()]: by default this client uses the global default endpoint
50/// (`https://datafusion.googleapis.com`). Applications using regional
51/// endpoints or running in restricted networks (e.g. a network configured
52// with [Private Google Access with VPC Service Controls]) may want to
53/// override this default.
54/// * [with_credentials()]: by default this client uses
55/// [Application Default Credentials]. Applications using custom
56/// authentication may need to override this default.
57///
58/// [with_endpoint()]: super::builder::data_fusion::ClientBuilder::with_endpoint
59/// [with_credentials()]: super::builder::data_fusion::ClientBuilder::with_credentials
60/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
61/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
62///
63/// # Pooling and Cloning
64///
65/// `DataFusion` holds a connection pool internally, it is advised to
66/// create one and reuse it. You do not need to wrap `DataFusion` in
67/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
68/// already uses an `Arc` internally.
69#[derive(Clone, Debug)]
70pub struct DataFusion {
71 inner: std::sync::Arc<dyn super::stub::dynamic::DataFusion>,
72}
73
74impl DataFusion {
75 /// Returns a builder for [DataFusion].
76 ///
77 /// ```
78 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
79 /// # use google_cloud_datafusion_v1::client::DataFusion;
80 /// let client = DataFusion::builder().build().await?;
81 /// # Ok(()) }
82 /// ```
83 pub fn builder() -> super::builder::data_fusion::ClientBuilder {
84 crate::new_client_builder(super::builder::data_fusion::client::Factory)
85 }
86
87 /// Creates a new client from the provided stub.
88 ///
89 /// The most common case for calling this function is in tests mocking the
90 /// client's behavior.
91 pub fn from_stub<T>(stub: T) -> Self
92 where
93 T: super::stub::DataFusion + 'static,
94 {
95 Self {
96 inner: std::sync::Arc::new(stub),
97 }
98 }
99
100 pub(crate) async fn new(
101 config: gaxi::options::ClientConfig,
102 ) -> crate::ClientBuilderResult<Self> {
103 let inner = Self::build_inner(config).await?;
104 Ok(Self { inner })
105 }
106
107 async fn build_inner(
108 conf: gaxi::options::ClientConfig,
109 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::DataFusion>> {
110 if gaxi::options::tracing_enabled(&conf) {
111 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
112 }
113 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
114 }
115
116 async fn build_transport(
117 conf: gaxi::options::ClientConfig,
118 ) -> crate::ClientBuilderResult<impl super::stub::DataFusion> {
119 super::transport::DataFusion::new(conf).await
120 }
121
122 async fn build_with_tracing(
123 conf: gaxi::options::ClientConfig,
124 ) -> crate::ClientBuilderResult<impl super::stub::DataFusion> {
125 Self::build_transport(conf)
126 .await
127 .map(super::tracing::DataFusion::new)
128 }
129
130 /// Lists possible versions for Data Fusion instances in the specified project
131 /// and location.
132 ///
133 /// # Example
134 /// ```
135 /// # use google_cloud_datafusion_v1::client::DataFusion;
136 /// use google_cloud_gax::paginator::ItemPaginator as _;
137 /// use google_cloud_datafusion_v1::Result;
138 /// async fn sample(
139 /// client: &DataFusion
140 /// ) -> Result<()> {
141 /// let mut list = client.list_available_versions()
142 /// /* set fields */
143 /// .by_item();
144 /// while let Some(item) = list.next().await.transpose()? {
145 /// println!("{:?}", item);
146 /// }
147 /// Ok(())
148 /// }
149 /// ```
150 pub fn list_available_versions(&self) -> super::builder::data_fusion::ListAvailableVersions {
151 super::builder::data_fusion::ListAvailableVersions::new(self.inner.clone())
152 }
153
154 /// Lists Data Fusion instances in the specified project and location.
155 ///
156 /// # Example
157 /// ```
158 /// # use google_cloud_datafusion_v1::client::DataFusion;
159 /// use google_cloud_gax::paginator::ItemPaginator as _;
160 /// use google_cloud_datafusion_v1::Result;
161 /// async fn sample(
162 /// client: &DataFusion, parent: &str
163 /// ) -> Result<()> {
164 /// let mut list = client.list_instances()
165 /// .set_parent(parent)
166 /// .by_item();
167 /// while let Some(item) = list.next().await.transpose()? {
168 /// println!("{:?}", item);
169 /// }
170 /// Ok(())
171 /// }
172 /// ```
173 pub fn list_instances(&self) -> super::builder::data_fusion::ListInstances {
174 super::builder::data_fusion::ListInstances::new(self.inner.clone())
175 }
176
177 /// Gets details of a single Data Fusion instance.
178 ///
179 /// # Example
180 /// ```
181 /// # use google_cloud_datafusion_v1::client::DataFusion;
182 /// use google_cloud_datafusion_v1::Result;
183 /// async fn sample(
184 /// client: &DataFusion, name: &str
185 /// ) -> Result<()> {
186 /// let response = client.get_instance()
187 /// .set_name(name)
188 /// .send().await?;
189 /// println!("response {:?}", response);
190 /// Ok(())
191 /// }
192 /// ```
193 pub fn get_instance(&self) -> super::builder::data_fusion::GetInstance {
194 super::builder::data_fusion::GetInstance::new(self.inner.clone())
195 }
196
197 /// Creates a new Data Fusion instance in the specified project and location.
198 ///
199 /// # Long running operations
200 ///
201 /// This method is used to start, and/or poll a [long-running Operation].
202 /// The [Working with long-running operations] chapter in the [user guide]
203 /// covers these operations in detail.
204 ///
205 /// [long-running operation]: https://google.aip.dev/151
206 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
207 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
208 ///
209 /// # Example
210 /// ```
211 /// # use google_cloud_datafusion_v1::client::DataFusion;
212 /// use google_cloud_lro::Poller;
213 /// use google_cloud_datafusion_v1::model::Instance;
214 /// use google_cloud_datafusion_v1::Result;
215 /// async fn sample(
216 /// client: &DataFusion, parent: &str
217 /// ) -> Result<()> {
218 /// let response = client.create_instance()
219 /// .set_parent(parent)
220 /// .set_instance_id("instance_id_value")
221 /// .set_instance(
222 /// Instance::new()/* set fields */
223 /// )
224 /// .poller().until_done().await?;
225 /// println!("response {:?}", response);
226 /// Ok(())
227 /// }
228 /// ```
229 pub fn create_instance(&self) -> super::builder::data_fusion::CreateInstance {
230 super::builder::data_fusion::CreateInstance::new(self.inner.clone())
231 }
232
233 /// Deletes a single Date Fusion instance.
234 ///
235 /// # Long running operations
236 ///
237 /// This method is used to start, and/or poll a [long-running Operation].
238 /// The [Working with long-running operations] chapter in the [user guide]
239 /// covers these operations in detail.
240 ///
241 /// [long-running operation]: https://google.aip.dev/151
242 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
243 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
244 ///
245 /// # Example
246 /// ```
247 /// # use google_cloud_datafusion_v1::client::DataFusion;
248 /// use google_cloud_lro::Poller;
249 /// use google_cloud_datafusion_v1::Result;
250 /// async fn sample(
251 /// client: &DataFusion, name: &str
252 /// ) -> Result<()> {
253 /// client.delete_instance()
254 /// .set_name(name)
255 /// .poller().until_done().await?;
256 /// Ok(())
257 /// }
258 /// ```
259 pub fn delete_instance(&self) -> super::builder::data_fusion::DeleteInstance {
260 super::builder::data_fusion::DeleteInstance::new(self.inner.clone())
261 }
262
263 /// Updates a single Data Fusion instance.
264 ///
265 /// # Long running operations
266 ///
267 /// This method is used to start, and/or poll a [long-running Operation].
268 /// The [Working with long-running operations] chapter in the [user guide]
269 /// covers these operations in detail.
270 ///
271 /// [long-running operation]: https://google.aip.dev/151
272 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
273 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
274 ///
275 /// # Example
276 /// ```
277 /// # use google_cloud_datafusion_v1::client::DataFusion;
278 /// use google_cloud_lro::Poller;
279 /// # extern crate wkt as google_cloud_wkt;
280 /// use google_cloud_wkt::FieldMask;
281 /// use google_cloud_datafusion_v1::model::Instance;
282 /// use google_cloud_datafusion_v1::Result;
283 /// async fn sample(
284 /// client: &DataFusion, name: &str
285 /// ) -> Result<()> {
286 /// let response = client.update_instance()
287 /// .set_instance(
288 /// Instance::new().set_name(name)/* set fields */
289 /// )
290 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
291 /// .poller().until_done().await?;
292 /// println!("response {:?}", response);
293 /// Ok(())
294 /// }
295 /// ```
296 pub fn update_instance(&self) -> super::builder::data_fusion::UpdateInstance {
297 super::builder::data_fusion::UpdateInstance::new(self.inner.clone())
298 }
299
300 /// Restart a single Data Fusion instance.
301 /// At the end of an operation instance is fully restarted.
302 ///
303 /// # Long running operations
304 ///
305 /// This method is used to start, and/or poll a [long-running Operation].
306 /// The [Working with long-running operations] chapter in the [user guide]
307 /// covers these operations in detail.
308 ///
309 /// [long-running operation]: https://google.aip.dev/151
310 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
311 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
312 ///
313 /// # Example
314 /// ```
315 /// # use google_cloud_datafusion_v1::client::DataFusion;
316 /// use google_cloud_lro::Poller;
317 /// use google_cloud_datafusion_v1::Result;
318 /// async fn sample(
319 /// client: &DataFusion
320 /// ) -> Result<()> {
321 /// let response = client.restart_instance()
322 /// /* set fields */
323 /// .poller().until_done().await?;
324 /// println!("response {:?}", response);
325 /// Ok(())
326 /// }
327 /// ```
328 pub fn restart_instance(&self) -> super::builder::data_fusion::RestartInstance {
329 super::builder::data_fusion::RestartInstance::new(self.inner.clone())
330 }
331
332 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
333 ///
334 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
335 ///
336 /// # Example
337 /// ```
338 /// # use google_cloud_datafusion_v1::client::DataFusion;
339 /// use google_cloud_gax::paginator::ItemPaginator as _;
340 /// use google_cloud_datafusion_v1::Result;
341 /// async fn sample(
342 /// client: &DataFusion
343 /// ) -> Result<()> {
344 /// let mut list = client.list_operations()
345 /// /* set fields */
346 /// .by_item();
347 /// while let Some(item) = list.next().await.transpose()? {
348 /// println!("{:?}", item);
349 /// }
350 /// Ok(())
351 /// }
352 /// ```
353 pub fn list_operations(&self) -> super::builder::data_fusion::ListOperations {
354 super::builder::data_fusion::ListOperations::new(self.inner.clone())
355 }
356
357 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
358 ///
359 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
360 ///
361 /// # Example
362 /// ```
363 /// # use google_cloud_datafusion_v1::client::DataFusion;
364 /// use google_cloud_datafusion_v1::Result;
365 /// async fn sample(
366 /// client: &DataFusion
367 /// ) -> Result<()> {
368 /// let response = client.get_operation()
369 /// /* set fields */
370 /// .send().await?;
371 /// println!("response {:?}", response);
372 /// Ok(())
373 /// }
374 /// ```
375 pub fn get_operation(&self) -> super::builder::data_fusion::GetOperation {
376 super::builder::data_fusion::GetOperation::new(self.inner.clone())
377 }
378
379 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
380 ///
381 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
382 ///
383 /// # Example
384 /// ```
385 /// # use google_cloud_datafusion_v1::client::DataFusion;
386 /// use google_cloud_datafusion_v1::Result;
387 /// async fn sample(
388 /// client: &DataFusion
389 /// ) -> Result<()> {
390 /// client.delete_operation()
391 /// /* set fields */
392 /// .send().await?;
393 /// Ok(())
394 /// }
395 /// ```
396 pub fn delete_operation(&self) -> super::builder::data_fusion::DeleteOperation {
397 super::builder::data_fusion::DeleteOperation::new(self.inner.clone())
398 }
399
400 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
401 ///
402 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
403 ///
404 /// # Example
405 /// ```
406 /// # use google_cloud_datafusion_v1::client::DataFusion;
407 /// use google_cloud_datafusion_v1::Result;
408 /// async fn sample(
409 /// client: &DataFusion
410 /// ) -> Result<()> {
411 /// client.cancel_operation()
412 /// /* set fields */
413 /// .send().await?;
414 /// Ok(())
415 /// }
416 /// ```
417 pub fn cancel_operation(&self) -> super::builder::data_fusion::CancelOperation {
418 super::builder::data_fusion::CancelOperation::new(self.inner.clone())
419 }
420}