ds_provider_xledger_py_lib.linked_service.xledger

Xledger linked service implementation.

This module provides a linked service for the Xledger GraphQL API. It reuses the shared HTTP protocol provider for retries, timeouts, and rate limiting, while exposing a provider-specific settings model.

Example

>>> linked_service = XledgerLinkedService(
...     settings=XledgerLinkedServiceSettings(
...         host="https://demo.xledger.net/graphql",
...         token="my-token",
...         timeout=60,
...     ),
... )
>>> linked_service.connect()
>>> linked_service.connection.post(
...     linked_service.settings.host,
...     json={"query": "query { __typename }"},
... )

Attributes

XledgerLinkedServiceSettingsType

Classes

XledgerLinkedServiceSettings

Connection settings for Xledger GraphQL API.

XledgerLinkedService

Linked service for Xledger GraphQL API.

Module Contents

class ds_provider_xledger_py_lib.linked_service.xledger.XledgerLinkedServiceSettings[source]

Bases: ds_resource_plugin_py_lib.common.resource.linked_service.LinkedServiceSettings

Connection settings for Xledger GraphQL API.

host

Full GraphQL endpoint URL.

token

API token used for Xledger Authorization header.

headers

Optional additional default headers.

timeout

Default request timeout in seconds.

host: str = 'https://demo.xledger.net/graphql'
token: str
headers: dict[str, str] | None = None
timeout: int | float = 60
ds_provider_xledger_py_lib.linked_service.xledger.XledgerLinkedServiceSettingsType
class ds_provider_xledger_py_lib.linked_service.xledger.XledgerLinkedService[source]

Bases: ds_resource_plugin_py_lib.common.resource.linked_service.LinkedService[XledgerLinkedServiceSettingsType], Generic[XledgerLinkedServiceSettingsType]

Linked service for Xledger GraphQL API.

settings: XledgerLinkedServiceSettingsType
_http: ds_protocol_http_py_lib.utils.http.provider.Http | None = None
property type: ds_provider_xledger_py_lib.enums.ResourceType

Return the resource type for this linked service.

Returns:

The linked-service resource identifier enum.

Return type:

ResourceType

property connection: ds_protocol_http_py_lib.utils.http.provider.Http

Return the established HTTP provider instance.

Returns:

Configured HTTP provider used by datasets.

Return type:

Http

Raises:

ConnectionError – If connect() has not been called.

_init_http() ds_protocol_http_py_lib.utils.http.provider.Http[source]

Build the internal HTTP provider.

Returns:

A configured HTTP provider instance with retry and token-bucket rate limiting enabled.

Return type:

Http

connect() None[source]

Connect to Xledger by preparing an authenticated HTTP session.

This method is idempotent. It initializes the HTTP provider on first use and updates default headers with bearer authentication.

Raises:

AuthenticationError – If the token is missing or blank.

test_connection() tuple[bool, str][source]

Run a lightweight GraphQL probe to verify connectivity.

Returns:

(True, "") on success, otherwise (False, error_message).

Return type:

tuple[bool, str]

close() None[source]

Close and clear the underlying HTTP provider.

This method is safe to call multiple times.