DataNode
- class ydk.path.DataNode
Class represents a Path API’s DataNode.
Note
The Python DataNode is wrapper for YDK C++ DataNode implementation. No constructor is defined and the user could not instantiate a
DataNode
instance. However, the user could get an instance ofDataNode
throughRootSchemaNode
:>>> from ydk.path import NetconfSession >>> session = NetconfSession('127.0.0.1', 'admin', 'admin', 830) >>> root_schema = session.get_root_schema() # <-- root_schema is an instance of RootSchemaNode >>> bgp = root_schema.create_datanode('openconfig-bgp:bgp') # <-- bgp is an instance of DataNode
- add_annotation(annotation)
This method adds the annotation to this Datanode.
- Parameters:
annotation – (
Annotation
) Annotation to be added.- Raises:
YInvalidArgumentError in case the argument is invalid.
- annotations()
Get the annotations associated with this data node.
- Returns:
List of annotations for this data node.
- Return type:
list of
Annotation
- get_children()
Return list of children for this data node.
- Returns:
List of data node children.
- Return type:
list of
DataNode
- create_datanode(path, value=None)
Create a DataNode corresponding to the path and set its value, if provided.
- Parameters:
path – (
str
) The XPath expression identifying the node.value – (
str
) The value to be set.
- Raises:
YPathError in case the path is invalid; YInvalidArgumentError in case the argument is invalid.
- create_action(path)
Create a DataNode representing a YANG 1.1 action corresponding to the path and set its value, if provided.
- Parameters:
path – (
str
) The XPath expression identifying the node.- Raises:
YPathError in case the path is invalid.
- Raises:
YInvalidArgumentError in case the argument is invalid.
- __call__(service_provider)
Execute/Invoke the DataNode containing a YANG 1.1 action through the given service provider.
- find(path)
Finds nodes that satisfy the given path expression. For details about the path expression see How do I use the Path API?.
- Parameters:
path – (
str
) The path expression.- Returns:
Data node satisfy the path expression supplied.
- Return type:
list of
DataNode
- get_value()
Returns this data node’s value.
- Returns:
Value of this data node.
- Return type:
A Python string
- get_path()
Returns the path expression representing this Node in in the NodeTree.
- Returns:
Path to this data node.
- Return type:
A Python string
- remove_annotation(annotation)
Remove given annotation for this node.
- Parameters:
annotation – (
Annotation
) Annotation to be removed.- Returns:
If
True
the annotation was found and removed,False
otherwise.- Return type:
bool
- get_root()
Get the root data node.
- Returns:
Root data node of current data node.
- Return type:
- get_schema_node()
Get
SchemaNode
associated with thisDataNode
.
- set_value(value)
Note
The DataNode should represent a
leaf
,leaf-list
oranyxml
element for this to work. The value should be the string representation of the type of according to the schema.This method does not validate the value being set.
- Parameters:
value – (
str
) The value to set. This should be the string representation of the YANG type.- Raises:
YInvalidArgumentError if the its value cannot be set (for example it represents a container).