feat(api-core): centralize rest transcoding helpers#17765
Conversation
There was a problem hiding this comment.
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.
3af2bfe to
0b05ab3
Compare
2e4481a to
c736fcd
Compare
|
/gemini review |
There was a problem hiding this comment.
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.
c736fcd to
e009a6b
Compare
e009a6b to
81ad231
Compare
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 utilitytranscode()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.