Skip to content

Commit bd0b1a0

Browse files
fix(deps): require google-api-core>=1.32.0,>=2.8.0 (#207)
- [ ] 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 62ddb37 commit bd0b1a0

8 files changed

Lines changed: 70 additions & 19 deletions

File tree

packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ def __init__(
596596
quota_project_id=client_options.quota_project_id,
597597
client_info=client_info,
598598
always_use_jwt_access=True,
599+
api_audience=client_options.api_audience,
599600
)
600601

601602
def create_conversation(

packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py

Lines changed: 11 additions & 5 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
**kwargs,
6364
) -> None:
6465
"""Instantiate the transport.
@@ -86,11 +87,6 @@ def __init__(
8687
be used for service account credentials.
8788
"""
8889

89-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
90-
if ":" not in host:
91-
host += ":443"
92-
self._host = host
93-
9490
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9591

9692
# Save the scopes.
@@ -111,6 +107,11 @@ def __init__(
111107
credentials, _ = google.auth.default(
112108
**scopes_kwargs, quota_project_id=quota_project_id
113109
)
110+
# Don't apply audience if the credentials file passed from user.
111+
if hasattr(credentials, "with_gdch_audience"):
112+
credentials = credentials.with_gdch_audience(
113+
api_audience if api_audience else host
114+
)
114115

115116
# If the credentials are service account credentials, then always try to use self signed JWT.
116117
if (
@@ -123,6 +124,11 @@ def __init__(
123124
# Save the credentials.
124125
self._credentials = credentials
125126

127+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
128+
if ":" not in host:
129+
host += ":443"
130+
self._host = host
131+
126132
def _prep_wrapped_messages(self, client_info):
127133
# Precompute the wrapped methods.
128134
self._wrapped_methods = {

packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(
6363
quota_project_id: Optional[str] = None,
6464
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6565
always_use_jwt_access: Optional[bool] = False,
66+
api_audience: Optional[str] = None,
6667
) -> None:
6768
"""Instantiate the transport.
6869
@@ -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:

packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def __init__(
108108
quota_project_id=None,
109109
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
110110
always_use_jwt_access: Optional[bool] = False,
111+
api_audience: Optional[str] = None,
111112
) -> None:
112113
"""Instantiate the transport.
113114
@@ -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:

packages/google-cloud-contact-center-insights/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 :: 5 - Production/Stable"
2626
url = "https://github.com/googleapis/python-contact-center-insights"
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
]

packages/google-cloud-contact-center-insights/testing/constraints-3.6.txt

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

packages/google-cloud-contact-center-insights/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

packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def test_contact_center_insights_client_client_options(
248248
quota_project_id=None,
249249
client_info=transports.base.DEFAULT_CLIENT_INFO,
250250
always_use_jwt_access=True,
251+
api_audience=None,
251252
)
252253

253254
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -265,6 +266,7 @@ def test_contact_center_insights_client_client_options(
265266
quota_project_id=None,
266267
client_info=transports.base.DEFAULT_CLIENT_INFO,
267268
always_use_jwt_access=True,
269+
api_audience=None,
268270
)
269271

270272
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -282,6 +284,7 @@ def test_contact_center_insights_client_client_options(
282284
quota_project_id=None,
283285
client_info=transports.base.DEFAULT_CLIENT_INFO,
284286
always_use_jwt_access=True,
287+
api_audience=None,
285288
)
286289

287290
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -311,6 +314,25 @@ def test_contact_center_insights_client_client_options(
311314
quota_project_id="octopus",
312315
client_info=transports.base.DEFAULT_CLIENT_INFO,
313316
always_use_jwt_access=True,
317+
api_audience=None,
318+
)
319+
# Check the case api_endpoint is provided
320+
options = client_options.ClientOptions(
321+
api_audience="https://language.googleapis.com"
322+
)
323+
with mock.patch.object(transport_class, "__init__") as patched:
324+
patched.return_value = None
325+
client = client_class(client_options=options, transport=transport_name)
326+
patched.assert_called_once_with(
327+
credentials=None,
328+
credentials_file=None,
329+
host=client.DEFAULT_ENDPOINT,
330+
scopes=None,
331+
client_cert_source_for_mtls=None,
332+
quota_project_id=None,
333+
client_info=transports.base.DEFAULT_CLIENT_INFO,
334+
always_use_jwt_access=True,
335+
api_audience="https://language.googleapis.com",
314336
)
315337

316338

@@ -388,6 +410,7 @@ def test_contact_center_insights_client_mtls_env_auto(
388410
quota_project_id=None,
389411
client_info=transports.base.DEFAULT_CLIENT_INFO,
390412
always_use_jwt_access=True,
413+
api_audience=None,
391414
)
392415

393416
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -422,6 +445,7 @@ def test_contact_center_insights_client_mtls_env_auto(
422445
quota_project_id=None,
423446
client_info=transports.base.DEFAULT_CLIENT_INFO,
424447
always_use_jwt_access=True,
448+
api_audience=None,
425449
)
426450

427451
# Check the case client_cert_source and ADC client cert are not provided.
@@ -444,6 +468,7 @@ def test_contact_center_insights_client_mtls_env_auto(
444468
quota_project_id=None,
445469
client_info=transports.base.DEFAULT_CLIENT_INFO,
446470
always_use_jwt_access=True,
471+
api_audience=None,
447472
)
448473

449474

@@ -562,6 +587,7 @@ def test_contact_center_insights_client_client_options_scopes(
562587
quota_project_id=None,
563588
client_info=transports.base.DEFAULT_CLIENT_INFO,
564589
always_use_jwt_access=True,
590+
api_audience=None,
565591
)
566592

567593

@@ -600,6 +626,7 @@ def test_contact_center_insights_client_client_options_credentials_file(
600626
quota_project_id=None,
601627
client_info=transports.base.DEFAULT_CLIENT_INFO,
602628
always_use_jwt_access=True,
629+
api_audience=None,
603630
)
604631

605632

@@ -620,6 +647,7 @@ def test_contact_center_insights_client_client_options_from_dict():
620647
quota_project_id=None,
621648
client_info=transports.base.DEFAULT_CLIENT_INFO,
622649
always_use_jwt_access=True,
650+
api_audience=None,
623651
)
624652

625653

@@ -658,6 +686,7 @@ def test_contact_center_insights_client_create_channel_credentials_file(
658686
quota_project_id=None,
659687
client_info=transports.base.DEFAULT_CLIENT_INFO,
660688
always_use_jwt_access=True,
689+
api_audience=None,
661690
)
662691

663692
# test that the credentials from file are saved and used as the credentials.
@@ -10085,6 +10114,28 @@ def test_contact_center_insights_transport_auth_adc(transport_class):
1008510114
)
1008610115

1008710116

10117+
@pytest.mark.parametrize(
10118+
"transport_class",
10119+
[
10120+
transports.ContactCenterInsightsGrpcTransport,
10121+
transports.ContactCenterInsightsGrpcAsyncIOTransport,
10122+
],
10123+
)
10124+
def test_contact_center_insights_transport_auth_gdch_credentials(transport_class):
10125+
host = "https://language.com"
10126+
api_audience_tests = [None, "https://language2.com"]
10127+
api_audience_expect = [host, "https://language2.com"]
10128+
for t, e in zip(api_audience_tests, api_audience_expect):
10129+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
10130+
gdch_mock = mock.MagicMock()
10131+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
10132+
return_value=gdch_mock
10133+
)
10134+
adc.return_value = (gdch_mock, None)
10135+
transport_class(host=host, api_audience=t)
10136+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
10137+
10138+
1008810139
@pytest.mark.parametrize(
1008910140
"transport_class,grpc_helpers",
1009010141
[
@@ -10795,4 +10846,5 @@ def test_api_key_credentials(client_class, transport_class):
1079510846
quota_project_id=None,
1079610847
client_info=transports.base.DEFAULT_CLIENT_INFO,
1079710848
always_use_jwt_access=True,
10849+
api_audience=None,
1079810850
)

0 commit comments

Comments
 (0)