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