Documentation ¶
Index ¶
- func GnmiFullPath(prefix, path *pb.Path) *pb.Path
- func ParseStringPath(stringPath string) ([]interface{}, error)
- func StrPathElem(pathElem []*pb.PathElem) string
- func ToFloat(value interface{}) (float32, error)
- func ToGNMIPath(xpath string) (*pb.Path, error)
- func ToString(value interface{}) (string, error)
- func ToUint64(value interface{}) (uint64, error)
- func ToXPath(path *pb.Path) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GnmiFullPath ¶
GnmiFullPath builds the full path from the prefix and path.
func ParseStringPath ¶
ParseStringPath parses a string path and produces a []interface{} of parsed path elements. Path elements in a string path are separated by '/'. Each path element can either be a schema node name or a List path element. Schema node names must be valid YANG identifiers. A List path element is encoded using the following pattern: list-name[key1=value1]...[keyN=valueN]. Each List path element generates two parsed path elements: List name and a map[string]string containing List key-value pairs with value(s) in string representation. A '/' within a List key value pair string, i.e., between a pair of '[' and ']', does not serve as a path separator, and is allowed to be part of a List key leaf value. For example, given a string path:
"/a/list-name[k=v/v]/c",
this API returns:
[]interface{}{"a", "list-name", map[string]string{"k": "v/v"}, "c"}.
String path parsing consists of two passes. In the first pass, the input string is split into []string using valid separator '/'. An incomplete List key value string, i.e, a '[' which starts a List key value string without a closing ']', in input string generates an error. In the above example, this pass produces:
[]string{"a", "list-name[k=v/v]", "c"}.
In the second pass, each element in split []string is parsed checking syntax and pattern correctness. Errors are generated for invalid YANG identifiers, malformed List key-value string, etc.. In the above example, the second pass produces:
[]interface{}{"a", "list-name", map[string]string{"k", "v/v"}, "c"}.
func StrPathElem ¶
StrPathElem builds a human-readable form of a list of path elements. e.g. /a/b/c[e=f]
func ToGNMIPath ¶
ToGNMIPath parses an xpath string into a gnmi Path struct defined in gnmi proto. Path convention can be found in https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-path-conventions.md
For example, xpath /interfaces/interface[name=Ethernet1/2/3]/state/counters will be parsed to:
elem: <name: "interfaces" > elem: < name: "interface" key: < key: "name" value: "Ethernet1/2/3" > > elem: <name: "state" > elem: <name: "counters" >
Types ¶
This section is empty.