ds_provider_xledger_py_lib.utils¶
File: __init__.py
Region: ds_provider_xledger_py_lib/utils
Description¶
Utility helpers for provider internals.
Submodules¶
Classes¶
Container for all loaded operations for one entrypoint. |
|
Load and cache entrypoint metadata for dataset lifecycle reuse. |
|
Operation-level metadata plus packaged GraphQL query template. |
|
Registry for GraphQL-to-provider exception mapping rules. |
|
Simple rule for mapping GraphQL errors to provider exceptions. |
Functions¶
|
Raise typed DS exceptions for GraphQL payload errors. |
|
Build a rendered GraphQL mutation for write operations. |
|
Build a rendered GraphQL query for read operations. |
|
Build GraphQL variables payload for an operation. |
Package Contents¶
- ds_provider_xledger_py_lib.utils.raise_for_graphql_errors(*, body: Any) dict[str, Any][source]¶
Raise typed DS exceptions for GraphQL payload errors.
GraphQL servers may return HTTP 200 while reporting failures under an
errorsfield in the response payload.- Parameters:
body – The GraphQL response body to inspect.
- Returns:
The original GraphQL response body when no error is present.
- class ds_provider_xledger_py_lib.utils.EntryPointMetaData[source]¶
Container for all loaded operations for one entrypoint.
- entrypoint: str¶
- operations: dict[ds_provider_xledger_py_lib.enums.OperationType, MetaData]¶
- get(*, operation: ds_provider_xledger_py_lib.enums.OperationType) MetaData[source]¶
Return metadata for a specific operation.
- Parameters:
operation – Operation to resolve.
- Returns:
Metadata for the requested operation.
- Raises:
NotSupportedError – If metadata for the operation is unavailable.
- class ds_provider_xledger_py_lib.utils.IntrospectionService[source]¶
Load and cache entrypoint metadata for dataset lifecycle reuse.
- entrypoint: str¶
- _metadata: EntryPointMetaData | None = None¶
- property metadata: EntryPointMetaData¶
Loaded entrypoint metadata.
- Returns:
Cached metadata snapshot for the configured entrypoint.
- load() EntryPointMetaData[source]¶
Load metadata snapshot if needed and return cached value.
- Returns:
Cached metadata snapshot for the configured entrypoint.
- load_metadata(*, operation: ds_provider_xledger_py_lib.enums.OperationType) MetaData[source]¶
Return metadata for a single operation.
- Parameters:
operation – Operation to resolve.
- Returns:
Metadata for the requested operation.
- class ds_provider_xledger_py_lib.utils.MetaData[source]¶
Bases:
ds_common_serde_py_lib.serializable.SerializableOperation-level metadata plus packaged GraphQL query template.
- name: str¶
- type: str¶
- description: str¶
- query: str¶
- supportPagination: bool = False¶
- ds_provider_xledger_py_lib.utils.build_mutation(*, metadata: ds_provider_xledger_py_lib.utils.introspection.MetaData, variables: dict[str, Any], return_fields: list[str] | None = None) str[source]¶
Build a rendered GraphQL mutation for write operations.
- Parameters:
metadata – Operation metadata.
variables – Resolved variables required by the mutation template.
return_fields – Optional explicit fields to return.
- Returns:
GraphQL mutation text.
- ds_provider_xledger_py_lib.utils.build_query(*, metadata: ds_provider_xledger_py_lib.utils.introspection.MetaData, **kwargs: Any) str[source]¶
Build a rendered GraphQL query for read operations.
- Parameters:
metadata – Operation metadata.
**kwargs – Query keyword arguments.
fieldscontrols selection set.
- Returns:
GraphQL query text.
- ds_provider_xledger_py_lib.utils.build_variables(*, obj: pandas.DataFrame, operation: ds_provider_xledger_py_lib.enums.OperationType, metadata: ds_provider_xledger_py_lib.utils.introspection.MetaData) dict[str, Any][source]¶
Build GraphQL variables payload for an operation.
- Parameters:
obj – Input dataframe.
operation – Dataset operation type.
metadata – Loaded operation metadata.
- Returns:
Variables dictionary matching the query template.
- class ds_provider_xledger_py_lib.utils.GraphQLErrorRuleBook[source]¶
Registry for GraphQL-to-provider exception mapping rules.
- classmethod resolve(*, code: str, extension_code: str, error_message: str) ResolvedRule | None[source]¶
Resolve a GraphQL error to a mapped provider exception.
- Parameters:
code – The error code to resolve.
extension_code – The extension code to resolve.
error_message – The error message to resolve.
- Returns:
The resolved rule.
- static _match_source(*, rule: Rule, message_lower: str, code: str, extension_code: str) str | None[source]¶
Return the source used to match the provided rule.
- Parameters:
rule – The rule to match.
message_lower – The lowercased error message to match.
code – The error code to match.
extension_code – The extension code to match.
- Returns:
A source label when the current error matches the provided rule.