Skip to content

Commit 5aabd90

Browse files
committed
refactor(generator): update templates and goldens to use client_utils instead of routing
1 parent c5d3a7d commit 5aabd90

13 files changed

Lines changed: 52 additions & 52 deletions

File tree

  • packages/gapic-generator
    • gapic/templates/%namespace/%name_%version/%sub/services/%service
    • tests/integration/goldens
      • asset/google/cloud/asset_v1/services/asset_service
      • credentials/google/iam/credentials_v1/services/iam_credentials
      • eventarc/google/cloud/eventarc_v1/services/eventarc
      • logging_internal/google/cloud/logging_v2/services
      • logging/google/cloud/logging_v2/services
      • redis_selective/google/cloud/redis_v1/services/cloud_redis
      • redis/google/cloud/redis_v1/services/cloud_redis
      • storagebatchoperations/google/cloud/storagebatchoperations_v1/services/storage_batch_operations

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ from google.api_core import exceptions as core_exceptions
3030
from google.api_core import extended_operation
3131
{% endif %}
3232
from google.api_core import gapic_v1
33-
from google.api_core.gapic_v1 import routing
33+
from google.api_core.gapic_v1 import client_utils
3434
from google.api_core import retry as retries
3535
from google.auth import credentials as ga_credentials # type: ignore
3636
from google.auth.transport import mtls # type: ignore
@@ -147,7 +147,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
147147
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
148148
DEFAULT_ENDPOINT = {% if service.host %}"{{ service.host }}"{% else %}None{% endif %}
149149

