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