Skip to content

feat(generator): gapic generator centralization routing - #17816

Open
hebaalazzeh wants to merge 34 commits into
mainfrom
feat/gapic-generator-centralization-routing
Open

feat(generator): gapic generator centralization routing#17816
hebaalazzeh wants to merge 34 commits into
mainfrom
feat/gapic-generator-centralization-routing

Conversation

@hebaalazzeh

@hebaalazzeh hebaalazzeh commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This PR refactors the generated client templates to utilize centralized endpoint routing and universe domain logic.

  • Helper Relocation: Moved _get_default_mtls_endpoint, _get_api_endpoint, and _get_universe_domain from generated client classes to the compatibility layer (_compat.py).
  • Backward Compatibility: Implemented these helpers locally in _compat.py to maintain compatibility with older google-api-core versions, laying groundwork for importing directly from google.api_core.universe (centralized in PR feat(api-core): add get_universe_domain helper to universe.py #17799) once the minimum dependency is bumped.
  • Test Migration: Moved unit tests for these routing functions from test_%service.py.j2 to test_compat.py.j2.

Towards: #17883

@hebaalazzeh hebaalazzeh self-assigned this Jul 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new compatibility template _compat.py.j2 to provide fallback implementations for get_default_mtls_endpoint, get_api_endpoint, and get_universe_domain when they are not available in google.api_core.universe. The client templates are updated to delegate these operations to the new compatibility module, and redundant unit tests are removed from the generated test suites. The review feedback highlights that both get_api_endpoint in _compat.py.j2 and _get_api_endpoint in client.py.j2 can return None under certain conditions, and recommends updating their return type annotations to Optional[str] for better type safety.

@hebaalazzeh
hebaalazzeh marked this pull request as ready for review July 21, 2026 21:58
@hebaalazzeh
hebaalazzeh requested a review from a team as a code owner July 21, 2026 21:58
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-generator-centralization-routing branch from b8ed069 to b7054c2 Compare July 21, 2026 23:14
@hebaalazzeh

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a compatibility module template _compat.py.j2 to centralize fallback logic for older versions of google-api-core, updating the generator and client templates to import and use these shared utilities. Feedback on the changes highlights two critical issues regarding generated files: first, the new mock.patch("os.path.exists", ...) in the golden files is missing from the generator's template test_%service.py.j2; second, the new test file test__compat.py was added directly to a golden directory without a corresponding template, which will cause integration test failures.

@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-generator-centralization-routing branch from f61bfa7 to a89c8ca Compare July 23, 2026 17:20
@hebaalazzeh
hebaalazzeh marked this pull request as draft July 24, 2026 19:26
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-generator-centralization-routing branch from 9954e16 to 0547563 Compare July 28, 2026 17:24
@hebaalazzeh
hebaalazzeh marked this pull request as ready for review July 29, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant