Skip to main content

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