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

Commit 63e75a3

Browse files
fix(deps): require google-api-core>=1.32.0,>=2.8.0 (#205)
- [ ] 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 f4080d0 commit 63e75a3

File tree

8 files changed

+70
-20
lines changed

8 files changed

+70
-20
lines changed

google/cloud/video/transcoder_v1/services/transcoder_service/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def __init__(
457457
quota_project_id=client_options.quota_project_id,
458458
client_info=client_info,
459459
always_use_jwt_access=True,
460+
api_audience=client_options.api_audience,
460461
)
461462

462463
def create_job(

google/cloud/video/transcoder_v1/services/transcoder_service/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/video/transcoder_v1/services/transcoder_service/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(
6464
quota_project_id: Optional[str] = None,
6565
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6666
always_use_jwt_access: Optional[bool] = False,
67+
api_audience: Optional[str] = None,
6768
) -> None:
6869
"""Instantiate the transport.
6970
@@ -159,6 +160,7 @@ def __init__(
159160
quota_project_id=quota_project_id,
160161
client_info=client_info,
161162
always_use_jwt_access=always_use_jwt_access,
163+
api_audience=api_audience,
162164
)
163165

164166
if not self._grpc_channel:

google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def __init__(
109109
quota_project_id=None,
110110
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
111111
always_use_jwt_access: Optional[bool] = False,
112+
api_audience: Optional[str] = None,
112113
) -> None:
113114
"""Instantiate the transport.
114115
@@ -204,6 +205,7 @@ def __init__(
204205
quota_project_id=quota_project_id,
205206
client_info=client_info,
206207
always_use_jwt_access=always_use_jwt_access,
208+
api_audience=api_audience,
207209
)
208210

209211
if not self._grpc_channel:

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@
4242
platforms="Posix; MacOS X; Windows",
4343
include_package_data=True,
4444
install_requires=(
45-
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
46-
# Until this issue is closed
47-
# https://github.com/googleapis/google-cloud-python/issues/10566
48-
"google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
45+
"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.*",
4946
"proto-plus >= 1.20.3, <2.0.0dev",
5047
"protobuf >= 3.19.0, <4.0.0dev",
5148
),

testing/constraints-3.6.txt

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

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.20.3
1010
protobuf==3.19.0

tests/unit/gapic/transcoder_v1/test_transcoder_service.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def test_transcoder_service_client_client_options(
232232
quota_project_id=None,
233233
client_info=transports.base.DEFAULT_CLIENT_INFO,
234234
always_use_jwt_access=True,
235+
api_audience=None,
235236
)
236237

237238
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -249,6 +250,7 @@ def test_transcoder_service_client_client_options(
249250
quota_project_id=None,
250251
client_info=transports.base.DEFAULT_CLIENT_INFO,
251252
always_use_jwt_access=True,
253+
api_audience=None,
252254
)
253255

254256
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -266,6 +268,7 @@ def test_transcoder_service_client_client_options(
266268
quota_project_id=None,
267269
client_info=transports.base.DEFAULT_CLIENT_INFO,
268270
always_use_jwt_access=True,
271+
api_audience=None,
269272
)
270273

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

300322

@@ -372,6 +394,7 @@ def test_transcoder_service_client_mtls_env_auto(
372394
quota_project_id=None,
373395
client_info=transports.base.DEFAULT_CLIENT_INFO,
374396
always_use_jwt_access=True,
397+
api_audience=None,
375398
)
376399

377400
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -406,6 +429,7 @@ def test_transcoder_service_client_mtls_env_auto(
406429
quota_project_id=None,
407430
client_info=transports.base.DEFAULT_CLIENT_INFO,
408431
always_use_jwt_access=True,
432+
api_audience=None,
409433
)
410434

411435
# Check the case client_cert_source and ADC client cert are not provided.
@@ -428,6 +452,7 @@ def test_transcoder_service_client_mtls_env_auto(
428452
quota_project_id=None,
429453
client_info=transports.base.DEFAULT_CLIENT_INFO,
430454
always_use_jwt_access=True,
455+
api_audience=None,
431456
)
432457

433458

@@ -542,6 +567,7 @@ def test_transcoder_service_client_client_options_scopes(
542567
quota_project_id=None,
543568
client_info=transports.base.DEFAULT_CLIENT_INFO,
544569
always_use_jwt_access=True,
570+
api_audience=None,
545571
)
546572

547573

@@ -580,6 +606,7 @@ def test_transcoder_service_client_client_options_credentials_file(
580606
quota_project_id=None,
581607
client_info=transports.base.DEFAULT_CLIENT_INFO,
582608
always_use_jwt_access=True,
609+
api_audience=None,
583610
)
584611

585612

@@ -600,6 +627,7 @@ def test_transcoder_service_client_client_options_from_dict():
600627
quota_project_id=None,
601628
client_info=transports.base.DEFAULT_CLIENT_INFO,
602629
always_use_jwt_access=True,
630+
api_audience=None,
603631
)
604632

605633

@@ -638,6 +666,7 @@ def test_transcoder_service_client_create_channel_credentials_file(
638666
quota_project_id=None,
639667
client_info=transports.base.DEFAULT_CLIENT_INFO,
640668
always_use_jwt_access=True,
669+
api_audience=None,
641670
)
642671

643672
# test that the credentials from file are saved and used as the credentials.
@@ -3217,6 +3246,28 @@ def test_transcoder_service_transport_auth_adc(transport_class):
32173246
)
32183247

32193248

3249+
@pytest.mark.parametrize(
3250+
"transport_class",
3251+
[
3252+
transports.TranscoderServiceGrpcTransport,
3253+
transports.TranscoderServiceGrpcAsyncIOTransport,
3254+
],
3255+
)
3256+
def test_transcoder_service_transport_auth_gdch_credentials(transport_class):
3257+
host = "https://language.com"
3258+
api_audience_tests = [None, "https://language2.com"]
3259+
api_audience_expect = [host, "https://language2.com"]
3260+
for t, e in zip(api_audience_tests, api_audience_expect):
3261+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
3262+
gdch_mock = mock.MagicMock()
3263+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
3264+
return_value=gdch_mock
3265+
)
3266+
adc.return_value = (gdch_mock, None)
3267+
transport_class(host=host, api_audience=t)
3268+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
3269+
3270+
32203271
@pytest.mark.parametrize(
32213272
"transport_class,grpc_helpers",
32223273
[
@@ -3716,4 +3767,5 @@ def test_api_key_credentials(client_class, transport_class):
37163767
quota_project_id=None,
37173768
client_info=transports.base.DEFAULT_CLIENT_INFO,
37183769
always_use_jwt_access=True,
3770+
api_audience=None,
37193771
)

0 commit comments

Comments
 (0)