1616from collections import OrderedDict
1717import functools
1818import re
19- from typing import Dict , Sequence , Tuple , Type , Union
19+ from typing import Dict , Optional , Sequence , Tuple , Type , Union
2020import pkg_resources
2121import warnings
2222
4646
4747
4848class DataTransferServiceAsyncClient :
49- """The Google BigQuery Data Transfer Service API enables
50- BigQuery users to configure the transfer of their data from
51- other Google Products into BigQuery. This service contains
52- methods that are end user exposed. It backs up the frontend.
49+ """This API allows users to manage their data transfers into
50+ BigQuery.
5351 """
5452
5553 _client : DataTransferServiceClient
@@ -125,6 +123,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
125123
126124 from_service_account_json = from_service_account_file
127125
126+ @classmethod
127+ def get_mtls_endpoint_and_cert_source (
128+ cls , client_options : Optional [ClientOptions ] = None
129+ ):
130+ """Return the API endpoint and client cert source for mutual TLS.
131+
132+ The client cert source is determined in the following order:
133+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
134+ client cert source is None.
135+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
136+ default client cert source exists, use the default one; otherwise the client cert
137+ source is None.
138+
139+ The API endpoint is determined in the following order:
140+ (1) if `client_options.api_endpoint` if provided, use the provided one.
141+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
142+ default mTLS endpoint; if the environment variabel is "never", use the default API
143+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
144+ use the default API endpoint.
145+
146+ More details can be found at https://google.aip.dev/auth/4114.
147+
148+ Args:
149+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
150+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
151+ in this method.
152+
153+ Returns:
154+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
155+ client cert source to use.
156+
157+ Raises:
158+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
159+ """
160+ return DataTransferServiceClient .get_mtls_endpoint_and_cert_source (client_options ) # type: ignore
161+
128162 @property
129163 def transport (self ) -> DataTransferServiceTransport :
130164 """Returns the transport used by the client instance.
@@ -196,7 +230,7 @@ async def get_data_source(
196230 metadata : Sequence [Tuple [str , str ]] = (),
197231 ) -> datatransfer .DataSource :
198232 r"""Retrieves a supported data source and returns its
199- settings, which can be used for UI rendering .
233+ settings.
200234
201235 Args:
202236 request (Union[google.cloud.bigquery_datatransfer_v1.types.GetDataSourceRequest, dict]):
@@ -219,9 +253,8 @@ async def get_data_source(
219253
220254 Returns:
221255 google.cloud.bigquery_datatransfer_v1.types.DataSource:
222- Represents data source metadata.
223- Metadata is sufficient to render UI and
224- request proper OAuth tokens.
256+ Defines the properties and custom
257+ parameters for a data source.
225258
226259 """
227260 # Create or coerce a protobuf request object.
@@ -281,7 +314,7 @@ async def list_data_sources(
281314 metadata : Sequence [Tuple [str , str ]] = (),
282315 ) -> pagers .ListDataSourcesAsyncPager :
283316 r"""Lists supported data sources and returns their
284- settings, which can be used for UI rendering .
317+ settings.
285318
286319 Args:
287320 request (Union[google.cloud.bigquery_datatransfer_v1.types.ListDataSourcesRequest, dict]):
@@ -562,8 +595,8 @@ async def delete_transfer_config(
562595 timeout : float = None ,
563596 metadata : Sequence [Tuple [str , str ]] = (),
564597 ) -> None :
565- r"""Deletes a data transfer configuration,
566- including any associated transfer runs and logs.
598+ r"""Deletes a data transfer configuration, including any
599+ associated transfer runs and logs.
567600
568601 Args:
569602 request (Union[google.cloud.bigquery_datatransfer_v1.types.DeleteTransferConfigRequest, dict]):
@@ -1134,14 +1167,13 @@ async def list_transfer_runs(
11341167 timeout : float = None ,
11351168 metadata : Sequence [Tuple [str , str ]] = (),
11361169 ) -> pagers .ListTransferRunsAsyncPager :
1137- r"""Returns information about running and completed jobs.
1170+ r"""Returns information about running and completed
1171+ transfer runs.
11381172
11391173 Args:
11401174 request (Union[google.cloud.bigquery_datatransfer_v1.types.ListTransferRunsRequest, dict]):
11411175 The request object. A request to list data transfer
1142- runs. UI can use this method to show/filter specific
1143- data transfer runs. The data source can use this method
1144- to request all scheduled transfer runs.
1176+ runs.
11451177 parent (:class:`str`):
11461178 Required. Name of transfer configuration for which
11471179 transfer runs should be retrieved. Format of transfer
@@ -1229,8 +1261,7 @@ async def list_transfer_logs(
12291261 timeout : float = None ,
12301262 metadata : Sequence [Tuple [str , str ]] = (),
12311263 ) -> pagers .ListTransferLogsAsyncPager :
1232- r"""Returns user facing log messages for the data
1233- transfer run.
1264+ r"""Returns log messages for the transfer run.
12341265
12351266 Args:
12361267 request (Union[google.cloud.bigquery_datatransfer_v1.types.ListTransferLogsRequest, dict]):
@@ -1324,11 +1355,6 @@ async def check_valid_creds(
13241355 ) -> datatransfer .CheckValidCredsResponse :
13251356 r"""Returns true if valid credentials exist for the given
13261357 data source and requesting user.
1327- Some data sources doesn't support service account, so we
1328- need to talk to them on behalf of the end user. This API
1329- just checks whether we have OAuth token for the
1330- particular user, which is a pre-requisite before user
1331- can create a transfer config.
13321358
13331359 Args:
13341360 request (Union[google.cloud.bigquery_datatransfer_v1.types.CheckValidCredsRequest, dict]):
@@ -1408,6 +1434,57 @@ async def check_valid_creds(
14081434 # Done; return the response.
14091435 return response
14101436
1437+ async def enroll_data_sources (
1438+ self ,
1439+ request : Union [datatransfer .EnrollDataSourcesRequest , dict ] = None ,
1440+ * ,
1441+ retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
1442+ timeout : float = None ,
1443+ metadata : Sequence [Tuple [str , str ]] = (),
1444+ ) -> None :
1445+ r"""Enroll data sources in a user project. This allows
1446+ users to create transfer configurations for these data
1447+ sources. They will also appear in the ListDataSources
1448+ RPC and as such, will appear in the BigQuery UI
1449+ 'https://bigquery.cloud.google.com' (and the documents
1450+ can be found at
1451+ https://cloud.google.com/bigquery/bigquery-web-ui and
1452+ https://cloud.google.com/bigquery/docs/working-with-
1453+ transfers).
1454+
1455+ Args:
1456+ request (Union[google.cloud.bigquery_datatransfer_v1.types.EnrollDataSourcesRequest, dict]):
1457+ The request object. A request to enroll a set of data
1458+ sources so they are visible in the BigQuery UI's
1459+ `Transfer` tab.
1460+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1461+ should be retried.
1462+ timeout (float): The timeout for this request.
1463+ metadata (Sequence[Tuple[str, str]]): Strings which should be
1464+ sent along with the request as metadata.
1465+ """
1466+ # Create or coerce a protobuf request object.
1467+ request = datatransfer .EnrollDataSourcesRequest (request )
1468+
1469+ # Wrap the RPC method; this adds retry and timeout information,
1470+ # and friendly error handling.
1471+ rpc = gapic_v1 .method_async .wrap_method (
1472+ self ._client ._transport .enroll_data_sources ,
1473+ default_timeout = None ,
1474+ client_info = DEFAULT_CLIENT_INFO ,
1475+ )
1476+
1477+ # Certain fields should be provided within the metadata header;
1478+ # add these here.
1479+ metadata = tuple (metadata ) + (
1480+ gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
1481+ )
1482+
1483+ # Send the request.
1484+ await rpc (
1485+ request , retry = retry , timeout = timeout , metadata = metadata ,
1486+ )
1487+
14111488 async def __aenter__ (self ):
14121489 return self
14131490
0 commit comments