Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 5ca3fac

Browse files
fix(deps): require google-api-core >= 2.8.0 (#111)
- [ ] 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 d76d314 commit 5ca3fac

8 files changed

Lines changed: 70 additions & 19 deletions

File tree

google/cloud/lifesciences_v2beta/services/workflows_service_v2_beta/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ def __init__(
407407
quota_project_id=client_options.quota_project_id,
408408
client_info=client_info,
409409
always_use_jwt_access=True,
410+
api_audience=client_options.api_audience,
410411
)
411412

412413
def run_pipeline(

google/cloud/lifesciences_v2beta/services/workflows_service_v2_beta/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/lifesciences_v2beta/services/workflows_service_v2_beta/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(
5959
quota_project_id: Optional[str] = None,
6060
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6161
always_use_jwt_access: Optional[bool] = False,
62+
api_audience: Optional[str] = None,
6263
) -> None:
6364
"""Instantiate the transport.
6465
@@ -155,6 +156,7 @@ def __init__(
155156
quota_project_id=quota_project_id,
156157
client_info=client_info,
157158
always_use_jwt_access=always_use_jwt_access,
159+
api_audience=api_audience,
158160
)
159161

160162
if not self._grpc_channel:

google/cloud/lifesciences_v2beta/services/workflows_service_v2_beta/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def __init__(
104104
quota_project_id=None,
105105
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
106106
always_use_jwt_access: Optional[bool] = False,
107+
api_audience: Optional[str] = None,
107108
) -> None:
108109
"""Instantiate the transport.
109110
@@ -200,6 +201,7 @@ def __init__(
200201
quota_project_id=quota_project_id,
201202
client_info=client_info,
202203
always_use_jwt_access=always_use_jwt_access,
204+
api_audience=api_audience,
203205
)
204206

205207
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
release_status = "Development Status :: 4 - Beta"
2626
url = "https://github.com/googleapis/python-life-sciences"
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

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

tests/unit/gapic/lifesciences_v2beta/test_workflows_service_v2_beta.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def test_workflows_service_v2_beta_client_client_options(
242242
quota_project_id=None,
243243
client_info=transports.base.DEFAULT_CLIENT_INFO,
244244
always_use_jwt_access=True,
245+
api_audience=None,
245246
)
246247

247248
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -259,6 +260,7 @@ def test_workflows_service_v2_beta_client_client_options(
259260
quota_project_id=None,
260261
client_info=transports.base.DEFAULT_CLIENT_INFO,
261262
always_use_jwt_access=True,
263+
api_audience=None,
262264
)
263265

264266
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -276,6 +278,7 @@ def test_workflows_service_v2_beta_client_client_options(
276278
quota_project_id=None,
277279
client_info=transports.base.DEFAULT_CLIENT_INFO,
278280
always_use_jwt_access=True,
281+
api_audience=None,
279282
)
280283

281284
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -305,6 +308,25 @@ def test_workflows_service_v2_beta_client_client_options(
305308
quota_project_id="octopus",
306309
client_info=transports.base.DEFAULT_CLIENT_INFO,
307310
always_use_jwt_access=True,
311+
api_audience=None,
312+
)
313+
# Check the case api_endpoint is provided
314+
options = client_options.ClientOptions(
315+
api_audience="https://language.googleapis.com"
316+
)
317+
with mock.patch.object(transport_class, "__init__") as patched:
318+
patched.return_value = None
319+
client = client_class(client_options=options, transport=transport_name)
320+
patched.assert_called_once_with(
321+
credentials=None,
322+
credentials_file=None,
323+
host=client.DEFAULT_ENDPOINT,
324+
scopes=None,
325+
client_cert_source_for_mtls=None,
326+
quota_project_id=None,
327+
client_info=transports.base.DEFAULT_CLIENT_INFO,
328+
always_use_jwt_access=True,
329+
api_audience="https://language.googleapis.com",
308330
)
309331

310332

@@ -382,6 +404,7 @@ def test_workflows_service_v2_beta_client_mtls_env_auto(
382404
quota_project_id=None,
383405
client_info=transports.base.DEFAULT_CLIENT_INFO,
384406
always_use_jwt_access=True,
407+
api_audience=None,
385408
)
386409

387410
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -416,6 +439,7 @@ def test_workflows_service_v2_beta_client_mtls_env_auto(
416439
quota_project_id=None,
417440
client_info=transports.base.DEFAULT_CLIENT_INFO,
418441
always_use_jwt_access=True,
442+
api_audience=None,
419443
)
420444

421445
# Check the case client_cert_source and ADC client cert are not provided.
@@ -438,6 +462,7 @@ def test_workflows_service_v2_beta_client_mtls_env_auto(
438462
quota_project_id=None,
439463
client_info=transports.base.DEFAULT_CLIENT_INFO,
440464
always_use_jwt_access=True,
465+
api_audience=None,
441466
)
442467

443468

@@ -558,6 +583,7 @@ def test_workflows_service_v2_beta_client_client_options_scopes(
558583
quota_project_id=None,
559584
client_info=transports.base.DEFAULT_CLIENT_INFO,
560585
always_use_jwt_access=True,
586+
api_audience=None,
561587
)
562588

563589

@@ -596,6 +622,7 @@ def test_workflows_service_v2_beta_client_client_options_credentials_file(
596622
quota_project_id=None,
597623
client_info=transports.base.DEFAULT_CLIENT_INFO,
598624
always_use_jwt_access=True,
625+
api_audience=None,
599626
)
600627

601628

@@ -616,6 +643,7 @@ def test_workflows_service_v2_beta_client_client_options_from_dict():
616643
quota_project_id=None,
617644
client_info=transports.base.DEFAULT_CLIENT_INFO,
618645
always_use_jwt_access=True,
646+
api_audience=None,
619647
)
620648

621649

@@ -654,6 +682,7 @@ def test_workflows_service_v2_beta_client_create_channel_credentials_file(
654682
quota_project_id=None,
655683
client_info=transports.base.DEFAULT_CLIENT_INFO,
656684
always_use_jwt_access=True,
685+
api_audience=None,
657686
)
658687

659688
# test that the credentials from file are saved and used as the credentials.
@@ -1051,6 +1080,28 @@ def test_workflows_service_v2_beta_transport_auth_adc(transport_class):
10511080
)
10521081

10531082

1083+
@pytest.mark.parametrize(
1084+
"transport_class",
1085+
[
1086+
transports.WorkflowsServiceV2BetaGrpcTransport,
1087+
transports.WorkflowsServiceV2BetaGrpcAsyncIOTransport,
1088+
],
1089+
)
1090+
def test_workflows_service_v2_beta_transport_auth_gdch_credentials(transport_class):
1091+
host = "https://language.com"
1092+
api_audience_tests = [None, "https://language2.com"]
1093+
api_audience_expect = [host, "https://language2.com"]
1094+
for t, e in zip(api_audience_tests, api_audience_expect):
1095+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
1096+
gdch_mock = mock.MagicMock()
1097+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
1098+
return_value=gdch_mock
1099+
)
1100+
adc.return_value = (gdch_mock, None)
1101+
transport_class(host=host, api_audience=t)
1102+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
1103+
1104+
10541105
@pytest.mark.parametrize(
10551106
"transport_class,grpc_helpers",
10561107
[
@@ -1534,4 +1585,5 @@ def test_api_key_credentials(client_class, transport_class):
15341585
quota_project_id=None,
15351586
client_info=transports.base.DEFAULT_CLIENT_INFO,
15361587
always_use_jwt_access=True,
1588+
api_audience=None,
15371589
)

0 commit comments

Comments
 (0)