8000 fix(deps): require google-api-core>=1.32.0,>=2.8.0 (#109) · QPC-github/python-deploy@580906e · GitHub
[go: up one dir, main page]

Skip to content

Commit 580906e

Browse files
fix(deps): require google-api-core>=1.32.0,>=2.8.0 (googleapis#109)
- [ ] 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 chore: use gapic-generator-python 1.1.1 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 4d9a67f commit 580906e

File tree

8 files changed

+70
-19
lines changed

8 files changed

+70
-19
lines changed

google/cloud/deploy_v1/services/cloud_deploy/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ def __init__(
615615
quota_project_id=client_options.quota_project_id,
616616
client_info=client_info,
617617
always_use_jwt_access=True,
618+
api_audience=client_options.api_audience,
618619
)
619620

620621
def list_delivery_pipelines(

google/cloud/deploy_v1/services/cloud_deploy/transports/base.py

Lines 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/deploy_v1/services/cloud_deploy/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(
6060
quota_project_id: Optional[str] = None,
6161
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6262
always_use_jwt_access: Optional[bool] = False,
63+
api_audience: Optional[str] = None,
6364
) -> None:
6465
"""Instantiate the transport.
6566
@@ -156,6 +157,7 @@ def __init__(
156157
quota_project_id=quota_project_id,
157158
client_info=client_info,
158159
always_use_jwt_access=always_use_jwt_access,
160+
api_audience=api_audience,
159161
)
160162

161163
if not self._grpc_channel:

google/cloud/deploy_v1/services/cloud_deploy/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def __init__(
105105
quota_project_id=None,
106106
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
107107
always_use_jwt_access: Optional[bool] = False,
108+
api_audience: Optional[str] = None,
108109
) -> None:
109110
"""Instantiate the transport.
110111
@@ -201,6 +202,7 @@ def __init__(
201202
quota_project_id=quota_project_id,
202203
client_info=client_info,
203204
always_use_jwt_access=always_use_jwt_access,
205+
api_audience=api_audience,
204206
)
205207

206208
if not self._grpc_channel:

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
url = "https://github.com/googleapis/python-deploy"
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] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*",
3229
"proto-plus >= 1.15.0, <2.0.0dev",
3330
"protobuf >= 3.19.0, <4.0.0dev",
3431
]

testing/constraints-3.6.txt

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

testing/constraints-3.7.txt

Lines 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==1.32.0
88
proto-plus==1.15.0
99
protobuf==3.19.0

tests/unit/gapic/deploy_v1/test_cloud_deploy.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ def test_cloud_deploy_client_client_options(
230230
quota_project_id=None,
231231
client_info=transports.base.DEFAULT_CLIENT_INFO,
232232
always_use_jwt_access=True,
233+
api_audience=None,
233234
)
234235

235236
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -247,6 +248,7 @@ def test_cloud_deploy_client_client_options(
247248
quota_project_id=None,
248249
client_info=transports.base.DEFAULT_CLIENT_INFO,
249250
always_use_jwt_access=True,
251+
api_audience=None,
250252
)
251253

252254
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -264,6 +266,7 @@ def test_cloud_deploy_client_client_options(
264266
quota_project_id=None,
265267
client_info=transports.base.DEFAULT_CLIENT_INFO,
266268
always_use_jwt_access=True,
269+
api_audience=None,
267270
)
268271

269272
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -293,6 +296,25 @@ def test_cloud_deploy_client_client_options(
293296
quota_project_id="octopus",
294297
client_info=transports.base.DEFAULT_CLIENT_INFO,
295298
always_use_jwt_access=True,
299+
api_audience=None,
300+
)
301+
# Check the case api_endpoint is provided
302+
options = client_options.ClientOptions(
303+
api_audience="https://language.googleapis.com"
304+
)
305+
with mock.patch.object(transport_class, "__init__") as patched:
306+
patched.return_value = None
307+
client = client_class(client_options=options, transport=transport_name)
308+
patched.assert_called_once_with(
309+
credentials=None,
310+
credentials_file=None,
311+
host=client.DEFAULT_ENDPOINT,
312+
scopes=None,
313+
client_cert_source_for_mtls=None,
314+
quota_project_id=None,
315+
client_info=transports.base.DEFAULT_CLIENT_INFO,
316+
always_use_jwt_access=True,
317+
api_audience="https://language.googleapis.com",
296318
)
297319

298320

@@ -358,6 +380,7 @@ def test_cloud_deploy_client_mtls_env_auto(
358380
quota_project_id=None,
359381
client_info=transports.base.DEFAULT_CLIENT_INFO,
360382
always_use_jwt_access=True,
383+
api_audience=None,
361384
)
362385

363386
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -392,6 +415,7 @@ def test_cloud_deploy_client_mtls_env_auto(
392415
quota_project_id=None,
393416
client_info=transports.base.DEFAULT_CLIENT_INFO,
394417
always_use_jwt_access=True,
418+
api_audience=None,
395419
)
396420

397421
# Check the case client_cert_source and ADC client cert are not provided.
@@ -414,6 +438,7 @@ def test_cloud_deploy_client_mtls_env_auto(
414438
quota_project_id=None,
415439
client_info=transports.base.DEFAULT_CLIENT_INFO,
416440
always_use_jwt_access=True,
441+
api_audience=None,
417442
)
418443

419444

@@ -524,6 +549,7 @@ def test_cloud_deploy_client_client_options_scopes(
524549
quota_project_id=None,
525550
client_info=transports.base.DEFAULT_CLIENT_INFO,
526551
always_use_jwt_access=True,
552+
api_audience=None,
527553
)
528554

529555

@@ -557,6 +583,7 @@ def test_cloud_deploy_client_client_options_credentials_file(
557583
quota_project_id=None,
558584
client_info=transports.base.DEFAULT_CLIENT_INFO,
559585
always_use_jwt_access=True,
586+
api_audience=None,
560587
)
561588

562589

@@ -575,6 +602,7 @@ def test_cloud_deploy_client_client_options_from_dict():
575602
quota_project_id=None,
576603
client_info=transports.base.DEFAULT_CLIENT_INFO,
577604
always_use_jwt_access=True,
605+
api_audience=None,
578606
)
579607

