Google Cloud BigQuery Connection API client library for managing external data source connections and credentials
npx @tessl/cli install tessl/pypi-google-cloud-bigquery-connection@1.18.00
# Google Cloud BigQuery Connection
1
2
A Python client library for Google Cloud BigQuery Connection API that enables management of external data source connections and credentials. The library provides programmatic access to create, read, update, and delete BigQuery connections to various external data sources including Cloud SQL, AWS, Azure, Cloud Spanner, and more.
3
4
## Package Information
5
6
- **Package Name**: google-cloud-bigquery-connection
7
- **Package Type**: pypi
8
- **Language**: Python
9
- **Installation**: `pip install google-cloud-bigquery-connection`
10
- **Version**: 1.18.3
11
12
## Core Imports
13
14
```python
15
from google.cloud.bigquery_connection import (
16
ConnectionServiceClient,
17
ConnectionServiceAsyncClient,
18
Connection,
19
CreateConnectionRequest,
20
ListConnectionsRequest,
21
UpdateConnectionRequest,
22
DeleteConnectionRequest,
23
GetConnectionRequest,
24
)
25
```
26
27
For message types and connection properties:
28
29
```python
30
from google.cloud.bigquery_connection import (
31
CloudSqlProperties,
32
AwsProperties,
33
AzureProperties,
34
CloudSpannerProperties,
35
CloudResourceProperties,
36
SparkProperties,
37
SalesforceDataCloudProperties,
38
)
39
```
40
41
## Basic Usage
42
43
```python
44
from google.cloud.bigquery_connection import ConnectionServiceClient, Connection
45
46
# Initialize the client (uses default credentials from environment)
47
client = ConnectionServiceClient()
48
49
# Define the parent resource (project and location)
50
parent = "projects/my-project/locations/us-central1"
51
52
# Create a connection configuration
53
connection = Connection()
54
connection.friendly_name = "My Test Connection"
55
connection.description = "Connection to external data source"
56
57
# For Cloud SQL connection
58
from google.cloud.bigquery_connection import CloudSqlProperties, CloudSqlCredential
59
60
connection.cloud_sql = CloudSqlProperties()
61
connection.cloud_sql.instance_id = "project:region:instance"
62
connection.cloud_sql.database = "my_database"
63
connection.cloud_sql.type_ = CloudSqlProperties.DatabaseType.POSTGRES
64
connection.cloud_sql.credential = CloudSqlCredential(
65
username="db_user",
66
password="db_password"
67
)
68
69
# Create the connection
70
created_connection = client.create_connection(
71
parent=parent,
72
connection=connection,
73
connection_id="my-connection-id"
74
)
75
76
print(f"Created connection: {created_connection.name}")
77
78
# List all connections
79
connections = client.list_connections(parent=parent)
80
for conn in connections:
81
print(f"Connection: {conn.name}, Type: {conn.friendly_name}")
82
83
# Get a specific connection
84
connection_name = f"{parent}/connections/my-connection-id"
85
retrieved_connection = client.get_connection(name=connection_name)
86
87
# Update a connection
88
retrieved_connection.description = "Updated description"
89
from google.protobuf import field_mask_pb2
90
update_mask = field_mask_pb2.FieldMask(paths=["description"])
91
92
updated_connection = client.update_connection(
93
connection=retrieved_connection,
94
update_mask=update_mask
95
)
96
97
# Delete a connection
98
client.delete_connection(name=connection_name)
99
```
100
101
## Architecture
102
103
The BigQuery Connection API follows Google Cloud's standard client library patterns:
104
105
- **Client Classes**: Both synchronous (`ConnectionServiceClient`) and asynchronous (`ConnectionServiceAsyncClient`) clients for different use cases
106
- **Message Types**: Protocol Buffer message classes for all requests, responses, and data structures
107
- **Connection Types**: Pluggable connection configurations for different external data sources
108
- **Resource Management**: Standard Google Cloud resource naming and CRUD operations
109
- **IAM Integration**: Built-in support for Identity and Access Management policies
110
- **Transport Layer**: Multiple transport options (gRPC, REST) with automatic retry and timeout handling
111
112
## Capabilities
113
114
### Connection Management
115
116
Core CRUD operations for managing BigQuery connections to external data sources. Supports creation, retrieval, listing, updating, and deletion of connection resources.
117
118
```python { .api }
119
def create_connection(
120
request: CreateConnectionRequest = None,
121
*,
122
parent: str = None,
123
connection: Connection = None,
124
connection_id: str = None,
125
retry: OptionalRetry = DEFAULT,
126
timeout: Union[float, object] = DEFAULT,
127
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
128
) -> Connection: ...
129
130
def get_connection(
131
request: GetConnectionRequest = None,
132
*,
133
name: str = None,
134
retry: OptionalRetry = DEFAULT,
135
timeout: Union[float, object] = DEFAULT,
136
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
137
) -> Connection: ...
138
139
def list_connections(
140
request: ListConnectionsRequest = None,
141
*,
142
parent: str = None,
143
retry: OptionalRetry = DEFAULT,
144
timeout: Union[float, object] = DEFAULT,
145
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
146
) -> ListConnectionsPager: ...
147
148
def update_connection(
149
request: UpdateConnectionRequest = None,
150
*,
151
name: str = None,
152
connection: Connection = None,
153
update_mask: FieldMask = None,
154
retry: OptionalRetry = DEFAULT,
155
timeout: Union[float, object] = DEFAULT,
156
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
157
) -> Connection: ...
158
159
def delete_connection(
160
request: DeleteConnectionRequest = None,
161
*,
162
name: str = None,
163
retry: OptionalRetry = DEFAULT,
164
timeout: Union[float, object] = DEFAULT,
165
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
166
) -> None: ...
167
```
168
169
[Connection Management](./connection-management.md)
170
171
### Connection Types
172
173
Support for multiple external data source connection types including Cloud SQL, AWS, Azure, Cloud Spanner, Cloud Resource, Spark, and Salesforce Data Cloud. Each connection type provides specific configuration options for its respective data source.
174
175
```python { .api }
176
class Connection:
177
name: str
178
friendly_name: str
179
description: str
180
creation_time: int
181
last_modified_time: int
182
has_credential: bool
183
# OneOf connection type fields
184
cloud_sql: CloudSqlProperties
185
aws: AwsProperties
186
azure: AzureProperties
187
cloud_spanner: CloudSpannerProperties
188
cloud_resource: CloudResourceProperties
189
spark: SparkProperties
190
salesforce_data_cloud: SalesforceDataCloudProperties
191
```
192
193
[Connection Types](./connection-types.md)
194
195
### Client Configuration
196
197
Options for configuring client behavior including credentials, transport selection, retry policies, timeouts, and metadata handling. Supports both synchronous and asynchronous operation modes.
198
199
```python { .api }
200
class ConnectionServiceClient:
201
def __init__(
202
self,
203
*,
204
credentials: Optional[Credentials] = None,
205
transport: Optional[Union[str, ConnectionServiceTransport]] = None,
206
client_options: Optional[Union[ClientOptions, dict]] = None,
207
client_info: ClientInfo = DEFAULT_CLIENT_INFO,
208
) -> None: ...
209
210
class ConnectionServiceAsyncClient:
211
def __init__(
212
self,
213
*,
214
credentials: Optional[Credentials] = None,
215
transport: Optional[Union[str, ConnectionServiceTransport]] = "grpc_asyncio",
216
client_options: Optional[ClientOptions] = None,
217
client_info: ClientInfo = DEFAULT_CLIENT_INFO,
218
) -> None: ...
219
```
220
221
[Client Configuration](./client-configuration.md)
222
223
### IAM Policy Management
224
225
Identity and Access Management operations for connection resources including getting, setting, and testing IAM policies and permissions.
226
227
```python { .api }
228
def get_iam_policy(
229
request: GetIamPolicyRequest = None,
230
*,
231
resource: str = None,
232
retry: OptionalRetry = DEFAULT,
233
timeout: Union[float, object] = DEFAULT,
234
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
235
) -> Policy: ...
236
237
def set_iam_policy(
238
request: SetIamPolicyRequest = None,
239
*,
240
resource: str = None,
241
retry: OptionalRetry = DEFAULT,
242
timeout: Union[float, object] = DEFAULT,
243
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
244
) -> Policy: ...
245
246
def test_iam_permissions(
247
request: TestIamPermissionsRequest = None,
248
*,
249
resource: str = None,
250
permissions: Optional[MutableSequence[str]] = None,
251
retry: OptionalRetry = DEFAULT,
252
timeout: Union[float, object] = DEFAULT,
253
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
254
) -> TestIamPermissionsResponse: ...
255
```
256
257
[IAM Policy Management](./iam-policy-management.md)
258
259
### Resource Path Helpers
260
261
Utility methods for constructing and parsing Google Cloud resource paths for connections, clusters, services, and common resources like projects, locations, and billing accounts.
262
263
```python { .api }
264
@classmethod
265
def connection_path(cls, project: str, location: str, connection: str) -> str: ...
266
267
@classmethod
268
def parse_connection_path(cls, path: str) -> Dict[str, str]: ...
269
270
@classmethod
271
def cluster_path(cls, project: str, region: str, cluster: str) -> str: ...
272
273
@classmethod
274
def service_path(cls, project: str, location: str, service: str) -> str: ...
275
276
@classmethod
277
def common_project_path(cls, project: str) -> str: ...
278
279
@classmethod
280
def common_location_path(cls, project: str, location: str) -> str: ...
281
```
282
283
[Resource Path Helpers](./resource-path-helpers.md)
284
285
## Types
286
287
### Core Types
288
289
```python { .api }
290
from typing import Optional, Union, Sequence, Tuple, MutableSequence
291
from google.api_core import retry as retries
292
from google.api_core import gapic_v1
293
from google.protobuf import field_mask_pb2
294
from google.iam.v1 import policy_pb2, iam_policy_pb2
295
296
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
297
```
298
299
### Request Message Types
300
301
```python { .api }
302
class CreateConnectionRequest:
303
parent: str
304
connection_id: str
305
connection: Connection
306
307
class GetConnectionRequest:
308
name: str
309
310
class ListConnectionsRequest:
311
parent: str
312
page_size: int
313
page_token: str
314
315
class UpdateConnectionRequest:
316
name: str
317
connection: Connection
318
update_mask: field_mask_pb2.FieldMask
319
320
class DeleteConnectionRequest:
321
name: str
322
```
323
324
### Response Message Types
325
326
```python { .api }
327
class ListConnectionsResponse:
328
next_page_token: str
329
connections: MutableSequence[Connection]
330
331
@property
332
def raw_page(self) -> "ListConnectionsResponse": ...
333
```
334
335
### Pagination Types
336
337
```python { .api }
338
class ListConnectionsPager:
339
def __iter__(self) -> Iterator[Connection]: ...
340
341
@property
342
def pages(self) -> Iterator[ListConnectionsResponse]: ...
343
344
class ListConnectionsAsyncPager:
345
def __aiter__(self) -> AsyncIterator[Connection]: ...
346
347
@property
348
def pages(self) -> AsyncIterator[ListConnectionsResponse]: ...
349
```