#3618 feat(taps): New `RESTStream.get_http_request` method to construct the HTTP request for a stream
Pull request opened by
edgarrmondragon
•
#3483
Summary by Sourcery
Introduce a structured HTTPRequest and PageContext abstraction for REST streams and switch RESTStream to build requests via a new get_http_request hook instead of prepare_request/get_url_params.
New Features:
• Add an HTTPRequest dataclass to represent REST stream HTTP requests, including URL, method, headers, params, body, and custom query encoding.
• Add a PageContext container that bundles stream context and pagination token for request construction.
• Add RESTStream.get_http_request as the primary extension point for customizing outgoing HTTP requests and pagination behavior.
Enhancements:
• Refactor RESTStream internals to construct PreparedRequest objects from HTTPRequest instances via a new internal _prepare_request method.
• Tighten typing for REST pagination, including a JSONPayload alias and generic paginator token typing.
• Update built-in taps and REST examples (e.g., GitLab, DummyJSON) to override get_http_request instead of get_url_params, aligning them with the new API.
• Adjust REST request metrics and pagination tests to work against the new HTTPRequest/PageContext abstractions.
Documentation:
• Document HTTPRequest and PageContext in the reference, and add dedicated API docs stubs for these classes.
• Update pagination, incremental replication, HATEOAS, and porting guides to show get_http_request-based patterns instead of get_url_params.
• Revise the tap cookiecutter REST client template to demonstrate overriding get_http_request for query parameters and payload composition.
Tests:
• Add unit tests for HTTPRequest parameter handling and encoding behavior, including safe characters and passthrough of raw query strings with deprecation warnings.
• Add tests ensuring prepare_request overrides now emit SingerSDKDeprecationWarning, including when overridden on intermediate base classes.
• Update existing REST pagination and metrics tests to validate behavior using the new get_http_request and PageContext abstractions.
Chores:
• Deprecate overriding prepare_request in RESTStream in favor of get_http_request and emit deprecation warnings when legacy overrides are detected.
meltano/sdk