File tree 3 files changed +29
-0
lines changed
3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 55
55
_DEFAULT_HOST = "https://bigquery.googleapis.com"
56
56
"""Default host for JSON API."""
57
57
58
+ _DEFAULT_UNIVERSE = "googleapis.com"
59
+ """Default universe for the JSON API."""
60
+
58
61
59
62
def _get_bigquery_host ():
60
63
return os .environ .get (BIGQUERY_EMULATOR_HOST , _DEFAULT_HOST )
Original file line number Diff line number Diff line change 78
78
from google .cloud .bigquery ._helpers import _verify_job_config_type
79
79
from google .cloud .bigquery ._helpers import _get_bigquery_host
80
80
from google .cloud .bigquery ._helpers import _DEFAULT_HOST
81
+ from google .cloud .bigquery ._helpers import _DEFAULT_UNIVERSE
81
82
from google .cloud .bigquery ._job_helpers import make_job_id as _make_job_id
82
83
from google .cloud .bigquery .dataset import Dataset
83
84
from google .cloud .bigquery .dataset import DatasetListItem
@@ -252,6 +253,14 @@ def __init__(
252
253
if client_options .api_endpoint :
253
254
api_endpoint = client_options .api_endpoint
254
255
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
+ )
255
264
256
265
self ._connection = Connection (self , ** kw_args )
257
266
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):
201
201
client ._connection .API_BASE_URL , "https://www.foo-googleapis.com"
202
202
)
203
203
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
+
204
221
def test_ctor_w_location (self ):
205
222
from google .cloud .bigquery ._http import Connection
206
223
You can’t perform that action at this time.
0 commit comments