ds_protocol_http_py_lib.dataset.http¶
File: http.py
Region: ds_protocol_http_py_lib/dataset/http
HTTP Dataset
This module implements a dataset for HTTP APIs.
Example
>>> from ds_protocol_http_py_lib.enums import AuthType
>>> from ds_protocol_http_py_lib.linked_service import OAuth2AuthSettings
>>> dataset = HttpDataset(
... deserializer=PandasDeserializer(format=DatasetStorageFormatType.JSON),
... serializer=PandasSerializer(format=DatasetStorageFormatType.JSON),
... settings=HttpDatasetSettings(
... url="https://api.example.com/data",
... method=HttpMethod.GET,
... ),
... linked_service=HttpLinkedService(
... settings=HttpLinkedServiceSettings(
... host="api.example.com",
... auth_type=AuthType.OAUTH2,
... oauth2=OAuth2AuthSettings(
... token_endpoint="https://auth.example.com/token",
... client_id="my-client",
... client_secret="secret",
... ),
... ),
... ),
... )
>>> dataset.read()
>>> data = dataset.output
Attributes¶
Classes¶
Operation-scoped settings for |
|
Settings for an HTTP dataset request. |
|
Tabular dataset backed by an HTTP API. |
Module Contents¶
- ds_protocol_http_py_lib.dataset.http.logger¶
- class ds_protocol_http_py_lib.dataset.http.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.http.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
- ds_protocol_http_py_lib.dataset.http.HttpDatasetSettingsType¶
- ds_protocol_http_py_lib.dataset.http.HttpLinkedServiceType¶
- class ds_protocol_http_py_lib.dataset.http.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.