Skip to content

Commit 7ac8e14

Browse files
fix: Allow protobuf 5.x (#972)
* chore: Update gapic-generator-python to v1.18.0 PiperOrigin-RevId: 638650618 Source-Link: googleapis/googleapis@6330f03 Source-Link: googleapis/googleapis-gen@44fa4f1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDRmYTRmMTk3OWRjNDVjMTc3OGZkN2NhZjEzZjhlNjFjNmQxY2FlOCJ9 * feat(spanner): Add support for Cloud Spanner Scheduled Backups PiperOrigin-RevId: 649277844 Source-Link: googleapis/googleapis@fd7efa2 Source-Link: googleapis/googleapis-gen@50be251 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTBiZTI1MTMyOWQ4ZGI1YjU1NTYyNmViZDQ4ODY3MjFmNTQ3ZDNjYyJ9 * feat: publish the Cloud Bigtable ExecuteQuery API The ExecuteQuery API will allow users to query Bigtable using SQL PiperOrigin-RevId: 650660213 Source-Link: googleapis/googleapis@f681f79 Source-Link: googleapis/googleapis-gen@3180845 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzE4MDg0NTQ4NzEzNjc5NDk1MmI4ZjM2NWZlNmM2ODY4OTk5ZDljMCJ9 * feat: publish ProtoRows Message This is needed to parse ExecuteQuery responses PiperOrigin-RevId: 651386373 Source-Link: googleapis/googleapis@a5be6fa Source-Link: googleapis/googleapis-gen@d467ce8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDQ2N2NlODkzYTA0YzQxZTUwNDk4MzM0NmMyMTVkNDFmZDI2MzY1MCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update setup.py to match googleapis/gapic-generator-python/blob/main/gapic/templates/setup.py.j2 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update constraints --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 481c8d6 commit 7ac8e14

File tree

27 files changed

+2935
-1072
lines changed

27 files changed

+2935
-1072
lines changed

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/async_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from google.auth import credentials as ga_credentials # type: ignore
3939
from google.oauth2 import service_account # type: ignore
4040

41+
4142
try:
4243
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
4344
except AttributeError: # pragma: NO COVER

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def __init__(
9696

9797
# Save the scopes.
9898
self._scopes = scopes
99+
if not hasattr(self, "_ignore_credentials"):
100+
self._ignore_credentials: bool = False
99101

100102
# If no credentials are provided, then determine the appropriate
101103
# defaults.
@@ -108,7 +110,7 @@ def __init__(
108110
credentials, _ = google.auth.load_credentials_from_file(
109111
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
110112
)
111-
elif credentials is None:
113+
elif credentials is None and not self._ignore_credentials:
112114
credentials, _ = google.auth.default(
113115
**scopes_kwargs, quota_project_id=quota_project_id
114116
)

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def __init__(
132132

133133
if isinstance(channel, grpc.Channel):
134134
# Ignore credentials if a channel was passed.
135-
credentials = False
135+
credentials = None
136+
self._ignore_credentials = True
136137
# If a channel was explicitly provided, set it.
137138
self._grpc_channel = channel
138139
self._ssl_channel_credentials = None

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc_asyncio.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def __init__(
179179

180180
if isinstance(channel, aio.Channel):
181181
# Ignore credentials if a channel was passed.
182-
credentials = False
182+
credentials = None
183+
self._ignore_credentials = True
183184
# If a channel was explicitly provided, set it.
184185
self._grpc_channel = channel
185186
self._ssl_channel_credentials = None

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/async_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from google.auth import credentials as ga_credentials # type: ignore
3939
from google.oauth2 import service_account # type: ignore
4040

41+
4142
try:
4243
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
4344
except AttributeError: # pragma: NO COVER

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def __init__(
9696

9797
# Save the scopes.
9898
self._scopes = scopes
99+
if not hasattr(self, "_ignore_credentials"):
100+
self._ignore_credentials: bool = False
99101

100102
# If no credentials are provided, then determine the appropriate
101103
# defaults.
@@ -108,7 +110,7 @@ def __init__(
108110
credentials, _ = google.auth.load_credentials_from_file(
109111
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
110112
)
111-
elif credentials is None:
113+
elif credentials is None and not self._ignore_credentials:
112114
credentials, _ = google.auth.default(
113115
**scopes_kwargs, quota_project_id=quota_project_id
114116
)

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ def __init__(
134134

135135
if isinstance(channel, grpc.Channel):
136136
# Ignore credentials if a channel was passed.
137-
credentials = False
137+
credentials = None
138+
self._ignore_credentials = True
138139
# If a channel was explicitly provided, set it.
139140
self._grpc_channel = channel
140141
self._ssl_channel_credentials = None

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc_asyncio.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def __init__(
181181

182182
if isinstance(channel, aio.Channel):
183183
# Ignore credentials if a channel was passed.
184-
credentials = False
184+
credentials = None
185+
self._ignore_credentials = True
185186
# If a channel was explicitly provided, set it.
186187
self._grpc_channel = channel
187188
self._ssl_channel_credentials = None

google/cloud/bigtable_v2/__init__.py

+22
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
from .types.bigtable import CheckAndMutateRowRequest
2525
from .types.bigtable import CheckAndMutateRowResponse
26+
from .types.bigtable import ExecuteQueryRequest
27+
from .types.bigtable import ExecuteQueryResponse
2628
from .types.bigtable import GenerateInitialChangeStreamPartitionsRequest
2729
from .types.bigtable import GenerateInitialChangeStreamPartitionsResponse
2830
from .types.bigtable import MutateRowRequest
@@ -40,12 +42,20 @@
4042
from .types.bigtable import ReadRowsResponse
4143
from .types.bigtable import SampleRowKeysRequest
4244
from .types.bigtable import SampleRowKeysResponse
45+
from .types.data import ArrayValue
4346
from .types.data import Cell
4447
from .types.data import Column
48+
from .types.data import ColumnMetadata
4549
from .types.data import ColumnRange
4650
from .types.data import Family
4751
from .types.data import Mutation
52+
from .types.data import PartialResultSet
53+
from .types.data import ProtoFormat
54+
from .types.data import ProtoRows
55+
from .types.data import ProtoRowsBatch
56+
from .types.data import ProtoSchema
4857
from .types.data import ReadModifyWriteRule
58+
from .types.data import ResultSetMetadata
4959
from .types.data import Row
5060
from .types.data import RowFilter
5161
from .types.data import RowRange
@@ -62,15 +72,20 @@
6272
from .types.request_stats import RequestLatencyStats
6373
from .types.request_stats import RequestStats
6474
from .types.response_params import ResponseParams
75+
from .types.types import Type
6576

6677
__all__ = (
6778
"BigtableAsyncClient",
79+
"ArrayValue",
6880
"BigtableClient",
6981
"Cell",
7082
"CheckAndMutateRowRequest",
7183
"CheckAndMutateRowResponse",
7284
"Column",
85+
"ColumnMetadata",
7386
"ColumnRange",
87+
"ExecuteQueryRequest",
88+
"ExecuteQueryResponse",
7489
"Family",
7590
"FeatureFlags",
7691
"FullReadStatsView",
@@ -81,8 +96,13 @@
8196
"MutateRowsRequest",
8297
"MutateRowsResponse",
8398
"Mutation",
99+
"PartialResultSet",
84100
"PingAndWarmRequest",
85101
"PingAndWarmResponse",
102+
"ProtoFormat",
103+
"ProtoRows",
104+
"ProtoRowsBatch",
105+
"ProtoSchema",
86106
"RateLimitInfo",
87107
"ReadChangeStreamRequest",
88108
"ReadChangeStreamResponse",
@@ -95,6 +115,7 @@
95115
"RequestLatencyStats",
96116
"RequestStats",
97117
"ResponseParams",
118+
"ResultSetMetadata",
98119
"Row",
99120
"RowFilter",
100121
"RowRange",
@@ -105,6 +126,7 @@
105126
"StreamContinuationTokens",
106127
"StreamPartition",
107128
"TimestampRange",
129+
"Type",
108130
"Value",
109131
"ValueRange",
110132
)

google/cloud/bigtable_v2/gapic_metadata.json

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"check_and_mutate_row"
1616
]
1717
},
18+
"ExecuteQuery": {
19+
"methods": [
20+
"execute_query"
21+
]
22+
},
1823
"GenerateInitialChangeStreamPartitions": {
1924
"methods": [
2025
"generate_initial_change_stream_partitions"
@@ -65,6 +70,11 @@
6570
"check_and_mutate_row"
6671
]
6772
},
73+
"ExecuteQuery": {
74+
"methods": [
75+
"execute_query"
76+
]
77+
},
6878
"GenerateInitialChangeStreamPartitions": {
6979
"methods": [
7080
"generate_initial_change_stream_partitions"
@@ -115,6 +125,11 @@
115125
"check_and_mutate_row"
116126
]
117127
},
128+
"ExecuteQuery": {
129+
"methods": [
130+
"execute_query"
131+
]
132+
},
118133
"GenerateInitialChangeStreamPartitions": {
119134
"methods": [
120135
"generate_initial_change_stream_partitions"

google/cloud/bigtable_v2/services/bigtable/async_client.py

+104
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from google.auth import credentials as ga_credentials # type: ignore
4141
from google.oauth2 import service_account # type: ignore
4242

43+
4344
try:
4445
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
4546
except AttributeError: # pragma: NO COVER
@@ -1293,6 +1294,109 @@ def read_change_stream(
12931294
# Done; return the response.
12941295
return response
12951296

1297+
def execute_query(
1298+
self,
1299+
request: Optional[Union[bigtable.ExecuteQueryRequest, dict]] = None,
1300+
*,
1301+
instance_name: Optional[str] = None,
1302+
query: Optional[str] = None,
1303+
app_profile_id: Optional[str] = None,
1304+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1305+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1306+
metadata: Sequence[Tuple[str, str]] = (),
1307+
) -> Awaitable[AsyncIterable[bigtable.ExecuteQueryResponse]]:
1308+
r"""Executes a BTQL query against a particular Cloud
1309+
Bigtable instance.
1310+
1311+
Args:
1312+
request (Optional[Union[google.cloud.bigtable_v2.types.ExecuteQueryRequest, dict]]):
1313+
The request object. Request message for
1314+
Bigtable.ExecuteQuery
1315+
instance_name (:class:`str`):
1316+
Required. The unique name of the instance against which
1317+
the query should be executed. Values are of the form
1318+
``projects/<project>/instances/<instance>``
1319+
1320+
This corresponds to the ``instance_name`` field
1321+
on the ``request`` instance; if ``request`` is provided, this
1322+
should not be set.
1323+
query (:class:`str`):
1324+
Required. The query string.
1325+
This corresponds to the ``query`` field
1326+
on the ``request`` instance; if ``request`` is provided, this
1327+
should not be set.
1328+
app_profile_id (:class:`str`):
1329+
Optional. This value specifies routing for replication.
1330+
If not specified, the ``default`` application profile
1331+
will be used.
1332+
1333+
This corresponds to the ``app_profile_id`` field
1334+
on the ``request`` instance; if ``request`` is provided, this
1335+
should not be set.
1336+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1337+
should be retried.
1338+
timeout (float): The timeout for this request.
1339+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1340+
sent along with the request as metadata.
1341+
1342+
Returns:
1343+
AsyncIterable[google.cloud.bigtable_v2.types.ExecuteQueryResponse]:
1344+
Response message for
1345+
Bigtable.ExecuteQuery
1346+
1347+
"""
1348+
# Create or coerce a protobuf request object.
1349+
# - Quick check: If we got a request object, we should *not* have
1350+
# gotten any keyword arguments that map to the request.
1351+
has_flattened_params = any([instance_name, query, app_profile_id])
1352+
if request is not None and has_flattened_params:
1353+
raise ValueError(
1354+
"If the `request` argument is set, then none of "
1355+
"the individual field arguments should be set."
1356+
)
1357+
1358+
# - Use the request object if provided (there's no risk of modifying the input as
1359+
# there are no flattened fields), or create one.
1360+
if not isinstance(request, bigtable.ExecuteQueryRequest):
1361+
request = bigtable.ExecuteQueryRequest(request)
1362+
1363+
# If we have keyword arguments corresponding to fields on the
1364+
# request, apply these.
1365+
if instance_name is not None:
1366+
request.instance_name = instance_name
1367+
if query is not None:
1368+
request.query = query
1369+
if app_profile_id is not None:
1370+
request.app_profile_id = app_profile_id
1371+
1372+
# Wrap the RPC method; this adds retry and timeout information,
1373+
# and friendly error handling.
1374+
rpc = self._client._transport._wrapped_methods[
1375+
self._client._transport.execute_query
1376+
]
1377+
1378+
# Certain fields should be provided within the metadata header;
1379+
# add these here.
1380+
metadata = tuple(metadata) + (
1381+
gapic_v1.routing_header.to_grpc_metadata(
1382+
(("instance_name", request.instance_name),)
1383+
),
1384+
)
1385+
1386+
# Validate the universe domain.
1387+
self._client._validate_universe_domain()
1388+
1389+
# Send the request.
1390+
response = rpc(
1391+
request,
1392+
retry=retry,
1393+
timeout=timeout,
1394+
metadata=metadata,
1395+
)
1396+
1397+
# Done; return the response.
1398+
return response
1399+
12961400
async def __aenter__(self) -> "BigtableAsyncClient":
12971401
return self
12981402

0 commit comments

Comments
 (0)