Skip to content

Commit b5639bd

Browse files
committed
fix(generator): update goldens with new routing templates and fix noxfile local api-core installation
1 parent e95b23a commit b5639bd

21 files changed

Lines changed: 125 additions & 94 deletions

File tree

packages/gapic-generator/gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,12 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
309309
client_cert_source = mtls.default_client_cert_source()
310310

311311
# Figure out which api endpoint to use.
312-
if client_options.api_endpoint is not None:
313-
api_endpoint = client_options.api_endpoint
312+
api_endpoint_opt = client_options.api_endpoint
313+
if api_endpoint_opt is not None:
314+
api_endpoint = api_endpoint_opt
314315
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
316+
if cls.DEFAULT_MTLS_ENDPOINT is None:
317+
raise MutualTLSChannelError("mTLS endpoint is not available.")
315318
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
316319
else:
317320
api_endpoint = cls.DEFAULT_ENDPOINT

packages/gapic-generator/tests/integration/goldens/asset/google/cloud/asset_v1/_compat.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ def get_api_endpoint(
7474
return default_endpoint_template.format(UNIVERSE_DOMAIN=universe_domain)
7575

7676
def get_universe_domain(
77-
client_universe_domain: Optional[str],
78-
universe_domain_env: Optional[str],
77+
*potential_universes: Optional[str],
7978
default_universe: str,
8079
) -> str:
8180
"""Return the universe domain used by the client."""
8281
universe_domain = default_universe
83-
if client_universe_domain is not None:
84-
universe_domain = client_universe_domain
85-
elif universe_domain_env is not None:
86-
universe_domain = universe_domain_env
82+
for potential_universe in potential_universes:
83+
if potential_universe is not None:
84+
universe_domain = potential_universe
85+
break
8786
if len(universe_domain.strip()) == 0:
88-
raise ValueError("Universe Domain cannot be an empty string.")
87+
raise ValueError("Universe Domain cannot be an empty string.")
8988
return universe_domain

packages/gapic-generator/tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,12 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
367367
client_cert_source = mtls.default_client_cert_source()
368368

369369
# Figure out which api endpoint to use.
370-
if client_options.api_endpoint is not None:
371-
api_endpoint = client_options.api_endpoint
370+
api_endpoint_opt = client_options.api_endpoint
371+
if api_endpoint_opt is not None:
372+
api_endpoint = api_endpoint_opt
372373
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
374+
if cls.DEFAULT_MTLS_ENDPOINT is None:
375+
raise MutualTLSChannelError("mTLS endpoint is not available.")
373376
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
374377
else:
375378
api_endpoint = cls.DEFAULT_ENDPOINT
@@ -437,7 +440,7 @@ def _get_api_endpoint(
437440
str: The API endpoint to be used by the client.
438441
"""
439442
use_mtls = use_mtls_endpoint == "always" or (
440-
use_mtls_endpoint == "auto" and client_cert_source
443+
use_mtls_endpoint == "auto" and bool(client_cert_source)
441444
)
442445
return client_utils.get_api_endpoint(
443446
api_override,

packages/gapic-generator/tests/integration/goldens/credentials/google/iam/credentials_v1/_compat.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ def get_api_endpoint(
7474
return default_endpoint_template.format(UNIVERSE_DOMAIN=universe_domain)
7575

7676
def get_universe_domain(
77-
client_universe_domain: Optional[str],
78-
universe_domain_env: Optional[str],
77+
*potential_universes: Optional[str],
7978
default_universe: str,
8079
) -> str:
8180
"""Return the universe domain used by the client."""
8281
universe_domain = default_universe
83-
if client_universe_domain is not None:
84-
universe_domain = client_universe_domain
85-
elif universe_domain_env is not None:
86-
universe_domain = universe_domain_env
82+
for potential_universe in potential_universes:
83+
if potential_universe is not None:
84+
universe_domain = potential_universe
85+
break
8786
if len(universe_domain.strip()) == 0:
88-
raise ValueError("Universe Domain cannot be an empty string.")
87+
raise ValueError("Universe Domain cannot be an empty string.")
8988
return universe_domain

packages/gapic-generator/tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,12 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
304304
client_cert_source = mtls.default_client_cert_source()
305305

306306
# Figure out which api endpoint to use.
307-
if client_options.api_endpoint is not None:
308-
api_endpoint = client_options.api_endpoint
307+
api_endpoint_opt = client_options.api_endpoint
308+
if api_endpoint_opt is not None:
309+
api_endpoint = api_endpoint_opt
309310
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
311+
if cls.DEFAULT_MTLS_ENDPOINT is None:
312+
raise MutualTLSChannelError("mTLS endpoint is not available.")
310313
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
311314
else:
312315
api_endpoint = cls.DEFAULT_ENDPOINT
@@ -374,7 +377,7 @@ def _get_api_endpoint(
374377
str: The API endpoint to be used by the client.
375378
"""
376379
use_mtls = use_mtls_endpoint == "always" or (
377-
use_mtls_endpoint == "auto" and client_cert_source
380+
use_mtls_endpoint == "auto" and bool(client_cert_source)
378381
)
379382
return client_utils.get_api_endpoint(
380383
api_override,

packages/gapic-generator/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/_compat.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ def get_api_endpoint(
7474
return default_endpoint_template.format(UNIVERSE_DOMAIN=universe_domain)
7575

7676
def get_universe_domain(
77-
client_universe_domain: Optional[str],
78-
universe_domain_env: Optional[str],
77+
*potential_universes: Optional[str],
7978
default_universe: str,
8079
) -> str:
8180
"""Return the universe domain used by the client."""
8281
universe_domain = default_universe
83-
if client_universe_domain is not None:
84-
universe_domain = client_universe_domain
85-
elif universe_domain_env is not None:
86-
universe_domain = universe_domain_env
82+
for potential_universe in potential_universes:
83+
if potential_universe is not None:
84+
universe_domain = potential_universe
85+
break
8786
if len(universe_domain.strip()) == 0:
88-
raise ValueError("Universe Domain cannot be an empty string.")
87+
raise ValueError("Universe Domain cannot be an empty string.")
8988
return universe_domain

packages/gapic-generator/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,12 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
487487
client_cert_source = mtls.default_client_cert_source()
488488

489489
# Figure out which api endpoint to use.
490-
if client_options.api_endpoint is not None:
491-
api_endpoint = client_options.api_endpoint
490+
api_endpoint_opt = client_options.api_endpoint
491+
if api_endpoint_opt is not None:
492+
api_endpoint = api_endpoint_opt
492493
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
494+
if cls.DEFAULT_MTLS_ENDPOINT is None:
495+
raise MutualTLSChannelError("mTLS endpoint is not available.")
493496
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
494497
else:
495498
api_endpoint = cls.DEFAULT_ENDPOINT
@@ -557,7 +560,7 @@ def _get_api_endpoint(
557560
str: The API endpoint to be used by the client.
558561
"""
559562
use_mtls = use_mtls_endpoint == "always" or (
560-
use_mtls_endpoint == "auto" and client_cert_source
563+
use_mtls_endpoint == "auto" and bool(client_cert_source)
561564
)
562565
return client_utils.get_api_endpoint(
563566
api_override,

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/_compat.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ def get_api_endpoint(
7474
return default_endpoint_template.format(UNIVERSE_DOMAIN=universe_domain)
7575

7676
def get_universe_domain(
77-
client_universe_domain: Optional[str],
78-
universe_domain_env: Optional[str],
77+
*potential_universes: Optional[str],
7978
default_universe: str,
8079
) -> str:
8180
"""Return the universe domain used by the client."""
8281
universe_domain = default_universe
83-
if client_universe_domain is not None:
84-
universe_domain = client_universe_domain
85-
elif universe_domain_env is not None:
86-
universe_domain = universe_domain_env
82+
for potential_universe in potential_universes:
83+
if potential_universe is not None:
84+
universe_domain = potential_universe
85+
break
8786
if len(universe_domain.strip()) == 0:
88-
raise ValueError("Universe Domain cannot be an empty string.")
87+
raise ValueError("Universe Domain cannot be an empty string.")
8988
return universe_domain

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/services/config_service_v2/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,12 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
363363
client_cert_source = mtls.default_client_cert_source()
364364

365365
# Figure out which api endpoint to use.
366-
if client_options.api_endpoint is not None:
367-
api_endpoint = client_options.api_endpoint
366+
api_endpoint_opt = client_options.api_endpoint
367+
if api_endpoint_opt is not None:
368+
api_endpoint = api_endpoint_opt
368369
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
370+
if cls.DEFAULT_MTLS_ENDPOINT is None:
371+
raise MutualTLSChannelError("mTLS endpoint is not available.")
369372
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
370373
else:
371374
api_endpoint = cls.DEFAULT_ENDPOINT
@@ -433,7 +436,7 @@ def _get_api_endpoint(
433436
str: The API endpoint to be used by the client.
434437
"""
435438
use_mtls = use_mtls_endpoint == "always" or (
436-
use_mtls_endpoint == "auto" and client_cert_source
439+
use_mtls_endpoint == "auto" and bool(client_cert_source)
437440
)
438441
return client_utils.get_api_endpoint(
439442
api_override,

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/services/logging_service_v2/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,12 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
294294
client_cert_source = mtls.default_client_cert_source()
295295

296296
# Figure out which api endpoint to use.
297-
if client_options.api_endpoint is not None:
298-
api_endpoint = client_options.api_endpoint
297+
api_endpoint_opt = client_options.api_endpoint
298+
if api_endpoint_opt is not None:
299+
api_endpoint = api_endpoint_opt
299300
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
301+
if cls.DEFAULT_MTLS_ENDPOINT is None:
302+
raise MutualTLSChannelError("mTLS endpoint is not available.")
300303
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
301304
else:
302305
api_endpoint = cls.DEFAULT_ENDPOINT
@@ -364,7 +367,7 @@ def _get_api_endpoint(
364367
str: The API endpoint to be used by the client.
365368
"""
366369
use_mtls = use_mtls_endpoint == "always" or (
367-
use_mtls_endpoint == "auto" and client_cert_source
370+
use_mtls_endpoint == "auto" and bool(client_cert_source)
368371
)
369372
return client_utils.get_api_endpoint(
370373
api_override,

0 commit comments

Comments
 (0)