chore(generator): use routing helper from api_core in templates #17746
chore(generator): use routing helper from api_core in templates #17746hebaalazzeh wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the client service templates by delegating endpoint and universe domain logic to the google.api_core.gapic_v1.routing module, which also allowed for the removal of redundant unit tests. The reviewer recommended adding type hints to the _get_default_mtls_endpoint and _get_api_endpoint methods to ensure code clarity following the removal of detailed docstrings.
3e2d8e2 to
0fe63b5
Compare
48f392a to
05fb32e
Compare
85cd706 to
8816dfe
Compare
d435c6c to
016d00e
Compare
00f5e2d to
6ae7468
Compare
| {{ service.client_name }}._DEFAULT_UNIVERSE, | ||
| {{ service.client_name }}.DEFAULT_MTLS_ENDPOINT, | ||
| {{ service.client_name }}._DEFAULT_ENDPOINT_TEMPLATE, | ||
| ) |
There was a problem hiding this comment.
shouldn't this be moved to _compat with the others?
| client_universe_domain, | ||
| universe_domain_env, | ||
| {{ service.client_name }}._DEFAULT_UNIVERSE, | ||
| ) |
There was a problem hiding this comment.
- shouldn't this also be moved to _compat?
- can we import it from api_core.universe, instead of doing this aliased import?
|
|
||
| with pytest.raises(MutualTLSChannelError) as excinfo: | ||
| {{ service.client_name }}._get_api_endpoint(None, mock_client_cert_source, mock_universe, "auto") | ||
| assert str(excinfo.value) == "mTLS is not supported in any universe other than googleapis.com." |
There was a problem hiding this comment.
Were these tests carried over? (I don't see get_api_endpoint in the linked PR: #17745
| return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") | ||
| def _get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]: | ||
| """Converts api endpoint to mTLS endpoint.""" | ||
| return client_utils.get_default_mtls_endpoint(api_endpoint) |
There was a problem hiding this comment.
I thought the function was being removed?
Updates generator templates and goldens to import public
routinghelpers fromgoogle-api-coregapic_v1and delegate API endpoint, mTLS, and universe domain resolution methods to it.Removes duplicate routing unit tests from the generated client unit tests (as they are now fully tested in
google-api-core).Associated / Dependent API Core PR:
chore(api-core): move universe and endpoint routing logic to gapic_v1 public helpers(#17745)