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

Commit 9d37f0d

Browse files
fix(deps): require google-api-core >= 2.8.0 (#176)
- [ ] 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 1dfe877 commit 9d37f0d

File tree

18 files changed

+206
-30
lines changed

18 files changed

+206
-30
lines changed

‎google/cloud/notebooks_v1/services/managed_notebook_service/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ def __init__(
433433
quota_project_id=client_options.quota_project_id,
434434
client_info=client_info,
435435
always_use_jwt_access=True,
436+
api_audience=client_options.api_audience,
436437
)
437438

438439
def list_runtimes(

‎google/cloud/notebooks_v1/services/managed_notebook_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/notebooks_v1/services/managed_notebook_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
@@ -154,6 +155,7 @@ def __init__(
154155
quota_project_id=quota_project_id,
155156
client_info=client_info,
156157
always_use_jwt_access=always_use_jwt_access,
158+
api_audience=api_audience,
157159
)
158160

159161
if not self._grpc_channel:

‎google/cloud/notebooks_v1/services/managed_notebook_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
@@ -199,6 +200,7 @@ def __init__(
199200
quota_project_id=quota_project_id,
200201
client_info=client_info,
201202
always_use_jwt_access=always_use_jwt_access,
203+
api_audience=api_audience,
202204
)
203205

204206
if not self._grpc_channel:

‎google/cloud/notebooks_v1/services/notebook_service/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ def __init__(
520520
quota_project_id=client_options.quota_project_id,
521521
client_info=client_info,
522522
always_use_jwt_access=True,
523+
api_audience=client_options.api_audience,
523524
)
524525

525526
def list_instances(

‎google/cloud/notebooks_v1/services/notebook_service/transports/base.py

Lines 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 = {

‎google/cloud/notebooks_v1/services/notebook_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
@@ -160,6 +161,7 @@ def __init__(
160161
quota_project_id=quota_project_id,
161162
client_info=client_info,
162163
always_use_jwt_access=always_use_jwt_access,
164+
api_audience=api_audience,
163165
)
164166

165167
if not self._grpc_channel:

‎google/cloud/notebooks_v1/services/notebook_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
@@ -205,6 +206,7 @@ def __init__(
205206
quota_project_id=quota_project_id,
206207
client_info=client_info,
207208
always_use_jwt_access=always_use_jwt_access,
209+
api_audience=api_audience,
208210
)
209211

210212
if not self._grpc_channel:

‎google/cloud/notebooks_v1beta1/services/notebook_service/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ def __init__(
444444
quota_project_id=client_options.quota_project_id,
445445
client_info=client_info,
446446
always_use_jwt_access=True,
447+
api_audience=client_options.api_audience,
447448
)
448449

449450
def list_instances(

‎google/cloud/notebooks_v1beta1/services/notebook_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 = {

0 commit comments

Comments
 (0)