Skip to content

Commit eff564b

Browse files
feat: Allow users to explicitly configure universe domain (#263)
* fix: Resolve AttributeError 'Credentials' object has no attribute 'universe_domain' fix: Add google-auth as a direct dependency fix: Add staticmethod decorator to methods added in v1.14.0 chore: Update gapic-generator-python to v1.14.1 PiperOrigin-RevId: 603728206 Source-Link: googleapis/googleapis@9063da8 Source-Link: googleapis/googleapis-gen@891c67d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODkxYzY3ZDBhODU1YjA4MDg1ZWIzMDFkYWJiMTQwNjRlZjRiMmM2ZCJ9 build: Update protobuf to 25.2 in WORKSPACE build: Update grpc to 1.60.0 in WORKSPACE build: Remove pin for boringssl in WORKSPACE build: Update bazel to 6.3.0 in .bazeliskrc PiperOrigin-RevId: 603226138 Source-Link: googleapis/googleapis@2aec9e1 Source-Link: googleapis/googleapis-gen@e9a5c2e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTlhNWMyZWYzN2I0ZDY5YzkzZTM5MTQxZDg3YWFlMGIxOTNjMDBiMSJ9 feat: Allow users to explicitly configure universe domain chore: Update gapic-generator-python to v1.14.0 PiperOrigin-RevId: 603108274 Source-Link: googleapis/googleapis@3d83e36 Source-Link: googleapis/googleapis-gen@baf5e9b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmFmNWU5YmJiMTRhNzY4YjJiNGM5ZWFlOWZlYjc4ZjE4ZjE3NTdmYSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix(diregapic): s/bazel/bazelisk/ in DIREGAPIC build GitHub action PiperOrigin-RevId: 604714585 Source-Link: googleapis/googleapis@e4dce13 Source-Link: googleapis/googleapis-gen@4036f78 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDAzNmY3ODMwNWM1YzJhYWI4MGZmOTE5NjBiM2EzZDk4M2ZmNGIwMyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix(deps): Require `google-api-core>=1.34.1` fix: Resolve issue with missing import for certain enums in `**/types/…` PiperOrigin-RevId: 607041732 Source-Link: googleapis/googleapis@b453267 Source-Link: googleapis/googleapis-gen@cd79641 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2Q3OTY0MTZmMGY1NGNiMjJiMmM0NGZiMmQ0ODY5NjBlNjkzYTM0NiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix(deps): Exclude google-auth 2.24.0 and 2.25.0 chore: Update gapic-generator-python to v1.14.4 PiperOrigin-RevId: 611561820 Source-Link: googleapis/googleapis@87ef1fe Source-Link: googleapis/googleapis-gen@1973161 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTk3MzE2MTM3NTk0YWFmYWQ5NGRlYTMxMjI2NTI4ZmJjYzM5MzEwYyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add include_recaptcha_script for as a new action in firewall policies PiperOrigin-RevId: 612851792 Source-Link: googleapis/googleapis@49ea2c0 Source-Link: googleapis/googleapis-gen@460fdcb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDYwZmRjYmJiZTAwZjM1YjFjNTkxYjFmM2VmMGM3N2ViZDNjZTI3NyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * filter warning from generated code --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent d66ae66 commit eff564b

File tree

48 files changed

+887
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+887
-217
lines changed

packages/google-cloud-org-policy/google/cloud/orgpolicy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright 2023 Google LLC
2+
# Copyright 2024 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

packages/google-cloud-org-policy/google/cloud/orgpolicy_v2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright 2023 Google LLC
2+
# Copyright 2024 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

packages/google-cloud-org-policy/google/cloud/orgpolicy_v2/services/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright 2023 Google LLC
2+
# Copyright 2024 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

packages/google-cloud-org-policy/google/cloud/orgpolicy_v2/services/org_policy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright 2023 Google LLC
2+
# Copyright 2024 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

packages/google-cloud-org-policy/google/cloud/orgpolicy_v2/services/org_policy/async_client.py

Lines changed: 89 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright 2023 Google LLC
2+
# Copyright 2024 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -38,9 +38,9 @@
3838
from google.oauth2 import service_account # type: ignore
3939

4040
try:
41-
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
41+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
4242
except AttributeError: # pragma: NO COVER
43-
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore
43+
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
4444

4545
from google.cloud.orgpolicy_v2.services.org_policy import pagers
4646
from google.cloud.orgpolicy_v2.types import constraint
@@ -78,8 +78,12 @@ class OrgPolicyAsyncClient:
7878

7979
_client: OrgPolicyClient
8080

81+
# Copy defaults from the synchronous client for use here.
82+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
8183
DEFAULT_ENDPOINT = OrgPolicyClient.DEFAULT_ENDPOINT
8284
DEFAULT_MTLS_ENDPOINT = OrgPolicyClient.DEFAULT_MTLS_ENDPOINT
85+
_DEFAULT_ENDPOINT_TEMPLATE = OrgPolicyClient._DEFAULT_ENDPOINT_TEMPLATE
86+
_DEFAULT_UNIVERSE = OrgPolicyClient._DEFAULT_UNIVERSE
8387

8488
constraint_path = staticmethod(OrgPolicyClient.constraint_path)
8589
parse_constraint_path = staticmethod(OrgPolicyClient.parse_constraint_path)
@@ -186,6 +190,25 @@ def transport(self) -> OrgPolicyTransport:
186190
"""
187191
return self._client.transport
188192

193+
@property
194+
def api_endpoint(self):
195+
"""Return the API endpoint used by the client instance.
196+
197+
Returns:
198+
str: The API endpoint used by the client instance.
199+
"""
200+
return self._client._api_endpoint
201+
202+
@property
203+
def universe_domain(self) -> str:
204+
"""Return the universe domain used by the client instance.
205+
206+
Returns:
207+
str: The universe domain used
208+
by the client instance.
209+
"""
210+
return self._client._universe_domain
211+
189212
get_transport_class = functools.partial(
190213
type(OrgPolicyClient).get_transport_class, type(OrgPolicyClient)
191214
)
@@ -198,7 +221,7 @@ def __init__(
198221
client_options: Optional[ClientOptions] = None,
199222
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
200223
) -> None:
201-
"""Instantiates the org policy client.
224+
"""Instantiates the org policy async client.
202225
203226
Args:
204227
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -209,23 +232,38 @@ def __init__(
209232
transport (Union[str, ~.OrgPolicyTransport]): The
210233
transport to use. If set to None, a transport is chosen
211234
automatically.
212-
client_options (ClientOptions): Custom options for the client. It
213-
won't take effect if a ``transport`` instance is provided.
214-
(1) The ``api_endpoint`` property can be used to override the
215-
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
216-
environment variable can also be used to override the endpoint:
235+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
236+
Custom options for the client.
237+
238+
1. The ``api_endpoint`` property can be used to override the
239+
default endpoint provided by the client when ``transport`` is
240+
not explicitly provided. Only if this property is not set and
241+
``transport`` was not explicitly provided, the endpoint is
242+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
243+
variable, which have one of the following values:
217244
"always" (always use the default mTLS endpoint), "never" (always
218-
use the default regular endpoint) and "auto" (auto switch to the
219-
default mTLS endpoint if client certificate is present, this is
220-
the default value). However, the ``api_endpoint`` property takes
221-
precedence if provided.
222-
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
245+
use the default regular endpoint) and "auto" (auto-switch to the
246+
default mTLS endpoint if client certificate is present; this is
247+
the default value).
248+
249+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
223250
is "true", then the ``client_cert_source`` property can be used
224-
to provide client certificate for mutual TLS transport. If
251+
to provide a client certificate for mTLS transport. If
225252
not provided, the default SSL client certificate will be used if
226253
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
227254
set, no client certificate will be used.
228255
256+
3. The ``universe_domain`` property can be used to override the
257+
default "googleapis.com" universe. Note that ``api_endpoint``
258+
property still takes precedence; and ``universe_domain`` is
259+
currently not supported for mTLS.
260+
261+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
262+
The client info used to send a user-agent string along with
263+
API requests. If ``None``, then default info will be used.
264+
Generally, you only need to set this if you're developing
265+
your own client library.
266+
229267
Raises:
230268
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
231269
creation failed for any reason.
@@ -350,6 +388,9 @@ async def sample_list_constraints():
350388
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
351389
)
352390

391+
# Validate the universe domain.
392+
self._client._validate_universe_domain()
393+
353394
# Send the request.
354395
response = await rpc(
355396
request,
@@ -486,6 +527,9 @@ async def sample_list_policies():
486527
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
487528
)
488529

530+
# Validate the universe domain.
531+
self._client._validate_universe_domain()
532+
489533
# Send the request.
490534
response = await rpc(
491535
request,
@@ -614,6 +658,9 @@ async def sample_get_policy():
614658
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
615659
)
616660

661+
# Validate the universe domain.
662+
self._client._validate_universe_domain()
663+
617664
# Send the request.
618665
response = await rpc(
619666
request,
@@ -735,6 +782,9 @@ async def sample_get_effective_policy():
735782
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
736783
)
737784

785+
# Validate the universe domain.
786+
self._client._validate_universe_domain()
787+
738788
# Send the request.
739789
response = await rpc(
740790
request,
@@ -869,6 +919,9 @@ async def sample_create_policy():
869919
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
870920
)
871921

922+
# Validate the universe domain.
923+
self._client._validate_universe_domain()
924+
872925
# Send the request.
873926
response = await rpc(
874927
request,
@@ -992,6 +1045,9 @@ async def sample_update_policy():
9921045
),
9931046
)
9941047

1048+
# Validate the universe domain.
1049+
self._client._validate_universe_domain()
1050+
9951051
# Send the request.
9961052
response = await rpc(
9971053
request,
@@ -1101,6 +1157,9 @@ async def sample_delete_policy():
11011157
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
11021158
)
11031159

1160+
# Validate the universe domain.
1161+
self._client._validate_universe_domain()
1162+
11041163
# Send the request.
11051164
await rpc(
11061165
request,
@@ -1233,6 +1292,9 @@ async def sample_create_custom_constraint():
12331292
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
12341293
)
12351294

1295+
# Validate the universe domain.
1296+
self._client._validate_universe_domain()
1297+
12361298
# Send the request.
12371299
response = await rpc(
12381300
request,
@@ -1356,6 +1418,9 @@ async def sample_update_custom_constraint():
13561418
),
13571419
)
13581420

1421+
# Validate the universe domain.
1422+
self._client._validate_universe_domain()
1423+
13591424
# Send the request.
13601425
response = await rpc(
13611426
request,
@@ -1479,6 +1544,9 @@ async def sample_get_custom_constraint():
14791544
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
14801545
)
14811546

1547+
# Validate the universe domain.
1548+
self._client._validate_universe_domain()
1549+
14821550
# Send the request.
14831551
response = await rpc(
14841552
request,
@@ -1602,6 +1670,9 @@ async def sample_list_custom_constraints():
16021670
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
16031671
)
16041672

1673+
# Validate the universe domain.
1674+
self._client._validate_universe_domain()
1675+
16051676
# Send the request.
16061677
response = await rpc(
16071678
request,
@@ -1719,6 +1790,9 @@ async def sample_delete_custom_constraint():
17191790
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
17201791
)
17211792

1793+
# Validate the universe domain.
1794+
self._client._validate_universe_domain()
1795+
17221796
# Send the request.
17231797
await rpc(
17241798
request,

0 commit comments

Comments
 (0)