Skip to content

feat: gapic centralization into api core - #17628

Closed
hebaalazzeh wants to merge 53 commits into
mainfrom
feat/gapic-centralization-api-core
Closed

feat: gapic centralization into api core#17628
hebaalazzeh wants to merge 53 commits into
mainfrom
feat/gapic-centralization-api-core

Conversation

@hebaalazzeh

@hebaalazzehhebaalazzeh commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Update and Release google-api-core

This PR introduces centralized helper functions into google.api_core.gapic_v1. The goal of this centralization is to reduce package size, improve maintainability, and boost import performance of generated GAPIC clients by moving redundant, service-agnostic boilerplate logic into google-api-core.

Key Changes

  • Centralized GAPIC Helpers: Extracted logic previously repeated across generated clients into focused, domain-specific modules within google.api_core.gapic_v1:
    • _routing.py (get_default_mtls_endpoint, get_api_endpoint, get_universe_domain)
    • _client_cert.py (use_client_cert_effective, get_client_cert_source)
    • _config_helpers.py (read_environment_variables)
    • _method_helpers.py (setup_request_id)
  • Public Method Exposure: Removed the _ prefix from these functions so they can be securely imported and utilized by external generated clients.
  • Backward Compatibility: Added internal aliases (e.g., _use_client_cert_effective = use_client_cert_effective) to prevent breaking changes for existing GAPIC clients (over 2,400+ repos) that have not yet been regenerated.
  • Comprehensive Test Coverage: Added exhaustive unit tests for all helper functions in dedicated, domain-specific test files (test_routing.py, test_client_cert.py, test_config_helpers.py, test_method_helpers.py).
  • CI Environment Hardening:
    • Handled grpc optional dependencies gracefully to ensure tests pass in install_grpc=False environments.
    • Ensured older versions of google-auth (e.g. <=2.14.1) pass in the CI test matrix by safely validating should_use_client_cert availability.

NOTE

  • Full details and baseline metrics are available in the attached Design Document.
  • PR that updates the GAPIC generator templates to delegate common, service-agnostic boilerplate logic to the newly centralized functions in google-api-core.gapic_v1 #17699

@gemini-code-assistgemini-code-assistBot 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 client_helpers module in google-api-core containing helper functions for GAPIC client initialization, and adds global lazy imports control (__lazy_modules__) to google-cloud-compute. The review feedback suggests optimizing performance by compiling the mTLS endpoint regular expression at the module level rather than inside the function. Additionally, it recommends correcting the type annotations in get_api_endpoint to use Optional[Any] for client_cert_source and Optional[str] for the return type.

Comment threadpackages/google-api-core/google/api_core/gapic_v1/client_helpers.py Outdated
Comment threadpackages/google-api-core/google/api_core/gapic_v1/client_helpers.py Outdated
Comment threadpackages/google-api-core/google/api_core/gapic_v1/client_helpers.py Outdated
Comment threadpackages/google-api-core/google/api_core/gapic_v1/client_helpers.py Outdated
@hebaalazzehhebaalazzeh self-assigned this Jul 6, 2026
@hebaalazzeh
hebaalazzehforce-pushed the feat/gapic-centralization-api-core branch from 5e1eb20 to ad1c01fCompareJuly 6, 2026 21:21
@hebaalazzeh

Copy link
Copy Markdown
ContributorAuthor

/gemini

@hebaalazzeh
hebaalazzehforce-pushed the feat/gapic-centralization-api-core branch from c27695d to 2353e82CompareJuly 7, 2026 20:56
@hebaalazzeh
hebaalazzeh marked this pull request as ready for review July 7, 2026 21:01
@hebaalazzeh
hebaalazzeh requested a review from a team as a code ownerJuly 7, 2026 21:01
@hebaalazzeh
hebaalazzehforce-pushed the feat/gapic-centralization-api-core branch 3 times, most recently from 1d7b5c2 to 3f02e35CompareJuly 9, 2026 20:02
@hebaalazzeh
hebaalazzehforce-pushed the feat/gapic-centralization-api-core branch from 713b557 to 70445efCompareJuly 14, 2026 21:19
@parthea

Copy link
Copy Markdown
Contributor

The Github status checks appear to be stuck. Closing and re-opening this PR may help

@partheaparthea assigned parthea and unassigned hebaalazzehJul 15, 2026
…s to public
Rename _client_cert, _config_helpers, _method_helpers, and _routing submodules and their functions to public names, as they are consumed across package boundaries by generated client libraries. Updates unit tests and top-level gapic_v1 imports accordingly.
@partheaparthea assigned hebaalazzeh and unassigned partheaJul 16, 2026
@hebaalazzeh
hebaalazzeh marked this pull request as draft July 16, 2026 15:01
Sign up for freeto 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.

3 participants

@hebaalazzeh@ohmayr@parthea