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;
20
21/// Implements a client for the BigQuery Data Transfer API.
22///
23/// # Example
24/// ```
25/// # tokio_test::block_on(async {
26/// # use google_cloud_bigquery_datatransfer_v1::client::DataTransferService;
27/// let client = DataTransferService::builder().build().await?;
28/// // use `client` to make requests to the BigQuery Data Transfer API.
29/// # gax::Result::<()>::Ok(()) });
30/// ```
31///
32/// # Service Description
33///
34/// This API allows users to manage their data transfers into BigQuery.
35///
36/// # Configuration
37///
38/// To configure `DataTransferService` use the `with_*` methods in the type returned
39/// by [builder()][DataTransferService::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://bigquerydatatransfer.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_transfer_service::ClientBuilder::with_endpoint
52/// [with_credentials()]: super::builder::data_transfer_service::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/// `DataTransferService` holds a connection pool internally, it is advised to
59/// create one and the reuse it. You do not need to wrap `DataTransferService` 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 DataTransferService {
64 inner: std::sync::Arc<dyn super::stub::dynamic::DataTransferService>,
65}
66
67impl DataTransferService {
68 /// Returns a builder for [DataTransferService].
69 ///
70 /// ```
71 /// # tokio_test::block_on(async {
72 /// # use google_cloud_bigquery_datatransfer_v1::client::DataTransferService;
73 /// let client = DataTransferService::builder().build().await?;
74 /// # gax::Result::<()>::Ok(()) });
75 /// ```
76 pub fn builder() -> super::builder::data_transfer_service::ClientBuilder {
77 gax::client_builder::internal::new_builder(
78 super::builder::data_transfer_service::client::Factory,
79 )
80 }
81
82 /// Creates a new client from the provided stub.
83 ///
84 /// The most common case for calling this function is in tests mocking the
85 /// client's behavior.
86 pub fn from_stub<T>(stub: T) -> Self
87 where
88 T: super::stub::DataTransferService + 'static,
89 {
90 Self {
91 inner: std::sync::Arc::new(stub),
92 }
93 }
94
95 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> 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 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::DataTransferService>> {
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 ) -> Result<impl super::stub::DataTransferService> {
112 super::transport::DataTransferService::new(conf).await
113 }
114
115 async fn build_with_tracing(
116 conf: gaxi::options::ClientConfig,
117 ) -> Result<impl super::stub::DataTransferService> {
118 Self::build_transport(conf)
119 .await
120 .map(super::tracing::DataTransferService::new)
121 }
122
123 /// Retrieves a supported data source and returns its settings.
124 pub fn get_data_source(&self) -> super::builder::data_transfer_service::GetDataSource {
125 super::builder::data_transfer_service::GetDataSource::new(self.inner.clone())
126 }
127
128 /// Lists supported data sources and returns their settings.
129 pub fn list_data_sources(&self) -> super::builder::data_transfer_service::ListDataSources {
130 super::builder::data_transfer_service::ListDataSources::new(self.inner.clone())
131 }
132
133 /// Creates a new data transfer configuration.
134 pub fn create_transfer_config(
135 &self,
136 ) -> super::builder::data_transfer_service::CreateTransferConfig {
137 super::builder::data_transfer_service::CreateTransferConfig::new(self.inner.clone())
138 }
139
140 /// Updates a data transfer configuration.
141 /// All fields must be set, even if they are not updated.
142 pub fn update_transfer_config(
143 &self,
144 ) -> super::builder::data_transfer_service::UpdateTransferConfig {
145 super::builder::data_transfer_service::UpdateTransferConfig::new(self.inner.clone())
146 }
147
148 /// Deletes a data transfer configuration, including any associated transfer
149 /// runs and logs.
150 pub fn delete_transfer_config(
151 &self,
152 ) -> super::builder::data_transfer_service::DeleteTransferConfig {
153 super::builder::data_transfer_service::DeleteTransferConfig::new(self.inner.clone())
154 }
155
156 /// Returns information about a data transfer config.
157 pub fn get_transfer_config(&self) -> super::builder::data_transfer_service::GetTransferConfig {
158 super::builder::data_transfer_service::GetTransferConfig::new(self.inner.clone())
159 }
160
161 /// Returns information about all transfer configs owned by a project in the
162 /// specified location.
163 pub fn list_transfer_configs(
164 &self,
165 ) -> super::builder::data_transfer_service::ListTransferConfigs {
166 super::builder::data_transfer_service::ListTransferConfigs::new(self.inner.clone())
167 }
168
169 /// Creates transfer runs for a time range [start_time, end_time].
170 /// For each date - or whatever granularity the data source supports - in the
171 /// range, one transfer run is created.
172 /// Note that runs are created per UTC time in the time range.
173 /// DEPRECATED: use StartManualTransferRuns instead.
174 #[deprecated]
175 pub fn schedule_transfer_runs(
176 &self,
177 ) -> super::builder::data_transfer_service::ScheduleTransferRuns {
178 super::builder::data_transfer_service::ScheduleTransferRuns::new(self.inner.clone())
179 }
180
181 /// Start manual transfer runs to be executed now with schedule_time equal to
182 /// current time. The transfer runs can be created for a time range where the
183 /// run_time is between start_time (inclusive) and end_time (exclusive), or for
184 /// a specific run_time.
185 pub fn start_manual_transfer_runs(
186 &self,
187 ) -> super::builder::data_transfer_service::StartManualTransferRuns {
188 super::builder::data_transfer_service::StartManualTransferRuns::new(self.inner.clone())
189 }
190
191 /// Returns information about the particular transfer run.
192 pub fn get_transfer_run(&self) -> super::builder::data_transfer_service::GetTransferRun {
193 super::builder::data_transfer_service::GetTransferRun::new(self.inner.clone())
194 }
195
196 /// Deletes the specified transfer run.
197 pub fn delete_transfer_run(&self) -> super::builder::data_transfer_service::DeleteTransferRun {
198 super::builder::data_transfer_service::DeleteTransferRun::new(self.inner.clone())
199 }
200
201 /// Returns information about running and completed transfer runs.
202 pub fn list_transfer_runs(&self) -> super::builder::data_transfer_service::ListTransferRuns {
203 super::builder::data_transfer_service::ListTransferRuns::new(self.inner.clone())
204 }
205
206 /// Returns log messages for the transfer run.
207 pub fn list_transfer_logs(&self) -> super::builder::data_transfer_service::ListTransferLogs {
208 super::builder::data_transfer_service::ListTransferLogs::new(self.inner.clone())
209 }
210
211 /// Returns true if valid credentials exist for the given data source and
212 /// requesting user.
213 pub fn check_valid_creds(&self) -> super::builder::data_transfer_service::CheckValidCreds {
214 super::builder::data_transfer_service::CheckValidCreds::new(self.inner.clone())
215 }
216
217 /// Enroll data sources in a user project. This allows users to create transfer
218 /// configurations for these data sources. They will also appear in the
219 /// ListDataSources RPC and as such, will appear in the
220 /// [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents
221 /// can be found in the public guide for
222 /// [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and
223 /// [Data Transfer
224 /// Service](https://cloud.google.com/bigquery/docs/working-with-transfers).
225 pub fn enroll_data_sources(&self) -> super::builder::data_transfer_service::EnrollDataSources {
226 super::builder::data_transfer_service::EnrollDataSources::new(self.inner.clone())
227 }
228
229 /// Unenroll data sources in a user project. This allows users to remove
230 /// transfer configurations for these data sources. They will no longer appear
231 /// in the ListDataSources RPC and will also no longer appear in the [BigQuery
232 /// UI](https://console.cloud.google.com/bigquery). Data transfers
233 /// configurations of unenrolled data sources will not be scheduled.
234 pub fn unenroll_data_sources(
235 &self,
236 ) -> super::builder::data_transfer_service::UnenrollDataSources {
237 super::builder::data_transfer_service::UnenrollDataSources::new(self.inner.clone())
238 }
239
240 /// Lists information about the supported locations for this service.
241 pub fn list_locations(&self) -> super::builder::data_transfer_service::ListLocations {
242 super::builder::data_transfer_service::ListLocations::new(self.inner.clone())
243 }
244
245 /// Gets information about a location.
246 pub fn get_location(&self) -> super::builder::data_transfer_service::GetLocation {
247 super::builder::data_transfer_service::GetLocation::new(self.inner.clone())
248 }
249}