Documentation ¶
Index ¶
- Constants
- type ConfigTreeAction
- type Option
- type Parser
- func (p *Parser) AddJSONDataToList(x interface{}) (interface{}, error)
- func (p *Parser) AppendElemInPath(path *config.Path, name, key string) *config.Path
- func (p *Parser) CleanCacheValueForComparison(path *config.Path, cacheValue interface{}, valueType string) (x1 interface{}, err error)
- func (p *Parser) CleanConfig(x1 map[string]interface{}) map[string]interface{}
- func (p *Parser) CleanConfig2String(cfg map[string]interface{}) (map[string]interface{}, *string, error)
- func (p *Parser) CleanDeviceValueForComparison(deviceValue interface{}) (interface{}, error)
- func (p *Parser) CompareValues(path *config.Path, cacheValue, deviceValue interface{}, valueType string) (jsondiff.Patch, error)
- func (p *Parser) ConfigGnmiPathToName(path *config.Path) string
- func (p *Parser) ConfigGnmiPathToXPath(path *config.Path, keys bool) *string
- func (p *Parser) CopyAndCleanTxValues(value interface{}) interface{}
- func (p *Parser) CreatePathElem(e *yang.Entry) *config.PathElem
- func (p *Parser) DeepCopy(in interface{}) (interface{}, error)
- func (p *Parser) DeepCopyPath(in *config.Path) *config.Path
- func (p *Parser) GetKeyInfo(keys map[string]string) ([]string, []string)
- func (p *Parser) GetKeyNamesFromConfigPaths(path *config.Path, lastElem string, refPaths []*config.Path) []string
- func (p *Parser) GetTypeKind(e *yang.Entry) string
- func (p *Parser) GetTypeName(e *yang.Entry) string
- func (p *Parser) GetUpdatesFromJSONData(path *config.Path, x1 interface{}, refPaths []*config.Path) []*config.Update
- func (p *Parser) GetValue(updValue *gnmi.TypedValue) (interface{}, error)
- func (p *Parser) GetValueType(value interface{}) string
- func (p *Parser) GnmiPath2ConfigPath(inPath *gnmi.Path) *config.Path
- func (p *Parser) GnmiPathToXPath(path *gnmi.Path, keys bool) *string
- func (p *Parser) ParseJSONData2ConfigUpdates(tc *TraceCtxt, path *config.Path, x1 interface{}, idx int, ...) ([]*config.Update, *TraceCtxt)
- func (p *Parser) ParseTreeWithAction(x1 interface{}, tc *TraceCtxt, idx int) interface{}
- func (p *Parser) PostProcessUpdates(updates []*config.Update) []*config.Update
- func (p *Parser) ProcessLeafRef(e *yang.Entry, resfullPath string, activeResPath *config.Path) (*config.Path, *config.Path, bool)
- func (p *Parser) RemoveFirstEntry(s string) string
- func (p *Parser) RemoveHierarchicalKeys(d []byte, hids []string) ([]byte, error)
- func (p *Parser) RemoveLeafsFromJSONData(x interface{}, leafStrings []string) interface{}
- func (p *Parser) TransformPathAsRelative2Resource(localPath, activeResPath *config.Path) *config.Path
- func (p *Parser) TransformPathToLeafRefPath(path *config.Path) *config.Path
- func (p *Parser) XpathToConfigGnmiPath(xpath string, offset int) (path *config.Path)
- type TraceCtxt
Constants ¶
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 ¶
This section is empty.
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 ¶
WithLogger specifies how the Parser should log messages.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) AddJSONDataToList ¶ added in v0.1.15
AddJSONDataToList adds the JSON data to a list
func (*Parser) AppendElemInPath ¶ added in v0.1.7
AppendElemInPath adds a pathElem to the config gnmi path
func (*Parser) CleanCacheValueForComparison ¶ added in v0.1.7
func (p *Parser) 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 (*Parser) CleanConfig ¶ added in v0.1.7
func (*Parser) CleanConfig2String ¶ added in v0.1.7
func (p *Parser) 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 (*Parser) CleanDeviceValueForComparison ¶ added in v0.1.7
CleanDeviceValueForComparison cleans the data coming from the device it cleans the prefixes of the yang value; key and value
func (*Parser) CompareValues ¶ added in v0.1.7
func (p *Parser) CompareValues(path *config.Path, cacheValue, deviceValue interface{}, valueType string) (jsondiff.Patch, error)
CompareValues compares the 2 values and provides a json diff result
func (*Parser) ConfigGnmiPathToName ¶ added in v0.1.7
ConfigGnmiPathToName converts a config gnmi path to a name where each element of the path is seperated by a "-"
func (*Parser) ConfigGnmiPathToXPath ¶ added in v0.1.7
ConfigGnmiPathToXPath converts a config gnmi path with or withour keys to a string pointer
func (*Parser) CopyAndCleanTxValues ¶ added in v0.1.7
func (p *Parser) CopyAndCleanTxValues(value interface{}) interface{}
func (*Parser) CreatePathElem ¶ added in v0.1.7
CreatePathElem returns a config path element from a yang Entry
func (*Parser) DeepCopyPath ¶ added in v0.1.8
func (*Parser) GetKeyInfo ¶ added in v0.1.7
GetKeyInfo returns all keys and values in a []slice
func (*Parser) GetKeyNamesFromConfigPaths ¶ added in v0.1.9
func (p *Parser) GetKeyNamesFromConfigPaths(path *config.Path, lastElem string, refPaths []*config.Path) []string
GetKeyNamesFromConfigPaths returns the keyNames for a path based on a reference path list (predetermined path list, coming from yang processing) due to yang processing this should always return keys, if not something was not configured properly
func (*Parser) GetTypeKind ¶ added in v0.1.7
GetTypeKind return a string of the kind of the yang entry
func (*Parser) GetTypeName ¶ added in v0.1.7
GetypeName return a string of the type of the yang entry
func (*Parser) GetUpdatesFromJSONData ¶ added in v0.1.9
func (p *Parser) GetUpdatesFromJSONData(path *config.Path, x1 interface{}, refPaths []*config.Path) []*config.Update
GetUpdatesFromJSONData returns config.Updates based on the JSON input data and config.Path/reference Paths These updates are used prepared so they can be send to a GNMI capable device
func (*Parser) GetValue ¶ added in v0.1.7
func (p *Parser) GetValue(updValue *gnmi.TypedValue) (interface{}, error)
GetValue return the data of the gnmo typed value
func (*Parser) GetValueType ¶ added in v0.1.7
GetValueType return if a value is a slice or not
func (*Parser) GnmiPath2ConfigPath ¶ added in v0.1.7
GnmiPath2ConfigPath converts the gnmi path to config path
func (*Parser) GnmiPathToXPath ¶ added in v0.1.7
GnmiPathToXPath converts a gnmi path with or withour keys to a string pointer
func (*Parser) ParseJSONData2ConfigUpdates ¶ added in v0.1.9
func (p *Parser) ParseJSONData2ConfigUpdates(tc *TraceCtxt, path *config.Path, x1 interface{}, idx int, updates []*config.Update, refPaths []*config.Path) ([]*config.Update, *TraceCtxt)
ParseJSONData2UpdatePaths returns config.Updates according to the gnmi spec based on JSON input data
func (*Parser) ParseTreeWithAction ¶ added in v0.1.7
p.ParseTreeWithAction parses various actions on a json object in a recursive way actions can be Get, Update, Delete and Create
func (*Parser) PostProcessUpdates ¶ added in v0.1.9
PostProcessUpdates sorts the update list and adds the key values in the config.Paths that could not be processed
func (*Parser) ProcessLeafRef ¶ added in v0.1.7
func (p *Parser) 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 (*Parser) RemoveFirstEntry ¶ added in v0.1.7
RemoveFirstEntry removes the first entry of the xpath, so it trims the first element of the /
func (*Parser) RemoveHierarchicalKeys ¶ added in v0.1.7
RemoveHierarchicalKeys removes the hierarchical keys from the data
func (*Parser) RemoveLeafsFromJSONData ¶ added in v0.1.14
RemoveLeafsFromJSONData removes the leaf keys from the data
func (*Parser) TransformPathAsRelative2Resource ¶ added in v0.1.7
func (p *Parser) TransformPathAsRelative2Resource(localPath, activeResPath *config.Path) *config.Path
TransformPathAsRelative2Resource returns a relative path
func (*Parser) TransformPathToLeafRefPath ¶ added in v0.1.7
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