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

Commit 81cf870

Browse filesBrowse files
fix(deps): require google-api-core >= 2.8.0 (#205)
- [ ] 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 14780e3 commit 81cf870
Copy full SHA for 81cf870

File tree

Expand file treeCollapse file tree

8 files changed

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

8 files changed

+70
-24
lines changed

‎packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/client.py

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/client.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ def __init__(
443443
quota_project_id=client_options.quota_project_id,
444444
client_info=client_info,
445445
always_use_jwt_access=True,
446+
api_audience=client_options.api_audience,
446447
)
447448

448449
def create_dashboard(

‎packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/transports/base.py

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/transports/base.py
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
quota_project_id: Optional[str] = None,
6262
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6363
always_use_jwt_access: Optional[bool] = False,
64+
api_audience: Optional[str] = None,
6465
**kwargs,
6566
) -> None:
6667
"""Instantiate the transport.
@@ -88,11 +89,6 @@ def __init__(
8889
be used for service account credentials.
8990
"""
9091

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

9894
# Save the scopes.
@@ -113,6 +109,11 @@ def __init__(
113109
credentials, _ = google.auth.default(
114110
**scopes_kwargs, quota_project_id=quota_project_id
115111
)
112+
# Don't apply audience if the credentials file passed from user.
113+
if hasattr(credentials, "with_gdch_audience"):
114+
credentials = credentials.with_gdch_audience(
115+
api_audience if api_audience else host
116+
)
116117

117118
# If the credentials are service account credentials, then always try to use self signed JWT.
118119
if (
@@ -125,6 +126,11 @@ def __init__(
125126
# Save the credentials.
126127
self._credentials = credentials
127128

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

‎packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/transports/grpc.py

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/transports/grpc.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
quota_project_id: Optional[str] = None,
6262
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6363
always_use_jwt_access: Optional[bool] = False,
64+
api_audience: Optional[str] = None,
6465
) -> None:
6566
"""Instantiate the transport.
6667
@@ -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:

‎packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/transports/grpc_asyncio.py

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/transports/grpc_asyncio.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def __init__(
106106
quota_project_id=None,
107107
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
108108
always_use_jwt_access: Optional[bool] = False,
109+
api_audience: Optional[str] = None,
109110
) -> None:
110111
"""Instantiate the transport.
111112
@@ -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:

‎packages/google-cloud-monitoring-dashboards/setup.py

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/setup.py
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,11 @@
2525
version = "2.6.1"
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
]
3532

36-
extras = {"libcst": "libcst >= 0.2.5"}
37-
3833
package_root = os.path.abspath(os.path.dirname(__file__))
3934

4035
readme_filename = os.path.join(package_root, "README.rst")

‎packages/google-cloud-monitoring-dashboards/testing/constraints-3.6.txt

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/testing/constraints-3.6.txt
-11Lines changed: 0 additions & 11 deletions
This file was deleted.

‎packages/google-cloud-monitoring-dashboards/testing/constraints-3.7.txt

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/testing/constraints-3.7.txt
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +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==2.8.0
99
proto-plus==1.15.0
10-
libcst==0.2.5
1110
protobuf==3.19.0

‎packages/google-cloud-monitoring-dashboards/tests/unit/gapic/dashboard_v1/test_dashboards_service.py

Copy file name to clipboardExpand all lines: packages/google-cloud-monitoring-dashboards/tests/unit/gapic/dashboard_v1/test_dashboards_service.py
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def test_dashboards_service_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_dashboards_service_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_dashboards_service_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_dashboards_service_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_dashboards_service_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_dashboards_service_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_dashboards_service_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

@@ -558,6 +583,7 @@ def test_dashboards_service_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_dashboards_service_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_dashboards_service_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_dashboards_service_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.
@@ -1881,6 +1910,28 @@ def test_dashboards_service_transport_auth_adc(transport_class):
18811910
)
18821911

18831912

1913+
@pytest.mark.parametrize(
1914+
"transport_class",
1915+
[
1916+
transports.DashboardsServiceGrpcTransport,
1917+
transports.DashboardsServiceGrpcAsyncIOTransport,
1918+
],
1919+
)
1920+
def test_dashboards_service_transport_auth_gdch_credentials(transport_class):
1921+
host = "https://language.com"
1922+
api_audience_tests = [None, "https://language2.com"]
1923+
api_audience_expect = [host, "https://language2.com"]
1924+
for t, e in zip(api_audience_tests, api_audience_expect):
1925+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
1926+
gdch_mock = mock.MagicMock()
1927+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
1928+
return_value=gdch_mock
1929+
)
1930+
adc.return_value = (gdch_mock, None)
1931+
transport_class(host=host, api_audience=t)
1932+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
1933+
1934+
18841935
@pytest.mark.parametrize(
18851936
"transport_class,grpc_helpers",
18861937
[
@@ -2377,4 +2428,5 @@ def test_api_key_credentials(client_class, transport_class):
23772428
quota_project_id=None,
23782429
client_info=transports.base.DEFAULT_CLIENT_INFO,
23792430
always_use_jwt_access=True,
2431+
api_audience=None,
23802432
)

0 commit comments

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