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

Commit 51f21e1

Browse files
fix(deps): require google-api-core>=1.32.0,>=2.8.0 (#403)
- [ ] 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 8d762e6 commit 51f21e1

File tree

22 files changed

+274
-25
lines changed

22 files changed

+274
-25
lines changed

google/cloud/automl_v1/services/auto_ml/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ def __init__(
527527
quota_project_id=client_options.quota_project_id,
528528
client_info=client_info,
529529
always_use_jwt_access=True,
530+
api_audience=client_options.api_audience,
530531
)
531532

532533
def create_dataset(

google/cloud/automl_v1/services/auto_ml/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(
6262
quota_project_id: Optional[str] = None,
6363
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6464
always_use_jwt_access: Optional[bool] = False,
65+
api_audience: Optional[str] = None,
6566
**kwargs,
6667
) -> None:
6768
"""Instantiate the transport.
@@ -89,11 +90,6 @@ def __init__(
8990
be used for service account credentials.
9091
"""
9192

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

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

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

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

google/cloud/automl_v1/services/auto_ml/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def __init__(
8080
quota_project_id: Optional[str] = None,
8181
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
8282
always_use_jwt_access: Optional[bool] = False,
83+
api_audience: Optional[str] = None,
8384
) -> None:
8485
"""Instantiate the transport.
8586
@@ -176,6 +177,7 @@ def __init__(
176177
quota_project_id=quota_project_id,
177178
client_info=client_info,
178179
always_use_jwt_access=always_use_jwt_access,
180+
api_audience=api_audience,
179181
)
180182

181183
if not self._grpc_channel:

google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def __init__(
125125
quota_project_id=None,
126126
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
127127
always_use_jwt_access: Optional[bool] = False,
128+
api_audience: Optional[str] = None,
128129
) -> None:
129130
"""Instantiate the transport.
130131
@@ -221,6 +222,7 @@ def __init__(
221222
quota_project_id=quota_project_id,
222223
client_info=client_info,
223224
always_use_jwt_access=always_use_jwt_access,
225+
api_audience=api_audience,
224226
)
225227

226228
if not self._grpc_channel:

google/cloud/automl_v1/services/prediction_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 predict(

google/cloud/automl_v1/services/prediction_service/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(
5656
quota_project_id: Optional[str] = None,
5757
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5858
always_use_jwt_access: Optional[bool] = False,
59+
api_audience: Optional[str] = None,
5960
**kwargs,
6061
) -> None:
6162
"""Instantiate the transport.
@@ -83,11 +84,6 @@ def __init__(
8384
be used for service account credentials.
8485
"""
8586

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

9389
# Save the scopes.
@@ -108,6 +104,11 @@ def __init__(
108104
credentials, _ = google.auth.default(
109105
**scopes_kwargs, quota_project_id=quota_project_id
110106
)
107+
# Don't apply audience if the credentials file passed from user.
108+
if hasattr(credentials, "with_gdch_audience"):
109+
credentials = credentials.with_gdch_audience(
110+
api_audience if api_audience else host
111+
)
111112

112113
# If the credentials are service account credentials, then always try to use self signed JWT.
113114
if (
@@ -120,6 +121,11 @@ def __init__(
120121
# Save the credentials.
121122
self._credentials = credentials
122123

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

google/cloud/automl_v1/services/prediction_service/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:

google/cloud/automl_v1/services/prediction_service/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:

google/cloud/automl_v1beta1/services/auto_ml/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ def __init__(
585585
quota_project_id=client_options.quota_project_id,
586586
client_info=client_info,
587587
always_use_jwt_access=True,
588+
api_audience=client_options.api_audience,
588589
)
589590

590591
def create_dataset(

google/cloud/automl_v1beta1/services/auto_ml/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
quota_project_id: Optional[str] = None,
6666
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6767
always_use_jwt_access: Optional[bool] = False,
68+
api_audience: Optional[str] = None,
6869
**kwargs,
6970
) -> None:
7071
"""Instantiate the transport.
@@ -92,11 +93,6 @@ def __init__(
9293
be used for service account credentials.
9394
"""
9495

95-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
96-
if ":" not in host:
97-
host += ":443"
98-
self._host = host
99-
10096
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
10197

10298
# Save the scopes.
@@ -117,6 +113,11 @@ def __init__(
117113
credentials, _ = google.auth.default(
118114
**scopes_kwargs, quota_project_id=quota_project_id
119115
)
116+
# Don't apply audience if the credentials file passed from user.
117+
if hasattr(credentials, "with_gdch_audience"):
118+
credentials = credentials.with_gdch_audience(
119+
api_audience if api_audience else host
120+
)
120121

121122
# If the credentials are service account credentials, then always try to use self signed JWT.
122123
if (
@@ -129,6 +130,11 @@ def __init__(
129130
# Save the credentials.
130131
self._credentials = credentials
131132

133+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
134+
if ":" not in host:
135+
host += ":443"
136+
self._host = host
137+
132138
def _prep_wrapped_messages(self, client_info):
133139
# Precompute the wrapped methods.
134140
self._wrapped_methods = {

0 commit comments

Comments
 (0)