580608

@@ -608,6 +636,7 @@ def test_cloud_deploy_client_create_channel_credentials_file(
608636
quota_project_id=None,
609637
client_info=transports.base.DEFAULT_CLIENT_INFO,
610638
always_use_jwt_access=True,
639+
api_audience=None,
611640
)
612641

613642
# test that the credentials from file are saved and used as the credentials.
@@ -6055,6 +6084,28 @@ def test_cloud_deploy_transport_auth_adc(transport_class):
60556084
)
60566085

60576086

6087+
@pytest.mark.parametrize(
6088+
"transport_class",
6089+
[
6090+
transports.CloudDeployGrpcTransport,
6091+
transports.CloudDeployGrpcAsyncIOTransport,
6092+
],
6093+
)
6094+
def test_cloud_deploy_transport_auth_gdch_credentials(transport_class):
6095+
host = "https://language.com"
6096+
api_audience_tests = [None, "https://language2.com"]
6097+
api_audience_expect = [host, "https://language2.com"]
6098+
for t, e in zip(api_audience_tests, api_audience_expect):
6099+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
6100+
gdch_mock = mock.MagicMock()
6101+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
6102+
return_value=gdch_mock
6103+
)
6104+
adc.return_value = (gdch_mock, None)
6105+
transport_class(host=host, api_audience=t)
6106+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
6107+
6108+
60586109
@pytest.mark.parametrize(
60596110
"transport_class,grpc_helpers",
60606111
[
@@ -6770,4 +6821,5 @@ def test_api_key_credentials(client_class, transport_class):
67706821
quota_project_id=None,
67716822
client_info=transports.base.DEFAULT_CLIENT_INFO,
67726823
always_use_jwt_access=True,
6824+
api_audience=None,
67736825
)

0 commit comments

Comments
 (0)
0