Core API Reference

This page documents the core classes and functions of the MTNA RDS Toolkit.

Server Connection

class dartfx.mtnards.MtnaRdsServer(*, host, base_path='rds', api_path='api', api_key=None, ssl_verify=True)[source]

Bases: BaseModel

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

host: str
base_path: str | None
api_path: str | None
api_key: str | None
ssl_verify: bool
classmethod ensure_https_host(values)[source]
property api_endpoint: str
property catalogs: dict[str, MtnaRdsCatalog]

Returns the server’s catalogs, loading them on first access.

refresh_catalogs()[source]

Refreshes and returns the catalog list from the server.

property base_url: str
property api_url: str
property hostname: str
property info: MtnaRdsServerInfo
property explorer_url: str
property tabengine_url: str
api_request(path, method='GET', headers=None, params=None, body_json=None)[source]

Makes an HTTP request to this server’s API.

create_catalog(id, name=None, description=None, is_private=True, lang='en')[source]

Creates a new catalog on the server.

delete_catalog(id)[source]

Deletes a catalog by ID.

delete_data_product(catalog_uri, data_product_uri)[source]

Deletes a data product from a catalog.

get_catalog_by_uri(uri)[source]

Returns a catalog by its URI, or None if not found.

get_catalog_by_id(id)[source]

Returns a catalog by its ID, or None if not found.

get_ddi_codebook(catalog_id, product_id, include_variables=True, include_statistics=False)[source]

Returns the DDI Codebook XML for a data product.

get_import_configuration(catalog_uri, product_uri, file_info)[source]

Returns import configuration for a data product.

get_info()[source]

Returns server information as a dictionary.

get_postman_collection(catalog_id=None, data_product_id=None)[source]

Returns a Postman collection for the server, a catalog, or a data product.

get_process_details(process_id)[source]

Returns details of a server-side process.

import_file(catalog_uri, product_uri, import_configuration)[source]

Imports data into a data product.

is_up()[source]

Returns True if the server is reachable, False otherwise.

upload_file(filepath)[source]

Uploads a file to the server.

wait_for_process(pid, sleep=1, timeout=300, max_get_errors=10)[source]

Waits for a server-side process to complete.

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

class dartfx.mtnards.base.MtnaRdsServerInfo(*, name, released, version)[source]

Bases: BaseModel

name: str
released: str
version: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Catalog

class dartfx.mtnards.MtnaRdsCatalog(*, uri, id, name=None, description=None, reference=None, revisionNumber=None, lastUpdate, isPrivate, dataProducts=None)[source]

Bases: MtnaRdsResource

last_update: str
is_private: bool
data_products: list[MtnaRdsDataProduct] | None
attach_catalog_to_products()[source]
get_data_product_by_uri(uri)[source]

Returns a data product by its URI, or None if not found.

get_data_product_by_id(id)[source]

Returns a data product by its ID, or None if not found.

property data_products_by_id: dict[str, MtnaRdsDataProduct]

Returns data products indexed by their id.

get_ddi_codebook(product_id, include_variables=True, include_statistics=False)[source]

Returns the DDI Codebook XML for a data product in this catalog.

get_import_configuration(product_uri, file_info)[source]

Returns import configuration for a data product.

create_sql_data_product(id, connection_string, table_name, username, password, name=None, description=None, is_private=True, lang='en')[source]

Creates a SQL-backed data product in this catalog.

delete()[source]

Deletes this catalog from the server.

delete_data_product(data_product_uri)[source]

Deletes a data product from this catalog.

get_postman_collection(data_product_id=None)[source]

Returns a Postman collection for this catalog or one of its data product.

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Data Product

class dartfx.mtnards.MtnaRdsDataProduct(*, uri, id, name=None, description=None, reference=None, revisionNumber=None, abbreviation=None, cached=None, doi=None, changeLog=None, citation=None, dataProductType=None, isPrivate=None, keywords=None, lastUpdate=None, provenance=None, urls=None)[source]

Bases: MtnaRdsResource

abbreviation: str | None
cached: bool | None
doi: bool | None
change_log: list[Any] | None
citation: str | None
data_product_type: str | None
is_private: bool | None
keywords: list[str] | None
last_update: str | None
provenance: str | None
urls: list[str] | None
property api_documentation_url: str
property catalog_id: str
property catalog_uri: str
property classifications: dict[str, MtnaRdsClassificationStub | MtnaRdsClassification]
property count_api_url: str
property csv_download_url: str
property explorer_url: str
property code_generators_api_url: str
property metadata_api_url: str
property parquet_download_url: str
property regression_api_url: str
property select_api_url: str
property tabulate_api_url: str
property tabengine_url: str
property variables: dict[str, MtnaRdsVariableStub | MtnaRdsVariable]
property variables_count: int
delete()[source]

