google-cloud-bigquery-datatransfer-v1 1.5.0

Google Cloud Client Libraries for Rust - BigQuery Data Transfer API
Documentation
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the BigQuery Data Transfer API.
///
/// # Example
/// ```
/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
/// # use google_cloud_bigquery_datatransfer_v1::client::DataTransferService;
/// let client = DataTransferService::builder().build().await?;
/// // use `client` to make requests to the BigQuery Data Transfer API.
/// # Ok(()) }
/// ```
///
/// # Service Description
///
/// This API allows users to manage their data transfers into BigQuery.
///
/// # Configuration
///
/// To configure `DataTransferService` use the `with_*` methods in the type returned
/// by [builder()][DataTransferService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://bigquerydatatransfer.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::data_transfer_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::data_transfer_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `DataTransferService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `DataTransferService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct DataTransferService {
    inner: std::sync::Arc<dyn super::stub::dynamic::DataTransferService>,
}

impl DataTransferService {
    /// Returns a builder for [DataTransferService].
    ///
    /// ```
    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
    /// # use google_cloud_bigquery_datatransfer_v1::client::DataTransferService;
    /// let client = DataTransferService::builder().build().await?;
    /// # Ok(()) }
    /// ```
    pub fn builder() -> super::builder::data_transfer_service::ClientBuilder {
        crate::new_client_builder(super::builder::data_transfer_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::DataTransferService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::DataTransferService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::DataTransferService> {
        super::transport::DataTransferService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::DataTransferService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::DataTransferService::new)
    }

    /// Retrieves a supported data source and returns its settings.
    pub fn get_data_source(&self) -> super::builder::data_transfer_service::GetDataSource {
        super::builder::data_transfer_service::GetDataSource::new(self.inner.clone())
    }

    /// Lists supported data sources and returns their settings.
    pub fn list_data_sources(&self) -> super::builder::data_transfer_service::ListDataSources {
        super::builder::data_transfer_service::ListDataSources::new(self.inner.clone())
    }

    /// Creates a new data transfer configuration.
    pub fn create_transfer_config(
        &self,
    ) -> super::builder::data_transfer_service::CreateTransferConfig {
        super::builder::data_transfer_service::CreateTransferConfig::new(self.inner.clone())
    }

    /// Updates a data transfer configuration.
    /// All fields must be set, even if they are not updated.
    pub fn update_transfer_config(
        &self,
    ) -> super::builder::data_transfer_service::UpdateTransferConfig {
        super::builder::data_transfer_service::UpdateTransferConfig::new(self.inner.clone())
    }

    /// Deletes a data transfer configuration, including any associated transfer
    /// runs and logs.
    pub fn delete_transfer_config(
        &self,
    ) -> super::builder::data_transfer_service::DeleteTransferConfig {
        super::builder::data_transfer_service::DeleteTransferConfig::new(self.inner.clone())
    }

    /// Returns information about a data transfer config.
    pub fn get_transfer_config(&self) -> super::builder::data_transfer_service::GetTransferConfig {
        super::builder::data_transfer_service::GetTransferConfig::new(self.inner.clone())
    }

    /// Returns information about all transfer configs owned by a project in the
    /// specified location.
    pub fn list_transfer_configs(
        &self,
    ) -> super::builder::data_transfer_service::ListTransferConfigs {
        super::builder::data_transfer_service::ListTransferConfigs::new(self.inner.clone())
    }

    /// Creates transfer runs for a time range [start_time, end_time].
    /// For each date - or whatever granularity the data source supports - in the
    /// range, one transfer run is created.
    /// Note that runs are created per UTC time in the time range.
    /// DEPRECATED: use StartManualTransferRuns instead.
    #[deprecated]
    pub fn schedule_transfer_runs(
        &self,
    ) -> super::builder::data_transfer_service::ScheduleTransferRuns {
        super::builder::data_transfer_service::ScheduleTransferRuns::new(self.inner.clone())
    }

    /// Start manual transfer runs to be executed now with schedule_time equal to
    /// current time. The transfer runs can be created for a time range where the
    /// run_time is between start_time (inclusive) and end_time (exclusive), or for
    /// a specific run_time.
    pub fn start_manual_transfer_runs(
        &self,
    ) -> super::builder::data_transfer_service::StartManualTransferRuns {
        super::builder::data_transfer_service::StartManualTransferRuns::new(self.inner.clone())
    }

    /// Returns information about the particular transfer run.
    pub fn get_transfer_run(&self) -> super::builder::data_transfer_service::GetTransferRun {
        super::builder::data_transfer_service::GetTransferRun::new(self.inner.clone())
    }

    /// Deletes the specified transfer run.
    pub fn delete_transfer_run(&self) -> super::builder::data_transfer_service::DeleteTransferRun {
        super::builder::data_transfer_service::DeleteTransferRun::new(self.inner.clone())
    }

    /// Returns information about running and completed transfer runs.
    pub fn list_transfer_runs(&self) -> super::builder::data_transfer_service::ListTransferRuns {
        super::builder::data_transfer_service::ListTransferRuns::new(self.inner.clone())
    }

    /// Returns log messages for the transfer run.
    pub fn list_transfer_logs(&self) -> super::builder::data_transfer_service::ListTransferLogs {
        super::builder::data_transfer_service::ListTransferLogs::new(self.inner.clone())
    }

    /// Returns true if valid credentials exist for the given data source and
    /// requesting user.
    pub fn check_valid_creds(&self) -> super::builder::data_transfer_service::CheckValidCreds {
        super::builder::data_transfer_service::CheckValidCreds::new(self.inner.clone())
    }

    /// Enroll data sources in a user project. This allows users to create transfer
    /// configurations for these data sources. They will also appear in the
    /// ListDataSources RPC and as such, will appear in the
    /// [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents
    /// can be found in the public guide for
    /// [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and
    /// [Data Transfer
    /// Service](https://cloud.google.com/bigquery/docs/working-with-transfers).
    pub fn enroll_data_sources(&self) -> super::builder::data_transfer_service::EnrollDataSources {
        super::builder::data_transfer_service::EnrollDataSources::new(self.inner.clone())
    }

    /// Unenroll data sources in a user project. This allows users to remove
    /// transfer configurations for these data sources. They will no longer appear
    /// in the ListDataSources RPC and will also no longer appear in the [BigQuery
    /// UI](https://console.cloud.google.com/bigquery). Data transfers
    /// configurations of unenrolled data sources will not be scheduled.
    pub fn unenroll_data_sources(
        &self,
    ) -> super::builder::data_transfer_service::UnenrollDataSources {
        super::builder::data_transfer_service::UnenrollDataSources::new(self.inner.clone())
    }

    /// Lists information about the supported locations for this service.
    pub fn list_locations(&self) -> super::builder::data_transfer_service::ListLocations {
        super::builder::data_transfer_service::ListLocations::new(self.inner.clone())
    }

    /// Gets information about a location.
    pub fn get_location(&self) -> super::builder::data_transfer_service::GetLocation {
        super::builder::data_transfer_service::GetLocation::new(self.inner.clone())
    }
}