@@ -133,6 +133,7 @@ def __init__(self):
133133 self ._request_metadata = None
134134 self ._resource_type = None
135135 self ._async_rest_credentials = None
136+ self ._universe_domain = None
136137
137138 def init (
138139 self ,
@@ -153,6 +154,7 @@ def init(
153154 api_key : Optional [str ] = None ,
154155 api_transport : Optional [str ] = None ,
155156 request_metadata : Optional [Sequence [Tuple [str , str ]]] = None ,
157+ universe_domain : Optional [str ] = None ,
156158 ):
157159 """Updates common initialization parameters with provided options.
158160
@@ -220,6 +222,8 @@ def init(
220222 beta state (preview).
221223 request_metadata:
222224 Optional. Additional gRPC metadata to send with every client request.
225+ universe_domain (str):
226+ Optional. The universe domain.
223227 Raises:
224228 ValueError:
225229 If experiment_description is provided but experiment is not.
@@ -291,6 +295,8 @@ def init(
291295 self ._request_metadata = request_metadata
292296 if api_key is not None :
293297 self ._api_key = api_key
298+ if universe_domain is not None :
299+ self ._universe_domain = universe_domain
294300 self ._resource_type = None
295301
296302 # Finally, perform secondary state updates
@@ -348,6 +354,11 @@ def api_key(self) -> Optional[str]:
348354 """API Key, if provided."""
349355 return self ._api_key
350356
357+ @property
358+ def universe_domain (self ) -> Optional [str ]:
359+ """Default universe domain, if provided."""
360+ return self ._universe_domain
361+
351362 @property
352363 def project (self ) -> str :
353364 """Default project."""
@@ -382,7 +393,11 @@ def location(self) -> str:
382393
383394 location = os .getenv ("GOOGLE_CLOUD_REGION" ) or os .getenv ("CLOUD_ML_REGION" )
384395 if location :
385- utils .validate_region (location )
396+ utils .validate_region (
397+ location ,
398+ api_endpoint = self .api_endpoint ,
399+ universe_domain = self .universe_domain ,
400+ )
386401 return location
387402
388403 return constants .DEFAULT_REGION
@@ -449,6 +464,7 @@ def get_client_options(
449464 api_base_path_override : Optional [str ] = None ,
450465 api_key : Optional [str ] = None ,
451466 api_path_override : Optional [str ] = None ,
467+ universe_domain : Optional [str ] = None ,
452468 ) -> client_options .ClientOptions :
453469 """Creates GAPIC client_options using location and type.
454470
@@ -461,6 +477,7 @@ def get_client_options(
461477 api_base_path_override (str): Optional. Override default API base path.
462478 api_key (str): Optional. API key to use for the client.
463479 api_path_override (str): Optional. Override default api path.
480+ universe_domain (str): Optional. Override default universe domain.
464481 Returns:
465482 clients_options (google.api_core.client_options.ClientOptions):
466483 A ClientOptions object set with regionalized API endpoint, i.e.
@@ -491,7 +508,11 @@ def get_client_options(
491508 region = location_override or self .location
492509 region = region .lower ()
493510
494- utils .validate_region (region )
511+ utils .validate_region (
512+ region ,
513+ api_endpoint = self .api_endpoint ,
514+ universe_domain = universe_domain or self .universe_domain ,
515+ )
495516
496517 service_base_path = api_base_path_override or (
497518 constants .PREDICTION_API_BASE_PATH
@@ -508,9 +529,14 @@ def get_client_options(
508529 # Project/location take precedence over api_key
509530 if api_key and not self ._project :
510531 return client_options .ClientOptions (
511- api_endpoint = api_endpoint , api_key = api_key
532+ api_endpoint = api_endpoint ,
533+ api_key = api_key ,
534+ universe_domain = universe_domain or self .universe_domain ,
512535 )
513- return client_options .ClientOptions (api_endpoint = api_endpoint )
536+ return client_options .ClientOptions (
537+ api_endpoint = api_endpoint ,
538+ universe_domain = universe_domain or self .universe_domain ,
539+ )
514540
515541 def common_location_path (
516542 self , project : Optional [str ] = None , location : Optional [str ] = None
@@ -524,7 +550,11 @@ def common_location_path(
524550 resource_parent: Formatted parent resource string.
525551 """
526552 if location :
527- utils .validate_region (location )
553+ utils .validate_region (
554+ location ,
555+ api_endpoint = self .api_endpoint ,
556+ universe_domain = self .universe_domain ,
557+ )
528558
529559 return "/" .join (
530560 [
@@ -546,6 +576,7 @@ def create_client(
546576 api_path_override : Optional [str ] = None ,
547577 appended_user_agent : Optional [List [str ]] = None ,
548578 appended_gapic_version : Optional [str ] = None ,
579+ universe_domain : Optional [str ] = None ,
549580 ) -> _TVertexAiServiceClientWithOverride :
550581 """Instantiates a given VertexAiServiceClient with optional
551582 overrides.
@@ -565,6 +596,8 @@ def create_client(
565596 separated by spaces.
566597 appended_gapic_version (str):
567598 Optional. GAPIC version suffix appended in the client info.
599+ universe_domain (str):
600+ Optional. universe domain override.
568601 Returns:
569602 client: Instantiated Vertex AI Service client with optional overrides
570603 """
@@ -607,6 +640,7 @@ def create_client(
607640 api_key = api_key ,
608641 api_base_path_override = api_base_path_override ,
609642 api_path_override = api_path_override ,
643+ universe_domain = universe_domain ,
610644 ),
611645 "client_info" : client_info ,
612646 }
0 commit comments