union

package
v0.0.0-...-fc2a63e Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: BSD-3-Clause, MPL-2.0 Imports: 16 Imported by: 4

README

configd union tree

The union tree library is the core for managing configuration changes. It provides an overlay/underlay abstraction of a configd data tree.

Documentation

Index

Constants

View Source
const (
	DontCheckAuth = false
	DontCare      = false
	CheckAuth     = true
)

Variables

This section is empty.

Functions

func ForceShowSecrets

func ForceShowSecrets(opts *unionOptions)

ForceShowSecrets forces secrets to not be filtered, even if the usual secret filtering logic would suggest they should be filtered.

func HideSecrets

func HideSecrets(opts *unionOptions)

func IncludeDefaults

func IncludeDefaults(opts *unionOptions)

func UnmarshalJSONConfigsWithoutValidation

func UnmarshalJSONConfigsWithoutValidation(
	configs [][]byte,
	ms schema.ModelSet,
) (*data.Node, error)

UnmarshalJSONConfigsWithoutValidation - merge JSON configs into data tree Function is of type schema.ConfigMultiplexerFn

Only used for test (from configd) - so needs to be exported, and can't be exported from _test.go file as that doesn't work outside this package (only works for exporting from pkg foo to foo_test AFAICT).

func UnmarshalJSONIntoNodeWithoutValidation

func UnmarshalJSONIntoNodeWithoutValidation(
	ut Node,
	cfgOrState encoding.ConfigOrState,
	jsonInput []byte,
) (err error)

Types

type Auther

type Auther interface {
	AuthRead([]string) bool
	AuthCreate([]string) bool
	AuthUpdate([]string) bool
	AuthDelete([]string) bool
	AuthReadSecrets([]string) bool
}

type BySystem

type BySystem []Node

func (BySystem) Len

func (b BySystem) Len() int

func (BySystem) Less

func (b BySystem) Less(i, j int) bool

func (BySystem) Swap

func (b BySystem) Swap(i, j int)

type ByUser

type ByUser []Node

Sorting interface for lists of Nodes. ByUser handles the ordered-by user semantics from the Yang spec this stores the list in the order they were inserted by the user. BySystem does natural sort order.

func (ByUser) Len

func (b ByUser) Len() int

func (ByUser) Less

func (b ByUser) Less(i, j int) bool

func (ByUser) Swap

func (b ByUser) Swap(i, j int)

type Choice

type Choice struct {
	Schema schema.Choice
	// contains filtered or unexported fields
}

func NewChoice

func NewChoice(overlay, underlay *data.Node, sch schema.Choice, parent Node, flags Flags) *Choice

func (Choice) Added

func (n Choice) Added() bool

func (Choice) Changed

func (n Choice) Changed() bool

func (Choice) Child

func (n Choice) Child(name string) Node

func (Choice) Children

func (n Choice) Children() map[string]Node

func (Choice) Data

func (n Choice) Data() *data.Node

func (Choice) Default

func (n Choice) Default() bool

func (Choice) Delete

func (n Choice) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (Choice) Descendant

func (n Choice) Descendant(auth Auther, path []string) (Node, error)

func (Choice) Empty

func (n Choice) Empty() bool

func (Choice) Exists

func (n Choice) Exists(auth Auther, path []string) error

func (Choice) Get

func (n Choice) Get(auth Auther, path []string) ([]string, error)

func (Choice) GetHelp

func (n Choice) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (Choice) GetSchema

func (n Choice) GetSchema() schema.Node

func (Choice) GetStateJson

func (n Choice) GetStateJson(path []string) ([][]byte, error)

func (Choice) GetStateJsonWithWarnings

func (n Choice) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (Choice) IsDefault

func (n Choice) IsDefault(auth Auther, path []string) (bool, error)

func (Choice) Marshal

func (n Choice) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (Choice) MarshalInternalJSON

func (n Choice) MarshalInternalJSON(options ...UnionOption) []byte

func (Choice) Merge

func (n Choice) Merge() *data.Node

func (Choice) MergeWithoutDefaults

func (n Choice) MergeWithoutDefaults() *data.Node

func (Choice) Module

func (n Choice) Module() string

func (Choice) Name

func (n Choice) Name() string

func (Choice) NumChildren

func (n Choice) NumChildren() int

func (Choice) Parent

func (n Choice) Parent() Node

func (Choice) Serialize

func (n Choice) Serialize(b Serializer, path []string, options ...UnionOption)

func (Choice) Set

func (n Choice) Set(auth Auther, path []string) error

func (Choice) Show

func (n Choice) Show(path []string, options ...UnionOption) (string, error)

func (Choice) SortedChildren

func (n Choice) SortedChildren() []Node

