ds_protocol_http_py_lib.dataset¶
File: __init__.py
Region: ds_protocol_http_py_lib/dataset
HTTP Dataset
This module implements a dataset for HTTP APIs.
Submodules¶
Classes¶
Where a value is written on the request. |
|
Tabular dataset backed by an HTTP API. |
|
Settings for an HTTP dataset request. |
|
Operation-scoped settings for |
|
Instruction nest for incremental rules used by Paginate. |
|
Declared incremental rulesets supported by Paginate. |
|
Configuration for opaque cursor / token pagination. |
|
Where a pagination value is read from the response. |
|
Configuration for offset / limit pagination. |
|
Configuration for page-number / page-size pagination. |
|
Composer for a paginated |
|
Declared pagination mechanism and strategy-specific nests. |
|
Declared pagination mechanisms supported by HttpDataset. |
Package Contents¶
- class ds_protocol_http_py_lib.dataset.InjectLocation[source]¶
Bases:
enum.StrEnumWhere a value is written on the request.
- QUERY = 'query'¶
- HEADER = 'header'¶
- BODY = 'body'¶
- class ds_protocol_http_py_lib.dataset.HttpDataset[source]¶
Bases:
ds_resource_plugin_py_lib.common.resource.dataset.TabularDataset[HttpLinkedServiceType,HttpDatasetSettingsType,ds_resource_plugin_py_lib.common.serde.serialize.PandasSerializer,ds_resource_plugin_py_lib.common.serde.deserialize.PandasDeserializer],Generic[HttpLinkedServiceType,HttpDatasetSettingsType]Tabular dataset backed by an HTTP API.
read()behavior is gated bysettings.read:pagination configured →
Paginate(optional incremental rules)otherwise → original single-request read
- linked_service: HttpLinkedServiceType¶
Linked service used to issue authenticated HTTP requests.
- settings: HttpDatasetSettingsType¶
Request and read-scoped configuration.
- serializer: ds_resource_plugin_py_lib.common.serde.serialize.PandasSerializer | None¶
Serializer used when writing payloads (
create).
- deserializer: ds_resource_plugin_py_lib.common.serde.deserialize.PandasDeserializer | None¶
Deserializer used to materialize
outputfrom response bodies.
- property type: ds_protocol_http_py_lib.enums.ResourceType¶
Resource type discriminator.
- property supports_checkpoint: bool¶
True when pagination (mid-run resume / optional watermark) is configured.
- create() None[source]¶
Create data at the specified endpoint (single request).
- Raises:
AuthenticationError – If authentication fails.
AuthorizationError – If authorization fails.
ConnectionError – If the connection fails.
CreateError – If the create call fails.
- read() None[source]¶
Read data from the specified endpoint.
When
settings.read.paginationis set, runsPaginate.from_dataset(self).run(self). Otherwise issues one request.- Raises:
AuthenticationError – If authentication fails.
AuthorizationError – If authorization fails.
ConnectionError – If the connection fails.
ReadError – If the read call or pagination fails.
- _map_files(files: collections.abc.Sequence[ds_protocol_http_py_lib.models.Files] | None) Any[source]¶
Convert typed Files descriptors into requests compatible files=….
HttpDatasetSettings.files is expected to already be deserialized into the correct typed model, so this method focuses purely on the requests shape conversion.
- class ds_protocol_http_py_lib.dataset.HttpDatasetSettings[source]¶
Bases:
ds_resource_plugin_py_lib.common.resource.dataset.DatasetSettingsSettings for an HTTP dataset request.
- method: ds_protocol_http_py_lib.enums.HttpMethod¶
The HTTP method to use.
- url: str¶
The URL to send the request to.
- data: Any | None = None¶
The data to send with the request.
- json: dict[str, Any] | None = None¶
The JSON data to send with the request.
- params: dict[str, Any] | None = None¶
The parameters to send with the request.
- files: list[ds_protocol_http_py_lib.models.Files] | None = None¶
The multipart files to send with the request.
- headers: dict[str, Any] | None = None¶
The headers to send with the request.
- path_params: dict[str, Any] | None = None¶
Path parameters to interpolate into the URL template using {param} syntax.
Example
url=”https://api.example.com/documents/{document_guid}/original” path_params={“document_guid”: “abc123”} # → https://api.example.com/documents/abc123/original
- read: HttpReadSettings¶
pagination (traversing) and incremental (shifting).
- Type:
Read-scoped settings
- class ds_protocol_http_py_lib.dataset.HttpReadSettings[source]¶
Bases:
ds_common_serde_py_lib.SerializableOperation-scoped settings for
HttpDataset.read().pagination— traversing scope within one read (absent = single request).incremental— watermark ruleset consulted by Paginate (not a separate gate).
- pagination: ds_protocol_http_py_lib.dataset.pagination.settings.PaginationSettings | None = None¶
Pagination mechanism.
Nonemeans a single request with no page loop.
- incremental: ds_protocol_http_py_lib.dataset.incremental.settings.IncrementalSettings | None = None¶
Incremental watermark rules for Paginate. Ignored when pagination is unset.
- class ds_protocol_http_py_lib.dataset.IncrementalSettings[source]¶
Bases:
ds_common_serde_py_lib.SerializableInstruction nest for incremental rules used by Paginate.
Instruction (stable): which request slot carries the lower bound and which response field advances the high-watermark.
State (runtime): the watermark value itself lives in
checkpoint, owned by the caller. Paginate reads it on prepare and writes it on commit.- strategy: ds_protocol_http_py_lib.dataset.incremental.enums.IncrementalStrategy¶
Incremental ruleset. Declared explicitly; never inferred.
- param: str¶
Name injected into the next run’s request (query, header, or body key).
- location: ds_protocol_http_py_lib.utils.http.request.InjectLocation¶
Where the watermark is injected on the request.
- watermark_path: str¶
Dotted path on each output row used to compute the new high-watermark.
- class ds_protocol_http_py_lib.dataset.IncrementalStrategy[source]¶
Bases:
enum.StrEnumDeclared incremental rulesets supported by Paginate.
- WATERMARK = 'watermark'¶
Param-injected high-watermark across runs.
- class ds_protocol_http_py_lib.dataset.CursorPaginationSettings[source]¶
Bases:
ds_common_serde_py_lib.SerializableConfiguration for opaque cursor / token pagination.
- cursor_path: str¶
Body path or header name where the next cursor is read.
- cursor_source: ds_protocol_http_py_lib.dataset.pagination.enums.ExtractSource¶
Whether the cursor is extracted from the response body or a header.
- cursor_param: str = 'cursor'¶
Parameter / header / body key used to inject the cursor.
- cursor_location: ds_protocol_http_py_lib.utils.http.request.InjectLocation¶
Where the cursor is injected on the next request.
- page_size_param: str | None = None¶
Optional page-size query parameter name (always injected as QUERY).
- page_size: int | None = None¶
Optional requested page size (sent with
page_size_param).
- class ds_protocol_http_py_lib.dataset.ExtractSource[source]¶
Bases:
enum.StrEnumWhere a pagination value is read from the response.
- BODY = 'body'¶
JSON response body path.
- HEADER = 'header'¶
Response header name.
- class ds_protocol_http_py_lib.dataset.OffsetPaginationSettings[source]¶
Bases:
ds_common_serde_py_lib.SerializableConfiguration for offset / limit pagination.
- offset_param: str = 'offset'¶
Query/body/header parameter name for the offset.
- limit_param: str = 'limit'¶
Query/body/header parameter name for the page size.
- page_size: int = 100¶
Number of records requested per page.
- initial_offset: int = 0¶
Offset used for the first page when no checkpoint exists.
- total_path: str | None = None¶
Optional body path to a total record count.
When the path resolves, a non-empty page stops once
offset + len(items) >= total. The next offset advances by the rows returned, and the request still asks forpage_size. An empty page stops immediately. A short page ends the read only when this path is unset or missing.
- inject_location: ds_protocol_http_py_lib.utils.http.request.InjectLocation¶
Where offset and limit are injected on the request.
- class ds_protocol_http_py_lib.dataset.PageNumberPaginationSettings[source]¶
Bases:
ds_common_serde_py_lib.SerializableConfiguration for page-number / page-size pagination.
- page_param: str = 'page'¶
Parameter name for the page ordinal.
- page_size_param: str = 'per_page'¶
Parameter name for the page size.
- page_size: int = 100¶
Number of records requested per page.
- start_page: int = 1¶
First page ordinal (0- or 1-based, must match the API).
- total_pages_path: str | None = None¶
Optional body path to a total page count.
When the path resolves, a non-empty page stops on the last ordinal. An empty page stops immediately. A short page ends the read only when this path is unset or missing.
- inject_location: ds_protocol_http_py_lib.utils.http.request.InjectLocation¶
Where page and page size are injected on the request.
- class ds_protocol_http_py_lib.dataset.Paginate(strategy: ds_protocol_http_py_lib.dataset.pagination.strategies.base.PaginationStrategyHandler[Any], pagination: ds_protocol_http_py_lib.dataset.pagination.settings.PaginationSettings, incremental_rules: ds_protocol_http_py_lib.dataset.incremental.rules.IncrementalRules, incremental: ds_protocol_http_py_lib.dataset.incremental.settings.IncrementalSettings | None)[source]¶
Composer for a paginated
HttpDataset.read.Resolves a registered page strategy and optional incremental ruleset, then runs prepare → drain → commit. Strategy hooks supply page variation only; this class owns HTTP, checkpoint pagination slice, and error mapping.
- strategy¶
- pagination¶
- incremental_rules¶
- incremental¶
- classmethod from_dataset(dataset: ds_protocol_http_py_lib.dataset.http.HttpDataset[Any, Any]) Paginate[source]¶
Build from
dataset.settings.readand the strategy / rules registries.
- run(dataset: ds_protocol_http_py_lib.dataset.http.HttpDataset[Any, Any]) None[source]¶
Prepare → drain → assign
output/ checkpoint.On full success: clear
checkpoint["pagination"], then incrementalcommitif configured. On failure: assign partialoutput, keep mid-run pagination resume, hold watermark.
- drain(dataset: ds_protocol_http_py_lib.dataset.http.HttpDataset[Any, Any], request: ds_protocol_http_py_lib.utils.http.request.RequestSnapshot, frames: list[pandas.DataFrame] | None = None) list[pandas.DataFrame][source]¶
Page loop via strategy hooks; write mid-run
checkpoint["pagination"].Appends page frames to
frames(created if omitted) so callers retain partial output when this method raises mid-drain.Each frame is
dataset.deserializer(response.content)— the API body the caller configured the deserializer for.items_pathis paging control only. An empty body is an empty frame and does not call the deserializer.- Raises:
ValueError – If
dataset.deserializeris missing.ReadError – If
max_pagesis exceeded without a natural stop.
- _snapshot(dataset: ds_protocol_http_py_lib.dataset.http.HttpDataset[Any, Any]) ds_protocol_http_py_lib.utils.http.request.RequestSnapshot[source]¶
Build an isolated request copy from dataset settings.
- class ds_protocol_http_py_lib.dataset.PaginationSettings[source]¶
Bases:
ds_common_serde_py_lib.SerializableDeclared pagination mechanism and strategy-specific nests.
Provide the nest matching
strategy(same pattern as auth nests onHttpLinkedServiceSettings). Other nests should be omitted from the payload; only the selected nest is read at runtime.- strategy: ds_protocol_http_py_lib.dataset.pagination.enums.PaginationStrategy¶
Pagination mechanism. Declared explicitly; never inferred.
- max_pages: int | None = None¶
Optional client-side safety ceiling on pages fetched per
read().None(default) means no ceiling — keep paging until the strategy signals stop (short page, total count, empty cursor, …). Set anintonly when you want a hard guard against runaway loops.
- items_path: str = 'data'¶
Path to the record array used for paging control (stop / advance).
Use
$for a root array. Does not select what the deserializer sees. Each page frame isdataset.deserializer(response.content).
- offset: OffsetPaginationSettings | None = None¶
Required when
strategyisoffset.
- page_number: PageNumberPaginationSettings | None = None¶
Required when
strategyispage_number.
- cursor: CursorPaginationSettings | None = None¶
Required when
strategyiscursor.
- _selected_nest() StrategyConfig | None[source]¶
- property strategy_config: StrategyConfig¶
Strategy-specific nest for
strategy(guaranteed by__post_init__).
- class ds_protocol_http_py_lib.dataset.PaginationStrategy[source]¶
Bases:
enum.StrEnumDeclared pagination mechanisms supported by HttpDataset.
- OFFSET = 'offset'¶
Offset / limit pagination.
- PAGE_NUMBER = 'page_number'¶
Page ordinal / page size pagination.
- CURSOR = 'cursor'¶
Opaque cursor / token pagination.