8000 fix(deps): require google-api-core >= 2.8.0 (#217) · googleapis/google-cloud-python@6f910a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f910a7

Browse files
fix(deps): require google-api-core >= 2.8.0 (#217)
- [ ] 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 5fb256c commit 6f910a7

File tree

8 files changed

+70
-24
lines changed

8 files changed

+70
-24
lines changed

packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ def __init__(
491491
quota_project_id=client_options.quota_project_id,
492492
client_info=client_info,
493493
always_use_jwt_access=True,
494+
api_audience=client_options.api_audience,
494495
)
495496

496497
def list_approval_requests(

packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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 = {

packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def __init__(
9292
quota_project_id: Optional[str] = None,
9393
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
9494
always_use_jwt_access: Optional[bool] = False,
95+
api_audience: Optional[str] = None,
9596
) -> None:
9697
"""Instantiate the transport.
9798
@@ -187,6 +188,7 @@ def __init__(
187188
quota_project_id=quota_project_id,
188189
client_info=client_info,
189190
always_use_jwt_access=always_use_jwt_access,
191+
api_audience=api_audience,
190192
)
191193

192194
if not self._grpc_channel:

packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def __init__(
137137
quota_project_id=None,
138138
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
139139
always_use_jwt_access: Optional[bool] = False,
140+
api_audience: Optional[str] = None,
140141
) -> None:
141142
"""Instantiate the transport.
142143
@@ -232,6 +233,7 @@ def __init__(
232233
quota_project_id=quota_project_id,
233234
client_info=client_info,
234235
always_use_jwt_access=always_use_jwt_access,
236+
api_audience=api_audience,
235237
)
236238

237239
if not self._grpc_channel:

packages/google-cloud-access-approval/setup.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,11 @@
2424
version = "1.6.1"
2525
release_status = "Development Status :: 5 - Production/Stable"
2626
dependencies = [
27-
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
28-
# Until this issue is closed
29-
# https://github.com/googleapis/google-cloud-python/issues/10566
30-
"google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
27+
"google-api-core[grpc] >= 2.8.0, <3.0.0dev",
3128
"proto-plus >= 1.15.0, <2.0.0dev",
3229
"protobuf >= 3.19.0, <4.0.0dev",
3330
]
3431

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

3934
readme_filename = os.path.join(package_root, "README.rst")
@@ -79,7 +74,6 @@
7974
scripts=["scripts/fixup_accessapproval_v1_keywords.py"],
8075
namespace_packages=namespaces,
8176
install_requires=dependencies,
82-
extras_require=extras,
8377
include_package_data=True,
8478
zip_safe=False,
8579
)

packages/google-cloud-access-approval/testing/constraints-3.6.txt

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

packages/google-cloud-access-approval/testing/constraints-3.7.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +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
9-
libcst==0.2.5
109
protobuf==3.19.0

packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def test_access_approval_client_client_options(
225225
quota_project_id=None,
226226
client_info=transports.base.DEFAULT_CLIENT_INFO,
227227
always_use_jwt_access=True,
228+
api_audience=None,
228229
)
229230

230231
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -242,6 +243,7 @@ def test_access_approval_client_client_options(
242243
quota_project_id=None,
243244
client_info=transports.base.DEFAULT_CLIENT_INFO,
244245
always_use_jwt_access=True,
246+
api_audience=None,
245247
)
246248

247249
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -259,6 +261,7 @@ def test_access_approval_client_client_options(
259261
quota_project_id=None,
260262
client_info=transports.base.DEFAULT_CLIENT_INFO,
261263
always_use_jwt_access=True,
264+
api_audience=None,
262265
)
263266

264267
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -288,6 +291,25 @@ def test_access_approval_client_client_options(
288291
quota_project_id="octopus",
289292
client_info=transports.base.DEFAULT_CLIENT_INFO,
290293
always_use_jwt_access=True,
294+
api_audience=None,
295+
)
296+
# Check the case api_endpoint is provided
297+
options = client_options.ClientOptions(
298+
api_audience="https://language.googleapis.com"
299+
)
300+
with mock.patch.object(transport_class, "__init__") as patched:
301+
patched.return_value = None
302+
client = client_class(client_options=options, transport=transport_name)
303+
patched.assert_called_once_with(
304+
credentials=None,
305+
credentials_file=None,
306+
host=client.DEFAULT_ENDPOINT,
307+
scopes=None,
308+
client_cert_source_for_mtls=None,
309+
quota_project_id=None,
310+
client_info=transports.base.DEFAULT_CLIENT_INFO,
311+
always_use_jwt_access=True,
312+
api_audience="https://language.googleapis.com",
291313
)
292314

293315

@@ -355,6 +377,7 @@ def test_access_approval_client_mtls_env_auto(
355377
quota_project_id=None,
356378
client_info=transports.base.DEFAULT_CLIENT_INFO,
357379
always_use_jwt_access=True,
380+
api_audience=None,
358381
)
359382

360383
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -389,6 +412,7 @@ def test_access_approval_client_mtls_env_auto(
389412
quota_project_id=None,
390413
client_info=transports.base.DEFAULT_CLIENT_INFO,
391414
always_use_jwt_access=True,
415+
api_audience=None,
392416
)
393417

394418
# Check the case client_cert_source and ADC client cert are not provided.
@@ -411,6 +435,7 @@ def test_access_approval_client_mtls_env_auto(
411435
quota_project_id=None,
412436
client_info=transports.base.DEFAULT_CLIENT_INFO,
413437
always_use_jwt_access=True,
438+
api_audience=None,
414439
)
415440

416441

@@ -525,6 +550,7 @@ def test_access_approval_client_client_options_scopes(
525550
quota_project_id=None,
526551
client_info=transports.base.DEFAULT_CLIENT_INFO,
527552
always_use_jwt_access=True,
553+
api_audience=None,
528554
)
529555

530556

@@ -563,6 +589,7 @@ def test_access_approval_client_client_options_credentials_file(
563589
quota_project_id=None,
564590
client_info=transports.base.DEFAULT_CLIENT_INFO,
565591
always_use_jwt_access=True,
592+
api_audience=None,
566593
)
567594

568595

@@ -583,6 +610,7 @@ def test_access_approval_client_client_options_from_dict():
583610
quota_project_id=None,
584611
client_info=transports.base.DEFAULT_CLIENT_INFO,
585612
always_use_jwt_access=True,
613+
api_audience=None,
586614
)
587615

588616

@@ -621,6 +649,7 @@ def test_access_approval_client_create_channel_credentials_file(
621649
quota_project_id=None,
622650
client_info=transports.base.DEFAULT_CLIENT_INFO,
623651
always_use_jwt_access=True,
652+
api_audience=None,
624653
)
625654

626655
# test that the credentials from file are saved and used as the credentials.
@@ -3110,6 +313 93D9 9,28 @@ def test_access_approval_transport_auth_adc(transport_class):
31103139
)
31113140

31123141

3142+
@pytest.mark.parametrize(
3143+
"transport_class",
3144+
[
3145+
transports.AccessApprovalGrpcTransport,
3146+
transports.AccessApprovalGrpcAsyncIOTransport,
3147+
],
3148+
)
3149+
def test_access_approval_transport_auth_gdch_credentials(transport_class):
3150+
host = "https://language.com"
3151+
api_audience_tests = [None, "https://language2.com"]
3152+
api_audience_expect = [host, "https://language2.com"]
3153+
for t, e in zip(api_audience_tests, api_audience_expect):
3154+
with mock.patch.object(google.auth, "default", autospec=True) as adc:
3155+
gdch_mock = mock.MagicMock()
3156+
type(gdch_mock).with_gdch_audience = mock.PropertyMock(
3157+
return_value=gdch_mock
3158+
)
3159+
adc.return_value = (gdch_mock, None)
3160+
transport_class(host=host, api_audience=t)
3161+
gdch_mock.with_gdch_audience.assert_called_once_with(e)
3162+
3163+
31133164
@pytest.mark.parametrize(
31143165
"transport_class,grpc_helpers",
31153166
[
@@ -3615,4 +3666,5 @@ def test_api_key_credentials(client_class, transport_class):
36153666
quota_project_id=None,
36163667
client_info=transports.base.DEFAULT_CLIENT_INFO,
36173668
always_use_jwt_access=True,
3669+
api_audience=None,
36183670
)

0 commit comments

Comments
 (0)
0