Deletes this data product from its catalog.

get_classification_by_uri(uri)[source]

Returns a classification by its URI, or None if not found.

get_classification_by_id(id)[source]

Returns a classification by its ID, or None if not found.

get_classification_variables(classification)[source]

Returns all variables that use the given classification.

get_croissant(include_codes=True, max_codes=100)[source]

Generates a Croissant ML metadata object for this data product.

get_ddi_codebook(include_variables=True, include_statistics=True)[source]

Returns the DDI Codebook XML for this data product.

get_import_configuration(file_info)[source]

Returns import configuration for uploading data into this product.

get_markdown(sections=None, max_codes=10)[source]

Returns the markdown description of the data product.

get_postman_collection()[source]

Returns a Postman collection for this data product.

get_variable_by_uri(uri)[source]

Returns a variable by its URI, or None if not found.

get_variable_by_id(id)[source]

Returns a variable by its ID, or None if not found.

load_metadata()[source]

Loads full metadata (variables and classifications) from the server.

resolve_classifications()[source]

Resolves all classification stubs into full classifications.

resolve_variables()[source]

Resolves all variable stubs into full variables.

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Variable

class dartfx.mtnards.variable.MtnaRdsVariableStub(*, uri, id, name=None, description=None, reference=None, revisionNumber=None)[source]

Bases: MtnaRdsResource

classification_id: str | None
classification_uri: str | None
data_type: str | None
is_dimension: bool | None
is_measure: bool | None
is_required: bool | None
is_weight: bool | None
label: str | None
last_update: str | None
storage_type: str | None
property croissant_data_type: DataType

Returns the Croissant data type for this variable.

property catalog_id: str | None
property catalog_uri: str | None
property classification: MtnaRdsClassificationStub | MtnaRdsClassification | None
property data_product_id: str | None
property data_product_uri: str | None
property is_stub: bool
resolve()[source]

Converts the stub into a detailed variable.

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

class dartfx.mtnards.MtnaRdsVariable(*, uri, id, name=None, description=None, reference=None, revisionNumber=None, classificationId=None, classificationUri=None, dataType=None, isDimension=None, isMeasure=None, isRequired=None, isWeight=None, label=None, lastUpdate=None, storageType=None)[source]

Bases: MtnaRdsVariableStub

decimals: int | None
end_position: int | None
fixed_storage_width: int | None
format: str | None
index: int | None
start_position: int | None
resolve()[source]

Already resolved — returns self.

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Classification

class dartfx.mtnards.MtnaRdsClassificationStub(*, uri, id, name=None, description=None, reference=None, revisionNumber=None)[source]

Bases: MtnaRdsResource

reference: bool | None
revision_number: int | None
code_count: int | None
property codes: list[MtnaRdsClassificationCode]
property is_stub: bool
resolve()[source]

Converts the stub into a detailed classification.

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

class dartfx.mtnards.classification.MtnaRdsClassification(*, uri, id, name=None, description=None, reference=None, revisionNumber=None, code_count=None)[source]

Bases: MtnaRdsClassificationStub

is_private: bool | None
keyword_count: int | None
last_update: str | None
level_count: int | None
resolve()[source]

Already resolved — returns self.

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

class dartfx.mtnards.classification.MtnaRdsClassificationCode(*, uri, id=None, name=None, description=None, reference=None, revisionNumber=None, codeValue=None, isPrivate=None)[source]

Bases: MtnaRdsResource

id: str | None
code_value: str | None
is_private: bool | None
reference: bool | None
model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Process

class dartfx.mtnards.process.MtnaRdsProcess(*, server=None, completed, id, failure=None, methodId, methodName, resourceName, resourceUri, status, completionDetails=None)[source]

Bases: BaseModel

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

server: MtnaRdsServer | None
completed: int
id: str
failure: str | None
method_id: str
method_name: str
resource_name: str
resource_uri: str
status: str
completion_details: Any | None
property completed_successfully: bool
property failed: bool
property in_progress: bool

Base Classes

class dartfx.mtnards.base.MtnaRdsResource(*, uri, id, name=None, description=None, reference=None, revisionNumber=None)[source]

Bases: BaseModel

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

uri: str
id: str
name: str | None
description: str | None
reference: bool | None
revision_number: int | None
__eq__(other)[source]

Two resources are equal if they share the same URI.

__hash__()[source]

Make the object hashable by using the uri so it can be used in sets.

Type Definitions

The module uses type hints extensively. Common types include:

  • str | None - Optional string values

  • dict[str, T] - Dictionary with string keys

  • list[T] - List of objects of type T

  • bool | None - Optional boolean values

All public APIs include complete type hints for parameters and return values.