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

Commit 4dca3f3

Browse files
feat: add audience parameter (#209)
- [ ] 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 PiperOrigin-RevId: 456827138 Source-Link: googleapis/googleapis@23f1a15 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4075a8514f676691ec156688a5bbf183aa9893ce Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9 fix(deps): require google-api-core >= 2.8.0
1 parent 5722c0a commit 4dca3f3

File tree

13 files changed

+138
-25
lines changed

13 files changed

+138
-25
lines changed

google/cloud/webrisk_v1/services/web_risk_service/client.py

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

411412
def compute_threat_list_diff(

google/cloud/webrisk_v1/services/web_risk_service/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
quota_project_id: Optional[str] = None,
5555
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5656
always_use_jwt_access: Optional[bool] = False,
57+
api_audience: Optional[str] = None,
5758
**kwargs,
5859
) -> None:
5960
"""Instantiate the transport.
@@ -81,11 +82,6 @@ def __init__(
8182
be used for service account credentials.
8283
"""
8384

84-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
85-
if ":" not in host:
86-
host += ":443"
87-
self._host = host
88-
8985
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9086

9187
# Save the scopes.
@@ -106,6 +102,11 @@ def __init__(
106102
credentials, _ = google.auth.default(
107103
**scopes_kwargs, quota_project_id=quota_project_id
108104
)
105+
# Don't apply audience if the credentials file passed from user.
106+
if hasattr(credentials, "with_gdch_audience"):
107+
credentials = credentials.with_gdch_audience(
108+
api_audience if api_audience else host
109+
)
109110

110111
# If the credentials are service account credentials, then always try to use self signed JWT.
111112
if (
@@ -118,6 +119,11 @@ def __init__(
118119
# Save the credentials.
119120
self._credentials = credentials
120121

122+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
123+
if ":" not in host:
124+
host += ":443"
125+
self._host = host
126+
121127
def _prep_wrapped_messages(self, client_info):
122128
# Precompute the wrapped methods.
123129
self._wrapped_methods = {

google/cloud/webrisk_v1/services/web_risk_service/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
quota_project_id: Optional[str] = None,
5959
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6060
always_use_jwt_access: Optional[bool] = False,
61+
api_audience: Optional[str] = None,
6162
) -> None:
6263
"""Instantiate the transport.
6364
@@ -153,6 +154,7 @@ def __init__(
153154
quota_project_id=quota_project_id,
154155
client_info=client_info,
155156
always_use_jwt_access=always_use_jwt_access,
157+
api_audience=api_audience,
156158
)
157159

158160
if not self._grpc_channel:

google/cloud/webrisk_v1/services/web_risk_service/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def __init__(
103103
quota_project_id=None,
104104
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
105105
always_use_jwt_access: Optional[bool] = False,
106+
api_audience: Optional[str] = None,
106107
) -> None:
107108
"""Instantiate the transport.
108109
@@ -198,6 +199,7 @@ def __init__(
198199
quota_project_id=quota_project_id,
199200
client_info=client_info,
200201
always_use_jwt_access=always_use_jwt_access,
202+
api_audience=api_audience,
201203
)
202204

203205
if not self._grpc_channel:

google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/client.py

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

411412
def compute_threat_list_diff(

google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
quota_project_id: Optional[str] = None,
5555
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5656
always_use_jwt_access: Optional[bool] = False,
57+
api_audience: Optional[str] = None,
5758
**kwargs,
5859
) -> None:
5960
"""Instantiate the transport.
@@ -81,11 +82,6 @@ def __init__(
8182
be used for service account credentials.
8283
"""
8384

84-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
85-
if ":" not in host:
86-
host += ":443"
87-
self._host = host
88-
8985
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9086

9187
# Save the scopes.
@@ -106,6 +102,11 @@ def __init__(
106102
credentials, _ = google.auth.default(
107103
**scopes_kwargs, quota_project_id=quota_project_id
108104
)
105+
# Don't apply audience if the credentials file passed from user.
106+
if hasattr(credentials, "with_gdch_audience"):
107+
credentials = credentials.with_gdch_audience(
108+
api_audience if api_audience else host
109+
)
109110

110111
# If the credentials are service account credentials, then always try to use self signed JWT.
111112
if (
@@ -118,6 +119,11 @@ def __init__(
118119
# Save the credentials.
119120
self._credentials = credentials
120121

122+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
123+
if ":" not in host:
124+
host += ":443"
125+
self._host = host
126+
121127
def _prep_wrapped_messages(self, client_info):
122128
# Precompute the wrapped methods.
123129
self._wrapped_methods = {

google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
quota_project_id: Optional[str] = None,
5959
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6060
always_use_jwt_access: Optional[bool] = False,
61+
api_audience: Optional[str] = None,
6162
) -> None:
6263
"""Instantiate the transport.
6364
@@ -153,6 +154,7 @@ def __init__(
153154
quota_project_id=quota_project_id,
154155
client_info=client_info,
155156
always_use_jwt_access=always_use_jwt_access,
157+
api_audience=api_audience,
156158
)
157159

158160
if not self._grpc_channel:

google/cloud/webrisk_v1beta1/services/web_risk_service_v1_beta1/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def __init__(
103103
quota_project_id=None,
104104
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
105105
always_use_jwt_access: Optional[bool] = False,
106+
api_audience: Optional[str] = None,
106107
) -> None:
107108
"""Instantiate the transport.
108109
@@ -198,6 +199,7 @@ def __init__(
198199
quota_project_id=quota_project_id,
199200
client_info=client_info,
200201
always_use_jwt_access=always_use_jwt_access,
202+
api_audience=api_audience,
201203
)
202204

203205
if not self._grpc_channel:

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
# 'Development Status :: 5 - Production/Stable'
2929
release_status = "Development Status :: 5 - Production/Stable"
3030
dependencies = [
31-
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
32-
# Until this issue is closed
33-
# https://github.com/googleapis/google-cloud-python/issues/10566
34-
"google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
31+
"google-api-core[grpc] >= 2.8.0, <3.0.0dev",
3532
"proto-plus >= 1.15.0, <2.0.0dev",
3633
"protobuf >= 3.19.0, <4.0.0dev",
3734
]

testing/constraints-3.6.txt

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

0 commit comments

Comments
 (0)