Documentation ¶
Overview ¶
Package path defines utilities to operate on translib path. TRanslib uses gnmi path syntax.
Index ¶
- func AppendElems(path *gnmi.Path, elems ...string) *gnmi.Path
- func AppendPathStr(path *gnmi.Path, suffix string) (*gnmi.Path, error)
- func Clone(path *gnmi.Path) *gnmi.Path
- func Copy(path *gnmi.Path) *gnmi.Path
- func Equals(p1, p2 *gnmi.Path) bool
- func GetElemAt(path *gnmi.Path, index int) string
- func HasElemAt(path *gnmi.Path, index int, elem string) bool
- func HasWildcardAtKey(p *gnmi.Path, index int) bool
- func HasWildcardKey(p *gnmi.Path) bool
- func Len(path *gnmi.Path) int
- func Matches(path *gnmi.Path, template *gnmi.Path) bool
- func MergeElemsAt(path *gnmi.Path, index int, elems ...string) int
- func New(pathStr string) (*gnmi.Path, error)
- func NewPathValidator(opts ...PathValidatorOpt) *pathValidator
- func RemoveModulePrefix(path *gnmi.Path)
- func SetKey(elem *gnmi.PathElem, name, value string)
- func SetKeyAt(path *gnmi.Path, index int, name, value string)
- func SplitLastElem(p string) (prefix, last string)
- func StrHasWildcardKey(p string) bool
- func String(path *gnmi.Path) string
- func SubPath(path *gnmi.Path, startIndex, endIndex int) *gnmi.Path
- type AddWildcardKeys
- type AppendModulePrefix
- type IgnoreKeyValidation
- type PathValidatorOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendElems ¶
AppendElems appends one or more path elements to a gnmi.Path
func AppendPathStr ¶
AppendPathStr parses and appends a path string to the gnmi.Path object.
func Copy ¶
Copy returns a new gnmi.Path using the elements of input gnmi.Path. Adding or removing elements from new path does not affect old one. But changes the element's contents will affect old path.
func GetElemAt ¶
GetElemAt returns the path element name at given index. Returns empty string if index is not valid.
func HasElemAt ¶
HasElemAt checks if the path element at the given index has the string Returns true if string is found else false
func HasWildcardAtKey ¶
HasWildcardAtKey checks if a gnmi.Path contains any wildcard key value ("*") at the given Elem index
func HasWildcardKey ¶
HasWildcardKey checks if a gnmi.Path contains any wildcard key value ("*").
func Matches ¶
Matches checks if the path matches a template. Path must satisfy following conditions for a match:
- Should be of equal length or longer than template.
- Element names at each position should match.
- Keys at each postion should match -- should have same set of key names with same values. Wildcard value in the template matches any value of corresponding key in the path. But wildcard value in the path can only match with a wildcard value in template.
Examples: "AA/BB/CC" matches "AA/BB" "AA/BB[x=1][y=1]" matches "AA/BB[x=1][y=*]" "AA/BB[x=1][y=*]" matches "AA/BB[x=1][y=*]" "AA/BB[x=1]" does not match "AA/BB[x=1][y=*]" "AA/BB[x=*]" does not match "AA/BB[x=1]"
func MergeElemsAt ¶
MergeElemsAt merges new path elements at given path position. Returns number of elements merged.
func New ¶
New returns gnmi.Path object for a path string. Returns nil with an error info for bad path value.
func NewPathValidator ¶
func NewPathValidator(opts ...PathValidatorOpt) *pathValidator
NewPathValidator returns the PathValidator struct to validate the gnmi path and also add the missing module prefix and key names and wild card values in the gnmi path based on the given PathValidatorOpt
func RemoveModulePrefix ¶
RemoveModulePrefix strips out module prefixes from each element of a path.
func SplitLastElem ¶
SplitLastElem splits a string path into prefix & last path element
func StrHasWildcardKey ¶
StrHasWildcardKey checks if gnmi path string has any wildcard key value. Equivalent of HasWildcardKey(ygot.StringToStructuredPath(p)); but checks for the wildcard without actually constructing a gnmi.Path.
Types ¶
type AddWildcardKeys ¶
type AddWildcardKeys struct{}
AddWildcardKeys is an PathValidator option that indicates that the missing wild card keys in the given gnmi path will be added during the path validation
func (*AddWildcardKeys) IsPathValidatorOpt ¶
func (*AddWildcardKeys) IsPathValidatorOpt()
IsPathValidatorOpt marks AddWildcardKeys as a valid PathValidatorOpt.
type AppendModulePrefix ¶
type AppendModulePrefix struct{}
AppendModulePrefix is an PathValidator option that indicates that the missing module prefix in the given gnmi path will be added during the path validation
func (*AppendModulePrefix) IsPathValidatorOpt ¶
func (*AppendModulePrefix) IsPathValidatorOpt()
IsPathValidatorOpt marks AppendModulePrefix as a valid PathValidatorOpt.
type IgnoreKeyValidation ¶
type IgnoreKeyValidation struct{}
IgnoreKeyValidation is an PathValidator option to indicate the validator to ignore the key validation in the given gnmi path during the path validation
func (*IgnoreKeyValidation) IsPathValidatorOpt ¶
func (*IgnoreKeyValidation) IsPathValidatorOpt()
IsPathValidatorOpt marks IgnoreKeyValidation as a valid PathValidatorOpt.
type PathValidatorOpt ¶
type PathValidatorOpt interface {
IsPathValidatorOpt()
}
PathValidatorOpt is an interface used for any option to be supplied