google_cloud_bigquery_datatransfer_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
19use crate::Result;
20use std::sync::Arc;
21
22/// Implements a client for the BigQuery Data Transfer API.
23///
24/// # Service Description
25///
26/// This API allows users to manage their data transfers into BigQuery.
27///
28/// # Configuration
29///
30/// `DataTransferService` has various configuration parameters, the defaults should
31/// work with most applications.
32///
33/// # Pooling and Cloning
34///
35/// `DataTransferService` holds a connection pool internally, it is advised to
36/// create one and the reuse it.  You do not need to wrap `DataTransferService` in
37/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
38/// internally.
39#[derive(Clone, Debug)]
40pub struct DataTransferService {
41    inner: Arc<dyn crate::stubs::dynamic::DataTransferService>,
42}
43
44impl DataTransferService {
45    /// Creates a new client with the default configuration.
46    pub async fn new() -> Result<Self> {
47        Self::new_with_config(gax::options::ClientConfig::default()).await
48    }
49
50    /// Creates a new client with the specified configuration.
51    pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result<Self> {
52        let inner = Self::build_inner(conf).await?;
53        Ok(Self { inner })
54    }
55
56    /// Creates a new client from the provided stub.
57    ///
58    /// The most common case for calling this function is when mocking the
59    /// client.
60    pub fn from_stub<T>(stub: T) -> Self
61    where
62        T: crate::stubs::DataTransferService + 'static,
63    {
64        Self {
65            inner: Arc::new(stub),
66        }
67    }
68
69    async fn build_inner(
70        conf: gax::options::ClientConfig,
71    ) -> Result<Arc<dyn crate::stubs::dynamic::DataTransferService>> {
72        if conf.tracing_enabled() {
73            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
74        }
75        Ok(Arc::new(Self::build_transport(conf).await?))
76    }
77
78    async fn build_transport(
79        conf: gax::options::ClientConfig,
80    ) -> Result<impl crate::stubs::DataTransferService> {
81        crate::transport::DataTransferService::new(conf).await
82    }
83
84    async fn build_with_tracing(
85        conf: gax::options::ClientConfig,
86    ) -> Result<impl crate::stubs::DataTransferService> {
87        Self::build_transport(conf)
88            .await
89            .map(crate::tracing::DataTransferService::new)
90    }
91
92    /// Retrieves a supported data source and returns its settings.
93    pub fn get_data_source(
94        &self,
95        name: impl Into<std::string::String>,
96    ) -> crate::builders::data_transfer_service::GetDataSource {
97        crate::builders::data_transfer_service::GetDataSource::new(self.inner.clone())
98            .set_name(name.into())
99    }
100
101    /// Lists supported data sources and returns their settings.
102    pub fn list_data_sources(
103        &self,
104        parent: impl Into<std::string::String>,
105    ) -> crate::builders::data_transfer_service::ListDataSources {
106        crate::builders::data_transfer_service::ListDataSources::new(self.inner.clone())
107            .set_parent(parent.into())
108    }
109
110    /// Creates a new data transfer configuration.
111    pub fn create_transfer_config(
112        &self,
113        parent: impl Into<std::string::String>,
114    ) -> crate::builders::data_transfer_service::CreateTransferConfig {
115        crate::builders::data_transfer_service::CreateTransferConfig::new(self.inner.clone())
116            .set_parent(parent.into())
117    }
118
119    /// Updates a data transfer configuration.
120    /// All fields must be set, even if they are not updated.
121    pub fn update_transfer_config(
122        &self,
123        transfer_config: impl Into<crate::model::TransferConfig>,
124    ) -> crate::builders::data_transfer_service::UpdateTransferConfig {
125        crate::builders::data_transfer_service::UpdateTransferConfig::new(self.inner.clone())
126            .set_transfer_config(transfer_config.into())
127    }
128
129    /// Deletes a data transfer configuration, including any associated transfer
130    /// runs and logs.
131    pub fn delete_transfer_config(
132        &self,
133        name: impl Into<std::string::String>,
134    ) -> crate::builders::data_transfer_service::DeleteTransferConfig {
135        crate::builders::data_transfer_service::DeleteTransferConfig::new(self.inner.clone())
136            .set_name(name.into())
137    }
138
139    /// Returns information about a data transfer config.
140    pub fn get_transfer_config(
141        &self,
142        name: impl Into<std::string::String>,
143    ) -> crate::builders::data_transfer_service::GetTransferConfig {
144        crate::builders::data_transfer_service::GetTransferConfig::new(self.inner.clone())
145            .set_name(name.into())
146    }
147
148    /// Returns information about all transfer configs owned by a project in the
149    /// specified location.
150    pub fn list_transfer_configs(
151        &self,
152        parent: impl Into<std::string::String>,
153    ) -> crate::builders::data_transfer_service::ListTransferConfigs {
154        crate::builders::data_transfer_service::ListTransferConfigs::new(self.inner.clone())
155            .set_parent(parent.into())
156    }
157
158    /// Creates transfer runs for a time range [start_time, end_time].
159    /// For each date - or whatever granularity the data source supports - in the
160    /// range, one transfer run is created.
161    /// Note that runs are created per UTC time in the time range.
162    /// DEPRECATED: use StartManualTransferRuns instead.
163    pub fn schedule_transfer_runs(
164        &self,
165        parent: impl Into<std::string::String>,
166    ) -> crate::builders::data_transfer_service::ScheduleTransferRuns {
167        crate::builders::data_transfer_service::ScheduleTransferRuns::new(self.inner.clone())
168            .set_parent(parent.into())
169    }
170
171    /// Start manual transfer runs to be executed now with schedule_time equal to
172    /// current time. The transfer runs can be created for a time range where the
173    /// run_time is between start_time (inclusive) and end_time (exclusive), or for
174    /// a specific run_time.
175    pub fn start_manual_transfer_runs(
176        &self,
177        parent: impl Into<std::string::String>,
178    ) -> crate::builders::data_transfer_service::StartManualTransferRuns {
179        crate::builders::data_transfer_service::StartManualTransferRuns::new(self.inner.clone())
180            .set_parent(parent.into())
181    }
182
183    /// Returns information about the particular transfer run.
184    pub fn get_transfer_run(
185        &self,
186        name: impl Into<std::string::String>,
187    ) -> crate::builders::data_transfer_service::GetTransferRun {
188        crate::builders::data_transfer_service::GetTransferRun::new(self.inner.clone())
189            .set_name(name.into())
190    }
191
192    /// Deletes the specified transfer run.
193    pub fn delete_transfer_run(
194        &self,
195        name: impl Into<std::string::String>,
196    ) -> crate::builders::data_transfer_service::DeleteTransferRun {
197        crate::builders::data_transfer_service::DeleteTransferRun::new(self.inner.clone())
198            .set_name(name.into())
199    }
200
201    /// Returns information about running and completed transfer runs.
202    pub fn list_transfer_runs(
203        &self,
204        parent: impl Into<std::string::String>,
205    ) -> crate::builders::data_transfer_service::ListTransferRuns {
206        crate::builders::data_transfer_service::ListTransferRuns::new(self.inner.clone())
207            .set_parent(parent.into())
208    }
209
210    /// Returns log messages for the transfer run.
211    pub fn list_transfer_logs(
212        &self,
213        parent: impl Into<std::string::String>,
214    ) -> crate::builders::data_transfer_service::ListTransferLogs {
215        crate::builders::data_transfer_service::ListTransferLogs::new(self.inner.clone())
216            .set_parent(parent.into())
217    }
218
219    /// Returns true if valid credentials exist for the given data source and
220    /// requesting user.
221    pub fn check_valid_creds(
222        &self,
223        name: impl Into<std::string::String>,
224    ) -> crate::builders::data_transfer_service::CheckValidCreds {
225        crate::builders::data_transfer_service::CheckValidCreds::new(self.inner.clone())
226            .set_name(name.into())
227    }
228
229    /// Enroll data sources in a user project. This allows users to create transfer
230    /// configurations for these data sources. They will also appear in the
231    /// ListDataSources RPC and as such, will appear in the
232    /// [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents
233    /// can be found in the public guide for
234    /// [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and
235    /// [Data Transfer
236    /// Service](https://cloud.google.com/bigquery/docs/working-with-transfers).
237    pub fn enroll_data_sources(
238        &self,
239        name: impl Into<std::string::String>,
240    ) -> crate::builders::data_transfer_service::EnrollDataSources {
241        crate::builders::data_transfer_service::EnrollDataSources::new(self.inner.clone())
242            .set_name(name.into())
243    }
244
245    /// Unenroll data sources in a user project. This allows users to remove
246    /// transfer configurations for these data sources. They will no longer appear
247    /// in the ListDataSources RPC and will also no longer appear in the [BigQuery
248    /// UI](https://console.cloud.google.com/bigquery). Data transfers
249    /// configurations of unenrolled data sources will not be scheduled.
250    pub fn unenroll_data_sources(
251        &self,
252        name: impl Into<std::string::String>,
253    ) -> crate::builders::data_transfer_service::UnenrollDataSources {
254        crate::builders::data_transfer_service::UnenrollDataSources::new(self.inner.clone())
255            .set_name(name.into())
256    }
257
258    /// Lists information about the supported locations for this service.
259    pub fn list_locations(
260        &self,
261        name: impl Into<std::string::String>,
262    ) -> crate::builders::data_transfer_service::ListLocations {
263        crate::builders::data_transfer_service::ListLocations::new(self.inner.clone())
264            .set_name(name.into())
265    }
266
267    /// Gets information about a location.
268    pub fn get_location(
269        &self,
270        name: impl Into<std::string::String>,
271    ) -> crate::builders::data_transfer_service::GetLocation {
272        crate::builders::data_transfer_service::GetLocation::new(self.inner.clone())
273            .set_name(name.into())
274    }
275}