CommonBaseModel

class CommonBaseModel

Bases: BaseModel

A base model providing common validation logic for all derived models.

adh_data

Dictionary for storing additional data.

Type:

Optional[Dict[str, Any]]

adh_root

Dictionary representing the root of the ADH (Application Data Hierarchy).

Type:

Optional[Dict[str, Any]]

aliases

Dictionary for storing alias to path mappings.

Type:

Optional[Dict[str, str]]

Attributes Summary

model_config

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

Methods Summary

copy_node(source_path, target_path)

Copy a node from a source path to a target path in the ADH.

create_node(path, data)

Create a new node in the ADH at the specified path with the provided data.

delete_node(path)

Delete a node from the ADH at the specified path.

get_node(path)

Retrieve a node from the ADH at the specified path.

link_nodes(source_path, target_path)

Create a link between a source node and a target node in the ADH.

merge_nodes(source_path, target_path)

Merge the data of a source node into a target node in the ADH.

move_node(source_path, target_path)

Move a node from one path to another in the ADH.

search_nodes(filter_criteria)

Search for nodes in the ADH that match the provided filter criteria.

strip_strings(value, info)

Strip leading and trailing whitespace from string fields before further validation.

unlink_nodes(source_path)

Remove the link between a source node and its target node in the ADH.

update_node(path, data)

Update a node in the ADH at the specified path with the provided data.

Attributes Documentation

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}

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

Methods Documentation

copy_node(source_path, target_path)

Copy a node from a source path to a target path in the ADH.

Parameters:
  • source_path (str) – The path of the node to be copied.

  • target_path (str) – The path where the node should be copied to.

Raises:
Return type:

None

create_node(path, data)

Create a new node in the ADH at the specified path with the provided data.

Parameters:
  • path (str) – The path where the new node should be created in the ADH.

  • data (Dict[str, Any]) – A dictionary containing the data to be stored in the new node.

Raises:
  • PathAlreadyExistsError – If the specified path already exists in the ADH.

  • TypeError – If the provided data is not a valid dictionary.

Return type:

None

delete_node(path)

Delete a node from the ADH at the specified path.

Parameters:

path (str) – The path of the node to delete from the ADH.

Raises:

NodeNotFoundError – If the specified path doesn’t exist in the ADH.

Return type:

None

get_node(path)

Retrieve a node from the ADH at the specified path.

Parameters:

path (str) – The path of the node to retrieve from the ADH.

Returns:

The node data as a dictionary if found, or None if the node doesn’t exist.

Return type:

Optional[Dict[str, Any]]

Create a link between a source node and a target node in the ADH.

Parameters:
  • source_path (str) – The path of the source node to link from.

  • target_path (str) – The path of the target node to link to.

Raises:

NodeNotFoundError – If either the source or target path doesn’t exist in the ADH.

Return type:

None

merge_nodes(source_path, target_path)

Merge the data of a source node into a target node in the ADH.

Parameters:
  • source_path (str) – The path of the source node to merge from.

  • target_path (str) – The path of the target node to merge into.

Raises:

NodeNotFoundError – If either the source or target path doesn’t exist in the ADH.

Return type:

None

move_node(source_path, target_path)

Move a node from one path to another in the ADH.

Parameters:
  • source_path (str) – The path of the node to be moved.

  • target_path (str) – The path where the node should be moved to.

Raises:
Return type:

None

search_nodes(filter_criteria)

Search for nodes in the ADH that match the provided filter criteria.

Parameters:

filter_criteria (Dict[str, Any]) – A dictionary specifying the filter criteria for the search.

Returns:

A list of nodes (as dictionaries) that match the filter criteria.

Return type:

List[Dict[str, Any]]

classmethod strip_strings(value, info)

Strip leading and trailing whitespace from string fields before further validation.

Parameters:
  • value (Any) – The value to be validated.

  • info (Any) – The field information.

Returns:

The validated and possibly modified value.

Return type:

Any

Raises:

ValueError – If the field value is an empty string after trimming.

Remove the link between a source node and its target node in the ADH.

Parameters:

source_path (str) – The path of the source node to unlink.

Raises:

NodeNotFoundError – If the specified path is not linked to any other node.

Return type:

None

update_node(path, data)

Update a node in the ADH at the specified path with the provided data.

Parameters:
  • path (str) – The path of the node to update in the ADH.

  • data (Dict[str, Any]) – A dictionary containing the updated data for the node.

