ds_provider_tripletex_py_lib.dataset¶
File: __init__.py
Region: ds_provider_tripletex_py_lib/dataset
Description¶
Dataset package for the Tripletex provider.
Submodules¶
Classes¶
Read-only tabular dataset for Tripletex products. |
|
Settings for the Tripletex dataset. |
|
Settings for Tripletex read operations. |
Package Contents¶
- class ds_provider_tripletex_py_lib.dataset.TripletexDataset[source]¶
Bases:
ds_resource_plugin_py_lib.common.resource.dataset.TabularDataset[TripletexLinkedServiceType,TripletexDatasetSettingsType,ds_resource_plugin_py_lib.common.serde.serialize.PandasSerializer,ds_resource_plugin_py_lib.common.serde.deserialize.PandasDeserializer],Generic[TripletexLinkedServiceType,TripletexDatasetSettingsType]Read-only tabular dataset for Tripletex products.
Exposed (caller-configurable):
id,name,description,version,settings,linked_service,serializer,deserializer,checkpoint.input/output(inherited fromTabularDataset) are excluded from serialization – they hold runtime read results, not configuration – though still constructible, matching the base class. No field on this class is fully internal (init=False).- linked_service: TripletexLinkedServiceType¶
- settings: TripletexDatasetSettingsType¶
- __post_init__() None[source]¶
Fill in a default serializer/deserializer if the caller didn’t provide one.
- property type: ds_provider_tripletex_py_lib.enums.ResourceType¶
Return the dataset resource type.
- property supports_checkpoint: bool¶
Whether this dataset supports incremental loads via
self.checkpoint.Checkpoint holds
{"checksums": {...}, "watermarks": {...}}– storedversionDigest/changedSincevalues per request. An empty checkpoint ({}) means a full load.- Returns:
Always
True.- Return type:
bool
- _resolve_reader(pagination: ds_provider_tripletex_py_lib.enums.PaginationKind) collections.abc.Callable[[_ReadContext], None][source]¶
Return the read implementation for the given pagination kind.
- Parameters:
pagination – The resolved endpoint’s pagination kind.
- Returns:
_read_date_windowedforDATE_WINDOW, otherwise_read_paginated.- Return type:
Callable[[_ReadContext], None]
- _resolve_product_name(product_name: str) ds_provider_tripletex_py_lib.enums.TripletexProductName[source]¶
Resolve a raw
settings.product_namevalue into aTripletexProductName.- Parameters:
product_name – The raw product name to validate.
- Returns:
The resolved product.
- Return type:
- Raises:
ReadError – If not a recognized
TripletexProductNamevalue.
- _resolve_packaged_read_info(product_name: str) ds_provider_tripletex_py_lib.read_info.ReadInfo[source]¶
Resolve read info for a packaged product, wrapping metadata failures as
ReadError.- Parameters:
product_name – The raw
settings.product_namevalue to resolve.- Returns:
The packaged product’s read info.
- Return type:
- Raises:
ReadError – If not a recognized product, or its packaged read metadata is missing or malformed.
- _resolve_read_info() ds_provider_tripletex_py_lib.read_info.ReadInfo[source]¶
Resolve the endpoint to read: a packaged product, or a custom path.
settings.product_nameis resolved via the packaged asset catalog if set; otherwisesettings.read.path/fields/paginationare used. See_validate_read_settingsfor the combination rules.- Returns:
The fully resolved endpoint to read.
- Return type:
- Raises:
ReadError – If the settings combination is invalid, or the resolved product/metadata is unrecognized/malformed.
- _resolve_read_info_from_settings() ds_provider_tripletex_py_lib.read_info.ReadInfo[source]¶
Build a
ReadInfodirectly fromsettings.read, for a custom (non-packaged) endpoint.Only called when
settings.product_nameis unset. Raises immediately on a missing value, so every field passed toReadInfois already guaranteed present.- Returns:
The endpoint built from
settings.read.- Return type:
- Raises:
ReadError – If
path/fields/pagination/changed_sincearen’t all set alongsideproduct_namebeing unset.
- _validate_read_settings(read_info: ds_provider_tripletex_py_lib.read_info.ReadInfo) None[source]¶
Validate
settings.product_name/settings.readagainst the resolvedread_info.- Parameters:
read_info – The resolved endpoint to read.
- Raises:
ReadError – If any
read.*setting is set alongsideproduct_name(ignored there),read.date_fromis set but pagination isn’tPaginationKind.DATE_WINDOW, orchanged_sinceis combined with date-windowed pagination (_read_date_windowednever emitschangedSince).
- read() None[source]¶
Read all rows for the configured product and assign them to
self.output.See
_resolve_read_infofor how the endpoint is resolved.- Raises:
AuthenticationError – If authentication fails.
AuthorizationError – If authorization fails.
ConnectionError – If the transport cannot reach Tripletex.
ReadError – If neither a known product nor a custom path is configured, or the read fails.
- _execute_read(read_info: ds_provider_tripletex_py_lib.read_info.ReadInfo, fields_param: str) None[source]¶
Run the resolved read against Tripletex and populate
self.output/self.checkpoint.- Parameters:
read_info – The endpoint to read, resolved by
_resolve_read_info.fields_param – The rendered
fieldsquery parameter value.
- Raises:
AuthenticationError – If authentication fails.
AuthorizationError – If authorization fails.
ConnectionError – If the transport cannot reach Tripletex.
ReadError – If the read fails for any other reason.
- _read_paginated(ctx: _ReadContext) None[source]¶
Fetch every page of a
from/countoffset-paginated product intoctx.records.Dispatches to
_read_paginated_by_changed_since(products supporting Tripletex’schangedSincefilter) or_read_paginated_by_digest(versionDigest/If-None-Match, every other product).
- _read_paginated_by_changed_since(ctx: _ReadContext) None[source]¶
Fetch every page of a
changedSince-capable product intoctx.records.Tripletex’s
changedSinceparam (formatYYYY-MM-DDThh:mm:ssZ) filters server-side to only rows changed since that timestamp. The next run’s watermark is captured as this run’s start time (so concurrent changes aren’t missed) and only stored inctx.watermarksonce every page succeeds.
- _read_paginated_by_digest(ctx: _ReadContext) None[source]¶
Fetch every page of an offset-paginated product using
versionDigest/If-None-Match.See
_fetch_pages_by_digestfor the mechanism.
- _fetch_pages_by_digest(ctx: _ReadContext, *, request_key: str, extra_query_params: dict[str, Any] | None = None) None[source]¶
Page through
ctx.urlviaversionDigest/If-None-Match, caching underrequest_key.Exits on
304(unchanged); falls back to"magic-value"sinceversionDigestcan be JSONnull.- Parameters:
ctx – Read context to append
recordsinto and cachechecksumson.request_key – Cache key identifying this request shape.
extra_query_params – Extra query params beyond
from/count/fields.
- _resolve_date_from(*, date_to: datetime.date) datetime.date[source]¶
Resolve
settings.read.date_frominto an absolute start date.A relative year offset from
date_to(e.g."3"/"-3", sign ignored). Defaults to 3 years back when unset.- Parameters:
date_to – The read window’s end date (today).
- Returns:
The resolved start date.
- Return type:
date
- Raises:
ReadError – If
settings.read.date_fromis not a valid integer.
- _read_date_windowed(ctx: _ReadContext) None[source]¶
Fetch a date-windowed product (
ledger/posting) across rolling monthly windows.Tripletex requires a bounded
dateFrom/dateToper request, so this walks the read window in monthly steps, offset-paginating and digest-caching within each.ctx.watermarks/ctx.changed_sinceare never touched here – no date-windowed product supportschangedSince– butctxis still accepted so the calling convention matches_read_paginated.- Raises:
ReadError – If
settings.read.date_fromis not a valid integer.
- class ds_provider_tripletex_py_lib.dataset.TripletexDatasetSettings[source]¶
Bases:
ds_resource_plugin_py_lib.common.resource.dataset.DatasetSettingsSettings for the Tripletex dataset.
- product_name: ds_provider_tripletex_py_lib.enums.TripletexProductName | None = None¶
Tripletex product to read. Exactly one of
product_name/read.pathmay be set.
- read: TripletexReadSettings¶
Settings for
read().
- class ds_provider_tripletex_py_lib.dataset.TripletexReadSettings[source]¶
Bases:
ds_common_serde_py_lib.SerializableSettings for Tripletex read operations.
- count: int = 5000¶
Page size for
from/countoffset pagination.
- fields: list[Any] | None = None¶
Field selector. Required with
path; ignored withproduct_name.Each item is a field name (
str), or a one-key dict expanding a nested object/sub-collection, e.g.{"account": ["id"]}.Example
>>> TripletexReadSettings(path="custom/thing", fields=["id", "name", {"account": ["id"]}]) # -> fields=id,name,account(id)
- params: dict[str, Any] | None = None¶
Additional query parameters merged into every request (e.g.
isInactive).Not for
dateFrom/dateToondate_window-paginated products (ledger_posting,balance_sheet) – those are auto-generated per window and would override any values passed here.
- path: str | None = None¶
Custom API path, for reading an endpoint not in the packaged product catalog.
Set together with
fieldsandpaginationinstead ofTripletexDatasetSettings.product_name. Exactly one ofproduct_name/pathmay be set – both raisesReadError.Example
>>> TripletexReadSettings(path="custom/thing", fields=["id"], pagination=PaginationKind.OFFSET)
- pagination: ds_provider_tripletex_py_lib.enums.PaginationKind | None = None¶
Required when
pathis set. Ignored (must be unset) whenproduct_nameis set.
- changed_since: bool | None = None¶
Whether
pathsupports Tripletex’schangedSincefilter.Required when
pathis set – no safe default, since silently assumingFalsecould mask never having checked. Ignored (must be unset) whenproduct_nameis set (fixed by its own metadata).
- date_from: str | None = None¶
Start of a date-windowed read (e.g.
ledger_posting), in years back from today.A relative year offset, e.g.
"3"or"-3"(sign doesn’t matter). Defaults to 3 years back when unset. Only valid forPaginationKind.DATE_WINDOWreads – otherwise raisesReadError.Example
>>> TripletexReadSettings(date_from="3")
- explode_columns: list[str] | None = None¶
Field names that are a list of objects, exploded into one row per element.
Only meaningful with
path– ignored (must be unset) whenproduct_nameis set, since a packaged product’s explode columns are fixed by its own metadata. Seeread_info.pyfor why this differs from a plain nested object (which flattens in place, no explode needed).