Skip to content

Commit 44fa6cb

Browse files
feat: add cloud spanner connection properties - serverless analytics (#296)
* feat: add cloud spanner connection properties - serverless analytics feat: add cloud spanner connection properties - database role PiperOrigin-RevId: 511807110 Source-Link: googleapis/googleapis@a563815 Source-Link: googleapis/googleapis-gen@a28f65a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTI4ZjY1YWNhY2UxMjUwNGRmZTQ0OGIyYmRjNTUxM2VlODk4NjI2NSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to v1.8.5 PiperOrigin-RevId: 511892190 Source-Link: googleapis/googleapis@a45d9c0 Source-Link: googleapis/googleapis-gen@1907294 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTkwNzI5NGIxZDgzNjVlYTI0ZjhjNWYyZTA1OWE2NDEyNGM0ZWQzYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Fixed Ruby documentation generation PiperOrigin-RevId: 512672271 Source-Link: googleapis/googleapis@bc22d91 Source-Link: googleapis/googleapis-gen@cad484d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2FkNDg0ZDRkYmRjNDM0YmFiOWJkZWIxN2NkZDA3ODQ1N2M3YzcwZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 28dcedc commit 44fa6cb

File tree

5 files changed

+74
-18
lines changed

5 files changed

+74
-18
lines changed

packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ async def sample_list_connections():
512512
Returns:
513513
google.cloud.bigquery_connection_v1.services.connection_service.pagers.ListConnectionsAsyncPager:
514514
The response for
515-
[ConnectionService.ListConnections][google.cloud.bigquery.connection.v1.ConnectionService.ListConnections].
515+
[ConnectionService.ListConnections][google.cloud.bigquery.connection.v1.ConnectionService.ListConnections].
516516
517517
Iterating over this object will yield results and
518518
resolve additional pages automatically.

packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ def sample_list_connections():
733733
Returns:
734734
google.cloud.bigquery_connection_v1.services.connection_service.pagers.ListConnectionsPager:
735735
The response for
736-
[ConnectionService.ListConnections][google.cloud.bigquery.connection.v1.ConnectionService.ListConnections].
736+
[ConnectionService.ListConnections][google.cloud.bigquery.connection.v1.ConnectionService.ListConnections].
737737
738738
Iterating over this object will yield results and
739739
resolve additional pages automatically.

packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/rest.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import dataclasses
1818
import json # type: ignore
1919
import re
20-
from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
20+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
2121
import warnings
2222

2323
from google.api_core import gapic_v1, path_template, rest_helpers, rest_streaming
@@ -404,7 +404,7 @@ class _CreateConnection(ConnectionServiceRestStub):
404404
def __hash__(self):
405405
return hash("CreateConnection")
406406

407-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {}
407+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
408408

409409
@classmethod
410410
def _get_unset_required_fields(cls, message_dict):
@@ -506,7 +506,7 @@ class _DeleteConnection(ConnectionServiceRestStub):
506506
def __hash__(self):
507507
return hash("DeleteConnection")
508508

509-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {}
509+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
510510

511511
@classmethod
512512
def _get_unset_required_fields(cls, message_dict):
@@ -584,7 +584,7 @@ class _GetConnection(ConnectionServiceRestStub):
584584
def __hash__(self):
585585
return hash("GetConnection")
586586

587-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {}
587+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
588588

589589
@classmethod
590590
def _get_unset_required_fields(cls, message_dict):
@@ -675,7 +675,7 @@ class _GetIamPolicy(ConnectionServiceRestStub):
675675
def __hash__(self):
676676
return hash("GetIamPolicy")
677677

678-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {}
678+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
679679

680680
@classmethod
681681
def _get_unset_required_fields(cls, message_dict):
@@ -844,7 +844,7 @@ class _ListConnections(ConnectionServiceRestStub):
844844
def __hash__(self):
845845
return hash("ListConnections")
846846

847-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {
847+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {
848848
"pageSize": 0,
849849
}
850850

@@ -938,7 +938,7 @@ class _SetIamPolicy(ConnectionServiceRestStub):
938938
def __hash__(self):
939939
return hash("SetIamPolicy")
940940

941-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {}
941+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
942942

943943
@classmethod
944944
def _get_unset_required_fields(cls, message_dict):
@@ -1107,7 +1107,7 @@ class _TestIamPermissions(ConnectionServiceRestStub):
11071107
def __hash__(self):
11081108
return hash("TestIamPermissions")
11091109

1110-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {}
1110+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
11111111

11121112
@classmethod
11131113
def _get_unset_required_fields(cls, message_dict):
@@ -1204,7 +1204,7 @@ class _UpdateConnection(ConnectionServiceRestStub):
12041204
def __hash__(self):
12051205
return hash("UpdateConnection")
12061206

1207-
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {
1207+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {
12081208
"updateMask": {},
12091209
}
12101210

packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/types/connection.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from __future__ import annotations
17+
1618
from typing import MutableMapping, MutableSequence
1719

1820
from google.protobuf import field_mask_pb2 # type: ignore
@@ -310,10 +312,11 @@ class CloudSqlProperties(proto.Message):
310312
service_account_id (str):
311313
Output only. The account ID of the service
312314
used for the purpose of this connection.
315+
313316
When the connection is used in the context of an
314317
operation in BigQuery, this service account will
315-
serve as identity being used for connecting to
316-
the CloudSQL instance specified in this
318+
serve as the identity being used for connecting
319+
to the CloudSQL instance specified in this
317320
connection.
318321
"""
319322

@@ -386,6 +389,30 @@ class CloudSpannerProperties(proto.Message):
386389
use_parallelism (bool):
387390
If parallelism should be used when reading
388391
from Cloud Spanner
392+
use_serverless_analytics (bool):
393+
If the serverless analytics service should be used to read
394+
data from Cloud Spanner. Note: ``use_parallelism`` must be
395+
set when using serverless analytics.
396+
database_role (str):
397+
Optional. Cloud Spanner database role for
398+
fine-grained access control. A database role is
399+
a collection of fine-grained access privileges.
400+
Example: Admin predefines roles that provides
401+
user a set of permissions (SELECT, INSERT, ..).
402+
The user can then specify a predefined role on a
403+
connection to execute their Cloud Spanner query.
404+
The role is passthrough here. If the user is not
405+
authorized to use the specified role, they get
406+
an error. This validation happens on Cloud
407+
Spanner.
408+
409+
See
410+
https://cloud.google.com/spanner/docs/fgac-about
411+
for more details.
412+
REQUIRES: database role name must start with
413+
uppercase/lowercase letter and only contain
414+
uppercase/lowercase letters, numbers, and
415+
underscores.
389416
"""
390417

391418
database: str = proto.Field(
@@ -396,6 +423,14 @@ class CloudSpannerProperties(proto.Message):
396423
proto.BOOL,
397424
number=2,
398425
)
426+
use_serverless_analytics: bool = proto.Field(
427+
proto.BOOL,
428+
number=3,
429+
)
430+
database_role: str = proto.Field(
431+
proto.STRING,
432+
number=4,
433+
)
399434

400435

401436
class AwsProperties(proto.Message):
@@ -514,7 +549,7 @@ class AzureProperties(proto.Message):
514549
The URL user will be redirected to after
515550
granting consent during connection setup.
516551
federated_application_client_id (str):
517-
The client id of the user's Azure Active
552+
The client ID of the user's Azure Active
518553
Directory Application used for a federated
519554
connection.
520555
identity (str):
@@ -562,6 +597,7 @@ class CloudResourceProperties(proto.Message):
562597
service_account_id (str):
563598
Output only. The account ID of the service
564599
created for the purpose of this connection.
600+
565601
The service account does not have any
566602
permissions associated with it when it is
567603
created. After creation, customers delegate

packages/google-cloud-bigquery-connection/tests/unit/gapic/bigquery_connection_v1/test_connection_service.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,7 +3049,12 @@ def test_create_connection_rest(request_type):
30493049
"federated_application_client_id": "federated_application_client_id_value",
30503050
"identity": "identity_value",
30513051
},
3052-
"cloud_spanner": {"database": "database_value", "use_parallelism": True},
3052+
"cloud_spanner": {
3053+
"database": "database_value",
3054+
"use_parallelism": True,
3055+
"use_serverless_analytics": True,
3056+
"database_role": "database_role_value",
3057+
},
30533058
"cloud_resource": {"service_account_id": "service_account_id_value"},
30543059
"creation_time": 1379,
30553060
"last_modified_time": 1890,
@@ -3287,7 +3292,12 @@ def test_create_connection_rest_bad_request(
32873292
"federated_application_client_id": "federated_application_client_id_value",
32883293
"identity": "identity_value",
32893294
},
3290-
"cloud_spanner": {"database": "database_value", "use_parallelism": True},
3295+
"cloud_spanner": {
3296+
"database": "database_value",
3297+
"use_parallelism": True,
3298+
"use_serverless_analytics": True,
3299+
"database_role": "database_role_value",
3300+
},
32913301
"cloud_resource": {"service_account_id": "service_account_id_value"},
32923302
"creation_time": 1379,
32933303
"last_modified_time": 1890,
@@ -4058,7 +4068,12 @@ def test_update_connection_rest(request_type):
40584068
"federated_application_client_id": "federated_application_client_id_value",
40594069
"identity": "identity_value",
40604070
},
4061-
"cloud_spanner": {"database": "database_value", "use_parallelism": True},
4071+
"cloud_spanner": {
4072+
"database": "database_value",
4073+
"use_parallelism": True,
4074+
"use_serverless_analytics": True,
4075+
"database_role": "database_role_value",
4076+
},
40624077
"cloud_resource": {"service_account_id": "service_account_id_value"},
40634078
"creation_time": 1379,
40644079
"last_modified_time": 1890,
@@ -4297,7 +4312,12 @@ def test_update_connection_rest_bad_request(
42974312
"federated_application_client_id": "federated_application_client_id_value",
42984313
"identity": "identity_value",
42994314
},
4300-
"cloud_spanner": {"database": "database_value", "use_parallelism": True},
4315+
"cloud_spanner": {
4316+
"database": "database_value",
4317+
"use_parallelism": True,
4318+
"use_serverless_analytics": True,
4319+
"database_role": "database_role_value",
4320+
},
43014321
"cloud_resource": {"service_account_id": "service_account_id_value"},
43024322
"creation_time": 1379,
43034323
"last_modified_time": 1890,

0 commit comments

Comments
 (0)