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