Documentation ¶
Index ¶
- func Capabilities(namespace, modulename, revision, feature string)
- func Delete(root DataNode, path string) error
- func Diff(node1, node2 DataNode) ([]DataNode, []DataNode, []DataNode)
- func DiffUpdated(node1, node2 DataNode, disDupCmp bool) ([]DataNode, []DataNode)
- func Equal(node1, node2 DataNode) bool
- func Error(etag ErrorTag, err error) error
- func Errorf(etag ErrorTag, eMessage string, arg ...interface{}) error
- func FindAllPossiblePath(schema *SchemaNode, spath string) []string
- func FindValue(root DataNode, path string) ([]interface{}, error)
- func FindValueString(root DataNode, path string) ([]string, error)
- func FindYangFiles(files []string) ([]string, error)
- func GeneratePath(schema *SchemaNode, keyPrint, prefixTagging bool) string
- func GetKeyValues(node DataNode) ([]string, []string)
- func GetOrNew(root DataNode, path string) (node DataNode, created DataNode, err error)
- func IsCreatedWithDefault(schema *SchemaNode) bool
- func IsValid(node DataNode) bool
- func JSONValueToString(jval interface{}) (string, error)
- func MarshalJSON(node DataNode, option ...Option) ([]byte, error)
- func MarshalJSONIndent(node DataNode, prefix, indent string, option ...Option) ([]byte, error)
- func MarshalXML(node DataNode, option ...Option) ([]byte, error)
- func MarshalXMLIndent(node DataNode, prefix, indent string, option ...Option) ([]byte, error)
- func MarshalYAML(node DataNode, option ...Option) ([]byte, error)
- func MarshalYAMLIndent(node DataNode, prefix, indent string, option ...Option) ([]byte, error)
- func Merge(root DataNode, path string, src DataNode) error
- func Move(src, dest DataNode) error
- func NewErrorf(etag ErrorTag, eMessage string, arg ...interface{}) error
- func PathMap(node []DataNode) map[string]DataNode
- func RemovePredicates(path *string) (string, bool)
- func Replace(root DataNode, path string, new DataNode) error
- func SetValue(root DataNode, path string, opt *EditOption, value ...interface{}) error
- func SetValueString(root DataNode, path string, opt *EditOption, value ...string) error
- func SplitQName(qname *string) (string, string)
- func TokenizeXPathExpr(token []string, s *string, pos int) ([]string, int, error)
- func Traverse(node DataNode, traverser func(DataNode, TrvsCallOption) error, ...) error
- func UnmarshalJSON(node DataNode, jbytes []byte, option ...Option) error
- func UnmarshalXML(node DataNode, data []byte, option ...Option) error
- func UnmarshalYAML(node DataNode, in []byte, option ...Option) error
- func Unzip(gzj []byte) ([]byte, error)
- func Validate(node DataNode) []error
- func ValueStringToValue(schema *SchemaNode, typ *yang.YangType, value string) (interface{}, error)
- func ValueToValidTypeValue(schema *SchemaNode, typ *yang.YangType, value interface{}) (interface{}, error)
- func ValueToValueString(value interface{}) string
- type ConfigOnly
- type DataBranch
- func (branch *DataBranch) Child(index int) DataNode
- func (branch *DataBranch) Children() []DataNode
- func (branch *DataBranch) Create(id string, value ...string) (DataNode, error)
- func (branch *DataBranch) CreateByMap(pmap map[string]interface{}) error
- func (branch *DataBranch) Delete(child DataNode) error
- func (branch *DataBranch) Exist(id string) bool
- func (branch *DataBranch) Get(id string) DataNode
- func (branch *DataBranch) GetAll(id string) []DataNode
- func (branch *DataBranch) GetOrNew(id string, insert InsertOption) (DataNode, bool, error)
- func (branch *DataBranch) GetValue(id string) interface{}
- func (branch *DataBranch) GetValueString(id string) string
- func (branch *DataBranch) HasMultipleValues() bool
- func (branch *DataBranch) HasStateNode() bool
- func (branch *DataBranch) HasValueString(value string) bool
- func (branch *DataBranch) ID() string
- func (branch *DataBranch) Index(id string) int
- func (branch *DataBranch) Insert(child DataNode, insert InsertOption) (DataNode, error)
- func (branch *DataBranch) IsBranchNode() bool
- func (branch *DataBranch) IsContainer() bool
- func (branch *DataBranch) IsDataNode()
- func (branch *DataBranch) IsDuplicatableNode() bool
- func (branch *DataBranch) IsLeaf() bool
- func (branch *DataBranch) IsLeafList() bool
- func (branch *DataBranch) IsLeafNode() bool
- func (branch *DataBranch) IsList() bool
- func (branch *DataBranch) IsListableNode() bool
- func (branch *DataBranch) IsNil() bool
- func (branch *DataBranch) IsStateNode() bool
- func (branch *DataBranch) Len() int
- func (branch *DataBranch) Lookup(prefix string) []DataNode
- func (branch *DataBranch) MarshalJSON() ([]byte, error)
- func (branch *DataBranch) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (branch *DataBranch) MarshalYAML() (interface{}, error)
- func (branch *DataBranch) Merge(src DataNode) error
- func (branch *DataBranch) Metadata() map[string]DataNode
- func (branch *DataBranch) Name() string
- func (branch *DataBranch) Parent() DataNode
- func (branch *DataBranch) Path() string
- func (branch *DataBranch) PathTo(descendant DataNode) string
- func (branch *DataBranch) QName(rfc7951 bool) (string, bool)
- func (branch *DataBranch) Remove() error
- func (branch *DataBranch) Replace(src DataNode) error
- func (branch *DataBranch) Schema() *SchemaNode
- func (branch *DataBranch) SetMetadata(name string, value ...interface{}) error
- func (branch *DataBranch) SetMetadataString(name string, value ...string) error
- func (branch *DataBranch) SetValue(value ...interface{}) error
- func (branch *DataBranch) SetValueSafe(value ...interface{}) error
- func (branch *DataBranch) SetValueString(value ...string) error
- func (branch *DataBranch) SetValueStringSafe(value ...string) error
- func (branch *DataBranch) String() string
- func (branch *DataBranch) UnmarshalJSON(jbytes []byte) error
- func (branch *DataBranch) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (branch *DataBranch) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (branch *DataBranch) UnsetMetadata(name string) error
- func (branch *DataBranch) UnsetValue(value ...interface{}) error
- func (branch *DataBranch) UnsetValueString(value ...string) error
- func (branch *DataBranch) Update(id string, value ...string) (DataNode, error)
- func (branch *DataBranch) UpdateByMap(pmap map[string]interface{}) error
- func (branch *DataBranch) Value() interface{}
- func (branch *DataBranch) ValueString() string
- func (branch *DataBranch) Values() []interface{}
- type DataLeaf
- func (leaf *DataLeaf) Child(index int) DataNode
- func (leaf *DataLeaf) Children() []DataNode
- func (leaf *DataLeaf) Create(id string, value ...string) (DataNode, error)
- func (leaf *DataLeaf) CreateByMap(pmap map[string]interface{}) error
- func (leaf *DataLeaf) Delete(child DataNode) error
- func (leaf *DataLeaf) Exist(id string) bool
- func (leaf *DataLeaf) Get(id string) DataNode
- func (leaf *DataLeaf) GetAll(id string) []DataNode
- func (leaf *DataLeaf) GetOrNew(id string, insert InsertOption) (DataNode, bool, error)
- func (leaf *DataLeaf) GetValue(id string) interface{}
- func (leaf *DataLeaf) GetValueString(id string) string
- func (leaf *DataLeaf) HasMultipleValues() bool
- func (leaf *DataLeaf) HasStateNode() bool
- func (leaf *DataLeaf) HasValueString(value string) bool
- func (leaf *DataLeaf) ID() string
- func (leaf *DataLeaf) Index(id string) int
- func (leaf *DataLeaf) Insert(child DataNode, insert InsertOption) (DataNode, error)
- func (leaf *DataLeaf) IsBranchNode() bool
- func (leaf *DataLeaf) IsContainer() bool
- func (leaf *DataLeaf) IsDataNode()
- func (leaf *DataLeaf) IsDuplicatableNode() bool
- func (leaf *DataLeaf) IsLeaf() bool
- func (leaf *DataLeaf) IsLeafList() bool
- func (leaf *DataLeaf) IsLeafNode() bool
- func (leaf *DataLeaf) IsList() bool
- func (leaf *DataLeaf) IsListableNode() bool
- func (leaf *DataLeaf) IsNil() bool
- func (leaf *DataLeaf) IsStateNode() bool
- func (leaf *DataLeaf) Len() int
- func (leaf *DataLeaf) Lookup(prefix string) []DataNode
- func (leaf *DataLeaf) MarshalJSON() ([]byte, error)
- func (leaf *DataLeaf) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (leaf *DataLeaf) MarshalYAML() (interface{}, error)
- func (leaf *DataLeaf) Merge(src DataNode) error
- func (leaf *DataLeaf) Metadata() map[string]DataNode
- func (leaf *DataLeaf) Name() string
- func (leaf *DataLeaf) Parent() DataNode
- func (leaf *DataLeaf) Path() string
- func (leaf *DataLeaf) PathTo(descendant DataNode) string
- func (leaf *DataLeaf) QName(rfc7951 bool) (string, bool)
- func (leaf *DataLeaf) Remove() error
- func (leaf *DataLeaf) Replace(src DataNode) error
- func (leaf *DataLeaf) Schema() *SchemaNode
- func (leaf *DataLeaf) SetMetadata(name string, value ...interface{}) error
- func (leaf *DataLeaf) SetMetadataString(name string, value ...string) error
- func (leaf *DataLeaf) SetValue(value ...interface{}) error
- func (leaf *DataLeaf) SetValueSafe(value ...interface{}) error
- func (leaf *DataLeaf) SetValueString(value ...string) error
- func (leaf *DataLeaf) SetValueStringSafe(value ...string) error
- func (leaf *DataLeaf) String() string
- func (leaf *DataLeaf) UnmarshalJSON(jbytes []byte) error
- func (leaf *DataLeaf) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (leaf *DataLeaf) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (leaf *DataLeaf) UnsetMetadata(name string) error
- func (leaf *DataLeaf) UnsetValue(value ...interface{}) error
- func (leaf *DataLeaf) UnsetValueString(value ...string) error
- func (leaf *DataLeaf) Update(id string, value ...string) (DataNode, error)
- func (leaf *DataLeaf) UpdateByMap(pmap map[string]interface{}) error
- func (leaf *DataLeaf) Value() interface{}
- func (leaf *DataLeaf) ValueString() string
- func (leaf *DataLeaf) Values() []interface{}
- type DataLeafList
- func (leaflist *DataLeafList) Child(index int) DataNode
- func (leaflist *DataLeafList) Children() []DataNode
- func (leaflist *DataLeafList) Create(id string, value ...string) (DataNode, error)
- func (leaflist *DataLeafList) CreateByMap(pmap map[string]interface{}) error
- func (leaflist *DataLeafList) Delete(child DataNode) error
- func (leaflist *DataLeafList) Exist(id string) bool
- func (leaflist *DataLeafList) Get(id string) DataNode
- func (leaflist *DataLeafList) GetAll(id string) []DataNode
- func (leaflist *DataLeafList) GetOrNew(id string, insert InsertOption) (DataNode, bool, error)
- func (leaflist *DataLeafList) GetValue(id string) interface{}
- func (leaflist *DataLeafList) GetValueString(id string) string
- func (leaflist *DataLeafList) HasMultipleValues() bool
- func (leaflist *DataLeafList) HasStateNode() bool
- func (leaflist *DataLeafList) HasValueString(value string) bool
- func (leaflist *DataLeafList) ID() string
- func (leaflist *DataLeafList) Index(id string) int
- func (leaflist *DataLeafList) Insert(child DataNode, insert InsertOption) (DataNode, error)
- func (leaflist *DataLeafList) IsBranchNode() bool
- func (leaflist *DataLeafList) IsContainer() bool
- func (leaflist *DataLeafList) IsDataNode()
- func (leaflist *DataLeafList) IsDuplicatableNode() bool
- func (leaflist *DataLeafList) IsLeaf() bool
- func (leaflist *DataLeafList) IsLeafList() bool
- func (leaflist *DataLeafList) IsLeafNode() bool
- func (leaflist *DataLeafList) IsList() bool
- func (leaflist *DataLeafList) IsListableNode() bool
- func (leaflist *DataLeafList) IsNil() bool
- func (leaflist *DataLeafList) IsStateNode() bool
- func (leaflist *DataLeafList) Len() int
- func (leaflist *DataLeafList) Lookup(prefix string) []DataNode
- func (leaflist *DataLeafList) MarshalJSON() ([]byte, error)
- func (leaflist *DataLeafList) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (leaflist *DataLeafList) MarshalYAML() (interface{}, error)
- func (leaflist *DataLeafList) Merge(src DataNode) error
- func (leaflist *DataLeafList) Metadata() map[string]DataNode
- func (leaflist *DataLeafList) Name() string
- func (leaflist *DataLeafList) Parent() DataNode
- func (leaflist *DataLeafList) Path() string
- func (leaflist *DataLeafList) PathTo(descendant DataNode) string
- func (leaflist *DataLeafList) QName(rfc7951 bool) (string, bool)
- func (leaflist *DataLeafList) Remove() error
- func (leaflist *DataLeafList) Replace(src DataNode) error
- func (leaflist *DataLeafList) Schema() *SchemaNode
- func (leaflist *DataLeafList) SetMetadata(name string, value ...interface{}) error
- func (leaflist *DataLeafList) SetMetadataString(name string, value ...string) error
- func (leaflist *DataLeafList) SetValue(value ...interface{}) error
- func (leaflist *DataLeafList) SetValueSafe(value ...interface{}) error
- func (leaflist *DataLeafList) SetValueString(value ...string) error
- func (leaflist *DataLeafList) SetValueStringSafe(value ...string) error
- func (leaflist *DataLeafList) String() string
- func (leaflist *DataLeafList) UnmarshalJSON(jbytes []byte) error
- func (leaflist *DataLeafList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (leaflist *DataLeafList) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (leaflist *DataLeafList) UnsetMetadata(name string) error
- func (leaflist *DataLeafList) UnsetValue(value ...interface{}) error
- func (leaflist *DataLeafList) UnsetValueString(value ...string) error
- func (leaflist *DataLeafList) Update(id string, value ...string) (DataNode, error)
- func (leaflist *DataLeafList) UpdateByMap(pmap map[string]interface{}) error
- func (leaflist *DataLeafList) Value() interface{}
- func (leaflist *DataLeafList) ValueString() string
- func (leaflist *DataLeafList) Values() []interface{}
- type DataNode
- func Clone(src DataNode) DataNode
- func DiffCreated(node1, node2 DataNode, disDupCmp bool) []DataNode
- func Find(root DataNode, path string, option ...Option) ([]DataNode, error)
- func FindAllInRoute(path string) []DataNode
- func New(schema *SchemaNode) (DataNode, error)
- func NewCollector() DataNode
- func NewWithID(schema *SchemaNode, id string) (DataNode, error)
- func NewWithValue(schema *SchemaNode, value ...interface{}) (DataNode, error)
- func NewWithValueString(schema *SchemaNode, value ...string) (DataNode, error)
- type DataNodeGroup
- func (group *DataNodeGroup) Child(index int) DataNode
- func (group *DataNodeGroup) Children() []DataNode
- func (group *DataNodeGroup) Create(id string, value ...string) (DataNode, error)
- func (group *DataNodeGroup) CreateByMap(pmap map[string]interface{}) error
- func (group *DataNodeGroup) Delete(child DataNode) error
- func (group *DataNodeGroup) Exist(id string) bool
- func (group *DataNodeGroup) Get(id string) DataNode
- func (group *DataNodeGroup) GetAll(id string) []DataNode
- func (group *DataNodeGroup) GetOrNew(id string, insert InsertOption) (DataNode, bool, error)
- func (group *DataNodeGroup) GetValue(id string) interface{}
- func (group *DataNodeGroup) GetValueString(id string) string
- func (group *DataNodeGroup) HasMultipleValues() bool
- func (group *DataNodeGroup) HasStateNode() bool
- func (group *DataNodeGroup) HasValueString(value string) bool
- func (group *DataNodeGroup) ID() string
- func (group *DataNodeGroup) Index(id string) int
- func (group *DataNodeGroup) Insert(child DataNode, insert InsertOption) (DataNode, error)
- func (group *DataNodeGroup) IsBranchNode() bool
- func (group *DataNodeGroup) IsContainer() bool
- func (group *DataNodeGroup) IsDataNode()
- func (group *DataNodeGroup) IsDuplicatableNode() bool
- func (group *DataNodeGroup) IsLeaf() bool
- func (group *DataNodeGroup) IsLeafList() bool
- func (group *DataNodeGroup) IsLeafNode() bool
- func (group *DataNodeGroup) IsList() bool
- func (group *DataNodeGroup) IsListableNode() bool
- func (group *DataNodeGroup) IsNil() bool
- func (group *DataNodeGroup) IsStateNode() bool
- func (group *DataNodeGroup) Len() int
- func (group *DataNodeGroup) Lookup(prefix string) []DataNode
- func (group *DataNodeGroup) MarshalJSON() ([]byte, error)
- func (group *DataNodeGroup) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (group *DataNodeGroup) MarshalYAML() (interface{}, error)
- func (group *DataNodeGroup) Merge(src DataNode) error
- func (group *DataNodeGroup) Metadata() map[string]DataNode
- func (group *DataNodeGroup) Name() string
- func (group *DataNodeGroup) Parent() DataNode
- func (group *DataNodeGroup) Path() string
- func (group *DataNodeGroup) PathTo(descendant DataNode) string
- func (group *DataNodeGroup) QName(rfc7951 bool) (string, bool)
- func (group *DataNodeGroup) Remove() error
- func (group *DataNodeGroup) Replace(src DataNode) error
- func (group *DataNodeGroup) Schema() *SchemaNode
- func (group *DataNodeGroup) SetMetadata(name string, value ...interface{}) error
- func (group *DataNodeGroup) SetMetadataString(name string, value ...string) error
- func (group *DataNodeGroup) SetValue(value ...interface{}) error
- func (group *DataNodeGroup) SetValueSafe(value ...interface{}) error
- func (group *DataNodeGroup) SetValueString(value ...string) error
- func (group *DataNodeGroup) SetValueStringSafe(value ...string) error
- func (group *DataNodeGroup) String() string
- func (group *DataNodeGroup) UnmarshalJSON(jbytes []byte) error
- func (group *DataNodeGroup) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (group *DataNodeGroup) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (group *DataNodeGroup) UnsetMetadata(name string) error
- func (group *DataNodeGroup) UnsetValue(value ...interface{}) error
- func (group *DataNodeGroup) UnsetValueString(value ...string) error
- func (group *DataNodeGroup) Update(id string, value ...string) (DataNode, error)
- func (group *DataNodeGroup) UpdateByMap(pmap map[string]interface{}) error
- func (group *DataNodeGroup) Value() interface{}
- func (group *DataNodeGroup) ValueString() string
- func (group *DataNodeGroup) Values() []interface{}
- type EditOp
- type EditOption
- func (edit *EditOption) GetCallback() func(EditOp, []DataNode, []DataNode) error
- func (edit *EditOption) GetFailureRecovery() bool
- func (edit *EditOption) GetInsertOption() InsertOption
- func (edit *EditOption) GetOperation() EditOp
- func (edit EditOption) IsOption()
- func (edit *EditOption) String() string
- type ErrorTag
- type ErrorType
- type Extension
- type HasState
- type InsertOption
- type InsertToAfter
- type InsertToBefore
- type InsertToFirst
- type InsertToLast
- type InternalFormat
- type Metadata
- type MultipleError
- type NodeSelect
- type Option
- type PathNode
- type RFC7951Format
- type RFC7951S
- type ReadCallback
- type RepresentItself
- type SchemaNode
- func (schema *SchemaNode) Append(changeParent bool, nodes ...*SchemaNode) error
- func (schema *SchemaNode) FindSchema(path string) *SchemaNode
- func (schema *SchemaNode) GenerateID(pmap map[string]interface{}) (string, bool, bool)
- func (schema *SchemaNode) GetMust() []*yang.Must
- func (schema *SchemaNode) GetNamespaceAndPrefix() (string, string)
- func (schema *SchemaNode) GetQName(rfc7951 bool) (string, bool)
- func (schema *SchemaNode) GetRootSchema() *SchemaNode
- func (schema *SchemaNode) GetSchema(name string) *SchemaNode
- func (schema *SchemaNode) GetYangLibrary() DataNode
- func (schema *SchemaNode) HasRPCInput() bool
- func (schema *SchemaNode) HasRPCOutput() bool
- func (schema *SchemaNode) IsAnyData() bool
- func (schema *SchemaNode) IsDuplicatable() bool
- func (schema *SchemaNode) IsDuplicatableList() bool
- func (schema *SchemaNode) IsListHasKey() bool
- func (schema *SchemaNode) IsListable() bool
- func (schema *SchemaNode) IsOrderedByUser() bool
- func (schema *SchemaNode) IsRPC() bool
- func (schema *SchemaNode) IsSingleLeafList() bool
- func (schema *SchemaNode) IsValidQName(qname *string, rfc7951 bool) bool
- func (schema *SchemaNode) Path() string
- func (schema *SchemaNode) QualifiedPath(RFC7951format bool) string
- func (schema *SchemaNode) String() string
- func (schema *SchemaNode) ValueToJSONBytes(typ *yang.YangType, value interface{}, rfc7951format bool) ([]byte, error)
- func (schema *SchemaNode) ValueToQValue(typ *yang.YangType, value interface{}, rfc7951format bool) (interface{}, error)
- func (schema *SchemaNode) ValueToYAMLBytes(typ *yang.YangType, value interface{}, rfc7951 bool) ([]byte, error)
- type StateOnly
- type TrvsCallOption
- type UseXPath
- type YANGTreeOption
- type YError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Capabilities ¶
func Capabilities(namespace, modulename, revision, feature string)
func Delete ¶
Delete() deletes the target data node in the path if the value is not specified. If the value is specified, only the value is deleted.
func Diff ¶
Diff() returns differences between nodes. It returns all created, replaced and deleted nodes in node2 (including itself) against node1.
func DiffUpdated ¶
DiffUpdated() returns created or updated nodes. It returns all created, replaced nodes in node2 (including itself) against node1. The deleted nodes can be obtained by the reverse input. if disDupCmp (disable duplicatable node comparison) is set, duplicatable nodes are not compared.
func FindAllPossiblePath ¶
func FindAllPossiblePath(schema *SchemaNode, spath string) []string
FindAllPossiblePath finds all possible paths. It resolves the gNMI path wildcards.
func FindValueString ¶
FindValueString() finds all data in the path and then returns their values by string.
func FindYangFiles ¶
func GeneratePath ¶
func GeneratePath(schema *SchemaNode, keyPrint, prefixTagging bool) string
func GetKeyValues ¶
Get key-value pairs of the list data node.
func GetOrNew ¶
GetOrNew returns the target data node and the ancestor node that was created first along the path from the root.
func IsCreatedWithDefault ¶
func IsCreatedWithDefault(schema *SchemaNode) bool
func JSONValueToString ¶
JSONValueToString() returns a string value from the json scalar value that is unmarshalled by json.Unmarshal()
func MarshalJSON ¶
MarshalJSON returns the JSON bytes of a data node.
func MarshalJSONIndent ¶
MarshalJSONIndent is like Marshal but applies an indent and a prefix to format the output.
func MarshalXML ¶
MarshalXML returns the XML bytes of a data node.
func MarshalXMLIndent ¶
MarshalXMLIndent returns the XML bytes of a data node.
func MarshalYAML ¶
MarshalYAML encodes the data node to a YAML document with a number of options. The options available are [ConfigOnly, StateOnly, RFC7951Format, InternalFormat].
func MarshalYAMLIndent ¶
MarshalYAMLIndent encodes the data node to a YAML document with a number of options. The options available are [ConfigOnly, StateOnly, RFC7951Format, InternalFormat].
func Merge ¶
Merge() merges the src data node to the target data node in the path. The target data node is updated using the src data node.
func Move ¶
Move() moves the src data node to the dest node. The dest node must have the same schema of the src parent nodes.
func RemovePredicates ¶
func SetValue ¶
func SetValue(root DataNode, path string, opt *EditOption, value ...interface{}) error
SetValue sets a value to the target DataNode in the path. If the target DataNode is a branch node, the value must be map[interface{}]interface{} or map[string]interface{}. If the target data node is a leaf or a leaf-list node, the value should be the value.
func SetValueString ¶
func SetValueString(root DataNode, path string, opt *EditOption, value ...string) error
SetValueString sets a value to the target DataNode in the path. If the target DataNode is a branch node, the value must be json or json_ietf bytes. If the target data node is a leaf or a leaf-list node, the value should be string.
func SplitQName ¶
SplitQName splits the namespace qualified name to prefix and node name.
func TokenizeXPathExpr ¶
func Traverse ¶
func Traverse(node DataNode, traverser func(DataNode, TrvsCallOption) error, calledAt TrvsCallOption, depth int, leafOnly bool) error
Traverse() loops the node's all children, descendants and itself to execute traverser() at each node.
func UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result in the data node.
func UnmarshalXML ¶
UnmarshalXML updates the data node using an XML document.
func UnmarshalYAML ¶
UnmarshalYAML updates the data node using YAML-encoded data.
func ValueStringToValue ¶
func ValueStringToValue(schema *SchemaNode, typ *yang.YangType, value string) (interface{}, error)
ValueStringToValue() converts a string value to an yangtree value It also check the range, length and pattern of the schema.
func ValueToValidTypeValue ¶
func ValueToValidTypeValue(schema *SchemaNode, typ *yang.YangType, value interface{}) (interface{}, error)
ValueToValidTypeValue() check the range, length and pattern of the schema.
func ValueToValueString ¶
func ValueToValueString(value interface{}) string
ValueToValueString() converts a golang value to the string value.
Types ¶
type ConfigOnly ¶
type ConfigOnly struct{}
ConfigOnly option is used to find config data nodes that have "config true" statement.
func (ConfigOnly) IsOption ¶
func (f ConfigOnly) IsOption()
func (ConfigOnly) String ¶
func (f ConfigOnly) String() string
type DataBranch ¶
type DataBranch struct {
// contains filtered or unexported fields
}
The node structure of yangtree for container and list data nodes.
func (*DataBranch) Child ¶
func (branch *DataBranch) Child(index int) DataNode
func (*DataBranch) Children ¶
func (branch *DataBranch) Children() []DataNode
func (*DataBranch) Create ¶
func (branch *DataBranch) Create(id string, value ...string) (DataNode, error)
func (*DataBranch) CreateByMap ¶
func (branch *DataBranch) CreateByMap(pmap map[string]interface{}) error
CreateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataBranch) Delete ¶
func (branch *DataBranch) Delete(child DataNode) error
func (*DataBranch) Exist ¶
func (branch *DataBranch) Exist(id string) bool
func (*DataBranch) Get ¶
func (branch *DataBranch) Get(id string) DataNode
func (*DataBranch) GetAll ¶
func (branch *DataBranch) GetAll(id string) []DataNode
func (*DataBranch) GetOrNew ¶
func (branch *DataBranch) GetOrNew(id string, insert InsertOption) (DataNode, bool, error)
GetOrNew() gets or creates a node having the id and returns the found or created node with the boolean value that indicates the returned node is created.
func (*DataBranch) GetValue ¶
func (branch *DataBranch) GetValue(id string) interface{}
func (*DataBranch) GetValueString ¶
func (branch *DataBranch) GetValueString(id string) string
func (*DataBranch) HasMultipleValues ¶
func (branch *DataBranch) HasMultipleValues() bool
func (*DataBranch) HasStateNode ¶
func (branch *DataBranch) HasStateNode() bool
func (*DataBranch) HasValueString ¶
func (branch *DataBranch) HasValueString(value string) bool
func (*DataBranch) ID ¶
func (branch *DataBranch) ID() string
func (*DataBranch) Index ¶
func (branch *DataBranch) Index(id string) int
func (*DataBranch) Insert ¶
func (branch *DataBranch) Insert(child DataNode, insert InsertOption) (DataNode, error)
func (*DataBranch) IsBranchNode ¶
func (branch *DataBranch) IsBranchNode() bool
func (*DataBranch) IsContainer ¶
func (branch *DataBranch) IsContainer() bool
func (*DataBranch) IsDataNode ¶
func (branch *DataBranch) IsDataNode()
func (*DataBranch) IsDuplicatableNode ¶
func (branch *DataBranch) IsDuplicatableNode() bool
func (*DataBranch) IsLeaf ¶
func (branch *DataBranch) IsLeaf() bool
func (*DataBranch) IsLeafList ¶
func (branch *DataBranch) IsLeafList() bool
func (*DataBranch) IsLeafNode ¶
func (branch *DataBranch) IsLeafNode() bool
func (*DataBranch) IsList ¶
func (branch *DataBranch) IsList() bool
func (*DataBranch) IsListableNode ¶
func (branch *DataBranch) IsListableNode() bool
func (*DataBranch) IsNil ¶
func (branch *DataBranch) IsNil() bool
func (*DataBranch) IsStateNode ¶
func (branch *DataBranch) IsStateNode() bool
func (*DataBranch) Len ¶
func (branch *DataBranch) Len() int
func (*DataBranch) Lookup ¶
func (branch *DataBranch) Lookup(prefix string) []DataNode
func (*DataBranch) MarshalJSON ¶
func (branch *DataBranch) MarshalJSON() ([]byte, error)
func (*DataBranch) MarshalXML ¶
func (branch *DataBranch) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*DataBranch) MarshalYAML ¶
func (branch *DataBranch) MarshalYAML() (interface{}, error)
func (*DataBranch) Merge ¶
func (branch *DataBranch) Merge(src DataNode) error
Merge() merges the src data node to the branch data node.
func (*DataBranch) Metadata ¶
func (branch *DataBranch) Metadata() map[string]DataNode
func (*DataBranch) Name ¶
func (branch *DataBranch) Name() string
func (*DataBranch) Parent ¶
func (branch *DataBranch) Parent() DataNode
func (*DataBranch) Path ¶
func (branch *DataBranch) Path() string
func (*DataBranch) PathTo ¶
func (branch *DataBranch) PathTo(descendant DataNode) string
func (*DataBranch) Remove ¶
func (branch *DataBranch) Remove() error
func (*DataBranch) Replace ¶
func (branch *DataBranch) Replace(src DataNode) error
Replace() replaces itself to the src node.
func (*DataBranch) Schema ¶
func (branch *DataBranch) Schema() *SchemaNode
func (*DataBranch) SetMetadata ¶
func (branch *DataBranch) SetMetadata(name string, value ...interface{}) error
SetMetadata() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadata("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataBranch) SetMetadataString ¶
func (branch *DataBranch) SetMetadataString(name string, value ...string) error
SetMetadataString() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadataString("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataBranch) SetValue ¶
func (branch *DataBranch) SetValue(value ...interface{}) error
func (*DataBranch) SetValueSafe ¶
func (branch *DataBranch) SetValueSafe(value ...interface{}) error
func (*DataBranch) SetValueString ¶
func (branch *DataBranch) SetValueString(value ...string) error
func (*DataBranch) SetValueStringSafe ¶
func (branch *DataBranch) SetValueStringSafe(value ...string) error
func (*DataBranch) String ¶
func (branch *DataBranch) String() string
func (*DataBranch) UnmarshalJSON ¶
func (branch *DataBranch) UnmarshalJSON(jbytes []byte) error
func (*DataBranch) UnmarshalXML ¶
func (branch *DataBranch) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
func (*DataBranch) UnmarshalYAML ¶
func (branch *DataBranch) UnmarshalYAML(unmarshal func(interface{}) error) error
func (*DataBranch) UnsetMetadata ¶
func (branch *DataBranch) UnsetMetadata(name string) error
UnsetMetadata() remove a metadata.
func (*DataBranch) UnsetValue ¶
func (branch *DataBranch) UnsetValue(value ...interface{}) error
func (*DataBranch) UnsetValueString ¶
func (branch *DataBranch) UnsetValueString(value ...string) error
func (*DataBranch) Update ¶
func (branch *DataBranch) Update(id string, value ...string) (DataNode, error)
func (*DataBranch) UpdateByMap ¶
func (branch *DataBranch) UpdateByMap(pmap map[string]interface{}) error
UpdateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataBranch) Value ¶
func (branch *DataBranch) Value() interface{}
func (*DataBranch) ValueString ¶
func (branch *DataBranch) ValueString() string
func (*DataBranch) Values ¶
func (branch *DataBranch) Values() []interface{}
type DataLeaf ¶
type DataLeaf struct {
// contains filtered or unexported fields
}
DataLeaf - The node structure of yangtree for list or leaf-list nodes.
func (*DataLeaf) CreateByMap ¶
CreateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataLeaf) GetOrNew ¶
GetOrNew() gets or creates a node having the id and returns the found or created node with the boolean value that indicates the returned node is created.
func (*DataLeaf) GetValueString ¶
func (*DataLeaf) HasMultipleValues ¶
func (*DataLeaf) HasStateNode ¶
func (*DataLeaf) HasValueString ¶
func (*DataLeaf) Insert ¶
func (leaf *DataLeaf) Insert(child DataNode, insert InsertOption) (DataNode, error)
func (*DataLeaf) IsBranchNode ¶
func (*DataLeaf) IsContainer ¶
func (*DataLeaf) IsDataNode ¶
func (leaf *DataLeaf) IsDataNode()
func (*DataLeaf) IsDuplicatableNode ¶
func (*DataLeaf) IsLeafList ¶
func (*DataLeaf) IsLeafNode ¶
func (*DataLeaf) IsListableNode ¶
func (*DataLeaf) IsStateNode ¶
func (*DataLeaf) MarshalJSON ¶
func (*DataLeaf) MarshalXML ¶
func (*DataLeaf) MarshalYAML ¶
func (*DataLeaf) Schema ¶
func (leaf *DataLeaf) Schema() *SchemaNode
func (*DataLeaf) SetMetadata ¶
SetMetadata() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadata("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataLeaf) SetMetadataString ¶
SetMetadataString() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadataString("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataLeaf) SetValueSafe ¶
func (*DataLeaf) SetValueString ¶
func (*DataLeaf) SetValueStringSafe ¶
func (*DataLeaf) UnmarshalJSON ¶
func (*DataLeaf) UnmarshalXML ¶
func (*DataLeaf) UnmarshalYAML ¶
func (*DataLeaf) UnsetMetadata ¶
UnsetMetadata() remove a metadata.
func (*DataLeaf) UnsetValue ¶
func (*DataLeaf) UnsetValueString ¶
func (*DataLeaf) UpdateByMap ¶
UpdateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataLeaf) ValueString ¶
type DataLeafList ¶
type DataLeafList struct {
// contains filtered or unexported fields
}
DataLeafList - The node structure of yangtree for leaf-list nodes. By default, it is not used for the data node representation of the leaf-list nodes. It will be only used when YANGTreeOption.SingleLeafList is enabled.
func (*DataLeafList) Child ¶
func (leaflist *DataLeafList) Child(index int) DataNode
func (*DataLeafList) Children ¶
func (leaflist *DataLeafList) Children() []DataNode
func (*DataLeafList) Create ¶
func (leaflist *DataLeafList) Create(id string, value ...string) (DataNode, error)
func (*DataLeafList) CreateByMap ¶
func (leaflist *DataLeafList) CreateByMap(pmap map[string]interface{}) error
CreateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataLeafList) Delete ¶
func (leaflist *DataLeafList) Delete(child DataNode) error
func (*DataLeafList) Exist ¶
func (leaflist *DataLeafList) Exist(id string) bool
func (*DataLeafList) Get ¶
func (leaflist *DataLeafList) Get(id string) DataNode
func (*DataLeafList) GetAll ¶
func (leaflist *DataLeafList) GetAll(id string) []DataNode
func (*DataLeafList) GetOrNew ¶
func (leaflist *DataLeafList) GetOrNew(id string, insert InsertOption) (DataNode, bool, error)
GetOrNew() gets or creates a node having the id and returns the found or created node with the boolean value that indicates the returned node is created.
func (*DataLeafList) GetValue ¶
func (leaflist *DataLeafList) GetValue(id string) interface{}
func (*DataLeafList) GetValueString ¶
func (leaflist *DataLeafList) GetValueString(id string) string
func (*DataLeafList) HasMultipleValues ¶
func (leaflist *DataLeafList) HasMultipleValues() bool
func (*DataLeafList) HasStateNode ¶
func (leaflist *DataLeafList) HasStateNode() bool
func (*DataLeafList) HasValueString ¶
func (leaflist *DataLeafList) HasValueString(value string) bool
func (*DataLeafList) ID ¶
func (leaflist *DataLeafList) ID() string
func (*DataLeafList) Index ¶
func (leaflist *DataLeafList) Index(id string) int
func (*DataLeafList) Insert ¶
func (leaflist *DataLeafList) Insert(child DataNode, insert InsertOption) (DataNode, error)
func (*DataLeafList) IsBranchNode ¶
func (leaflist *DataLeafList) IsBranchNode() bool
func (*DataLeafList) IsContainer ¶
func (leaflist *DataLeafList) IsContainer() bool
func (*DataLeafList) IsDataNode ¶
func (leaflist *DataLeafList) IsDataNode()
func (*DataLeafList) IsDuplicatableNode ¶
func (leaflist *DataLeafList) IsDuplicatableNode() bool
func (*DataLeafList) IsLeaf ¶
func (leaflist *DataLeafList) IsLeaf() bool
func (*DataLeafList) IsLeafList ¶
func (leaflist *DataLeafList) IsLeafList() bool
func (*DataLeafList) IsLeafNode ¶
func (leaflist *DataLeafList) IsLeafNode() bool
func (*DataLeafList) IsList ¶
func (leaflist *DataLeafList) IsList() bool
func (*DataLeafList) IsListableNode ¶
func (leaflist *DataLeafList) IsListableNode() bool
func (*DataLeafList) IsNil ¶
func (leaflist *DataLeafList) IsNil() bool
func (*DataLeafList) IsStateNode ¶
func (leaflist *DataLeafList) IsStateNode() bool
func (*DataLeafList) Len ¶
func (leaflist *DataLeafList) Len() int
func (*DataLeafList) Lookup ¶
func (leaflist *DataLeafList) Lookup(prefix string) []DataNode
func (*DataLeafList) MarshalJSON ¶
func (leaflist *DataLeafList) MarshalJSON() ([]byte, error)
func (*DataLeafList) MarshalXML ¶
func (leaflist *DataLeafList) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*DataLeafList) MarshalYAML ¶
func (leaflist *DataLeafList) MarshalYAML() (interface{}, error)
func (*DataLeafList) Merge ¶
func (leaflist *DataLeafList) Merge(src DataNode) error
Merge() merges the src data node to the leaflist data node.
func (*DataLeafList) Metadata ¶
func (leaflist *DataLeafList) Metadata() map[string]DataNode
func (*DataLeafList) Name ¶
func (leaflist *DataLeafList) Name() string
func (*DataLeafList) Parent ¶
func (leaflist *DataLeafList) Parent() DataNode
func (*DataLeafList) Path ¶
func (leaflist *DataLeafList) Path() string
func (*DataLeafList) PathTo ¶
func (leaflist *DataLeafList) PathTo(descendant DataNode) string
func (*DataLeafList) Remove ¶
func (leaflist *DataLeafList) Remove() error
func (*DataLeafList) Replace ¶
func (leaflist *DataLeafList) Replace(src DataNode) error
Replace() replaces itself to the src node.
func (*DataLeafList) Schema ¶
func (leaflist *DataLeafList) Schema() *SchemaNode
func (*DataLeafList) SetMetadata ¶
func (leaflist *DataLeafList) SetMetadata(name string, value ...interface{}) error
SetMetadata() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadata("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataLeafList) SetMetadataString ¶
func (leaflist *DataLeafList) SetMetadataString(name string, value ...string) error
SetMetadataString() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadataString("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataLeafList) SetValue ¶
func (leaflist *DataLeafList) SetValue(value ...interface{}) error
func (*DataLeafList) SetValueSafe ¶
func (leaflist *DataLeafList) SetValueSafe(value ...interface{}) error
func (*DataLeafList) SetValueString ¶
func (leaflist *DataLeafList) SetValueString(value ...string) error
func (*DataLeafList) SetValueStringSafe ¶
func (leaflist *DataLeafList) SetValueStringSafe(value ...string) error
func (*DataLeafList) String ¶
func (leaflist *DataLeafList) String() string
func (*DataLeafList) UnmarshalJSON ¶
func (leaflist *DataLeafList) UnmarshalJSON(jbytes []byte) error
func (*DataLeafList) UnmarshalXML ¶
func (leaflist *DataLeafList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
func (*DataLeafList) UnmarshalYAML ¶
func (leaflist *DataLeafList) UnmarshalYAML(unmarshal func(interface{}) error) error
func (*DataLeafList) UnsetMetadata ¶
func (leaflist *DataLeafList) UnsetMetadata(name string) error
UnsetMetadata() remove a metadata.
func (*DataLeafList) UnsetValue ¶
func (leaflist *DataLeafList) UnsetValue(value ...interface{}) error
func (*DataLeafList) UnsetValueString ¶
func (leaflist *DataLeafList) UnsetValueString(value ...string) error
func (*DataLeafList) Update ¶
func (leaflist *DataLeafList) Update(id string, value ...string) (DataNode, error)
func (*DataLeafList) UpdateByMap ¶
func (leaflist *DataLeafList) UpdateByMap(pmap map[string]interface{}) error
UpdateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataLeafList) Value ¶
func (leaflist *DataLeafList) Value() interface{}
func (*DataLeafList) ValueString ¶
func (leaflist *DataLeafList) ValueString() string
FIXME - Incomplete conversion to string
func (*DataLeafList) Values ¶
func (leaflist *DataLeafList) Values() []interface{}
type DataNode ¶
type DataNode interface { IsDataNode() IsNil() bool // IsNil() is used to check the data node is null. IsBranchNode() bool // IsBranchNode() returns true if the data node is a DataBranch (a container or a list node). IsLeafNode() bool // IsLeafNode() returns true if the data node is a DataLeaf (a leaf or a multiple leaf-list node) or DataLeafList (a single leaf-list node). IsDuplicatableNode() bool // IsDuplicatable() returns true if multiple nodes having the same ID can exist in the tree. IsListableNode() bool // IsListable() returns true if the nodes that has the same schema are listed in the tree. IsStateNode() bool // IsStateNode() returns true if the node is a config=false node. HasStateNode() bool // HasStateNode() returns true if the node has a config=false child node. HasMultipleValues() bool // HasMultipleValues() returns true if the node has a set of values (= *DataLeafList). IsLeaf() bool // IsLeaf() returns true if the data node is an yang leaf. IsLeafList() bool // IsLeafList() returns true if the data node is an yang leaf-list. IsList() bool // IsList() returns true if the data node is an yang list. IsContainer() bool // IsContainer returns true if the data node is an yang container node. Name() string // Name() returns the name of the data node. QName(rfc7951 bool) (string, bool) // QName() returns the namespace-qualified name e.g. module-name:node-name or module-prefix:node-name. ID() string // ID() returns the data node ID (NODE[KEY=VALUE]). The ID is an XPath element combined with XPath predicates to identify the node instance. Schema() *SchemaNode // Schema() returns the schema of the data node. Parent() DataNode // Parent() returns the parent if it is present. Children() []DataNode // Children() returns all child nodes. Insert(child DataNode, i InsertOption) (DataNode, error) // Insert() inserts a new child node. It replaces and returns the old one. Delete(child DataNode) error // Delete() deletes the child node if it is present. Replace(src DataNode) error // Replace() replaces itself to the src node. Merge(src DataNode) error // Merge() merges the src node including all children to the current data node. Remove() error // Remove() removes itself. // GetOrNew() gets or creates a node having the id (NODE_NAME or NODE_NAME[KEY=VALUE]) and returns // the found or created node with the boolean value that // indicates the returned node is created. GetOrNew(id string, i InsertOption) (DataNode, bool, error) Create(id string, value ...string) (DataNode, error) // Create() creates a child using the node id (NODE_NAME or NODE_NAME[KEY=VALUE]). Update(id string, value ...string) (DataNode, error) // Update() updates a child that has the node id (NODE_NAME or NODE_NAME[KEY=VALUE]) using the input values. CreateByMap(pmap map[string]interface{}) error // CreateByMap() updates the data node using pmap (path predicate map) and string values. UpdateByMap(pmap map[string]interface{}) error // UpdateByMap() updates the data node using pmap (path predicate map) and string values. Exist(id string) bool // Exist() is used to check a data node is present. Get(id string) DataNode // Get() is used to get the first child has the id. GetValue(id string) interface{} // GetValue() is used to get the value of the child that has the id. GetValueString(id string) string // GetValueString() is used to get the value, converted to string, of the child that has the id. GetAll(id string) []DataNode // GetAll() is used to get all children that have the id. Lookup(idPrefix string) []DataNode // Lookup() is used to get all children on which their keys start with the prefix string of the node id. Len() int // Len() returns the number of children or the number of values. Index(id string) int // Index() finds all children by the node id and returns the position. Child(index int) DataNode // Child() gets the child of the index. String() string // String() returns a string to identify the node. Path() string // Path() returns the path from the root to the current data node. PathTo(descendant DataNode) string // PathTo() returns a relative path to a descendant node. SetValue(value ...interface{}) error // SetValue() writes the values to the data node. SetValueSafe(value ...interface{}) error // SetValueSafe() writes the values to the data node. It will recover the value if failed. UnsetValue(value ...interface{}) error // UnsetValue() clear the value of the data node to the default. SetValueString(value ...string) error // SetValueString() writes the values to the data node. The value must be string. SetValueStringSafe(value ...string) error // SetValueStringSafe() writes the values to the data node. It will recover the value if failed. UnsetValueString(value ...string) error // UnsetValueString() clear the value of the data node to the default. HasValueString(value string) bool // HasValueString() returns true if the data node value has the value. Value() interface{} // Value() returns the raw data of the data node. Values() []interface{} // Values() returns its values using []interface{} slice ValueString() string // ValueString() returns the string value of the data node. SetMetadata(name string, value ...interface{}) error // SetMetadata() sets a metadata. SetMetadataString(name string, value ...string) error // SetMetadataString() sets a metadata using string values. UnsetMetadata(name string) error // UnsetMetadata() remove a metadata. // Metadata(name string) interface{} // Metadatas(name string) []interface{} Metadata() map[string]DataNode }
yangtree consists of the data node.
func DiffCreated ¶
DiffCreated() returns created nodes. It returns all created nodes in node2 (including itself) against node1. The deleted nodes can be obtained by the reverse input.
func Find ¶
Find() finds all data nodes in the path. xpath format can be used for the path as following example.
Find(root, "//path/to/data[name='xxx']", UseXPath{})
func FindAllInRoute ¶
FindAllInRoute() find all parent nodes in the path. The path must indicate an unique node. (not support wildcard and multiple node selection)
func New ¶
func New(schema *SchemaNode) (DataNode, error)
New() creates a new DataNode (*DataBranch or *DataLeaf) according to the schema.
func NewCollector ¶
func NewCollector() DataNode
NewCollector() creates a fake node that can be used to collect all kindes of data nodes. Any of data nodes can be contained to the collector data node.
func NewWithID ¶
func NewWithID(schema *SchemaNode, id string) (DataNode, error)
NewWithID() creates a new DataNode using id (NODE_NAME or NODE_NAME[KEY=VALUE])
func NewWithValue ¶
func NewWithValue(schema *SchemaNode, value ...interface{}) (DataNode, error)
NewWithValue() creates a new DataNode (*DataBranch or *DataLeaf) according to the schema with its values. The values should be a string if the new DataNode is *DataLeaf, *DataLeafList. The values should be JSON encoded bytes if the node is *DataBranch.
func NewWithValueString ¶
func NewWithValueString(schema *SchemaNode, value ...string) (DataNode, error)
NewWithValueString() creates a new DataNode (*DataBranch or *DataLeaf) according to the schema with its values. The values should be a string if the new DataNode is *DataLeaf, *DataLeafList. The values should be JSON encoded bytes if the node is *DataBranch.
type DataNodeGroup ¶
type DataNodeGroup struct { Nodes []DataNode // contains filtered or unexported fields }
A set of data nodes that have the same schema.
func ConvertToGroup ¶
func ConvertToGroup(schema *SchemaNode, nodes []DataNode) (*DataNodeGroup, error)
ConvertToGroup() creates a set of new data nodes (DataNodeGroup) having the same schema. To create a set of data nodes, the value must be encoded to a JSON object or a JSON array of the data. It is useful to create multiple list or leaf-list nodes.
// e.g. groups, err := NewGroupWithValueString(schema, `["leaf-list-value1", "leaf-list-value2"]`) for _, node := range groups { // Process the created nodes ("leaf-list-value1" and "leaf-list-value2") here. }
func NewGroupWithValue ¶
func NewGroupWithValue(schema *SchemaNode, value ...interface{}) (*DataNodeGroup, error)
NewGroupWithValue() creates a set of new data nodes (*DataNodeGroup) having the same schema. To create a set of data nodes, the value must be encoded to a JSON object or a JSON array of the data. It is useful to create multiple list or leaf-list nodes.
// e.g. groups, err := NewGroupWithValue(schema, `["leaf-list-value1", "leaf-list-value2"]`) for _, node := range groups.Nodes { // Process the created nodes ("leaf-list-value1" and "leaf-list-value2") here. }
func NewGroupWithValueString ¶
func NewGroupWithValueString(schema *SchemaNode, value ...string) (*DataNodeGroup, error)
NewGroupWithValueString() creates a set of new data nodes (*DataNodeGroup) having the same schema. To create a set of data nodes, the value must be encoded to a JSON object or a JSON array of the data. It is useful to create multiple list or leaf-list nodes.
// e.g. groups, err := NewGroupWithValueString(schema, `["leaf-list-value1", "leaf-list-value2"]`) for _, node := range groups.Nodes { // Process the created nodes ("leaf-list-value1" and "leaf-list-value2") here. }
func (*DataNodeGroup) Child ¶
func (group *DataNodeGroup) Child(index int) DataNode
func (*DataNodeGroup) Children ¶
func (group *DataNodeGroup) Children() []DataNode
func (*DataNodeGroup) Create ¶
func (group *DataNodeGroup) Create(id string, value ...string) (DataNode, error)
func (*DataNodeGroup) CreateByMap ¶
func (group *DataNodeGroup) CreateByMap(pmap map[string]interface{}) error
CreateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataNodeGroup) Delete ¶
func (group *DataNodeGroup) Delete(child DataNode) error
func (*DataNodeGroup) Exist ¶
func (group *DataNodeGroup) Exist(id string) bool
func (*DataNodeGroup) Get ¶
func (group *DataNodeGroup) Get(id string) DataNode
func (*DataNodeGroup) GetAll ¶
func (group *DataNodeGroup) GetAll(id string) []DataNode
func (*DataNodeGroup) GetOrNew ¶
func (group *DataNodeGroup) GetOrNew(id string, insert InsertOption) (DataNode, bool, error)
GetOrNew() gets or creates a node having the id and returns the found or created node with the boolean value that indicates the returned node is created.
func (*DataNodeGroup) GetValue ¶
func (group *DataNodeGroup) GetValue(id string) interface{}
func (*DataNodeGroup) GetValueString ¶
func (group *DataNodeGroup) GetValueString(id string) string
func (*DataNodeGroup) HasMultipleValues ¶
func (group *DataNodeGroup) HasMultipleValues() bool
func (*DataNodeGroup) HasStateNode ¶
func (group *DataNodeGroup) HasStateNode() bool
func (*DataNodeGroup) HasValueString ¶
func (group *DataNodeGroup) HasValueString(value string) bool
func (*DataNodeGroup) ID ¶
func (group *DataNodeGroup) ID() string
func (*DataNodeGroup) Index ¶
func (group *DataNodeGroup) Index(id string) int
func (*DataNodeGroup) Insert ¶
func (group *DataNodeGroup) Insert(child DataNode, insert InsertOption) (DataNode, error)
func (*DataNodeGroup) IsBranchNode ¶
func (group *DataNodeGroup) IsBranchNode() bool
func (*DataNodeGroup) IsContainer ¶
func (group *DataNodeGroup) IsContainer() bool
func (*DataNodeGroup) IsDataNode ¶
func (group *DataNodeGroup) IsDataNode()
func (*DataNodeGroup) IsDuplicatableNode ¶
func (group *DataNodeGroup) IsDuplicatableNode() bool
func (*DataNodeGroup) IsLeaf ¶
func (group *DataNodeGroup) IsLeaf() bool
func (*DataNodeGroup) IsLeafList ¶
func (group *DataNodeGroup) IsLeafList() bool
func (*DataNodeGroup) IsLeafNode ¶
func (group *DataNodeGroup) IsLeafNode() bool
func (*DataNodeGroup) IsList ¶
func (group *DataNodeGroup) IsList() bool
func (*DataNodeGroup) IsListableNode ¶
func (group *DataNodeGroup) IsListableNode() bool
func (*DataNodeGroup) IsNil ¶
func (group *DataNodeGroup) IsNil() bool
func (*DataNodeGroup) IsStateNode ¶
func (group *DataNodeGroup) IsStateNode() bool
func (*DataNodeGroup) Len ¶
func (group *DataNodeGroup) Len() int
func (*DataNodeGroup) Lookup ¶
func (group *DataNodeGroup) Lookup(prefix string) []DataNode
func (*DataNodeGroup) MarshalJSON ¶
func (group *DataNodeGroup) MarshalJSON() ([]byte, error)
func (*DataNodeGroup) MarshalXML ¶
func (group *DataNodeGroup) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*DataNodeGroup) MarshalYAML ¶
func (group *DataNodeGroup) MarshalYAML() (interface{}, error)
func (*DataNodeGroup) Merge ¶
func (group *DataNodeGroup) Merge(src DataNode) error
Merge() merges the src data node to the leaf data node.
func (*DataNodeGroup) Metadata ¶
func (group *DataNodeGroup) Metadata() map[string]DataNode
func (*DataNodeGroup) Name ¶
func (group *DataNodeGroup) Name() string
func (*DataNodeGroup) Parent ¶
func (group *DataNodeGroup) Parent() DataNode
func (*DataNodeGroup) Path ¶
func (group *DataNodeGroup) Path() string
func (*DataNodeGroup) PathTo ¶
func (group *DataNodeGroup) PathTo(descendant DataNode) string
func (*DataNodeGroup) Remove ¶
func (group *DataNodeGroup) Remove() error
func (*DataNodeGroup) Replace ¶
func (group *DataNodeGroup) Replace(src DataNode) error
Replace() replaces itself to the src node.
func (*DataNodeGroup) Schema ¶
func (group *DataNodeGroup) Schema() *SchemaNode
func (*DataNodeGroup) SetMetadata ¶
func (group *DataNodeGroup) SetMetadata(name string, value ...interface{}) error
SetMetadata() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadata("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataNodeGroup) SetMetadataString ¶
func (group *DataNodeGroup) SetMetadataString(name string, value ...string) error
SetMetadataString() sets a metadata. for example, the following last-modified is set to the node as a metadata.
node.SetMetadataString("last-modified", "2015-06-18T17:01:14+02:00")
func (*DataNodeGroup) SetValue ¶
func (group *DataNodeGroup) SetValue(value ...interface{}) error
func (*DataNodeGroup) SetValueSafe ¶
func (group *DataNodeGroup) SetValueSafe(value ...interface{}) error
func (*DataNodeGroup) SetValueString ¶
func (group *DataNodeGroup) SetValueString(value ...string) error
func (*DataNodeGroup) SetValueStringSafe ¶
func (group *DataNodeGroup) SetValueStringSafe(value ...string) error
func (*DataNodeGroup) String ¶
func (group *DataNodeGroup) String() string
func (*DataNodeGroup) UnmarshalJSON ¶
func (group *DataNodeGroup) UnmarshalJSON(jbytes []byte) error
func (*DataNodeGroup) UnmarshalXML ¶
func (group *DataNodeGroup) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
func (*DataNodeGroup) UnmarshalYAML ¶
func (group *DataNodeGroup) UnmarshalYAML(unmarshal func(interface{}) error) error
func (*DataNodeGroup) UnsetMetadata ¶
func (group *DataNodeGroup) UnsetMetadata(name string) error
UnsetMetadata() remove a metadata.
func (*DataNodeGroup) UnsetValue ¶
func (group *DataNodeGroup) UnsetValue(value ...interface{}) error
func (*DataNodeGroup) UnsetValueString ¶
func (group *DataNodeGroup) UnsetValueString(value ...string) error
func (*DataNodeGroup) Update ¶
func (group *DataNodeGroup) Update(id string, value ...string) (DataNode, error)
func (*DataNodeGroup) UpdateByMap ¶
func (group *DataNodeGroup) UpdateByMap(pmap map[string]interface{}) error
UpdateByMap() updates the data node using pmap (path predicate map) and string values.
func (*DataNodeGroup) Value ¶
func (group *DataNodeGroup) Value() interface{}
func (*DataNodeGroup) ValueString ¶
func (group *DataNodeGroup) ValueString() string
func (*DataNodeGroup) Values ¶
func (group *DataNodeGroup) Values() []interface{}
type EditOp ¶
type EditOp int
EditOperation [EditMerge, EditCreate, EditReplace, EditDelete, EditRemove] for yangtree
const ( EditMerge EditOp = iota // similar to NETCONF edit-config: merge operation EditCreate // similar to NETCONF edit-config: create operation EditReplace // similar to NETCONF edit-config: replace operation EditDelete // similar to NETCONF edit-config: delete operation EditRemove // similar to NETCONF edit-config: remove operation )
type EditOption ¶
type EditOption struct { EditOp // EditOperation InsertOption // Insert option for ordered-by yang option Callback func(op EditOp, old, new []DataNode) error // Callback is invoked upon the node changes. FailureRecovery bool }
EditOption is used for yangtree set operation.
func (*EditOption) GetCallback ¶
func (edit *EditOption) GetCallback() func(EditOp, []DataNode, []DataNode) error
func (*EditOption) GetFailureRecovery ¶
func (edit *EditOption) GetFailureRecovery() bool
func (*EditOption) GetInsertOption ¶
func (edit *EditOption) GetInsertOption() InsertOption
func (*EditOption) GetOperation ¶
func (edit *EditOption) GetOperation() EditOp
func (EditOption) IsOption ¶
func (edit EditOption) IsOption()
func (*EditOption) String ¶
func (edit *EditOption) String() string
type ErrorTag ¶
type ErrorTag int
const ( ETagInUse ErrorTag = iota ETagInvalidValue ETagTooBig ETagMissingAttribute ETagBadAttribute ETagUnknownAttribute ETagMissingElement ETagBadElement ETagUnknownElement ETagUnknownNamespace ETagAccessDenied ETagLockDenied ETagResourceDenied ETagRollbackFailed ETagDataExists ETagDataMissing ETagOperationNotSupported ETagOperationFailed ETagPartialOperation ETagMarlformedMessage EAppTagUnknownError ErrorTag = iota + 100 EAppTagDataNodeMissing EAppTagDataNodeExists EAppTagInvalidArg EAppTagJSONParsing EAppTagJSONEmitting EAppTagYAMLParsing EAppTagYAMLEmitting )
type Extension ¶
type Extension struct { ExtSchema map[string]*SchemaNode MetadataSchema map[string]*SchemaNode }
type HasState ¶
type HasState struct{}
HasState option is used to find state data nodes and data nodes having state data nodes.
type InsertOption ¶
type InsertToAfter ¶
type InsertToAfter struct {
Key string
}
func (InsertToAfter) GetInsertKey ¶
func (o InsertToAfter) GetInsertKey() string
func (InsertToAfter) String ¶
func (o InsertToAfter) String() string
type InsertToBefore ¶
type InsertToBefore struct {
Key string
}
func (InsertToBefore) GetInsertKey ¶
func (o InsertToBefore) GetInsertKey() string
func (InsertToBefore) String ¶
func (o InsertToBefore) String() string
type InsertToFirst ¶
type InsertToFirst struct{}
func (InsertToFirst) GetInsertKey ¶
func (o InsertToFirst) GetInsertKey() string
func (InsertToFirst) String ¶
func (o InsertToFirst) String() string
type InsertToLast ¶
type InsertToLast struct{}
func (InsertToLast) GetInsertKey ¶
func (o InsertToLast) GetInsertKey() string
func (InsertToLast) String ¶
func (o InsertToLast) String() string
type InternalFormat ¶
type InternalFormat struct{}
InternalFormat is an option to marshal a data node to an internal YAML format.
func (InternalFormat) IsOption ¶
func (o InternalFormat) IsOption()
type Metadata ¶
type Metadata struct{}
Metadata option is used to print out the metadata of the tree.
type MultipleError ¶
type MultipleError []error
func (MultipleError) Error ¶
func (me MultipleError) Error() string
type NodeSelect ¶
type NodeSelect int
const ( NodeSelectChild NodeSelect = iota // select the child nodes using the element name and predicate NodeSelectSelf // if the path starts with `.` NodeSelectFromRoot // if the path starts with `/` NodeSelectAll // if the path starts with `//` or `...` NodeSelectParent // if the path starts with `..` NodeSelectAllChildren // Wildcard '*' )
type PathNode ¶
type PathNode struct { Prefix string // used to save the prefix of the data node Name string // used to save the name of the data node Value string // used to save the value of the data node Select NodeSelect Predicates []string // used to filter the selected data node set. }
func (*PathNode) PredicatesToMap ¶
type RFC7951Format ¶
type RFC7951Format struct{}
func (RFC7951Format) IsOption ¶
func (f RFC7951Format) IsOption()
type ReadCallback ¶
type ReadCallback func(cur DataNode) interface{}
ReadCallback is a callback executed upon reading or marshaling the data of the node.
readList := []string{} SetValue(root, "/sample/str-val", nil, func(cur DataNode) interface{} { readList = append(readList, cur.String()) return nil })
type RepresentItself ¶
type RepresentItself struct{}
RepresentItself option is used to print out a top node itself to a json or yaml document.
enumSchema := RootSchema.FindSchema("/sample/container-val/enum-val") datanode, _ := NewWithValue(enumSchema, "enum1") if j, _ := MarshalJSON(datanode); len(j) > 0 { fmt.Println(string(j)) // "enum1" } if j, _ := MarshalJSON(datanode, RepresentItself{}); len(j) > 0 { fmt.Println(string(j)) // {"enum-val":"enum1"} }
func (RepresentItself) IsOption ¶
func (f RepresentItself) IsOption()
type SchemaNode ¶
type SchemaNode struct { *yang.Entry Parent *SchemaNode // The parent schema node of the schema node Module *yang.Module // The module of the schema node Children []*SchemaNode // The child schema nodes of the schema node Directory map[string]*SchemaNode // used to store the children of the schema node with all schema node's aliases Enum map[string]int64 // used to store all enumeration string Bits map[string]int64 BitsR map[int64]string Identityref map[string]*yang.Module // used to store all identity values of the schema node Keyname []string // used to store key list Qboundary bool // used to indicate the boundary of the namespace-qualified name of RFC7951 IsRoot bool // used to indicate the schema is the root of the schema tree. IsKey bool // used to indicate the schema node is a key node of a list. IsState bool // used to indicate the schema node is state node. HasState bool // used to indicate the schema node has a state node at least. OrderedByUser bool // used to indicate the ordering of the list or the leaf-list nodes. Option *YANGTreeOption Modules *yang.Modules *Extension // Set option ContainAny bool }
SchemaNode - The node structure of yangtree schema.
func CollectSchemaEntries ¶
func CollectSchemaEntries(e *SchemaNode, leafOnly bool) []*SchemaNode
CollectSchemaEntries returns all entries of the schema tree.
func Load ¶
func Load(file, dir, excluded []string, option ...Option) (*SchemaNode, error)
Load() loads all yang files and then build the schema tree of the files. dir is reference directories for imported or included yang files. excluded is yang module names to be excluded.
func (*SchemaNode) Append ¶
func (schema *SchemaNode) Append(changeParent bool, nodes ...*SchemaNode) error
Append() adds the nodes to the schema node as child nodes. If the changeParent is set, the Parent of each child becomes the scema node. This affacts the schema tree of a yangtree.
func (*SchemaNode) FindSchema ¶
func (schema *SchemaNode) FindSchema(path string) *SchemaNode
FindSchema() returns a descendant schema node in the path.
func (*SchemaNode) GenerateID ¶
func (schema *SchemaNode) GenerateID(pmap map[string]interface{}) (string, bool, bool)
GenerateID generates the node ID of the schema using the value in the pmap. It also returns a boolean value to true if the ID is used for the access of multiple data nodes.
func (*SchemaNode) GetMust ¶
func (schema *SchemaNode) GetMust() []*yang.Must
GetMust() returns the "must" statements of the schema node.
func (*SchemaNode) GetNamespaceAndPrefix ¶
func (schema *SchemaNode) GetNamespaceAndPrefix() (string, string)
func (*SchemaNode) GetQName ¶
func (schema *SchemaNode) GetQName(rfc7951 bool) (string, bool)
GetQName() returns the qname (namespace-qualified name e.g. module-name:node-name) of the schema node.
func (*SchemaNode) GetRootSchema ¶
func (schema *SchemaNode) GetRootSchema() *SchemaNode
GetRootSchema() returns its root schema node.
func (*SchemaNode) GetSchema ¶
func (schema *SchemaNode) GetSchema(name string) *SchemaNode
GetSchema() returns a child of the schema node. The namespace-qualified name is used for the name.
func (*SchemaNode) GetYangLibrary ¶
func (schema *SchemaNode) GetYangLibrary() DataNode
func (*SchemaNode) HasRPCInput ¶
func (schema *SchemaNode) HasRPCInput() bool
func (*SchemaNode) HasRPCOutput ¶
func (schema *SchemaNode) HasRPCOutput() bool
func (*SchemaNode) IsAnyData ¶
func (schema *SchemaNode) IsAnyData() bool
IsAnyData() returns true if the schema node is anydata.
func (*SchemaNode) IsDuplicatable ¶
func (schema *SchemaNode) IsDuplicatable() bool
IsDuplicatable() checks the data nodes can be inserted duplicately several times.
func (*SchemaNode) IsDuplicatableList ¶
func (schema *SchemaNode) IsDuplicatableList() bool
IsDuplicatableList() checks the data nodes is a list node and it can be inserted duplicately.
func (*SchemaNode) IsListHasKey ¶
func (schema *SchemaNode) IsListHasKey() bool
IsListHasKey() checks the list nodes has keys.
func (*SchemaNode) IsListable ¶
func (schema *SchemaNode) IsListable() bool
IsListable() checks if the schema node is a list or a leaf-list node. If SingleLeafList is set, it is not lisable because it has serveral values in the single leaf-list node.
func (*SchemaNode) IsOrderedByUser ¶
func (schema *SchemaNode) IsOrderedByUser() bool
IsOrderedByUser() is used to check the node is ordered by the user.
func (*SchemaNode) IsRPC ¶
func (schema *SchemaNode) IsRPC() bool
func (*SchemaNode) IsSingleLeafList ¶
func (schema *SchemaNode) IsSingleLeafList() bool
IsSingleLeafList() returns true if the schema node is single leaf-list schema.
func (*SchemaNode) IsValidQName ¶
func (schema *SchemaNode) IsValidQName(qname *string, rfc7951 bool) bool
IsValidQName() returns true if the qualified name is valid.
func (*SchemaNode) Path ¶
func (schema *SchemaNode) Path() string
Path() generates the schema path of the schema node.
func (*SchemaNode) QualifiedPath ¶
func (schema *SchemaNode) QualifiedPath(RFC7951format bool) string
QualifiedPath() generates the qualified schema path of the schema node.
func (*SchemaNode) String ¶
func (schema *SchemaNode) String() string
func (*SchemaNode) ValueToJSONBytes ¶
func (schema *SchemaNode) ValueToJSONBytes(typ *yang.YangType, value interface{}, rfc7951format bool) ([]byte, error)
ValueToJSONBytes() marshals a value based on its schema, type and representing format.
func (*SchemaNode) ValueToQValue ¶
func (schema *SchemaNode) ValueToQValue(typ *yang.YangType, value interface{}, rfc7951format bool) (interface{}, error)
ValueToQValue returns the raw value using namespace-qualified format.
func (*SchemaNode) ValueToYAMLBytes ¶
func (schema *SchemaNode) ValueToYAMLBytes(typ *yang.YangType, value interface{}, rfc7951 bool) ([]byte, error)
ValueToYAMLBytes encodes the value to a YAML-encoded data. the schema and the type of the value must be set.
type StateOnly ¶
type StateOnly struct{}
StateOnly option is used to find state data nodes that have "config false" statement.
type TrvsCallOption ¶
type TrvsCallOption int
TrvsCallOption is an argument of Traverse() to decide where user-defined traverser() is called.
- TrvsCalledAtEnter TrvsCallOption // call user-defined traverser() at the entrance of of child nodes.
- TrvsCalledAtExit // call user-defined traverser() at the exit of of child nodes.
- TrvsCalledAtEnterAndExit // call user-defined traverser() at the entrance and exit of child nodes.
const ( TrvsCalledAtEnter TrvsCallOption = 0 // call user-defined traverser() at the entrance of of child nodes. TrvsCalledAtExit TrvsCallOption = 2 // call user-defined traverser() at the exit of of child nodes. TrvsCalledAtEnterAndExit TrvsCallOption = 1 // call user-defined traverser() at the entrance and exit of child nodes. )
type YANGTreeOption ¶
type YANGTreeOption struct { // If SingleLeafList is enabled, leaf-list data represents to a single leaf-list node that contains several values. // If disabled, leaf-list data represents to multiple leaf-list nodes that contains each single value. SingleLeafList bool LeafListValueAsKey bool // leaf-list value can be represented to the xpath if it is set to true. CreatedWithDefault bool // DataNode (data node) is created with the default value of the schema if set. YANGLibrary2016 bool // Load ietf-yang-library@2016-06-21 YANGLibrary2019 bool // Load ietf-yang-library@2019-01-04 SchemaSetName string // The name of the schema set }
YANGTreeOption is used to store yangtree options.
func (YANGTreeOption) IsOption ¶
func (yangtreeOption YANGTreeOption) IsOption()