File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 5555_DEFAULT_HOST = "https://bigquery.googleapis.com"
5656"""Default host for JSON API."""
5757
58+ _DEFAULT_UNIVERSE = "googleapis.com"
59+ """Default universe for the JSON API."""
60+
5861
5962def _get_bigquery_host ():
6063 return os .environ .get (BIGQUERY_EMULATOR_HOST , _DEFAULT_HOST )
Original file line number Diff line number Diff line change 7878from google .cloud .bigquery ._helpers import _verify_job_config_type
7979from google .cloud .bigquery ._helpers import _get_bigquery_host
8080from google .cloud .bigquery ._helpers import _DEFAULT_HOST
81+ from google .cloud .bigquery ._helpers import _DEFAULT_UNIVERSE
8182from google .cloud .bigquery ._job_helpers import make_job_id as _make_job_id
8283from google .cloud .bigquery .dataset import Dataset
8384from google .cloud .bigquery .dataset import DatasetListItem
@@ -252,6 +253,14 @@ def __init__(
252253 if client_options .api_endpoint :
253254 api_endpoint = client_options .api_endpoint
254255 kw_args ["api_endpoint" ] = api_endpoint
256+ elif (
257+ hasattr (client_options , "universe_domain" )
258+ and client_options .universe_domain
259+ and client_options .universe_domain is not _DEFAULT_UNIVERSE
260+ ):
261+ kw_args ["api_endpoint" ] = _DEFAULT_HOST .replace (
262+ _DEFAULT_UNIVERSE , client_options .universe_domain
263+ )
255264
256265 self ._connection = Connection (self , ** kw_args )
257266 self ._location = location
Original file line number Diff line number Diff line change @@ -201,6 +201,23 @@ def test_ctor_w_client_options_object(self):
201201 client ._connection .API_BASE_URL , "https://www.foo-googleapis.com"
202202 )
203203
204+ @pytest .mark .skipif (
205+ packaging .version .parse (getattr (google .api_core , "__version__" , "0.0.0" ))
206+ < packaging .version .Version ("2.15.0" ),
207+ reason = "universe_domain not supported with google-api-core < 2.15.0" ,
208+ )
209+ def test_ctor_w_client_options_universe (self ):
210+ creds = _make_credentials ()
211+ http = object ()
212+ client_options = {"universe_domain" : "foo.com" }
213+ client = self ._make_one (
214+ project = self .PROJECT ,
215+ credentials = creds ,
216+ _http = http ,
217+ client_options = client_options ,
218+ )
219+ self .assertEqual (client ._connection .API_BASE_URL , "https://bigquery.foo.com" )
220+
204221 def test_ctor_w_location (self ):
205222 from google .cloud .bigquery ._http import Connection
206223
You can’t perform that action at this time.
0 commit comments