Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 9ef3f98

Browse filesBrowse files
fix(deps): require google-api-core >= 2.8.0 (#194)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 459095142 Source-Link: googleapis/googleapis@4f1be99 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ae686d9cde4fc3e36d0ac02efb8643b15890c1ed Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9 feat: add audience parameter PiperOrigin-RevId: 456827138 Source-Link: googleapis/googleapis@23f1a15 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4075a8514f676691ec156688a5bbf183aa9893ce Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9
1 parent a792592 commit 9ef3f98
Copy full SHA for 9ef3f98

File tree

Expand file treeCollapse file tree

13 files changed

+138
-24
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+138
-24
lines changed

‎google/cloud/memcache_v1/services/cloud_memcache/client.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1/services/cloud_memcache/client.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ def __init__(
448448
quota_project_id=client_options.quota_project_id,
449449
client_info=client_info,
450450
always_use_jwt_access=True,
451+
api_audience=client_options.api_audience,
451452
)
452453

453454
def list_instances(

‎google/cloud/memcache_v1/services/cloud_memcache/transports/base.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1/services/cloud_memcache/transports/base.py
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
quota_project_id: Optional[str] = None,
5656
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5757
always_use_jwt_access: Optional[bool] = False,
58+
api_audience: Optional[str] = None,
5859
**kwargs,
5960
) -> None:
6061
"""Instantiate the transport.
@@ -82,11 +83,6 @@ def __init__(
8283
be used for service account credentials.
8384
"""
8485

85-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
86-
if ":" not in host:
87-
host += ":443"
88-
self._host = host
89-
9086
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9187

9288
# Save the scopes.
@@ -107,6 +103,11 @@ def __init__(
107103
credentials, _ = google.auth.default(
108104
**scopes_kwargs, quota_project_id=quota_project_id
109105
)
106+
# Don't apply audience if the credentials file passed from user.
107+
if hasattr(credentials, "with_gdch_audience"):
108+
credentials = credentials.with_gdch_audience(
109+
api_audience if api_audience else host
110+
)
110111

111112
# If the credentials are service account credentials, then always try to use self signed JWT.
112113
if (
@@ -119,6 +120,11 @@ def __init__(
119120
# Save the credentials.
120121
self._credentials = credentials
121122

123+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
124+
if ":" not in host:
125+
host += ":443"
126+
self._host = host
127+
122128
def _prep_wrapped_messages(self, client_info):
123129
# Precompute the wrapped methods.
124130
self._wrapped_methods = {

‎google/cloud/memcache_v1/services/cloud_memcache/transports/grpc.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1/services/cloud_memcache/transports/grpc.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(
7676
quota_project_id: Optional[str] = None,
7777
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
7878
always_use_jwt_access: Optional[bool] = False,
79+
api_audience: Optional[str] = None,
7980
) -> None:
8081
"""Instantiate the transport.
8182
@@ -172,6 +173,7 @@ def __init__(
172173
quota_project_id=quota_project_id,
173174
client_info=client_info,
174175
always_use_jwt_access=always_use_jwt_access,
176+
api_audience=api_audience,
175177
)
176178

177179
if not self._grpc_channel:

‎google/cloud/memcache_v1/services/cloud_memcache/transports/grpc_asyncio.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1/services/cloud_memcache/transports/grpc_asyncio.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def __init__(
121121
quota_project_id=None,
122122
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
123123
always_use_jwt_access: Optional[bool] = False,
124+
api_audience: Optional[str] = None,
124125
) -> None:
125126
"""Instantiate the transport.
126127
@@ -217,6 +218,7 @@ def __init__(
217218
quota_project_id=quota_project_id,
218219
client_info=client_info,
219220
always_use_jwt_access=always_use_jwt_access,
221+
api_audience=api_audience,
220222
)
221223

222224
if not self._grpc_channel:

‎google/cloud/memcache_v1beta2/services/cloud_memcache/client.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1beta2/services/cloud_memcache/client.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ def __init__(
448448
quota_project_id=client_options.quota_project_id,
449449
client_info=client_info,
450450
always_use_jwt_access=True,
451+
api_audience=client_options.api_audience,
451452
)
452453

453454
def list_instances(

‎google/cloud/memcache_v1beta2/services/cloud_memcache/transports/base.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1beta2/services/cloud_memcache/transports/base.py
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
quota_project_id: Optional[str] = None,
5656
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5757
always_use_jwt_access: Optional[bool] = False,
58+
api_audience: Optional[str] = None,
5859
**kwargs,
5960
) -> None:
6061
"""Instantiate the transport.
@@ -82,11 +83,6 @@ def __init__(
8283
be used for service account credentials.
8384
"""
8485

85-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
86-
if ":" not in host:
87-
host += ":443"
88-
self._host = host
89-
9086
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9187

9288
# Save the scopes.
@@ -107,6 +103,11 @@ def __init__(
107103
credentials, _ = google.auth.default(
108104
**scopes_kwargs, quota_project_id=quota_project_id
109105
)
106+
# Don't apply audience if the credentials file passed from user.
107+
if hasattr(credentials, "with_gdch_audience"):
108+
credentials = credentials.with_gdch_audience(
109+
api_audience if api_audience else host
110+
)
110111

111112
# If the credentials are service account credentials, then always try to use self signed JWT.
112113
if (
@@ -119,6 +120,11 @@ def __init__(
119120
# Save the credentials.
120121
self._credentials = credentials
121122

123+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
124+
if ":" not in host:
125+
host += ":443"
126+
self._host = host
127+
122128
def _prep_wrapped_messages(self, client_info):
123129
# Precompute the wrapped methods.
124130
self._wrapped_methods = {

‎google/cloud/memcache_v1beta2/services/cloud_memcache/transports/grpc.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1beta2/services/cloud_memcache/transports/grpc.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(
7676
quota_project_id: Optional[str] = None,
7777
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
7878
always_use_jwt_access: Optional[bool] = False,
79+
api_audience: Optional[str] = None,
7980
) -> None:
8081
"""Instantiate the transport.
8182
@@ -172,6 +173,7 @@ def __init__(
172173
quota_project_id=quota_project_id,
173174
client_info=client_info,
174175
always_use_jwt_access=always_use_jwt_access,
176+
api_audience=api_audience,
175177
)
176178

177179
if not self._grpc_channel:

‎google/cloud/memcache_v1beta2/services/cloud_memcache/transports/grpc_asyncio.py

Copy file name to clipboardExpand all lines: google/cloud/memcache_v1beta2/services/cloud_memcache/transports/grpc_asyncio.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def __init__(
121121
quota_project_id=None,
122122
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
123123
always_use_jwt_access: Optional[bool] = False,
124+
api_audience: Optional[str] = None,
124125
) -> None:
125126
"""Instantiate the transport.
126127
@@ -217,6 +218,7 @@ def __init__(
217218
quota_project_id=quota_project_id,
218219
client_info=client_info,
219220
always_use_jwt_access=always_use_jwt_access,
221+
api_audience=api_audience,
220222
)
221223

222224
if not self._grpc_channel:

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
version = "1.3.2"
2626
release_status = "Development Status :: 5 - Production/Stable"
2727
dependencies = [
28-
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
29-
# Until this issue is closed
30-
# https://github.com/googleapis/google-cloud-python/issues/10566
31-
"google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
28+
"google-api-core[grpc] >= 2.8.0, <3.0.0dev",
3229
"proto-plus >= 1.15.0, <2.0.0dev",
3330
"protobuf >= 3.19.0, <4.0.0dev",
3431
]

‎testing/constraints-3.6.txt

Copy file name to clipboardExpand all lines: testing/constraints-3.6.txt
-9Lines changed: 0 additions & 9 deletions
This file was deleted.

‎testing/constraints-3.7.txt

Copy file name to clipboardExpand all lines: testing/constraints-3.7.txt
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# Pin the version to the lower bound.
55
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev",
66
# Then this file should have google-cloud-foo==1.14.0
7-
google-api-core==1.31.5
7+
google-api-core==2.8.0
88
proto-plus==1.15.0
99
protobuf==3.19.0

‎tests/unit/gapic/memcache_v1/test_cloud_memcache.py

Copy file name to clipboardExpand all lines: tests/unit/gapic/memcache_v1/test_cloud_memcache.py
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def test_cloud_memcache_client_client_options(
235235
quota_project_id=None,
236236
client_info=transports.base.DEFAULT_CLIENT_INFO,
237237
always_use_jwt_access=True,
238+
api_audience=None,
238239
)
239240

240241
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -252,6 +253,7 @@ def test_cloud_memcache_client_client_options(
252253
quota_project_id=None,
253254
client_info=transports.base.DEFAULT_CLIENT_INFO,
254255
always_use_jwt_access=True,
256+
api_audience=None,
255257
)
256258

257259
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -269,6 +271,7 @@ def test_cloud_memcache_client_client_options(
269271
quota_project_id=None,
270272
client_info=transports.base.DEFAULT_CLIENT_INFO,
271273
always_use_jwt_access=True,
274+
api_audience=None,
272275
)
273276

274277
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -298,6 +301,25 @@ def test_cloud_memcache_client_client_options(
298301
quota_project_id="octopus",
299302
client_info=transports.base.DEFAULT_CLIENT_INFO,
300303
always_use_jwt_access=True,
304+
api_audience=None,
305+
)
306+
# Check the case api_endpoint is provided
307+
options = client_options.ClientOptions(
308+
api_audience="https://language.googleapis.com"
309+
)
310+
with mock.patch.object(transport_class, "__init__") as patched:
311+
patched.return_value = None
312+
client = client_class(client_options=options, transport=transport_name)
313+
patched.assert_called_once_with(
314+
credentials=None,
315+
credentials_file=None,
316+
host=client.DEFAULT_ENDPOINT,
317+
scopes=None,
318+
client_cert_source_for_mtls=None,
319+
quota_project_id=None,
320+
client_info=transports.base.DEFAULT_CLIENT_INFO,
321+
always_use_jwt_access=True,
322+
api_audience="https://language.googleapis.com",
301323
)
302324

303325

@@ -365,6 +387,7 @@ def test_cloud_memcache_client_mtls_env_auto(
365387
quota_project_id=None,
366388
client_info=transports.base.DEFAULT_CLIENT_INFO,
367389
always_use_jwt_access=True,
390+
api_audience=None,
368391
)
369392

370393
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -399,6 +422,7 @@ def test_cloud_memcache_client_mtls_env_auto(
399422
quota_project_id=None,
400423
client_info=transports.base.DEFAULT_CLIENT_INFO,
401424
always_use_jwt_access=True,
425+
api_audience=None,
402426
)
403427

404428
# Check the case client_cert_source and ADC client cert are not provided.
@@ -421,6 +445,7 @@ def test_cloud_memcache_client_mtls_env_auto(
421445
quota_project_id=None,
422446
client_info=transports.base.DEFAULT_CLIENT_INFO,
423447
always_use_jwt_access=True,
448+
api_audience=None,
424449
)
425450

426451

@@ -535,6 +560,7 @@ def test_cloud_memcache_client_client_options_scopes(
535560
quota_project_id=None,
536561
client_info=transports.base.DEFAULT_CLIENT_INFO,
537562
always_use_jwt_access=True,
563+
api_audience=None,
538564
)
539565

540566

@@ -573,6 +599,7 @@ def test_cloud_memcache_client_client_options_credentials_file(
573599
quota_project_id=None,
574600
client_info=transports.base.DEFAULT_CLIENT_INFO,
575601
always_use_jwt_access=True,
602+
api_audience=None,
576603
)
577604

578605

@@ -593,6 +620,7 @@ def test_cloud_memcache_client_client_options_from_dict():
593620
quota_project_id=None,
594621
client_info=transports.base.DEFAULT_CLIENT_INFO,
595622
always_use_jwt_access=True,
623+
api_audience=None,
596624
)
597625

598626

@@ -631,6 +659,7 @@ def test_cloud_memcache_client_create_channel_credentials_file(
631659
quota_project_id=None,
632660
client_info=transports.base.DEFAULT_CLIENT_INFO,
633661
always_use_jwt_access=True,
662+
api_audience=None,
634663
)
635664

636665
# test that the credentials from file are saved and used as the credentials.
@@ -2794,6 +2823,28 @@ def test_cloud_memcache_transport_auth_adc(transport_class):
27942823
)
27952824

27962825

2826+
@pytest.mark.parametrize(
2827+
"transport_class",
2828+
[
2829+
transports.CloudMemcacheGrpcTransport,
2830+
transports.CloudMemcacheGrpcAsyncIOTransport,
2831+
],
2832+
)
2833+
def test_cloud_memcache_transport_auth_gdch_credentials(transport_class):
2834+
host = "https://language.com"
2835+
api_audience_tests = [None, "https://language2.com"]
2836+
api_audience_expect = [host, "https://language2.com"]
2837+
for t, e in zip(api_audience_tests, api_audience_expect):
2838+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
2839+
gdch_mock = mock.MagicMock()
2840+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
2841+
return_value=gdch_mock
2842+
)
2843+
adc.return_value = (gdch_mock, None)
2844+
transport_class(host=host, api_audience=t)
2845+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
2846+
2847+
27972848
@pytest.mark.parametrize(
27982849
"transport_class,grpc_helpers",
27992850
[
@@ -3294,4 +3345,5 @@ def test_api_key_credentials(client_class, transport_class):
32943345
quota_project_id=None,
32953346
client_info=transports.base.DEFAULT_CLIENT_INFO,
32963347
always_use_jwt_access=True,
3348+
api_audience=None,
32973349
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.