Raises:
  • NodeNotFoundError – If the specified path doesn’t exist in the ADH.

  • TypeError – If the provided data is not a valid dictionary.

Return type:

None

Methods:

strip_strings(value, info)

Strip leading and trailing whitespace from string fields before further validation.

create_node(path, data)

Create a new node in the ADH at the specified path with the provided data.

get_node(path)

Retrieve a node from the ADH at the specified path.

search_nodes(filter_criteria)

Search for nodes in the ADH that match the provided filter criteria.

update_node(path, data)

Update a node in the ADH at the specified path with the provided data.

move_node(source_path, target_path)

Move a node from one path to another in the ADH.

delete_node(path)

Delete a node from the ADH at the specified path.

merge_nodes(source_path, target_path)

Merge the data of a source node into a target node in the ADH.

copy_node(source_path, target_path)

Copy a node from a source path to a target path in the ADH.

link_nodes(source_path, target_path)

Create a link between a source node and a target node in the ADH.

unlink_nodes(source_path)

Remove the link between a source node and its target node in the ADH.

Attributes:

__pydantic_setattr_handlers__

__setattr__ handlers.

classmethod strip_strings(value, info)

Strip leading and trailing whitespace from string fields before further validation.

Parameters:
  • value (Any) – The value to be validated.

  • info (Any) – The field information.

Returns:

The validated and possibly modified value.

Return type:

Any

Raises:

ValueError – If the field value is an empty string after trimming.

create_node(path, data)

Create a new node in the ADH at the specified path with the provided data.

Parameters:
  • path (str) – The path where the new node should be created in the ADH.

  • data (Dict[str, Any]) – A dictionary containing the data to be stored in the new node.

Raises:
  • PathAlreadyExistsError – If the specified path already exists in the ADH.

  • TypeError – If the provided data is not a valid dictionary.

Return type:

None

get_node(path)

Retrieve a node from the ADH at the specified path.

Parameters:

path (str) – The path of the node to retrieve from the ADH.

Returns:

The node data as a dictionary if found, or None if the node doesn’t exist.

Return type:

Optional[Dict[str, Any]]

search_nodes(filter_criteria)

Search for nodes in the ADH that match the provided filter criteria.

Parameters:

filter_criteria (Dict[str, Any]) – A dictionary specifying the filter criteria for the search.

Returns:

A list of nodes (as dictionaries) that match the filter criteria.

Return type:

List[Dict[str, Any]]

update_node(path, data)

Update a node in the ADH at the specified path with the provided data.

Parameters:
  • path (str) – The path of the node to update in the ADH.

  • data (Dict[str, Any]) – A dictionary containing the updated data for the node.

Raises:
  • NodeNotFoundError – If the specified path doesn’t exist in the ADH.

  • TypeError – If the provided data is not a valid dictionary.

Return type:

None

move_node(source_path, target_path)

Move a node from one path to another in the ADH.

Parameters:
  • source_path (str) – The path of the node to be moved.

  • target_path (str) – The path where the node should be moved to.

Raises:
Return type:

None

delete_node(path)

Delete a node from the ADH at the specified path.

Parameters:

path (str) – The path of the node to delete from the ADH.

Raises:

NodeNotFoundError – If the specified path doesn’t exist in the ADH.

Return type:

None

merge_nodes(source_path, target_path)

Merge the data of a source node into a target node in the ADH.

Parameters:
  • source_path (str) – The path of the source node to merge from.

  • target_path (str) – The path of the target node to merge into.

Raises:

NodeNotFoundError – If either the source or target path doesn’t exist in the ADH.

Return type:

None

copy_node(source_path, target_path)

Copy a node from a source path to a target path in the ADH.

Parameters:
  • source_path (str) – The path of the node to be copied.

  • target_path (str) – The path where the node should be copied to.

Raises:
Return type:

None

link_nodes(source_path, target_path)

Create a link between a source node and a target node in the ADH.

Parameters:
  • source_path (str) – The path of the source node to link from.

  • target_path (str) – The path of the target node to link to.

Raises:

NodeNotFoundError – If either the source or target path doesn’t exist in the ADH.

Return type:

None

unlink_nodes(source_path)

Remove the link between a source node and its target node in the ADH.

Parameters:

source_path (str) – The path of the source node to unlink.

Raises:

NodeNotFoundError – If the specified path is not linked to any other node.

Return type:

None

__pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}

__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__