ash_model.NProfile¶
- class ash_model.NProfile(node_id=None, **kwargs)[source]¶
A profile holding attributes and computed statistics for a node.
Methods
__init__([node_id])Initialize a new NProfile.
add_attribute(key, value)Add or update a single attribute in the profile.
add_attributes(**kwargs)Add or update multiple attributes in the profile.
add_statistic(attr_name, stat_name, value)Add or update a computed statistic for a given attribute.
attribute_computed_statistics(attr_name)List all computed statistic names for a given attribute.
get_attribute(key)Retrieve the value of a given attribute.
Retrieve all attributes in the profile.
get_statistic(attr_name[, stats_name])Retrieve computed statistics for a given attribute.
has_attribute(key)Check if an attribute exists in the profile.
has_statistic(attr_name, stats_name)Check if a specific statistic exists for a given attribute.
items()Get all attribute key-value pairs as a list.
to_dict()Convert the profile to a dictionary representation.
- add_attributes(**kwargs)[source]¶
Add or update multiple attributes in the profile.
- Parameters:
kwargs (Any) – Key-value pairs of attributes to add.
- Return type:
None
- get_attribute(key)[source]¶
Retrieve the value of a given attribute.
- Parameters:
key (str) – Name of the attribute to retrieve.
- Returns:
The attribute’s value.
- Raises:
ValueError – If the attribute is not present.
- Return type:
- add_statistic(attr_name, stat_name, value)[source]¶
Add or update a computed statistic for a given attribute.
- Parameters:
- Raises:
ValueError – If the attribute is not present in the profile.
- Return type:
None
- get_statistic(attr_name, stats_name=None)[source]¶
Retrieve computed statistics for a given attribute.
- Parameters:
- Returns:
Dictionary of statistic names to their values.
- Raises:
ValueError – If the attribute or statistic is not present.
- Return type:
- has_statistic(attr_name, stats_name)[source]¶
Check if a specific statistic exists for a given attribute.
- Parameters:
- Returns:
True if the statistic exists, False otherwise.
- Raises:
ValueError – If the attribute is not present.
- Return type:
- attribute_computed_statistics(attr_name)[source]¶
List all computed statistic names for a given attribute.
- Parameters:
attr_name (str) – The attribute to query.
- Returns:
List of statistic names.
- Raises:
ValueError – If the attribute is not present or has no statistics.
- Return type: