parser

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// values
	Slice    = "slice"
	NonSlice = "nonSlice"
	// errors
	ErrJSONMarshal       = "cannot marshal JSON object"
	ErrJSONCompare       = "cannot compare JSON objects"
	ErrJSONMarshalIndent = "cannot marshal JSON object with indent"
)

Variables

This section is empty.

Functions

func AppendElemInPath

func AppendElemInPath(path *config.Path, name, key string) *config.Path

AppendElemInPath adds a pathElem to the config gnmi path

func CleanCacheValueForComparison added in v0.1.4

func CleanCacheValueForComparison(path *config.Path, cacheValue interface{}, valueType string) (x1 interface{}, err error)

we update the cache value for comparison 1. any map[string]interface{} -> will come from another subscription 2. any key in the path can be removed since this is part of the path iso data comparison 3. if the value is a slice we should remove all strings/int/floats, if the data is not a slice we remove all slices -> the gnmi server splits slice data and non slice data

func CleanConfig2String

func CleanConfig2String(cfg map[string]interface{}) (map[string]interface{}, *string, error)

CleanConfig2String returns a clean config and a string clean means removing the prefixes in the json elements

func CleanDeviceValueForComparison added in v0.1.4

func CleanDeviceValueForComparison(deviceValue interface{}) (interface{}, error)

CleanDeviceValueForComparison cleans the data coming from the device it cleans the prefixes of the yang value; key and value

func CompareValues added in v0.1.4

func CompareValues(path *config.Path, cacheValue, deviceValue interface{}, valueType string) (jsondiff.Patch, error)

CompareValues compares the 2 values and provides a json diff result

func ConfigGnmiPathToName added in v0.1.1

func ConfigGnmiPathToName(path *config.Path) string

ConfigGnmiPathToName converts a config gnmi path to a name where each element of the path is seperated by a "-"

func ConfigGnmiPathToXPath added in v0.1.2

func ConfigGnmiPathToXPath(path *config.Path, keys bool) *string

ConfigGnmiPathToXPath converts a config gnmi path with or withour keys to a string pointer

func CreatePathElem

func CreatePathElem(e *yang.Entry) *config.PathElem

CreatePathElem returns a config path element from a yang Entry

func DeepCopy

func DeepCopy(in interface{}) (interface{}, error)

Make a deep copy from in into out object.

func GetKeyInfo added in v0.1.4

func GetKeyInfo(keys map[string]string) ([]string, []string)

GetKeyInfo returns all keys and values in a []slice

func GetTypeKind

func GetTypeKind(e *yang.Entry) string

GetTypeKind return a string of the kind of the yang entry

func GetTypeName

func GetTypeName(e *yang.Entry) string

GetypeName return a string of the type of the yang entry

func GetValue added in v0.1.6

func GetValue(updValue *gnmi.TypedValue) (interface{}, error)

GetValue return the data of the gnmo typed value

func GetValueType added in v0.1.4

func GetValueType(value interface{}) string

GetValueType return if a value is a slice or not

func GnmiPath2ConfigPath

func GnmiPath2ConfigPath(inPath *gnmi.Path) *config.Path

GnmiPath2ConfigPath converts the gnmi path to config path

func GnmiPathToXPath

func GnmiPathToXPath(path *gnmi.Path, keys bool) *string

GnmiPathToXPath converts a gnmi path with or withour keys to a string pointer

func ParseTreeWithAction added in v0.1.5

func ParseTreeWithAction(x1 interface{}, tc *TraceCtxt, idx int) interface{}

ParseTreeWithAction parses various actions on a json object in a recursive way actions can be Get, Update, Delete and Create

func ProcessLeafRef

func ProcessLeafRef(e *yang.Entry, resfullPath string, activeResPath *config.Path) (*config.Path, *config.Path, bool)

ProcessLeafRef processes the leafref and returns if a leafref localPath, remotePath and if the leafRef is local or external to the resource used for yang parser

func RemoveFirstEntry

func RemoveFirstEntry(s string) string

RemoveFirstEntry removes the first entry of the xpath, so it trims the first element of the /

func RemoveHierarchicalKeys

func RemoveHierarchicalKeys(d []byte, hids []string) ([]byte, error)

RemoveHierarchicalKeys removes the hierarchical keys from the data

func TransformPathAsRelative2Resource

func TransformPathAsRelative2Resource(localPath, activeResPath *config.Path) *config.Path

TransformPathAsRelative2Resource returns a relative path

func TransformPathToLeafRefPath

func TransformPathToLeafRefPath(path *config.Path) *config.Path

TransformPathToLeafRefPath returns a config gnmi path tailored for leafrefs For a leafRef path the last entry of the name should be a key in the previous element

func XpathToGnmiPath

func XpathToGnmiPath(p string, offset int) (path *config.Path)

XpathToGnmiPath convertss a xpath string to a config gnmi path

Types

type ConfigTreeAction added in v0.1.4

type ConfigTreeAction string

ConfigTreeAction defines the states the resource object is reporting

const (
	ConfigTreeActionGet    ConfigTreeAction = "get"
	ConfigTreeActionDelete ConfigTreeAction = "delete"
	ConfigTreeActionCreate ConfigTreeAction = "create"
	ConfigTreeActionUpdate ConfigTreeAction = "update"
)

func (*ConfigTreeAction) String added in v0.1.4

func (c *ConfigTreeAction) String() string

type Option

type Option func(p *Parser)

Option can be used to manipulate Options.

func WithLogger

func WithLogger(log logging.Logger) Option

WithLogger specifies how the Parser should log messages.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(opts ...Option) *Parser

type TraceCtxt added in v0.1.4

type TraceCtxt struct {
	Action ConfigTreeAction
	Found  bool
	Idx    int
	Path   *config.Path
	Data   interface{}
	Value  interface{}
	Msg    []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL