Skip to content

feat(api-core): centralize rest transcoding helpers#17765

Open
hebaalazzeh wants to merge 1 commit into
mainfrom
feat/gapic-centralization-api-core-transcoding
Open

feat(api-core): centralize rest transcoding helpers#17765
hebaalazzeh wants to merge 1 commit into
mainfrom
feat/gapic-centralization-api-core-transcoding

Conversation

@hebaalazzeh

@hebaalazzeh hebaalazzeh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

introduces a generic REST Transcoding helper under google.api_core.gapic_v1.rest_transcoding.

Scope of Changes:

  • rest_helpers.py: A centralized, parameters-driven generic utility transcode() that replaces the redundant code generated inside the client REST transport constructors (query parameter JSON parsing, required field default checking, body parsing, and numeric enum serialization).
  • __init__.py: Registered lazy-loading for the module.
  • conftest.py: Added session-scoped mock fixtures for mTLS variables to prevent local workstation client certificate leakage during python unit tests.
  • test_rest_transcoding.py: A comprehensive test suite validating transcoding behavior for query parameters, nested fields, required field default injection, and numeric enums.

This is the runtime package companion to the generator PR.

@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 rest_transcoding module under google/api_core/gapic_v1 to handle transcoding of requests into HTTP methods, URIs, bodies, and query parameters. It also adds comprehensive unit tests for this new functionality, configures a session-scoped pytest fixture to isolate tests from workstation mTLS environments, and updates Python version configurations. The feedback suggests optimizing the conversion of protobuf messages to Python dictionaries in rest_transcoding.py by using json_format.MessageToDict instead of serializing to JSON and deserializing it back.

Comment thread packages/google-api-core/google/api_core/gapic_v1/rest_helpers.py Outdated
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-centralization-api-core-transcoding branch from 3af2bfe to 0b05ab3 Compare July 17, 2026 23:37
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-centralization-api-core-transcoding branch 2 times, most recently from 2e4481a to c736fcd Compare July 18, 2026 00:27
@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 new helper module rest_helpers in google.api_core.gapic_v1 containing a transcode function, which converts protobuf or proto-plus request messages into HTTP methods, URIs, JSON bodies, and query parameters. It also includes comprehensive unit tests for this function and a new session-scoped test fixture to isolate unit tests from workstation mTLS environments. There are no review comments, and I have no additional feedback to provide.

@hebaalazzeh
hebaalazzeh marked this pull request as ready for review July 18, 2026 00:47
@hebaalazzeh
hebaalazzeh requested a review from a team as a code owner July 18, 2026 00:47
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-centralization-api-core-transcoding branch from c736fcd to e009a6b Compare July 18, 2026 06:01
@hebaalazzeh
hebaalazzeh force-pushed the feat/gapic-centralization-api-core-transcoding branch from e009a6b to 81ad231 Compare July 18, 2026 06:01
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