8000 fix(deps): require google-api-core>=1.32.0,>=2.8.0 (#173) · googleapis/google-cloud-python@81670bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 81670bc

Browse files
fix(deps): require google-api-core>=1.32.0,>=2.8.0 (#173)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 459095142 Source-Link: googleapis/googleapis@4f1be99 Source-Link: googleapis/googleapis-gen@ae686d9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9 feat: add audience parameter PiperOrigin-RevId: 456827138 Source-Link: googleapis/googleapis@23f1a15 Source-Link: googleapis/googleapis-gen@4075a85 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9
1 parent 53302e4 commit 81670bc

File tree

8 files changed

+70
-20
lines changed

8 files changed

+70
-20
lines changed

packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ def __init__(
464464
quota_project_id=client_options.quota_project_id,
465465
client_info=client_info,
466466
always_use_jwt_access=True,
467+
api_audience=client_options.api_audience,
467468
)
468469

469470
def get_table(

packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(
6262
quota_project_id: Optional[str] = None,
6363
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6464
always_use_jwt_access: Optional[bool] = False,
65+
api_audience: Optional[str] = None,
6566
**kwargs,
6667
) -> None:
6768
"""Instantiate the transport.
@@ -89,11 +90,6 @@ def __init__(
8990
be used for service account credentials.
9091
"""
9192

92-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
93-
if ":" not in host:
94-
host += ":443"
95-
self._host = host
96-
9793
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9894

9995
# Save the scopes.
@@ -114,6 +110,11 @@ def __init__(
114110
credentials, _ = google.auth.default(
115111
**scopes_kwargs, quota_project_id=quota_project_id
116112
)
113+
# Don't apply audience if the credentials file passed from user.
114+
if hasattr(credentials, "with_gdch_audience"):
115+
credentials = credentials.with_gdch_audience(
116+
api_audience if api_audience else host
117+
)
117118

118119
# If the credentials are service account credentials, then always try to use self signed JWT.
119120
if (
@@ -126,6 +127,11 @@ def __init__(
126127
# Save the credentials.
127128
self._credentials = credentials
128129

130+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
131+
if ":" not in host:
132+
host += ":443"
133+
self._host = host
134+
129135
def _prep_wrapped_messages(self, client_info):
130136
# Precompute the wrapped methods.
131137
self._wrapped_methods = {

packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(
7171
quota_project_id: Optional[str] = None,
7272
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
7373
always_use_jwt_access: Optional[bool] = False,
74+
api_audience: Optional[str] = None,
7475
) -> None:
7576
"""Instantiate the transport.
7677
@@ -166,6 +167,7 @@ def __init__(
166167
quota_project_id=quota_project_id,
167168
client_info=client_info,
168169
always_use_jwt_access=always_use_jwt_access,
170+
api_audience=api_audience,
169171
)
170172

171173
if not self._grpc_channel:

packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def __init__(
116116
quota_project_id=None,
117117
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
118118
always_use_jwt_access: Optional[bool] = False,
119+
api_audience: Optional[str] = None,
119120
) -> None:
120121
"""Instantiate the transport.
121122
@@ -211,6 +212,7 @@ def __init__(
211212
quota_project_id=quota_project_id,
212213
client_info=client_info,
213214
always_use_jwt_access=always_use_jwt_access,
215+
api_audience=api_audience,
214216
)
215217

216218
if not self._grpc_channel:

packages/google-area120-tables/setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@
4646
platforms="Posix; MacOS X; Windows",
4747
include_package_data=True,
4848
install_requires=(
49-
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
50-
# Until this issue is closed
51-
# https://github.com/googleapis/google-cloud-python/issues/10566
52-
"google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
49+
"google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*",
5350
"proto-plus >= 1.15.0, <2.0.0dev",
5451
"protobuf >= 3.19.0, <4.0.0dev",
5552
),

packages/google-area120-tables/testing/constraints-3.6.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/google-area120-tables/testing/constraints-3.7.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
#
66
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
77
# Then this file should have foo==1.14.0
8-
google-api-core==1.31.5
8+
google-api-core==1.32.0
99
proto-plus==1.15.0
1010
protobuf==3.19.0

packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def test_tables_service_client_client_options(
225225
quota_project_id=None,
226226
client_info=transports.base.DEFAULT_CLIENT_INFO,
227227
always_use_jwt_access=True,
228+
api_audience=None,
228229
)
229230

230231
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -242,6 +243,7 @@ def test_tables_service_client_client_options(
242243
quota_project_id=None,
243244
client_info=transports.base.DEFAULT_CLIENT_INFO,
244245
always_use_jwt_access=True,
246+
api_audience=None,
245247
)
246248

247249
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -259,6 +261,7 @@ def test_tables_service_client_client_options(
259261
quota_project_id=None,
260262
client_info=transports.base.DEFAULT_CLIENT_INFO,
261263
always_use_jwt_access=True,
264+
api_audience=None,
262265
)
263266

264267
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -288,6 +291,25 @@ def test_tables_service_client_client_options(
288291
quota_project_id="octopus",
289292
client_info=transports.base.DEFAULT_CLIENT_INFO,
290293
always_use_jwt_access=True,
294+
api_audience=None,
295+
)
296+
# Check the case api_endpoint is provided
297+
options = client_options.ClientOptions(
298+
api_audience="https://language.googleapis.com"
299+
)
300+
with mock.patch.object(transport_class, "__init__") as patched:
301+
patched.return_value = None
302+
client = client_class(client_options=options, transport=transport_name)
303+
patched.assert_called_once_with(
304+
credentials=None,
305+
credentials_file=None,
306+
host=client.DEFAULT_ENDPOINT,
307+
scopes=None,
308+
client_cert_source_for_mtls=None,
309+
quota_project_id=None,
310+
client_info=transports.base.DEFAULT_CLIENT_INFO,
311+
always_use_jwt_access=True,
312+
api_audience="https://language.googleapis.com",
291313
)
292314

293315

@@ -355,6 +377,7 @@ def test_tables_service_client_mtls_env_auto(
355377
quota_project_id=None,
356378
client_info=transports.base.DEFAULT_CLIENT_INFO,
357379
always_use_jwt_access=True,
380+
api_audience=None,
358381
)
359382

360383
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -389,6 +412,7 @@ def test_tables_service_client_mtls_env_auto(
389412
quota_project_id=None,
390413
client_info=transports.base.DEFAULT_CLIENT_INFO,
391414
always_use_jwt_access=True,
415+
api_audience=None,
392416
)
393417

394418
# Check the case client_cert_source and ADC client cert are not provided.
@@ -411,6 +435,7 @@ def test_tables_service_client_mtls_env_auto(
411435
quota_project_id=None,
412436
client_info=transports.base.DEFAULT_CLIENT_INFO,
413437
always_use_jwt_access=True,
438+
api_audience=None,
414439
)
415440

416441

@@ -525,6 +550,7 @@ def test_tables_service_client_client_options_scopes(
525550
quota_project_id=None,
526551
client_info=transports.base.DEFAULT_CLIENT_INFO,
527552
always_use_jwt_access=True,
553+
api_audience=None,
528554
)
529555

530556

@@ -563,6 +589,7 @@ def test_tables_service_client_client_options_credentials_file(
563589
quota_project_id=None,
564590
client_info=transports.base.DEFAULT_CLIENT_INFO,
565591
always_use_jwt_access=True,
592+
api_audience=None,
566593
)
567594

568595

@@ -583,6 +610,7 @@ def test_tables_service_client_client_options_from_dict():
583610
quota_project_id=None,
584611
client_info=transports.base.DEFAULT_CLIENT_INFO,
585612
always_use_jwt_access=True,
613+
api_audience=None,
586614
)
587615

588616

@@ -621,6 +649,7 @@ def test_tables_service_client_create_channel_credentials_file(
621649
quota_project_id=None,
622650
client_info=transports.base.DEFAULT_CLIENT_INFO,
623651
always_use_jwt_access=True,
652+
api_audience=None,
624653
)
625654

626655
# test that the credentials from file are saved and used as the credentials.
@@ -3724,6 +3753,28 @@ def test_tables_service_transport_auth_adc(transport_class):
37243753
)
37253754

37263755

3756+
@pytest.mark.parametrize(
3757+
"transport_class",
3758+
[
3759+
transports.TablesServiceGrpcTransport,
3760+
transports.TablesServiceGrpcAsyncIOTransport,
3761+
],
3762+
)
3763+
def test_tables_service_transport_auth_gdch_credentials(transport_class):
3764+
host = "https://language.com"
3765+
api_audience_tests = [None, "https://language2.com"]
3766+
api_audience_expect = [host, "https://language2.com"]
3767+
for t, e in zip(api_audience_tests, api_audience_expect):
3768+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
3769+
gdch_mock = mock.MagicMock()
3770+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
3771+
return_value=gdch_mock
3772+
)
3773+
adc.return_value = (gdch_mock, None)
3774+
transport_class(host=host, api_audience=t)
3775+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
3776+
3777+
37273778
@pytest.mark.parametrize(
37283779
"transport_class,grpc_helpers",
37293780
[
@@ -4234,4 +4285,5 @@ def test_api_key_credentials(client_class, transport_class):
42344285
quota_project_id=None,
42354286
client_info=transports.base.DEFAULT_CLIENT_INFO,
42364287
always_use_jwt_access=True,
4288+
api_audience=None,
42374289
)

0 commit comments

Comments
 (0)
0