CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-google-cloud-bigquery-datatransfer

Python client library for managing BigQuery Data Transfer Service operations and scheduling data transfers from partner SaaS applications.

Pending
Overview
Eval results
Files

data-sources.mddocs/

Data Source Management

Operations for discovering and managing available data sources, including listing supported sources, retrieving source configurations, and validating credentials for data source connections.

Capabilities

Get Data Source

Retrieves a supported data source configuration and its parameters.

def get_data_source(
    self,
    request: Optional[Union[GetDataSourceRequest, dict]] = None,
    *,
    name: Optional[str] = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> DataSource:
    """
    Retrieves a supported data source and returns its settings.

    Args:
        request: The request object containing data source name.
        name: Required. The field will contain name of the resource requested.
        retry: Designation of what errors should be retried.
        timeout: The timeout for this request.
        metadata: Strings which should be sent along with the request.

    Returns:
        DataSource: The requested data source configuration.
    """

List Data Sources

Lists supported data sources and returns their settings.

def list_data_sources(
    self,
    request: Optional[Union[ListDataSourcesRequest, dict]] = None,
    *,
    parent: Optional[str] = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> pagers.ListDataSourcesPager:
    """
    Lists supported data sources and returns their settings.

    Args:
        request: The request object containing parent location.
        parent: Required. The BigQuery project id for which data sources should be returned.
        retry: Designation of what errors should be retried.
        timeout: The timeout for this request.
        metadata: Strings which should be sent along with the request.

    Returns:
        ListDataSourcesResponse: The list of supported data sources.
    """

Check Valid Credentials

Checks if credentials are valid for a data source.

def check_valid_creds(
    self,
    request: Optional[Union[CheckValidCredsRequest, dict]] = None,
    *,
    name: Optional[str] = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> CheckValidCredsResponse:
    """
    Returns true if valid credentials exist for the given data source and requesting user.

    Args:
        request: The request object containing data source name.
        name: Required. The data source in the form projects/{project_id}/dataSources/{data_source_id}.
        retry: Designation of what errors should be retried.
        timeout: The timeout for this request.
        metadata: Strings which should be sent along with the request.

    Returns:
        CheckValidCredsResponse: Whether credentials are valid.
    """

Enroll Data Sources

Enrolls data sources in a user project.

def enroll_data_sources(
    self,
    request: Optional[Union[EnrollDataSourcesRequest, dict]] = None,
    *,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> None:
    """
    Enroll data sources in a user project.

    Args:
        request: The request object containing data sources to enroll.
        retry: Designation of what errors should be retried.
        timeout: The timeout for this request.
        metadata: Strings which should be sent along with the request.
    """

Unenroll Data Sources

Unenrolls data sources in a user project.

def unenroll_data_sources(
    self,
    request: Optional[Union[UnenrollDataSourcesRequest, dict]] = None,
    *,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> None:
    """
    Unenroll data sources in a user project.

    Args:
        request: The request object containing data sources to unenroll.
        retry: Designation of what errors should be retried.
        timeout: The timeout for this request.
        metadata: Strings which should be sent along with the request.
    """

Request Types

class GetDataSourceRequest:
    """
    A request to retrieve a data source configuration.
    
    Attributes:
        name (str): Required. The field will contain name of the resource requested.
                   Format: projects/{project}/locations/{location}/dataSources/{data_source}
    """
    name: str

class ListDataSourcesRequest:
    """
    Request message for ListDataSources.
    
    Attributes:
        parent (str): Required. The BigQuery project id for which data sources should be returned.
                     Format: projects/{project_id}/locations/{location_id}
        page_token (str): Pagination token, which can be used to request a specific page.
        page_size (int): Page size. The default page size is the maximum value of 1000 results.
    """
    parent: str
    page_token: str
    page_size: int

class CheckValidCredsRequest:
    """
    A request to check if credentials are valid for the given data source.
    
    Attributes:
        name (str): Required. The data source in the form:
                   projects/{project_id}/locations/{location_id}/dataSources/{data_source_id}
    """
    name: str

class EnrollDataSourcesRequest:
    """
    A request to enroll data sources in a user project.
    
    Attributes:
        name (str): Required. The name of the project resource.
                   Format: projects/{project_id}
        data_source_ids (Sequence[str]): Data sources that are enrolled.
    """
    name: str
    data_source_ids: Sequence[str]

class UnenrollDataSourcesRequest:
    """
    A request to unenroll data sources in a user project.
    
    Attributes:
        name (str): Required. The name of the project resource.
                   Format: projects/{project_id}
        data_source_ids (Sequence[str]): Data sources that are unenrolled.
    """
    name: str
    data_source_ids: Sequence[str]

Response Types

class ListDataSourcesResponse:
    """
    Returns list of supported data sources and their metadata.
    
    Attributes:
        data_sources (Sequence[DataSource]): List of supported data sources.
        next_page_token (str): Output only. The next-pagination token.
    """
    data_sources: Sequence[DataSource]
    next_page_token: str

class CheckValidCredsResponse:
    """
    A response indicating whether the credentials exist and are valid.
    
    Attributes:
        has_valid_creds (bool): If set to true, the credentials exist and are valid.
    """
    has_valid_creds: bool

Usage Examples

List Available Data Sources

from google.cloud import bigquery_datatransfer

client = bigquery_datatransfer.DataTransferServiceClient()

# List all data sources for a project/location
parent = f"projects/{project_id}/locations/{location}"
response = client.list_data_sources(parent=parent)

print("Available data sources:")
for data_source in response:
    print(f"  {data_source.display_name} ({data_source.data_source_id})")
    print(f"    Description: {data_source.description}")
    print(f"    Transfer type: {data_source.transfer_type}")
    print(f"    Supports multiple transfers: {data_source.supports_multiple_transfers}")

Get Specific Data Source Details

from google.cloud import bigquery_datatransfer

client = bigquery_datatransfer.DataTransferServiceClient()

# Get details for a specific data source
data_source_name = f"projects/{project_id}/locations/{location}/dataSources/scheduled_query"
data_source = client.get_data_source(name=data_source_name)

print(f"Data Source: {data_source.display_name}")
print(f"Authorization Type: {data_source.authorization_type}")
print(f"Data Refresh Type: {data_source.data_refresh_type}")

print("Parameters:")
for param in data_source.parameters:
    print(f"  {param.param_id}: {param.display_name}")
    print(f"    Type: {param.type_}")
    print(f"    Required: {param.required}")
    if param.description:
        print(f"    Description: {param.description}")

Check Data Source Credentials

from google.cloud import bigquery_datatransfer

client = bigquery_datatransfer.DataTransferServiceClient()

# Check if credentials are valid for a data source
data_source_name = f"projects/{project_id}/locations/{location}/dataSources/google_ads"
response = client.check_valid_creds(name=data_source_name)

if response.has_valid_creds:
    print("Valid credentials exist for this data source")
else:
    print("No valid credentials found - authorization required")

Enroll Data Sources

from google.cloud import bigquery_datatransfer

client = bigquery_datatransfer.DataTransferServiceClient()

# Enroll specific data sources for a project
request = {
    "name": f"projects/{project_id}",
    "data_source_ids": ["google_ads", "google_analytics", "youtube_channel"]
}

client.enroll_data_sources(request=request)
print("Data sources enrolled successfully")

Install with Tessl CLI

npx tessl i tessl/pypi-google-cloud-bigquery-datatransfer

docs

data-sources.md

data-types.md

index.md

scheduling.md

service-clients.md

transfer-configs.md

transfer-runs.md

tile.json