utils

package
v0.0.67 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NcBase1_0 = "urn:ietf:params:xml:ns:netconf:base:1.0"
)

Variables

This section is empty.

Functions

func AddXMLOperation added in v0.0.44

func AddXMLOperation(elem *etree.Element, operation XMLOperation, operationWithNamespace bool, useOperationRemove bool)

AddXMLOperation adds the operation Attribute to the given etree.Element if the operation is XMLOperationDelete or XMLOperationRemove, the useOperationRemove parameter defines which operation of these is finally used. if XMLOperationReplace is providede, the replace operation is addded.

func BoolPtr added in v0.0.54

func BoolPtr(b bool) *bool

BoolPtr retrieve a pointer to a bool value

func ConvertJsonValueToTv added in v0.0.44

func ConvertJsonValueToTv(d any, slt *sdcpb.SchemaLeafType) (*sdcpb.TypedValue, error)

func FormatProtoJSON added in v0.0.65

func FormatProtoJSON(m proto.Message) string

func FromGNMIPath

func FromGNMIPath(pre, p *gnmi.Path) *sdcpb.Path

func FromGNMITypedValue

func FromGNMITypedValue(ctx context.Context, v *gnmi.TypedValue) *sdcpb.TypedValue

func GetJsonValue added in v0.0.44

func GetJsonValue(tv *sdcpb.TypedValue, ietf bool) (any, error)

func GetNamespaceFromGetSchema added in v0.0.44

func GetNamespaceFromGetSchema(s *sdcpb.SchemaElem) string

func GetSchemaElemModuleName added in v0.0.44

func GetSchemaElemModuleName(s *sdcpb.SchemaElem) (moduleName string)

func GetSchemaValue

func GetSchemaValue(updValue *sdcpb.TypedValue) (interface{}, error)

func MapApplyFuncToMap added in v0.0.64

func MapApplyFuncToMap[K comparable, V any, X any](m map[K]V, f func(K, V) X) map[K]X

func MapToSlice added in v0.0.64

func MapToSlice[K comparable, V any, X any](m map[K]V, f func(K, V) X) []X

MapToSlice executes a function on all the elements of a map, taking in key and value and returns the collected results in a slice

func MapToString added in v0.0.63

func MapToString[K comparable, V any](m map[K]V, sep string, format func(K, V) string) string

MapToString converts a map into a string using a formatter function.

func MapToStringEmptyMessage added in v0.0.63

func MapToStringEmptyMessage[K comparable, V any](m map[K]V, sep string, format func(K, V) string, emptyMessage string) string

MapToStringEmptyMessage converts a map into a string using a formatter function, returning the emptyMessage if the map does not contain entries.

func NotificationsEqual

func NotificationsEqual(n1, n2 *sdcpb.Notification) bool

func ParseDecimal64

func ParseDecimal64(v string) (*sdcpb.Decimal64, error)

func SdcpbUpdateToCacheUpdate added in v0.0.56

func SdcpbUpdateToCacheUpdate(upd *sdcpb.Update, owner string, prio int32) (*cache.Update, error)

func SdcpbUpdatesToCacheUpdates added in v0.0.56

func SdcpbUpdatesToCacheUpdates(upds []*sdcpb.Update, owner string, prio int32) ([]*cache.Update, error)

func ToGNMIPath

func ToGNMIPath(p *sdcpb.Path) *gnmi.Path

func ToGNMITypedValue

func ToGNMITypedValue(v *sdcpb.TypedValue) *gnmi.TypedValue

func ToSchemaNotification

func ToSchemaNotification(ctx context.Context, n *gnmi.Notification) *sdcpb.Notification

func TypedValueToXML added in v0.0.44

func TypedValueToXML(parent *etree.Element, tv *sdcpb.TypedValue, name string, namespace string, onlyNewOrUpdated bool, operationWithNamespace bool, useOperationRemove bool)

func XmlRecursiveSortElementsByTagName added in v0.0.44

func XmlRecursiveSortElementsByTagName(element *etree.Element)

XmlRecursiveSortElementsByTagName - is a function used in testing to recursively sort XML elements by their tag name

Types

type Converter added in v0.0.44

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

func NewConverter added in v0.0.44

func NewConverter(scb SchemaClientBound) *Converter

func (*Converter) ExpandContainerValue added in v0.0.44

func (c *Converter) ExpandContainerValue(ctx context.Context, p *sdcpb.Path, jv any, cs *sdcpb.SchemaElem_Container) ([]*sdcpb.Update, error)

func (*Converter) ExpandUpdate added in v0.0.44

func (c *Converter) ExpandUpdate(ctx context.Context, upd *sdcpb.Update) ([]*sdcpb.Update, error)

expandUpdate Expands the value, in case of json to single typed value updates

func (*Converter) ExpandUpdateKeysAsLeaf added in v0.0.44

func (c *Converter) ExpandUpdateKeysAsLeaf(ctx context.Context, upd *sdcpb.Update) ([]*sdcpb.Update, error)

func (*Converter) ExpandUpdates added in v0.0.44

func (c *Converter) ExpandUpdates(ctx context.Context, updates []*sdcpb.Update) ([]*sdcpb.Update, error)

type SchemaClientBound added in v0.0.44

type SchemaClientBound interface {
	// GetSchema retrieves the schema for the given path
	GetSchemaSdcpbPath(ctx context.Context, path *sdcpb.Path) (*sdcpb.GetSchemaResponse, error)
	// GetSchemaElements retrieves the Schema Elements for all levels of the given path
	GetSchemaElements(ctx context.Context, p *sdcpb.Path, done chan struct{}) (chan *sdcpb.GetSchemaResponse, error)
}

SchemaClientBound provides access to a certain vendor + model + version based schema

type XMLOperation added in v0.0.44

type XMLOperation string
const (
	XMLOperationDelete  XMLOperation = "delete"
	XMLOperationRemove  XMLOperation = "remove"
	XMLOperationReplace XMLOperation = "replace"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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