ds_provider_unimicro_py_lib.dataset.unimicro

File: unimicro.py Region: ds_provider_unimicro_py_lib/dataset/unimicro

Generic Unimicro biz-dataset reader (/api/biz/{data_product}).

Attributes

logger

UnimicroDatasetSettingsType

UnimicroLinkedServiceType

Classes

UnimicroReadSettings

Read settings specific to the Unimicro provider.

UnimicroDatasetSettings

Dataset settings specific to the Unimicro provider.

UnimicroDataset

UnimicroDataset represents a dataset specific to the Unimicro provider.

Module Contents

ds_provider_unimicro_py_lib.dataset.unimicro.logger
class ds_provider_unimicro_py_lib.dataset.unimicro.UnimicroReadSettings[source]

Bases: ds_common_serde_py_lib.Serializable

Read settings specific to the Unimicro provider.

id: int | None = None

The unique identifier of the record to read from the Unimicro dataset. Optional.

page_size: int = 1000

The number of records to fetch per page from the Unimicro dataset. Default is 1000.

fields: list[str] | None = None

The specific fields to read from the Unimicro dataset. Optional.

filters: str | None = None

Custom filters to apply when reading from the Unimicro dataset. Knowledge of the filter syntax is required. Optional.

params: dict[str, str | int] | None = None

Extra query parameters merged into the request URL. Optional.

The dataset owns top, skip, select and filter (set them through page_size, fields and filters), so those keys are rejected here. For data_product="trialbalance" this scopes the read: financialyear (required) and period (default 1-12), each an int or a start-end range.

class ds_provider_unimicro_py_lib.dataset.unimicro.UnimicroDatasetSettings[source]

Bases: ds_resource_plugin_py_lib.common.resource.dataset.DatasetSettings

Dataset settings specific to the Unimicro provider.

data_product: str

Native Unimicro biz entity name (e.g. Customers, accounts), read with offset pagination, or a provider-defined product from DataProduct (e.g. trialbalance).

company_key: str

The company key used for fetching data from the Unimicro provider.

read: UnimicroReadSettings

Read settings for the Unimicro dataset.

ds_provider_unimicro_py_lib.dataset.unimicro.UnimicroDatasetSettingsType
ds_provider_unimicro_py_lib.dataset.unimicro.UnimicroLinkedServiceType
class ds_provider_unimicro_py_lib.dataset.unimicro.UnimicroDataset[source]

Bases: ds_resource_plugin_py_lib.common.resource.dataset.TabularDataset[UnimicroLinkedServiceType, UnimicroDatasetSettingsType, ds_resource_plugin_py_lib.common.serde.serialize.PandasSerializer, ds_resource_plugin_py_lib.common.serde.deserialize.PandasDeserializer], Generic[UnimicroLinkedServiceType, UnimicroDatasetSettingsType]

UnimicroDataset represents a dataset specific to the Unimicro provider.

linked_service: UnimicroLinkedServiceType
settings: UnimicroDatasetSettingsType
serializer: ds_resource_plugin_py_lib.common.serde.serialize.PandasSerializer | None
deserializer: ds_resource_plugin_py_lib.common.serde.deserialize.PandasDeserializer | None
property type: ds_provider_unimicro_py_lib.enums.ResourceType

Get the type of the dataset.

property supports_checkpoint: bool

Whether this provider supports checkpointing for incremental reads.

The checkpoint has this structure:

{
    "incremental": {"value": <timestamp or None>},
    "pagination": {"value": <record offset>},
}

During a read, pagination.value is used as the initial API skip offset (defaulting to 0). Pagination is handled within the read call: each subsequent request skips the initial offset plus the number of records already fetched during that call.

When incremental.value is set, requests filter for records whose CreatedAt or UpdatedAt timestamp is greater than that value. After a successful read, the checkpoint is replaced with the latest valid timestamp found in the returned records, and pagination.value is reset to 0. If no valid timestamps are found, the incremental value is None.

If a request fails, the checkpoint is updated with the number of records fetched during that read attempt and retains the prior incremental value. Consumers should persist checkpoints separately for each dataset and company.

trialbalance reads are always full loads: the checkpoint is not used as a starting point and is reset after a successful read.

Returns:

Always True.

Return type:

bool

read() → None[source]

Reads data from the Unimicro dataset.

Native biz entities are paged through with top/skip, respecting the current checkpoint for incremental loading. Provider-defined products (DataProduct) use their own read pattern.

Returns:

None

_fetch_data(session: Any) → None[source]

Fetches data from the Unimicro API using the provided session.

Parameters:

session (Any) – The session object used to make API requests.

Returns:

None

_build_url_with_filters(page_size: int, records_to_skip: int | None, last_modified_date: str | None) → str[source]

Build the Unimicro request URL for the current read settings.

Parameters:
  • page_size – OData top page size.

  • records_to_skip – OData skip offset.

  • last_modified_date – Incremental watermark for CreatedAt/UpdatedAt filter.

Returns:

Fully qualified request URL including query string.

_build_url() → str[source]

Constructs the URL for accessing the Unimicro API.

Returns:

The constructed URL.

Return type:

str

close() → None[source]

Release any resources held by the dataset.

Connection lifecycle is managed by the linked service.

create() → None[source]

Insert all rows in self.input into the target as a single atomic transaction. Must not delete, update, or overwrite existing data.

Raises:
  • CreateError – If the operation fails.

  • NotSupportedError – If the provider does not support create.

See also

Full contract: docs/DATASET_CONTRACT.md – create()

delete() → None[source]

Remove specific rows from the target matched by identity columns defined in self.settings. Atomic. Idempotent.

Raises:
  • DeleteError – If the operation fails.

  • NotSupportedError – If the provider does not support delete.

See also

Full contract: docs/DATASET_CONTRACT.md – delete()

update() → None[source]

Update existing rows in the target matched by identity columns defined in self.settings. Atomic. Must not insert new rows.

Raises:
  • UpdateError – If the operation fails.

  • NotSupportedError – If the provider does not support update.

See also

Full contract: docs/DATASET_CONTRACT.md – update()

rename() → None[source]

Rename the resource in the backend. Atomic. Not idempotent.

Raises:
  • RenameError – If the operation fails.

  • NotSupportedError – If the provider does not support renaming.

See also

Full contract: docs/DATASET_CONTRACT.md – rename()

list() → None[source]

Discover available resources and populate self.output with a DataFrame of resources and their metadata. Idempotent.

Raises:
  • ListError – If the operation fails.

  • NotSupportedError – If the provider does not support listing.

See also

Full contract: docs/DATASET_CONTRACT.md – list()

upsert() → None[source]

Insert rows that do not exist, update rows that do, matched by identity columns defined in self.settings. Atomic.

Raises:
  • UpsertError – If the operation fails.

  • NotSupportedError – If the provider does not support upsert.

See also

Full contract: docs/DATASET_CONTRACT.md – upsert()

purge() → None[source]

Remove all content from the target. self.input is not used. Atomic. Idempotent.

Raises:
  • PurgeError – If the operation fails.

  • NotSupportedError – If the provider does not support purge.

See also

Full contract: docs/DATASET_CONTRACT.md – purge()