Skip to content

Commit a0392ee

Browse files
feat: Allow users to explicitly configure universe domain (googleapis#12237)
BEGIN_COMMIT_OVERRIDE feat: Allow users to explicitly configure universe domain END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. chore: Update gapic-generator-python to v1.14.0 PiperOrigin-RevId: 603108274 Source-Link: googleapis/googleapis@3d83e36 Source-Link: https://github.com/googleapis/googleapis-gen/commit/baf5e9bbb14a768b2b4c9eae9feb78f18f1757fa Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFpLWdlbmVyYXRpdmVsYW5ndWFnZS8uT3dsQm90LnlhbWwiLCJoIjoiYmFmNWU5YmJiMTRhNzY4YjJiNGM5ZWFlOWZlYjc4ZjE4ZjE3NTdmYSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFuYWx5dGljcy1hZG1pbi8uT3dsQm90LnlhbWwiLCJoIjoiYmFmNWU5YmJiMTRhNzY4YjJiNGM5ZWFlOWZlYjc4ZjE4ZjE3NTdmYSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFuYWx5dGljcy1kYXRhLy5Pd2xCb3QueWFtbCIsImgiOiJiYWY1ZTliYmIxNGE3NjhiMmI0YzllYWU5ZmViNzhmMThmMTc1N2ZhIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtbWVldC8uT3dsQm90LnlhbWwiLCJoIjoiYmFmNWU5YmJiMTRhNzY4YjJiNGM5ZWFlOWZlYjc4ZjE4ZjE3NTdmYSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFyZWExMjAtdGFibGVzLy5Pd2xCb3QueWFtbCIsImgiOiJiYWY1ZTliYmIxNGE3NjhiMmI0YzllYWU5ZmViNzhmMThmMTc1N2ZhIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFjY2Vzcy1hcHByb3ZhbC8uT3dsQm90LnlhbWwiLCJoIjoiY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jE0YTc2OGIyYjRjOWVhZTlmZWI3OGYxOGYxNzU3ZmEifQ== --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 4368029 commit a0392ee

517 files changed

Lines changed: 64643 additions & 20399 deletions

File tree

Some content is hidden

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

packages/google-ai-generativelanguage/google/ai/generativelanguage/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.5.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.5.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/async_client.py

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
from google.ai.generativelanguage_v1 import gapic_version as package_version
4141

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

4747
from google.longrunning import operations_pb2 # type: ignore
4848

@@ -62,8 +62,12 @@ class GenerativeServiceAsyncClient:
6262

6363
_client: GenerativeServiceClient
6464

65+
# Copy defaults from the synchronous client for use here.
66+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
6567
DEFAULT_ENDPOINT = GenerativeServiceClient.DEFAULT_ENDPOINT
6668
DEFAULT_MTLS_ENDPOINT = GenerativeServiceClient.DEFAULT_MTLS_ENDPOINT
69+
_DEFAULT_ENDPOINT_TEMPLATE = GenerativeServiceClient._DEFAULT_ENDPOINT_TEMPLATE
70+
_DEFAULT_UNIVERSE = GenerativeServiceClient._DEFAULT_UNIVERSE
6771

6872
model_path = staticmethod(GenerativeServiceClient.model_path)
6973
parse_model_path = staticmethod(GenerativeServiceClient.parse_model_path)
@@ -170,6 +174,25 @@ def transport(self) -> GenerativeServiceTransport:
170174
"""
171175
return self._client.transport
172176

177+
@property
178+
def api_endpoint(self):
179+
"""Return the API endpoint used by the client instance.
180+
181+
Returns:
182+
str: The API endpoint used by the client instance.
183+
"""
184+
return self._client._api_endpoint
185+
186+
@property
187+
def universe_domain(self) -> str:
188+
"""Return the universe domain used by the client instance.
189+
190+
Returns:
191+
str: The universe domain used
192+
by the client instance.
193+
"""
194+
return self._client._universe_domain
195+
173196
get_transport_class = functools.partial(
174197
type(GenerativeServiceClient).get_transport_class, type(GenerativeServiceClient)
175198
)
@@ -182,7 +205,7 @@ def __init__(
182205
client_options: Optional[ClientOptions] = None,
183206
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
184207
) -> None:
185-
"""Instantiates the generative service client.
208+
"""Instantiates the generative service async client.
186209
187210
Args:
188211
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -193,23 +216,38 @@ def __init__(
193216
transport (Union[str, ~.GenerativeServiceTransport]): The
194217
transport to use. If set to None, a transport is chosen
195218
automatically.
196-
client_options (ClientOptions): Custom options for the client. It
197-
won't take effect if a ``transport`` instance is provided.
198-
(1) The ``api_endpoint`` property can be used to override the
199-
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
200-
environment variable can also be used to override the endpoint:
219+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
220+
Custom options for the client.
221+
222+
1. The ``api_endpoint`` property can be used to override the
223+
default endpoint provided by the client when ``transport`` is
224+
not explicitly provided. Only if this property is not set and
225+
``transport`` was not explicitly provided, the endpoint is
226+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
227+
variable, which have one of the following values:
201228
"always" (always use the default mTLS endpoint), "never" (always
202-
use the default regular endpoint) and "auto" (auto switch to the
203-
default mTLS endpoint if client certificate is present, this is
204-
the default value). However, the ``api_endpoint`` property takes
205-
precedence if provided.
206-
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
229+
use the default regular endpoint) and "auto" (auto-switch to the
230+
default mTLS endpoint if client certificate is present; this is
231+
the default value).
232+
233+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
207234
is "true", then the ``client_cert_source`` property can be used
208-
to provide client certificate for mutual TLS transport. If
235+
to provide a client certificate for mTLS transport. If
209236
not provided, the default SSL client certificate will be used if
210237
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
211238
set, no client certificate will be used.
212239
240+
3. The ``universe_domain`` property can be used to override the
241+
default "googleapis.com" universe. Note that ``api_endpoint``
242+
property still takes precedence; and ``universe_domain`` is
243+
currently not supported for mTLS.
244+
245+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
246+
The client info used to send a user-agent string along with
247+
API requests. If ``None``, then default info will be used.
248+
Generally, you only need to set this if you're developing
249+
your own client library.
250+
213251
Raises:
214252
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
215253
creation failed for any reason.
@@ -350,6 +388,9 @@ async def sample_generate_content():
350388
gapic_v1.routing_header.to_grpc_metadata((("model", request.model),)),
351389
)
352390

391+
# Validate the universe domain.
392+
self._client._validate_universe_domain()
393+
353394
# Send the request.
354395
response = await rpc(
355396
request,
@@ -491,6 +532,9 @@ async def sample_stream_generate_content():
491532
gapic_v1.routing_header.to_grpc_metadata((("model", request.model),)),
492533
)
493534

535+
# Validate the universe domain.
536+
self._client._validate_universe_domain()
537+
494538
# Send the request.
495539
response = rpc(
496540
request,
@@ -616,6 +660,9 @@ async def sample_embed_content():
616660
gapic_v1.routing_header.to_grpc_metadata((("model", request.model),)),
617661
)
618662

663+
# Validate the universe domain.
664+
self._client._validate_universe_domain()
665+
619666
# Send the request.
620667
response = await rpc(
621668
request,
@@ -750,6 +797,9 @@ async def sample_batch_embed_contents():
750797
gapic_v1.routing_header.to_grpc_metadata((("model", request.model),)),
751798
)
752799

800+
# Validate the universe domain.
801+
self._client._validate_universe_domain()
802+
753803
# Send the request.
754804
response = await rpc(
755805
request,
@@ -881,6 +931,9 @@ async def sample_count_tokens():
881931
gapic_v1.routing_header.to_grpc_metadata((("model", request.model),)),
882932
)
883933

934+
# Validate the universe domain.
935+
self._client._validate_universe_domain()
936+
884937
# Send the request.
885938
response = await rpc(
886939
request,
@@ -935,6 +988,9 @@ async def list_operations(
935988
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
936989
)
937990

991+
# Validate the universe domain.
992+
self._client._validate_universe_domain()
993+
938994
# Send the request.
939995
response = await rpc(
940996
request,
@@ -989,6 +1045,9 @@ async def get_operation(
9891045
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
9901046
)
9911047

1048+
# Validate the universe domain.
1049+
self._client._validate_universe_domain()
1050+
9921051
# Send the request.
9931052
response = await rpc(
9941053
request,
@@ -1046,6 +1105,9 @@ async def cancel_operation(
10461105
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
10471106
)
10481107

1108+
# Validate the universe domain.
1109+
self._client._validate_universe_domain()
1110+
10491111
# Send the request.
10501112
await rpc(
10511113
request,

0 commit comments

Comments
 (0)