Documentation ¶
Index ¶
- Constants
- type ConfigTreeAction
- type LeafRef
- 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) ConfigPath2GnmiPath(inPath *config.Path) *gnmi.Path
- 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) DeepCopyResolvedLeafRef(in *ResolvedLeafRef) (out *ResolvedLeafRef)
- 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(rootPath, 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) HandleEndOfListWithKeyInParseKeyWithAction(x interface{}, value string, tc *TraceCtxt)
- func (p *Parser) HandleNotEndOfListWithKeyInParseKeyWithAction(x interface{}, value string, tc *TraceCtxt) bool
- 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) ParseTreeWithActionOld(x1 interface{}, tc *TraceCtxt, idx int) interface{}
- func (p *Parser) PopulateLocalLeafRefKey(x interface{}, tc *TraceCtxt, idx int)
- func (p *Parser) PopulateLocalLeafRefValue(x interface{}, tc *TraceCtxt, idx int)
- func (p *Parser) PostProcessAugmentValues(updates []*config.Update, objKeyValues map[int]map[string][]string, ...) []*config.Update
- func (p *Parser) PostProcessUpdates(rootPath *config.Path, updates []*config.Update) []*config.Update
- func (p *Parser) PostProcessUpdatesCaptureValues(updates []*config.Update) (map[int]map[string][]string, map[int]map[string]int)
- 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) 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 ResolvedLeafRef
- 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" ConfigTreeActionFind ConfigTreeAction = "find" ConfigResolveLeafRef ConfigTreeAction = "resolve leafref" )
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) ConfigPath2GnmiPath ¶ added in v0.1.28
ConfigPath2GnmiPath converts the config path to gnmi path
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) DeepCopyResolvedLeafRef ¶ added in v0.1.42
func (p *Parser) DeepCopyResolvedLeafRef(in *ResolvedLeafRef) (out *ResolvedLeafRef)
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(rootPath, 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) HandleEndOfListWithKeyInParseKeyWithAction ¶ added in v0.1.42
func (p *Parser) HandleEndOfListWithKeyInParseKeyWithAction(x interface{}, value string, tc *TraceCtxt)
HandleEndOfListWithKeyInParseKeyWithAction is called to assist Get, Create, Delete, Update Action it validates if the value of the JSON object matches the key value of the path
func (*Parser) HandleNotEndOfListWithKeyInParseKeyWithAction ¶ added in v0.1.42
func (p *Parser) HandleNotEndOfListWithKeyInParseKeyWithAction(x interface{}, value string, tc *TraceCtxt) bool
HandleNotEndOfListWithKeyInParseKeyWithAction is called to assist Get, Create, Delete, Update Action it validates if the value of the JSON object matches the key value of the path
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) ParseTreeWithActionOld ¶ added in v0.1.42
p.ParseTreeWithAction parses various actions on a json object in a recursive way actions can be Get, Update, Delete and Create
func (*Parser) PopulateLocalLeafRefKey ¶ added in v0.1.42
func (*Parser) PopulateLocalLeafRefValue ¶ added in v0.1.42
PopulateLocalLeafRefValue, populates the values and the keyvalues in the resolved leafref objects
func (*Parser) PostProcessAugmentValues ¶ added in v0.1.41
func (*Parser) PostProcessUpdates ¶ added in v0.1.9
func (p *Parser) PostProcessUpdates(rootPath *config.Path, updates []*config.Update) []*config.Update
the order of the processed paths should remain fixed since this allows to fill out the data ina consistent way First we process the data to capture the values of all resolved keys per pathElem level Second we augment the values with the recorded data from the previous step Lastly we augment the path with the rootPath information
func (*Parser) PostProcessUpdatesCaptureValues ¶ added in v0.1.41
func (p *Parser) PostProcessUpdatesCaptureValues(updates []*config.Update) (map[int]map[string][]string, map[int]map[string]int)
PostProcessUpdatesCaptureValues captures the values of all resolved keys per pathElem level map[int]map[string][]string -> map[int -> level in path]map[string -> keyName][]string -> Value
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) 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
type ResolvedLeafRef ¶ added in v0.1.42
type TraceCtxt ¶ added in v0.1.4
type TraceCtxt struct { Action ConfigTreeAction Found bool Idx int Path *config.Path // the input path data ResolvedIdx int // keeps track of the amount of amount of resolved Indexes ResolvedLeafRefs []*ResolvedLeafRef Data interface{} Value interface{} Msg []string }