150-
DEFAULT_MTLS_ENDPOINT = routing.get_default_mtls_endpoint(
150+
DEFAULT_MTLS_ENDPOINT = client_utils.get_default_mtls_endpoint(
151151
DEFAULT_ENDPOINT
152152
)
153153

@@ -378,7 +378,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
378378
Returns:
379379
str: The API endpoint to be used by the client.
380380
"""
381-
return routing.get_api_endpoint(
381+
return client_utils.get_api_endpoint(
382382
api_override,
383383
client_cert_source,
384384
universe_domain,
@@ -402,7 +402,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
402402
Raises:
403403
ValueError: If the universe domain is an empty string.
404404
"""
405-
return routing.get_universe_domain(
405+
return client_utils.get_universe_domain(
406406
client_universe_domain,
407407
universe_domain_env,
408408
{{ service.client_name }}._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -104,7 +104,7 @@ class AssetServiceClient(metaclass=AssetServiceClientMeta):
104104
@staticmethod
105105
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
106106
"""Converts api endpoint to mTLS endpoint."""
107-
return routing.get_default_mtls_endpoint(api_endpoint)
107+
return client_utils.get_default_mtls_endpoint(api_endpoint)
108108

109109
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
110110
DEFAULT_ENDPOINT = "cloudasset.googleapis.com"
@@ -429,7 +429,7 @@ def _get_api_endpoint(
429429
use_mtls_endpoint: str,
430430
) -> str:
431431
"""Return the API endpoint used by the client."""
432-
return routing.get_api_endpoint(
432+
return client_utils.get_api_endpoint(
433433
api_override,
434434
client_cert_source,
435435
universe_domain,
@@ -442,7 +442,7 @@ def _get_api_endpoint(
442442
@staticmethod
443443
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
444444
"""Return the universe domain used by the client."""
445-
return routing.get_universe_domain(
445+
return client_utils.get_universe_domain(
446446
client_universe_domain,
447447
universe_domain_env,
448448
AssetServiceClient._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -107,7 +107,7 @@ class IAMCredentialsClient(metaclass=IAMCredentialsClientMeta):
107107
@staticmethod
108108
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
109109
"""Converts api endpoint to mTLS endpoint."""
110-
return routing.get_default_mtls_endpoint(api_endpoint)
110+
return client_utils.get_default_mtls_endpoint(api_endpoint)
111111

112112
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
113113
DEFAULT_ENDPOINT = "iamcredentials.googleapis.com"
@@ -366,7 +366,7 @@ def _get_api_endpoint(
366366
use_mtls_endpoint: str,
367367
) -> str:
368368
"""Return the API endpoint used by the client."""
369-
return routing.get_api_endpoint(
369+
return client_utils.get_api_endpoint(
370370
api_override,
371371
client_cert_source,
372372
universe_domain,
@@ -379,7 +379,7 @@ def _get_api_endpoint(
379379
@staticmethod
380380
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
381381
"""Return the universe domain used by the client."""
382-
return routing.get_universe_domain(
382+
return client_utils.get_universe_domain(
383383
client_universe_domain,
384384
universe_domain_env,
385385
IAMCredentialsClient._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -125,7 +125,7 @@ class EventarcClient(metaclass=EventarcClientMeta):
125125
@staticmethod
126126
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
127127
"""Converts api endpoint to mTLS endpoint."""
128-
return routing.get_default_mtls_endpoint(api_endpoint)
128+
return client_utils.get_default_mtls_endpoint(api_endpoint)
129129

130130
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
131131
DEFAULT_ENDPOINT = "eventarc.googleapis.com"
@@ -549,7 +549,7 @@ def _get_api_endpoint(
549549
use_mtls_endpoint: str,
550550
) -> str:
551551
"""Return the API endpoint used by the client."""
552-
return routing.get_api_endpoint(
552+
return client_utils.get_api_endpoint(
553553
api_override,
554554
client_cert_source,
555555
universe_domain,
@@ -562,7 +562,7 @@ def _get_api_endpoint(
562562
@staticmethod
563563
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
564564
"""Return the universe domain used by the client."""
565-
return routing.get_universe_domain(
565+
return client_utils.get_universe_domain(
566566
client_universe_domain,
567567
universe_domain_env,
568568
EventarcClient._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -100,7 +100,7 @@ class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta):
100100
@staticmethod
101101
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
102102
"""Converts api endpoint to mTLS endpoint."""
103-
return routing.get_default_mtls_endpoint(api_endpoint)
103+
return client_utils.get_default_mtls_endpoint(api_endpoint)
104104

105105
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
106106
DEFAULT_ENDPOINT = "logging.googleapis.com"
@@ -425,7 +425,7 @@ def _get_api_endpoint(
425425
use_mtls_endpoint: str,
426426
) -> str:
427427
"""Return the API endpoint used by the client."""
428-
return routing.get_api_endpoint(
428+
return client_utils.get_api_endpoint(
429429
api_override,
430430
client_cert_source,
431431
universe_domain,
@@ -438,7 +438,7 @@ def _get_api_endpoint(
438438
@staticmethod
439439
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
440440
"""Return the universe domain used by the client."""
441-
return routing.get_universe_domain(
441+
return client_utils.get_universe_domain(
442442
client_universe_domain,
443443
universe_domain_env,
444444
ConfigServiceV2Client._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -97,7 +97,7 @@ class LoggingServiceV2Client(metaclass=LoggingServiceV2ClientMeta):
9797
@staticmethod
9898
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
9999
"""Converts api endpoint to mTLS endpoint."""
100-
return routing.get_default_mtls_endpoint(api_endpoint)
100+
return client_utils.get_default_mtls_endpoint(api_endpoint)
101101

102102
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
103103
DEFAULT_ENDPOINT = "logging.googleapis.com"
@@ -356,7 +356,7 @@ def _get_api_endpoint(
356356
use_mtls_endpoint: str,
357357
) -> str:
358358
"""Return the API endpoint used by the client."""
359-
return routing.get_api_endpoint(
359+
return client_utils.get_api_endpoint(
360360
api_override,
361361
client_cert_source,
362362
universe_domain,
@@ -369,7 +369,7 @@ def _get_api_endpoint(
369369
@staticmethod
370370
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
371371
"""Return the universe domain used by the client."""
372-
return routing.get_universe_domain(
372+
return client_utils.get_universe_domain(
373373
client_universe_domain,
374374
universe_domain_env,
375375
LoggingServiceV2Client._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -98,7 +98,7 @@ class MetricsServiceV2Client(metaclass=MetricsServiceV2ClientMeta):
9898
@staticmethod
9999
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
100100
"""Converts api endpoint to mTLS endpoint."""
101-
return routing.get_default_mtls_endpoint(api_endpoint)
101+
return client_utils.get_default_mtls_endpoint(api_endpoint)
102102

103103
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
104104
DEFAULT_ENDPOINT = "logging.googleapis.com"
@@ -357,7 +357,7 @@ def _get_api_endpoint(
357357
use_mtls_endpoint: str,
358358
) -> str:
359359
"""Return the API endpoint used by the client."""
360-
return routing.get_api_endpoint(
360+
return client_utils.get_api_endpoint(
361361
api_override,
362362
client_cert_source,
363363
universe_domain,
@@ -370,7 +370,7 @@ def _get_api_endpoint(
370370
@staticmethod
371371
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
372372
"""Return the universe domain used by the client."""
373-
return routing.get_universe_domain(
373+
return client_utils.get_universe_domain(
374374
client_universe_domain,
375375
universe_domain_env,
376376
MetricsServiceV2Client._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -100,7 +100,7 @@ class BaseConfigServiceV2Client(metaclass=BaseConfigServiceV2ClientMeta):
100100
@staticmethod
101101
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
102102
"""Converts api endpoint to mTLS endpoint."""
103-
return routing.get_default_mtls_endpoint(api_endpoint)
103+
return client_utils.get_default_mtls_endpoint(api_endpoint)
104104

105105
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
106106
DEFAULT_ENDPOINT = "logging.googleapis.com"
@@ -425,7 +425,7 @@ def _get_api_endpoint(
425425
use_mtls_endpoint: str,
426426
) -> str:
427427
"""Return the API endpoint used by the client."""
428-
return routing.get_api_endpoint(
428+
return client_utils.get_api_endpoint(
429429
api_override,
430430
client_cert_source,
431431
universe_domain,
@@ -438,7 +438,7 @@ def _get_api_endpoint(
438438
@staticmethod
439439
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
440440
"""Return the universe domain used by the client."""
441-
return routing.get_universe_domain(
441+
return client_utils.get_universe_domain(
442442
client_universe_domain,
443443
universe_domain_env,
444444
BaseConfigServiceV2Client._DEFAULT_UNIVERSE,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -97,7 +97,7 @@ class LoggingServiceV2Client(metaclass=LoggingServiceV2ClientMeta):
9797
@staticmethod
9898
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
9999
"""Converts api endpoint to mTLS endpoint."""
100-
return routing.get_default_mtls_endpoint(api_endpoint)
100+
return client_utils.get_default_mtls_endpoint(api_endpoint)
101101

102102
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
103103
DEFAULT_ENDPOINT = "logging.googleapis.com"
@@ -356,7 +356,7 @@ def _get_api_endpoint(
356356
use_mtls_endpoint: str,
357357
) -> str:
358358
"""Return the API endpoint used by the client."""
359-
return routing.get_api_endpoint(
359+
return client_utils.get_api_endpoint(
360360
api_override,
361361
client_cert_source,
362362
universe_domain,
@@ -369,7 +369,7 @@ def _get_api_endpoint(
369369
@staticmethod
370370
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
371371
"""Return the universe domain used by the client."""
372-
return routing.get_universe_domain(
372+
return client_utils.get_universe_domain(
373373
client_universe_domain,
374374
universe_domain_env,
375375
LoggingServiceV2Client._DEFAULT_UNIVERSE,

packages/gapic-generator/tests/integration/goldens/logging_internal/google/cloud/logging_v2/services/metrics_service_v2/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from google.api_core import client_options as client_options_lib
2828
from google.api_core import exceptions as core_exceptions
2929
from google.api_core import gapic_v1
30-
from google.api_core.gapic_v1 import routing
30+
from google.api_core.gapic_v1 import client_utils
3131
from google.api_core import retry as retries
3232
from google.auth import credentials as ga_credentials # type: ignore
3333
from google.auth.transport import mtls # type: ignore
@@ -98,7 +98,7 @@ class BaseMetricsServiceV2Client(metaclass=BaseMetricsServiceV2ClientMeta):
9898
@staticmethod
9999
def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
100100
"""Converts api endpoint to mTLS endpoint."""
101-
return routing.get_default_mtls_endpoint(api_endpoint)
101+
return client_utils.get_default_mtls_endpoint(api_endpoint)
102102

103103
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
104104
DEFAULT_ENDPOINT = "logging.googleapis.com"
@@ -357,7 +357,7 @@ def _get_api_endpoint(
357357
use_mtls_endpoint: str,
358358
) -> str:
359359
"""Return the API endpoint used by the client."""
360-
return routing.get_api_endpoint(
360+
return client_utils.get_api_endpoint(
361361
api_override,
362362
client_cert_source,
363363
universe_domain,
@@ -370,7 +370,7 @@ def _get_api_endpoint(
370370
@staticmethod
371371
def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str:
372372
"""Return the universe domain used by the client."""
373-
return routing.get_universe_domain(
373+
return client_utils.get_universe_domain(
374374
client_universe_domain,
375375
universe_domain_env,
376376
BaseMetricsServiceV2Client._DEFAULT_UNIVERSE,

0 commit comments

Comments
 (0)