func (Choice) ToJSON

func (n Choice) ToJSON(options ...UnionOption) []byte

func (Choice) ToNETCONF

func (n Choice) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (Choice) ToRFC7951

func (n Choice) ToRFC7951(options ...UnionOption) []byte

func (Choice) ToXML

func (n Choice) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (Choice) Updated

func (n Choice) Updated() bool

func (Choice) YangDataChildren

func (n Choice) YangDataChildren() []datanode.DataNode

func (Choice) YangDataChildrenNoSorting

func (n Choice) YangDataChildrenNoSorting() []datanode.DataNode

func (Choice) YangDataName

func (n Choice) YangDataName() string

func (Choice) YangDataValues

func (n Choice) YangDataValues() []string

func (Choice) YangDataValuesNoSorting

func (n Choice) YangDataValuesNoSorting() []string

type Container

type Container struct {
	Schema schema.Container
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer(overlay, underlay *data.Node, sch schema.Container, parent Node, flags Flags) *Container

func (Container) Added

func (n Container) Added() bool

func (Container) Changed

func (n Container) Changed() bool

func (Container) Child

func (n Container) Child(name string) Node

func (Container) Children

func (n Container) Children() map[string]Node

func (Container) Data

func (n Container) Data() *data.Node

func (Container) Default

func (n Container) Default() bool

func (Container) Delete

func (n Container) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (Container) Descendant

func (n Container) Descendant(auth Auther, path []string) (Node, error)

func (Container) Empty

func (n Container) Empty() bool

func (Container) Exists

func (n Container) Exists(auth Auther, path []string) error

func (Container) Get

func (n Container) Get(auth Auther, path []string) ([]string, error)

func (Container) GetHelp

func (n Container) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (Container) GetSchema

func (n Container) GetSchema() schema.Node

func (Container) GetStateJson

func (n Container) GetStateJson(path []string) ([][]byte, error)

func (Container) GetStateJsonWithWarnings

func (n Container) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (Container) IsDefault

func (n Container) IsDefault(auth Auther, path []string) (bool, error)

func (Container) Marshal

func (n Container) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (Container) MarshalInternalJSON

func (n Container) MarshalInternalJSON(options ...UnionOption) []byte

func (Container) Merge

func (n Container) Merge() *data.Node

func (Container) MergeWithoutDefaults

func (n Container) MergeWithoutDefaults() *data.Node

func (Container) Module

func (n Container) Module() string

func (Container) Name

func (n Container) Name() string

func (Container) NumChildren

func (n Container) NumChildren() int

func (Container) Parent

func (n Container) Parent() Node

func (Container) Serialize

func (n Container) Serialize(b Serializer, path []string, options ...UnionOption)

func (Container) Set

func (n Container) Set(auth Auther, path []string) error

func (Container) Show

func (n Container) Show(path []string, options ...UnionOption) (string, error)

func (Container) SortedChildren

func (n Container) SortedChildren() []Node

func (Container) ToJSON

func (n Container) ToJSON(options ...UnionOption) []byte

func (Container) ToNETCONF

func (n Container) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (Container) ToRFC7951

func (n Container) ToRFC7951(options ...UnionOption) []byte

func (Container) ToXML

func (n Container) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (Container) Updated

func (n Container) Updated() bool

func (Container) YangDataChildren

func (n Container) YangDataChildren() []datanode.DataNode

func (Container) YangDataChildrenNoSorting

func (n Container) YangDataChildrenNoSorting() []datanode.DataNode

func (Container) YangDataName

func (n Container) YangDataName() string

func (Container) YangDataValues

func (n Container) YangDataValues() []string

func (Container) YangDataValuesNoSorting

func (n Container) YangDataValuesNoSorting() []string

type Flags

type Flags uint32

type InternalJSONWriter

type InternalJSONWriter struct {
	*JSONWriter
}

func (*InternalJSONWriter) BeginList

func (b *InternalJSONWriter) BeginList(n *List, empty bool, level int)

func (*InternalJSONWriter) BeginListEntry

func (b *InternalJSONWriter) BeginListEntry(n *ListEntry, empty bool, level int, hideSecrets bool)

func (*InternalJSONWriter) EndList

func (b *InternalJSONWriter) EndList(n *List, empty bool, level int)

type JSONWriter

type JSONWriter struct {
	bytes.Buffer
	// contains filtered or unexported fields
}

func (*JSONWriter) BeginContainer

func (b *JSONWriter) BeginContainer(n *Container, empty bool, level int)

func (*JSONWriter) BeginLeaf

func (b *JSONWriter) BeginLeaf(n *Leaf, empty bool, level int, hideSecrets bool)

func (*JSONWriter) BeginLeafList

func (b *JSONWriter) BeginLeafList(
	n *LeafList,
	empty bool,
	level int,
	hideSecrets bool,
)

func (*JSONWriter) BeginList

func (b *JSONWriter) BeginList(n *List, empty bool, level int)

func (*JSONWriter) BeginListEntry

func (b *JSONWriter) BeginListEntry(n *ListEntry, empty bool, level int, hideSecrets bool)

func (*JSONWriter) EndContainer

func (b *JSONWriter) EndContainer(n *Container, empty bool, level int)

func (*JSONWriter) EndLeaf

func (b *JSONWriter) EndLeaf(n *Leaf, empty bool, level int)

func (*JSONWriter) EndLeafList

func (b *JSONWriter) EndLeafList(n *LeafList, empty bool, level int)

func (*JSONWriter) EndList

func (b *JSONWriter) EndList(n *List, empty bool, level int)

func (*JSONWriter) EndListEntry

func (b *JSONWriter) EndListEntry(n *ListEntry, empty bool, level int)

func (*JSONWriter) PrintSep

func (b *JSONWriter) PrintSep()

func (*JSONWriter) WriteLeafListValues

func (b *JSONWriter) WriteLeafListValues(
	n *LeafList,
	empty bool,
	level int,
	hideSecrets bool,
)

func (*JSONWriter) WriteLeafValue

func (b *JSONWriter) WriteLeafValue(
	n *Leaf,
	empty bool,
	level int,
	hideSecrets bool,
)

type Leaf

type Leaf struct {
	Schema schema.Leaf
	// contains filtered or unexported fields
}

func NewLeaf

func NewLeaf(overlay, underlay *data.Node, sch schema.Leaf, parent Node, flags Flags) *Leaf

func (Leaf) Added

func (n Leaf) Added() bool

func (Leaf) Changed

func (n Leaf) Changed() bool

func (Leaf) Child

func (n Leaf) Child(name string) Node

func (Leaf) Children

func (n Leaf) Children() map[string]Node

func (Leaf) Data

func (n Leaf) Data() *data.Node

func (Leaf) Default

func (n Leaf) Default() bool

func (Leaf) Delete

func (n Leaf) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (Leaf) Descendant

func (n Leaf) Descendant(auth Auther, path []string) (Node, error)

func (Leaf) Empty

func (n Leaf) Empty() bool

func (Leaf) Exists

func (n Leaf) Exists(auth Auther, path []string) error

func (Leaf) Get

func (n Leaf) Get(auth Auther, path []string) ([]string, error)

func (Leaf) GetHelp

func (n Leaf) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (Leaf) GetSchema

func (n Leaf) GetSchema() schema.Node

func (Leaf) GetStateJson

func (n Leaf) GetStateJson(path []string) ([][]byte, error)

func (Leaf) GetStateJsonWithWarnings

func (n Leaf) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (Leaf) IsDefault

func (n Leaf) IsDefault(auth Auther, path []string) (bool, error)

func (Leaf) Marshal

func (n Leaf) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (Leaf) MarshalInternalJSON

func (n Leaf) MarshalInternalJSON(options ...UnionOption) []byte

func (Leaf) Merge

func (n Leaf) Merge() *data.Node

func (Leaf) MergeWithoutDefaults

func (n Leaf) MergeWithoutDefaults() *data.Node

func (Leaf) Module

func (n Leaf) Module() string

func (Leaf) Name

func (n Leaf) Name() string

func (Leaf) NumChildren

func (n Leaf) NumChildren() int

func (Leaf) Parent

func (n Leaf) Parent() Node

func (Leaf) Serialize

func (n Leaf) Serialize(b Serializer, path []string, options ...UnionOption)

func (Leaf) Set

func (n Leaf) Set(auth Auther, path []string) error

func (Leaf) Show

func (n Leaf) Show(path []string, options ...UnionOption) (string, error)

func (Leaf) SortedChildren

func (n Leaf) SortedChildren() []Node

func (Leaf) ToJSON

func (n Leaf) ToJSON(options ...UnionOption) []byte

func (Leaf) ToNETCONF

func (n Leaf) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (Leaf) ToRFC7951

func (n Leaf) ToRFC7951(options ...UnionOption) []byte

func (Leaf) ToXML

func (n Leaf) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (Leaf) Updated

func (n Leaf) Updated() bool

func (Leaf) YangDataChildren

func (n Leaf) YangDataChildren() []datanode.DataNode

func (Leaf) YangDataChildrenNoSorting

func (n Leaf) YangDataChildrenNoSorting() []datanode.DataNode

func (Leaf) YangDataName

func (n Leaf) YangDataName() string

func (Leaf) YangDataValues

func (n Leaf) YangDataValues() []string

func (Leaf) YangDataValuesNoSorting

func (n Leaf) YangDataValuesNoSorting() []string

type LeafList

type LeafList struct {
	Schema schema.LeafList
	// contains filtered or unexported fields
}

func NewLeafList

func NewLeafList(overlay, underlay *data.Node, sch schema.LeafList, parent Node, flags Flags) *LeafList

func (LeafList) Added

func (n LeafList) Added() bool

func (LeafList) Changed

func (n LeafList) Changed() bool

func (LeafList) Child

func (n LeafList) Child(name string) Node

func (LeafList) Children

func (n LeafList) Children() map[string]Node

func (LeafList) Data

func (n LeafList) Data() *data.Node

func (LeafList) Default

func (n LeafList) Default() bool

func (LeafList) Delete

func (n LeafList) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (LeafList) Descendant

func (n LeafList) Descendant(auth Auther, path []string) (Node, error)

func (LeafList) Empty

func (n LeafList) Empty() bool

func (LeafList) Exists

func (n LeafList) Exists(auth Auther, path []string) error

func (LeafList) Get

func (n LeafList) Get(auth Auther, path []string) ([]string, error)

func (LeafList) GetHelp

func (n LeafList) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (LeafList) GetSchema

func (n LeafList) GetSchema() schema.Node

func (LeafList) GetStateJson

func (n LeafList) GetStateJson(path []string) ([][]byte, error)

func (LeafList) GetStateJsonWithWarnings

func (n LeafList) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (LeafList) IsDefault

func (n LeafList) IsDefault(auth Auther, path []string) (bool, error)

func (LeafList) Marshal

func (n LeafList) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (LeafList) MarshalInternalJSON

func (n LeafList) MarshalInternalJSON(options ...UnionOption) []byte

func (LeafList) Merge

func (n LeafList) Merge() *data.Node

func (LeafList) MergeWithoutDefaults

func (n LeafList) MergeWithoutDefaults() *data.Node

func (LeafList) Module

func (n LeafList) Module() string

func (LeafList) Name

func (n LeafList) Name() string

func (LeafList) NumChildren

func (n LeafList) NumChildren() int

func (LeafList) Parent

func (n LeafList) Parent() Node

func (LeafList) Serialize

func (n LeafList) Serialize(b Serializer, path []string, options ...UnionOption)

func (LeafList) Set

func (n LeafList) Set(auth Auther, path []string) error

func (LeafList) Show

func (n LeafList) Show(path []string, options ...UnionOption) (string, error)

func (LeafList) SortedChildren

func (n LeafList) SortedChildren() []Node

func (LeafList) ToJSON

func (n LeafList) ToJSON(options ...UnionOption) []byte

func (LeafList) ToNETCONF

func (n LeafList) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (LeafList) ToRFC7951

func (n LeafList) ToRFC7951(options ...UnionOption) []byte

func (LeafList) ToXML

func (n LeafList) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (LeafList) Updated

func (n LeafList) Updated() bool

func (LeafList) YangDataChildren

func (n LeafList) YangDataChildren() []datanode.DataNode

func (LeafList) YangDataChildrenNoSorting

func (n LeafList) YangDataChildrenNoSorting() []datanode.DataNode

func (LeafList) YangDataName

func (n LeafList) YangDataName() string

func (LeafList) YangDataValues

func (n LeafList) YangDataValues() []string

func (LeafList) YangDataValuesNoSorting

func (n LeafList) YangDataValuesNoSorting() []string

type LeafValue

type LeafValue struct {
	Schema schema.LeafValue
	// contains filtered or unexported fields
}

func NewLeafValue

func NewLeafValue(overlay, underlay *data.Node, sch schema.LeafValue, parent Node, flags Flags) *LeafValue

func (LeafValue) Added

func (n LeafValue) Added() bool

func (LeafValue) Changed

func (n LeafValue) Changed() bool

func (LeafValue) Child

func (n LeafValue) Child(name string) Node

func (LeafValue) Children

func (n LeafValue) Children() map[string]Node

func (LeafValue) Data

func (n LeafValue) Data() *data.Node

func (LeafValue) Default

func (n LeafValue) Default() bool

func (LeafValue) Delete

func (n LeafValue) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (LeafValue) Descendant

func (n LeafValue) Descendant(auth Auther, path []string) (Node, error)

func (LeafValue) Empty

func (n LeafValue) Empty() bool

func (LeafValue) Exists

func (n LeafValue) Exists(auth Auther, path []string) error

func (LeafValue) Get

func (n LeafValue) Get(auth Auther, path []string) ([]string, error)

func (LeafValue) GetHelp

func (n LeafValue) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (LeafValue) GetSchema

func (n LeafValue) GetSchema() schema.Node

func (LeafValue) GetStateJson

func (n LeafValue) GetStateJson(path []string) ([][]byte, error)

func (LeafValue) GetStateJsonWithWarnings

func (n LeafValue) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (LeafValue) IsDefault

func (n LeafValue) IsDefault(auth Auther, path []string) (bool, error)

func (LeafValue) Marshal

func (n LeafValue) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (LeafValue) MarshalInternalJSON

func (n LeafValue) MarshalInternalJSON(options ...UnionOption) []byte

func (LeafValue) Merge

func (n LeafValue) Merge() *data.Node

func (LeafValue) MergeWithoutDefaults

func (n LeafValue) MergeWithoutDefaults() *data.Node

func (LeafValue) Module

func (n LeafValue) Module() string

func (LeafValue) Name

func (n LeafValue) Name() string

func (LeafValue) NumChildren

func (n LeafValue) NumChildren() int

func (LeafValue) Parent

func (n LeafValue) Parent() Node

func (LeafValue) Serialize

func (n LeafValue) Serialize(b Serializer, path []string, options ...UnionOption)

func (LeafValue) Set

func (n LeafValue) Set(auth Auther, path []string) error

func (LeafValue) Show

func (n LeafValue) Show(path []string, options ...UnionOption) (string, error)

func (LeafValue) SortedChildren

func (n LeafValue) SortedChildren() []Node

func (LeafValue) ToJSON

func (n LeafValue) ToJSON(options ...UnionOption) []byte

func (LeafValue) ToNETCONF

func (n LeafValue) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (LeafValue) ToRFC7951

func (n LeafValue) ToRFC7951(options ...UnionOption) []byte

func (LeafValue) ToXML

func (n LeafValue) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (LeafValue) Updated

func (n LeafValue) Updated() bool

func (LeafValue) YangDataChildren

func (n LeafValue) YangDataChildren() []datanode.DataNode

func (LeafValue) YangDataChildrenNoSorting

func (n LeafValue) YangDataChildrenNoSorting() []datanode.DataNode

func (LeafValue) YangDataName

func (n LeafValue) YangDataName() string

func (LeafValue) YangDataValues

func (n LeafValue) YangDataValues() []string

func (LeafValue) YangDataValuesNoSorting

func (n LeafValue) YangDataValuesNoSorting() []string

type List

type List struct {
	Schema schema.List
	// contains filtered or unexported fields
}

func NewList

func NewList(overlay, underlay *data.Node, sch schema.List, parent Node, flags Flags) *List

func (List) Added

func (n List) Added() bool

func (List) Changed

func (n List) Changed() bool

func (List) Child

func (n List) Child(name string) Node

func (List) Children

func (n List) Children() map[string]Node

func (List) Data

func (n List) Data() *data.Node

func (List) Default

func (n List) Default() bool

func (List) Delete

func (n List) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (List) Descendant

func (n List) Descendant(auth Auther, path []string) (Node, error)

func (List) Empty

func (n List) Empty() bool

func (List) Exists

func (n List) Exists(auth Auther, path []string) error

func (List) Get

func (n List) Get(auth Auther, path []string) ([]string, error)

func (List) GetHelp

func (n List) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (List) GetSchema

func (n List) GetSchema() schema.Node

func (List) GetStateJson

func (n List) GetStateJson(path []string) ([][]byte, error)

func (List) GetStateJsonWithWarnings

func (n List) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (List) IsDefault

func (n List) IsDefault(auth Auther, path []string) (bool, error)

func (List) Marshal

func (n List) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (List) MarshalInternalJSON

func (n List) MarshalInternalJSON(options ...UnionOption) []byte

func (List) Merge

func (n List) Merge() *data.Node

func (List) MergeWithoutDefaults

func (n List) MergeWithoutDefaults() *data.Node

func (List) Module

func (n List) Module() string

func (List) Name

func (n List) Name() string

func (List) NumChildren

func (n List) NumChildren() int

func (List) Parent

func (n List) Parent() Node

func (List) Serialize

func (n List) Serialize(b Serializer, path []string, options ...UnionOption)

func (List) Set

func (n List) Set(auth Auther, path []string) error

func (List) Show

func (n List) Show(path []string, options ...UnionOption) (string, error)

func (List) SortedChildren

func (n List) SortedChildren() []Node

func (List) ToJSON

func (n List) ToJSON(options ...UnionOption) []byte

func (List) ToNETCONF

func (n List) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (List) ToRFC7951

func (n List) ToRFC7951(options ...UnionOption) []byte

func (List) ToXML

func (n List) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (List) Updated

func (n List) Updated() bool

func (List) YangDataChildren

func (n List) YangDataChildren() []datanode.DataNode

func (List) YangDataChildrenNoSorting

func (n List) YangDataChildrenNoSorting() []datanode.DataNode

func (List) YangDataName

func (n List) YangDataName() string

func (List) YangDataValues

func (n List) YangDataValues() []string

func (List) YangDataValuesNoSorting

func (n List) YangDataValuesNoSorting() []string

type ListEntry

type ListEntry struct {
	Schema schema.ListEntry
	// contains filtered or unexported fields
}

func NewListEntry

func NewListEntry(overlay, underlay *data.Node, sch schema.ListEntry, parent Node, flags Flags) *ListEntry

func (ListEntry) Added

func (n ListEntry) Added() bool

func (ListEntry) Changed

func (n ListEntry) Changed() bool

func (ListEntry) Child

func (n ListEntry) Child(name string) Node

func (ListEntry) Children

func (n ListEntry) Children() map[string]Node

func (ListEntry) Data

func (n ListEntry) Data() *data.Node

func (ListEntry) Default

func (n ListEntry) Default() bool

func (ListEntry) Delete

func (n ListEntry) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (ListEntry) Descendant

func (n ListEntry) Descendant(auth Auther, path []string) (Node, error)

func (ListEntry) Empty

func (n ListEntry) Empty() bool

func (ListEntry) Exists

func (n ListEntry) Exists(auth Auther, path []string) error

func (ListEntry) Get

func (n ListEntry) Get(auth Auther, path []string) ([]string, error)

func (ListEntry) GetHelp

func (n ListEntry) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (ListEntry) GetSchema

func (n ListEntry) GetSchema() schema.Node

func (ListEntry) GetStateJson

func (n ListEntry) GetStateJson(path []string) ([][]byte, error)

func (ListEntry) GetStateJsonWithWarnings

func (n ListEntry) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (ListEntry) IsDefault

func (n ListEntry) IsDefault(auth Auther, path []string) (bool, error)

func (ListEntry) Marshal

func (n ListEntry) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (ListEntry) MarshalInternalJSON

func (n ListEntry) MarshalInternalJSON(options ...UnionOption) []byte

func (ListEntry) Merge

func (n ListEntry) Merge() *data.Node

func (ListEntry) MergeWithoutDefaults

func (n ListEntry) MergeWithoutDefaults() *data.Node

func (ListEntry) Module

func (n ListEntry) Module() string

func (ListEntry) Name

func (n ListEntry) Name() string

func (ListEntry) NumChildren

func (n ListEntry) NumChildren() int

func (ListEntry) Parent

func (n ListEntry) Parent() Node

func (ListEntry) Serialize

func (n ListEntry) Serialize(b Serializer, path []string, options ...UnionOption)

func (ListEntry) Set

func (n ListEntry) Set(auth Auther, path []string) error

func (ListEntry) Show

func (n ListEntry) Show(path []string, options ...UnionOption) (string, error)

func (ListEntry) SortedChildren

func (n ListEntry) SortedChildren() []Node

func (ListEntry) ToJSON

func (n ListEntry) ToJSON(options ...UnionOption) []byte

func (ListEntry) ToNETCONF

func (n ListEntry) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (ListEntry) ToRFC7951

func (n ListEntry) ToRFC7951(options ...UnionOption) []byte

func (ListEntry) ToXML

func (n ListEntry) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (ListEntry) Updated

func (n ListEntry) Updated() bool

func (ListEntry) YangDataChildren

func (n ListEntry) YangDataChildren() []datanode.DataNode

func (ListEntry) YangDataChildrenNoSorting

func (n ListEntry) YangDataChildrenNoSorting() []datanode.DataNode

func (ListEntry) YangDataName

func (n ListEntry) YangDataName() string

func (ListEntry) YangDataValues

func (n ListEntry) YangDataValues() []string

func (ListEntry) YangDataValuesNoSorting

func (n ListEntry) YangDataValuesNoSorting() []string

type Node

type Node interface {
	datanode.DataNode
	// contains filtered or unexported methods
}

Node describes the full external API

func NewNode

func NewNode(overlay, underlay *data.Node, sch schema.Node, parent Node, flags Flags) Node

func UnmarshalJSON

func UnmarshalJSON(schemaRoot schema.Node, jsonInput []byte) (Node, error)

Take the JSON message and create a UnionTree using the given schema and message content.

func UnmarshalJSONWithoutValidation

func UnmarshalJSONWithoutValidation(
	schemaRoot schema.Node,
	jsonInput []byte,
) (Node, error)

func UnmarshalRFC7951

func UnmarshalRFC7951(schemaRoot schema.Node, jsonInput []byte) (Node, error)

func UnmarshalXML

func UnmarshalXML(schemaRoot schema.Node, xml_input []byte) (root Node, err error)

type Root

type Root struct {
	Schema schema.Tree
	// contains filtered or unexported fields
}

func NewRoot

func NewRoot(overlay, underlay *data.Node, sch schema.Tree, parent Node, flags Flags) *Root

func (Root) Added

func (n Root) Added() bool

func (Root) Changed

func (n Root) Changed() bool

func (Root) Child

func (n Root) Child(name string) Node

func (Root) Children

func (n Root) Children() map[string]Node

func (Root) Data

func (n Root) Data() *data.Node

func (Root) Default

func (n Root) Default() bool

func (Root) Delete

func (n Root) Delete(auth Auther, path []string, checkAuth bool) error

Two modes of operation:

- CheckAuth: check authorization on each node. Bottom up deletion - DontCheckAuth: propagate top level authorization. Top down deletion

func (Root) Descendant

func (n Root) Descendant(auth Auther, path []string) (Node, error)

func (Root) Empty

func (n Root) Empty() bool

func (Root) Exists

func (n Root) Exists(auth Auther, path []string) error

func (Root) Get

func (n Root) Get(auth Auther, path []string) ([]string, error)

func (Root) GetHelp

func (n Root) GetHelp(auth Auther, fromSchema bool, path []string) (map[string]string, error)

func (Root) GetSchema

func (n Root) GetSchema() schema.Node

func (Root) GetStateJson

func (n Root) GetStateJson(path []string) ([][]byte, error)

func (Root) GetStateJsonWithWarnings

func (n Root) GetStateJsonWithWarnings(
	path []string,
	logger schema.StateLogger,
) ([][]byte, []error)

func (Root) IsDefault

func (n Root) IsDefault(auth Auther, path []string) (bool, error)

func (Root) Marshal

func (n Root) Marshal(rootName, encoding string, options ...UnionOption) (string, error)

func (Root) MarshalInternalJSON

func (n Root) MarshalInternalJSON(options ...UnionOption) []byte

func (Root) Merge

func (n Root) Merge() *data.Node

func (Root) MergeWithoutDefaults

func (n Root) MergeWithoutDefaults() *data.Node

func (Root) Module

func (n Root) Module() string

func (Root) Name

func (n Root) Name() string

func (Root) NumChildren

func (n Root) NumChildren() int

func (Root) Parent

func (n Root) Parent() Node

func (Root) Serialize

func (n Root) Serialize(b Serializer, path []string, options ...UnionOption)

func (Root) Set

func (n Root) Set(auth Auther, path []string) error

func (Root) Show

func (n Root) Show(path []string, options ...UnionOption) (string, error)

func (Root) SortedChildren

func (n Root) SortedChildren() []Node

func (Root) ToJSON

func (n Root) ToJSON(options ...UnionOption) []byte

func (Root) ToNETCONF

func (n Root) ToNETCONF(rootName string, options ...UnionOption) []byte

ToNETCONF - return <n> serialized in NETCONF format.

For 'netconf', we need to fill in the enclosing tags up to root, eg if <n> represents '/interfaces/dataplane/dp0s1/address', we need to return tags for interfaces, dataplane *and* tagnode (dp0s1)

func (Root) ToRFC7951

func (n Root) ToRFC7951(options ...UnionOption) []byte

func (Root) ToXML

func (n Root) ToXML(rootName string, options ...UnionOption) []byte

ToXML - return <n> serialized in XML format.

For 'xml', we just return the node and entries under it, wrapped in the tag for the rootName.

func (Root) Updated

func (n Root) Updated() bool

func (Root) YangDataChildren

func (n Root) YangDataChildren() []datanode.DataNode

func (Root) YangDataChildrenNoSorting

func (n Root) YangDataChildrenNoSorting() []datanode.DataNode

func (Root) YangDataName

func (n Root) YangDataName() string

func (Root) YangDataValues

func (n Root) YangDataValues() []string

func (Root) YangDataValuesNoSorting

func (n Root) YangDataValuesNoSorting() []string

type Serializer

type Serializer interface {
	BeginContainer(n *Container, empty bool, level int)
	EndContainer(n *Container, empty bool, level int)

	BeginList(n *List, empty bool, level int)
	EndList(n *List, empty bool, level int)
	BeginListEntry(n *ListEntry, empty bool, level int, hidesecrets bool)
	EndListEntry(n *ListEntry, empty bool, level int)

	BeginLeaf(n *Leaf, empty bool, level int, hideSecrets bool)
	WriteLeafValue(n *Leaf, empty bool, level int, hideSecrets bool)
	EndLeaf(n *Leaf, empty bool, level int)

	BeginLeafList(n *LeafList, empty bool, level int, hideSecrets bool)
	WriteLeafListValues(n *LeafList, empty bool, level int, hideSecrets bool)
	EndLeafList(n *LeafList, empty bool, level int)

	PrintSep()
}

type StringWriter

type StringWriter struct {
	bytes.Buffer
}

func (*StringWriter) BeginContainer

func (b *StringWriter) BeginContainer(n *Container, empty bool, level int)

func (*StringWriter) BeginLeaf

func (b *StringWriter) BeginLeaf(n *Leaf, empty bool, level int, hideSecrets bool)

func (*StringWriter) BeginLeafList

func (b *StringWriter) BeginLeafList(n *LeafList, empty bool, level int, hideSecrets bool)

func (*StringWriter) BeginList

func (b *StringWriter) BeginList(n *List, empty bool, level int)

func (*StringWriter) BeginListEntry

func (b *StringWriter) BeginListEntry(n *ListEntry, empty bool, level int, hideSecrets bool)

func (*StringWriter) EndContainer

func (b *StringWriter) EndContainer(n *Container, empty bool, level int)

func (*StringWriter) EndLeaf

func (b *StringWriter) EndLeaf(n *Leaf, empty bool, level int)

func (*StringWriter) EndLeafList

func (b *StringWriter) EndLeafList(n *LeafList, empty bool, level int)

func (*StringWriter) EndList

func (b *StringWriter) EndList(n *List, empty bool, level int)

func (*StringWriter) EndListEntry

func (b *StringWriter) EndListEntry(n *ListEntry, empty bool, level int)

func (*StringWriter) PrintSep

func (b *StringWriter) PrintSep()

func (*StringWriter) WriteLeafListValues

func (b *StringWriter) WriteLeafListValues(n *LeafList, empty bool, level int, hideSecrets bool)

func (*StringWriter) WriteLeafValue

func (b *StringWriter) WriteLeafValue(n *Leaf, empty bool, level int, hideSecrets bool)

type UnionOption

type UnionOption func(*unionOptions)

func Authorizer

func Authorizer(auth Auther) UnionOption

type Unmarshaller

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

We can completely avoid the rat's nest of ever increasing APIs for unmarshalling different encoding types with different validation requirements by using the generic unmarshaller interface provided by the 'encoder'.

func NewUnmarshaller

func NewUnmarshaller(enc encoding.EncType) *Unmarshaller

func (*Unmarshaller) SetValidation

func (um *Unmarshaller) SetValidation(
	valType yang.ValidationType,
) *Unmarshaller

func (*Unmarshaller) Unmarshal

func (um *Unmarshaller) Unmarshal(
	ms schema.ModelSet,
	input []byte,
) (root Node, err error)

type XMLWriter

type XMLWriter struct {
	*xml.Encoder
}

func (*XMLWriter) BeginContainer

func (enc *XMLWriter) BeginContainer(n *Container, empty bool, level int)

func (*XMLWriter) BeginLeaf

func (enc *XMLWriter) BeginLeaf(n *Leaf, empty bool, level int, hideSecrets bool)

func (*XMLWriter) BeginLeafList

func (enc *XMLWriter) BeginLeafList(n *LeafList, empty bool, level int, hideSecrets bool)

func (*XMLWriter) BeginList

func (enc *XMLWriter) BeginList(n *List, empty bool, level int)

func (*XMLWriter) BeginListEntry

func (enc *XMLWriter) BeginListEntry(n *ListEntry, empty bool, level int, hideSecrets bool)

func (*XMLWriter) EndContainer

func (enc *XMLWriter) EndContainer(n *Container, empty bool, level int)

func (*XMLWriter) EndLeaf

func (enc *XMLWriter) EndLeaf(n *Leaf, empty bool, level int)

func (*XMLWriter) EndLeafList

func (enc *XMLWriter) EndLeafList(n *LeafList, empty bool, level int)

func (*XMLWriter) EndList

func (enc *XMLWriter) EndList(n *List, empty bool, level int)

func (*XMLWriter) EndListEntry

func (enc *XMLWriter) EndListEntry(n *ListEntry, empty bool, level int)

func (*XMLWriter) PrintSep

func (enc *XMLWriter) PrintSep()

func (*XMLWriter) WriteLeafListValues

func (enc *XMLWriter) WriteLeafListValues(n *LeafList, empty bool, level int, hideSecrets bool)

func (*XMLWriter) WriteLeafValue

func (enc *XMLWriter) WriteLeafValue(n *Leaf, empty bool, level int, hideSecrets bool)

Jump to

Keyboard shortcuts

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