Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit d29082b

Browse files
1 parent d69d0e2 commit d29082b

47 files changed

Lines changed: 692 additions & 13879 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google/cloud/bigquery_datatransfer/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
from google.cloud.bigquery_datatransfer_v1.types.datatransfer import (
3939
DeleteTransferRunRequest,
4040
)
41+
from google.cloud.bigquery_datatransfer_v1.types.datatransfer import (
42+
EnrollDataSourcesRequest,
43+
)
4144
from google.cloud.bigquery_datatransfer_v1.types.datatransfer import (
4245
GetDataSourceRequest,
4346
)
@@ -91,6 +94,7 @@
9194
from google.cloud.bigquery_datatransfer_v1.types.transfer import TransferConfig
9295
from google.cloud.bigquery_datatransfer_v1.types.transfer import TransferMessage
9396
from google.cloud.bigquery_datatransfer_v1.types.transfer import TransferRun
97+
from google.cloud.bigquery_datatransfer_v1.types.transfer import UserInfo
9498
from google.cloud.bigquery_datatransfer_v1.types.transfer import TransferState
9599
from google.cloud.bigquery_datatransfer_v1.types.transfer import TransferType
96100

@@ -104,6 +108,7 @@
104108
"DataSourceParameter",
105109
"DeleteTransferConfigRequest",
106110
"DeleteTransferRunRequest",
111+
"EnrollDataSourcesRequest",
107112
"GetDataSourceRequest",
108113
"GetTransferConfigRequest",
109114
"GetTransferRunRequest",
@@ -125,6 +130,7 @@
125130
"TransferConfig",
126131
"TransferMessage",
127132
"TransferRun",
133+
"UserInfo",
128134
"TransferState",
129135
"TransferType",
130136
)

google/cloud/bigquery_datatransfer_v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .types.datatransfer import DataSourceParameter
2525
from .types.datatransfer import DeleteTransferConfigRequest
2626
from .types.datatransfer import DeleteTransferRunRequest
27+
from .types.datatransfer import EnrollDataSourcesRequest
2728
from .types.datatransfer import GetDataSourceRequest
2829
from .types.datatransfer import GetTransferConfigRequest
2930
from .types.datatransfer import GetTransferRunRequest
@@ -45,6 +46,7 @@
4546
from .types.transfer import TransferConfig
4647
from .types.transfer import TransferMessage
4748
from .types.transfer import TransferRun
49+
from .types.transfer import UserInfo
4850
from .types.transfer import TransferState
4951
from .types.transfer import TransferType
5052

@@ -59,6 +61,7 @@
5961
"DeleteTransferConfigRequest",
6062
"DeleteTransferRunRequest",
6163
"EmailPreferences",
64+
"EnrollDataSourcesRequest",
6265
"GetDataSourceRequest",
6366
"GetTransferConfigRequest",
6467
"GetTransferRunRequest",
@@ -81,4 +84,5 @@
8184
"TransferState",
8285
"TransferType",
8386
"UpdateTransferConfigRequest",
87+
"UserInfo",
8488
)

google/cloud/bigquery_datatransfer_v1/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"delete_transfer_run"
3131
]
3232
},
33+
"EnrollDataSources": {
34+
"methods": [
35+
"enroll_data_sources"
36+
]
37+
},
3338
"GetDataSource": {
3439
"methods": [
3540
"get_data_source"
@@ -105,6 +110,11 @@
105110
"delete_transfer_run"
106111
]
107112
},
113+
"EnrollDataSources": {
114+
"methods": [
115+
"enroll_data_sources"
116+
]
117+
},
108118
"GetDataSource": {
109119
"methods": [
110120
"get_data_source"

google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/async_client.py

Lines changed: 100 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from collections import OrderedDict
1717
import functools
1818
import re
19-
from typing import Dict, Sequence, Tuple, Type, Union
19+
from typing import Dict, Optional, Sequence, Tuple, Type, Union
2020
import pkg_resources
2121
import warnings
2222

@@ -46,10 +46,8 @@
4646

4747

4848
class 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

Comments
 (0)