Documentation ¶
Overview ¶
Package yang is used to parse .yang files (see RFC 6020).
A generic yang statments takes one of the forms:
keyword [argument] ; keyword [argument] { [statement [...]] }
At the lowest level, package yang returns a simple tree of statements via the Parse function. The Parse function makes no attempt to determine the validity of the source, other than checking for generic syntax errors.
At it's simplest, the GetModule function is used. The GetModule function searches the current directory, and any directory added to the Path variable, for a matching .yang source file by appending .yang to the name of the module:
// Get the tree for the module module-name by looking for the source // file named module-name.yang. e, errs := yang.GetModule("module-name" [, optional sources...]) if len(errs) > 0 { for _, err := range errs { fmt.Fprintln(os.Stderr, err) } os.Exit(1) } // e is the Entry tree for "module-name"
More complicated uses cases should use NewModules and then some combination of Modules.GetModule, Modules.Read, Modules.Parse, and Modules.GetErrors.
The GetErrors method is mandatory, however, both yang.GetModule and Modules.GetModule automatically call Modules.GetErrors.
Index ¶
- Constants
- Variables
- func AddPath(paths ...string)
- func CamelCase(s string) string
- func Frac(f float64) float64
- func PathsWithModules(root string) (paths []string, err error)
- func PrintNode(w io.Writer, n Node)
- func Source(n Node) string
- type Action
- type AnyData
- type AnyXML
- type Argument
- type Augment
- type BelongsTo
- type Bit
- type Case
- type Choice
- type Container
- type Deviate
- type Deviation
- type Element
- type Entry
- func (e *Entry) Augment(addErrors bool) (processed, skipped int)
- func (e *Entry) DefaultValue() string
- func (e *Entry) Find(name string) *Entry
- func (e *Entry) FixChoice()
- func (e *Entry) GetErrors() []error
- func (e *Entry) InstantiatingModule() (string, error)
- func (e *Entry) IsCase() bool
- func (e *Entry) IsChoice() bool
- func (e *Entry) IsContainer() bool
- func (e *Entry) IsDir() bool
- func (e *Entry) IsLeaf() bool
- func (e *Entry) IsLeafList() bool
- func (e *Entry) IsList() bool
- func (e *Entry) Modules() *Modules
- func (e *Entry) Namespace() *Value
- func (e *Entry) Path() string
- func (e *Entry) Print(w io.Writer)
- func (e *Entry) ReadOnly() bool
- type EntryKind
- type Enum
- type EnumType
- func (e *EnumType) IsDefined(name string) bool
- func (e *EnumType) Name(value int64) string
- func (e *EnumType) NameMap() map[string]int64
- func (e *EnumType) Names() []string
- func (e *EnumType) Set(name string, value int64) error
- func (e *EnumType) SetNext(name string) error
- func (e *EnumType) Value(name string) int64
- func (e *EnumType) ValueMap() map[int64]string
- func (e *EnumType) Values() []int64
- type ErrorNode
- type Extension
- type Feature
- type Grouping
- type Identity
- func (s *Identity) Exts() []*Statement
- func (s *Identity) GetValue(name string) *Identity
- func (s *Identity) IsDefined(name string) bool
- func (Identity) Kind() string
- func (s *Identity) NName() string
- func (s *Identity) ParentNode() Node
- func (s *Identity) PrefixedName() string
- func (s *Identity) Statement() *Statement
- type Import
- type Include
- type Input
- type Leaf
- type LeafList
- type Length
- type List
- type ListAttr
- type Module
- func (s *Module) Current() string
- func (s *Module) Exts() []*Statement
- func (s *Module) FullName() string
- func (m *Module) GetPrefix() string
- func (s *Module) Groupings() []*Grouping
- func (s *Module) Identities() []*Identity
- func (s *Module) Kind() string
- func (s *Module) NName() string
- func (s *Module) ParentNode() Node
- func (s *Module) Statement() *Statement
- func (s *Module) Typedefs() []*Typedef
- type Modules
- func (ms *Modules) FindModule(n Node) *Module
- func (ms *Modules) FindModuleByNamespace(ns string) (*Module, error)
- func (ms *Modules) FindModuleByPrefix(prefix string) (*Module, error)
- func (ms *Modules) GetModule(name string) (*Entry, []error)
- func (ms *Modules) Parse(data, name string) error
- func (ms *Modules) Process() []error
- func (ms *Modules) Read(name string) error
- type Must
- type Node
- type Notification
- type Number
- type NumberKind
- type Options
- type Output
- type Pattern
- type RPC
- type RPCEntry
- type Range
- type Refine
- type Revision
- type Statement
- func (s *Statement) Arg() (string, bool)
- func (s *Statement) Exts() []*Statement
- func (s *Statement) Kind() string
- func (s *Statement) Location() string
- func (s *Statement) NName() string
- func (s *Statement) ParentNode() Node
- func (s *Statement) Statement() *Statement
- func (s *Statement) String() string
- func (s *Statement) SubStatements() []*Statement
- func (s *Statement) Write(w io.Writer, indent string) error
- type TriState
- type Type
- type TypeKind
- type Typedef
- type Typedefer
- type Uses
- type Value
- type YRange
- type YangRange
- type YangType
- Bugs
Constants ¶
const ( TSUnset = TriState(iota) TSTrue TSFalse )
The possible states of a TriState.
const ( LeafEntry = EntryKind(iota) DirectoryEntry AnyDataEntry AnyXMLEntry CaseEntry ChoiceEntry InputEntry NotificationEntry OutputEntry )
Enumeration of the types of entries.
const ( Ynone = TypeKind(iota) Yint8 // int in range [-128, 127] Yint16 // int in range [-32768, 32767] Yint32 // int in range [-2147483648, 2147483647] Yint64 // int in range [-9223372036854775808, 9223372036854775807] Yuint8 // int in range [0, 255] Yuint16 // int in range [0, 65535] Yuint32 // int in range [0, 4294967295] Yuint64 // int in range [0, 18446744073709551615] Ybinary // arbitrary data Ybits // set of bits or flags Ybool // true or false Ydecimal64 // signed decimal number Yempty // no associated value Yenum // enumerated strings Yidentityref // reference to abstrace identity YinstanceIdentifier // reference of a data tree node Yleafref // reference to a leaf instance Ystring // human readable string Yunion // choice of types )
const ( MaxInt64 = 1<<63 - 1 // maximum value of a signed int64 MinInt64 = -1 << 63 // minimum value of a signed int64 AbsMinInt64 = 1 << 63 // the absolute value of MinInt64 MaxEnum = 1<<31 - 1 // maximum value of an enum MinEnum = -1 << 31 // minimum value of an enum MaxBitfieldSize = 1 << 32 // maximum number of bits in a bitfield MaxFractionDigits uint8 = 18 // maximum fractional digits per Section 9.3.4 )
const ( Positive = NumberKind(iota) // Number is non-negative Negative // Number is negative MinNumber // Number is minimum value allowed for range MaxNumber // Number is maximum value allowed for range )
Variables ¶
var ( Int8Range = mustParseRanges("-128..127") Int16Range = mustParseRanges("-32768..32767") Int32Range = mustParseRanges("-2147483648..2147483647") Int64Range = mustParseRanges("-9223372036854775808..9223372036854775807") Uint8Range = mustParseRanges("0..255") Uint16Range = mustParseRanges("0..65535") Uint32Range = mustParseRanges("0..4294967295") Uint64Range = mustParseRanges("0..18446744073709551615") Decimal64Range = mustParseRanges("min..max") )
These are the default ranges defined by the YANG standard.
var BaseTypedefs = map[string]*Typedef{}
BaseTypedefs is a map of all base types to the Typedef structure manufactured for the type.
var EntryKindToName = map[EntryKind]string{ LeafEntry: "Leaf", DirectoryEntry: "Directory", AnyDataEntry: "AnyData", AnyXMLEntry: "AnyXML", CaseEntry: "Case", ChoiceEntry: "Choice", InputEntry: "Input", NotificationEntry: "Notification", OutputEntry: "Output", }
EntryKindToName maps EntryKind to their names
var ParseOptions = Options{}
ParseOptions sets the options for the current YANG module parsing. It can be directly set by the caller to influence how goyang will behave in the presence of certain exceptional cases.
var Path []string
Path is the list of directories to look for .yang files in.
var TypeKindFromName = map[string]TypeKind{ "none": Ynone, "int8": Yint8, "int16": Yint16, "int32": Yint32, "int64": Yint64, "uint8": Yuint8, "uint16": Yuint16, "uint32": Yuint32, "uint64": Yuint64, "binary": Ybinary, "bits": Ybits, "boolean": Ybool, "decimal64": Ydecimal64, "empty": Yempty, "enumeration": Yenum, "identityref": Yidentityref, "instance-identifier": YinstanceIdentifier, "leafref": Yleafref, "string": Ystring, "union": Yunion, }
var TypeKindToName = map[TypeKind]string{ Ynone: "none", Yint8: "int8", Yint16: "int16", Yint32: "int32", Yint64: "int64", Yuint8: "uint8", Yuint16: "uint16", Yuint32: "uint32", Yuint64: "uint64", Ybinary: "binary", Ybits: "bits", Ybool: "boolean", Ydecimal64: "decimal64", Yempty: "empty", Yenum: "enumeration", Yidentityref: "identityref", YinstanceIdentifier: "instance-identifier", Yleafref: "leafref", Ystring: "string", Yunion: "union", }
Functions ¶
func AddPath ¶
func AddPath(paths ...string)
AddPath adds the directories specified in p, a colon separated list of directory names, to Path, if they are not already in Path. Using multiple arguments is also supported.
func CamelCase ¶
CamelCase returns the CamelCased name. If there is an interior underscore or dash followed by a lower case letter, drop the underscore or dash and convert the letter to upper case. There is a remote possibility of this rewrite causing a name collision, but it's so remote we're prepared to pretend it's nonexistent - since the C++ generator lowercases names, it's extremely unlikely to have two fields with different capitalizations. In short, _my_field_name_2 becomes XMyFieldName_2.
func PathsWithModules ¶
PathsWithModules returns all paths under and including the root containing files with a ".yang" extension, as well as any error encountered
Types ¶
type Action ¶
type Action struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` Grouping []*Grouping `yang:"grouping"` IfFeature []*Value `yang:"if-feature"` Input *Input `yang:"input"` Output *Output `yang:"output"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Typedef []*Typedef `yang:"typedef"` }
An Action is defined in http://tools.ietf.org/html/rfc7950#section-7.15
Action define an RPC operation connected to a specific container or list data node in the schema. In the schema tree, Action differ from RPC only in where in the tree they are found. RPC nodes are only found as sub-statements of a Module, while Action are found only as sub-statements of Container, List, Grouping and Augment nodes.
func (*Action) ParentNode ¶
type AnyData ¶
type AnyData struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Config *Value `yang:"config"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Mandatory *Value `yang:"mandatory"` Must []*Must `yang:"must"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` When *Value `yang:"when"` }
An AnyData is defined in: http://tools.ietf.org/html/rfc7950#section-7.10
AnyData are only expected in YANG 1.1 modules (those with a "yang-version 1.1;" statement in the module).
func (*AnyData) ParentNode ¶
type AnyXML ¶
type AnyXML struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Config *Value `yang:"config"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Mandatory *Value `yang:"mandatory"` Must []*Must `yang:"must"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` When *Value `yang:"when"` }
An AnyXML is defined in: http://tools.ietf.org/html/rfc6020#section-7.10
func (*AnyXML) ParentNode ¶
type Argument ¶
type Argument struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` YinElement *Value `yang:"yin-element"` }
An Argument is defined in: http://tools.ietf.org/html/rfc6020#section-7.17.2
func (*Argument) ParentNode ¶
type Augment ¶
type Augment struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Action []*Action `yang:"action"` Anyxml []*AnyXML `yang:"anyxml"` Case []*Case `yang:"case"` Choice []*Choice `yang:"choice"` Container []*Container `yang:"container"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Uses []*Uses `yang:"uses"` When *Value `yang:"when"` }
An Augment is defined in: http://tools.ietf.org/html/rfc6020#section-7.15 and http://tools.ietf.org/html/rfc7950#section-7.17 ("action" sub-statement)
func (*Augment) ParentNode ¶
type BelongsTo ¶
type BelongsTo struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Prefix *Value `yang:"prefix,required"` }
A BelongsTo is defined in: http://tools.ietf.org/html/rfc6020#section-7.2.2
func (*BelongsTo) ParentNode ¶
type Bit ¶
type Bit struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Position *Value `yang:"position"` }
A Bit is defined in: http://tools.ietf.org/html/rfc6020#section-9.7.4
func (*Bit) ParentNode ¶
type Case ¶
type Case struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Anyxml []*AnyXML `yang:"anyxml"` Choice []*Choice `yang:"choice"` Container []*Container `yang:"container"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Uses []*Uses `yang:"uses"` When *Value `yang:"when"` }
A Case is defined in: http://tools.ietf.org/html/rfc6020#section-7.9.2
func (*Case) ParentNode ¶
type Choice ¶
type Choice struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Anyxml []*AnyXML `yang:"anyxml"` Case []*Case `yang:"case"` Config *Value `yang:"config"` Container []*Container `yang:"container"` Default *Value `yang:"default"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Mandatory *Value `yang:"mandatory"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` When *Value `yang:"when"` }
A Choice is defined in: http://tools.ietf.org/html/rfc6020#section-7.9
func (*Choice) ParentNode ¶
type Container ¶
type Container struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Action []*Action `yang:"action"` Anyxml []*AnyXML `yang:"anyxml"` Choice []*Choice `yang:"choice"` Config *Value `yang:"config"` Container []*Container `yang:"container"` Description *Value `yang:"description"` Grouping []*Grouping `yang:"grouping"` IfFeature []*Value `yang:"if-feature"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Must []*Must `yang:"must"` Presence *Value `yang:"presence"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Typedef []*Typedef `yang:"typedef"` Uses []*Uses `yang:"uses"` When *Value `yang:"when"` }
A Container is defined in: http://tools.ietf.org/html/rfc6020#section-7.5 and http://tools.ietf.org/html/rfc7950#section-7.5 ("action" sub-statement)
func (*Container) ParentNode ¶
type Deviate ¶
type Deviate struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Config *Value `yang:"config"` Default *Value `yang:"default"` Mandatory *Value `yang:"mandatory"` MaxElements *Value `yang:"max-elements"` MinElements *Value `yang:"min-elements"` Must []*Must `yang:"must"` Type *Type `yang:"type"` Unique []*Value `yang:"unique"` Units *Value `yang:"units"` }
A Deviate is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.3.2
func (*Deviate) ParentNode ¶
type Deviation ¶
type Deviation struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` Deviate []*Deviate `yang:"deviate,required"` Reference *Value `yang:"reference"` }
A Deviation is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.3
func (*Deviation) ParentNode ¶
type Element ¶
type Element struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` YinElement *Value `yang:"yin-element"` }
An Element is defined in: http://tools.ietf.org/html/rfc6020#section-7.17.2.2
func (*Element) ParentNode ¶
type Entry ¶
type Entry struct { Parent *Entry `json:"-"` Node Node `json:"-"` // the base node this Entry was derived from. Name string // our name, same as the key in our parent Dirs Description string `json:",omitempty"` // description from node, if any Default string `json:",omitempty"` // default from node, if any Errors []error `json:"-"` // list of errors encountered on this node Kind EntryKind // kind of Entry Config TriState // config state of this entry, if known Prefix *Value `json:",omitempty"` // prefix to use from this point down // Fields associated with directory nodes Dir map[string]*Entry `json:",omitempty"` Key string `json:",omitempty"` // Optional key name for lists (i.e., maps) // Fields associated with leaf nodes Type *YangType `json:",omitempty"` Exts []*Statement `json:",omitempty"` // extensions found // Fields associated with list nodes (both lists and leaf-lists) ListAttr *ListAttr `json:",omitempty"` RPC *RPCEntry `json:",omitempty"` // set if we are an RPC // Identities that are defined in this context, this is set if the Entry // is a module only. Identities []*Identity `json:",omitempty"` Augments []*Entry `json:"-"` // Augments associated with this entry // Extra maps all the unsupported fields to their values Extra map[string][]interface{} `json:"-"` // Annotation stores annotated values, and is not populated by this // library but rather can be used by calling code where additional // information should be stored alongside the Entry. Annotation map[string]interface{} `json:",omitempty"` // contains filtered or unexported fields }
An Entry represents a single node (directory or leaf) created from the AST. Directory entries have a non-nil Dir entry. Leaf nodes have a nil Dir entry. If Errors is not nil then the only other valid field is Node.
func GetModule ¶
GetModule optionally reads in a set of YANG source files, named by sources, and then returns the Entry for the module named module. If sources is missing, or the named module is not yet known, GetModule searches for name with the suffix ".yang". GetModule either returns an Entry or returns one or more errors.
GetModule is a convience function for calling NewModules, Read, and Process, and then looking up the module name.
func ToEntry ¶
ToEntry expands node n into a directory Entry. Expansion is based on the YANG tags in the structure behind n. ToEntry must only be used with nodes that are directories, such as top level modules and sub-modules. ToEntry never returns nil. Any errors encountered are found in the Errors fields of the returned Entry and its children. Use GetErrors to determine if there were any errors.
func (*Entry) Augment ¶
Augment processes augments in e, return the number of augments processed and the augments skipped. If addErrors is true then missing augments will generate errors.
func (*Entry) DefaultValue ¶
DefaultValue returns the schema default value for e, if any. If the leaf has no explicit default, its type default (if any) will be used.
func (*Entry) FixChoice ¶
func (e *Entry) FixChoice()
FixChoice inserts missing Case entries in a choice
func (*Entry) InstantiatingModule ¶
InstantiatingModule returns the YANG module which instanitated the Entry within the schema tree - using the same rules described in the documentation of the Namespace function. The namespace is resolved in the module name. This approach to namespacing is used when serialising YANG-modelled data to JSON as per RFC7951.
func (*Entry) IsContainer ¶
IsContainer returns true if e is a container.
func (*Entry) IsLeaf ¶
IsLeaf returns true if e is a leaf i.e. is not a container, list, leaf-list, choice or case statement.
func (*Entry) IsLeafList ¶
IsLeafList returns true if e is a leaf-list.
func (*Entry) Modules ¶
Modules returns the Modules structure that e is part of. This is needed when looking for rooted nodes not part of this Entry tree.
func (*Entry) Namespace ¶
Namespace returns the YANG/XML namespace Value for e as mounted in the Entry tree (e.g., as placed by grouping statements).
Per RFC6020 section 7.12, the namespace on elements in the tree due to a "uses" statement is that of the where the uses statement occurs, i.e., the user, rather than creator (grouping) of those elements, so we follow the usage (Entry) tree up to the parent before obtaining the (then adjacent) root node for its namespace Value.
type EntryKind ¶
type EntryKind int
An EntryKind is the kind of node an Entry is. All leaf nodes are of kind LeafEntry. A LeafList is also considered a leaf node. All other kinds are directory nodes.
type Enum ¶
type Enum struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Value *Value `yang:"value"` }
An Enum is defined in: http://tools.ietf.org/html/rfc6020#section-9.6.4
func (*Enum) ParentNode ¶
type EnumType ¶
type EnumType struct {
// contains filtered or unexported fields
}
A EnumType represents a mapping of strings to integers. It is used both for enumerations as well as bitfields.
func NewBitfield ¶
func NewBitfield() *EnumType
NewBitfield returns an EnumType initialized as a bitfield. Multiple string values may map to the same numeric values. Numeric values must be small non-negative integers.
func (*EnumType) Name ¶
Name returns the name in e associated with value. The empty string is returned if no name has been assigned to value.
func (*EnumType) Set ¶
Set sets name in e to the provided value. Set returns an error if the value is invalid, name is already signed, or when used as an enum rather than a bitfield, the value has previousl been used. When two different names are assigned to the same value, the conversion from value to name will result in the most recently assigned name.
func (*EnumType) SetNext ¶
SetNext sets the name in e using the next possible value that is greater than all previous values.
func (*EnumType) Value ¶
Value returns the value associated with name in e associated. 0 is returned if name is not in e, or if it is the first value in an unnumbered enum. Use IsDefined to definitively confirm name is in e.
type Extension ¶
type Extension struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Argument *Argument `yang:"argument"` Description *Value `yang:"description"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` }
An Extension is defined in: http://tools.ietf.org/html/rfc6020#section-7.17
func (*Extension) ParentNode ¶
type Feature ¶
type Feature struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Status *Value `yang:"status"` Reference *Value `yang:"reference"` }
A Feature is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.1
func (*Feature) ParentNode ¶
type Grouping ¶
type Grouping struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Action []*Action `yang:"action"` Anyxml []*AnyXML `yang:"anyxml"` Choice []*Choice `yang:"choice"` Container []*Container `yang:"container"` Description *Value `yang:"description"` Grouping []*Grouping `yang:"grouping"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Typedef []*Typedef `yang:"typedef"` Uses []*Uses `yang:"uses"` }
A Grouping is defined in: http://tools.ietf.org/html/rfc6020#section-7.11 and http://tools.ietf.org/html/rfc7950#section-7.12 ("action" sub-statement)
func FindGrouping ¶
FindGrouping finds the grouping named name in one of the parent node's grouping fields, seen provides a list of the modules previously seen by FindGrouping during traversal. If no parent has the named grouping, nil is returned. Imported and included modules are also checked.
func (*Grouping) ParentNode ¶
type Identity ¶
type Identity struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge" json:"-"` Parent Node `yang:"Parent,nomerge" json:"-"` Extensions []*Statement `yang:"Ext" json:"-"` Base *Value `yang:"base" json:"-"` Description *Value `yang:"description" json:"-"` Reference *Value `yang:"reference" json:"-"` Status *Value `yang:"status" json:"-"` Values []*Identity `json:",omitempty"` }
An Identity is defined in: http://tools.ietf.org/html/rfc6020#section-7.16
func (*Identity) GetValue ¶
GetValue returns a pointer to the identity with name "name" that is within the values of the identity
func (*Identity) IsDefined ¶
IsDefined behaves the same as the implementation for Enum - it returns true if an identity with the name is defined within the Values of the identity
func (*Identity) ParentNode ¶
func (*Identity) PrefixedName ¶
PrefixedName returns the prefix-qualified name for the identity
type Import ¶
type Import struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Prefix *Value `yang:"prefix,required"` RevisionDate *Value `yang:"revision-date"` // Module is the imported module. The types and groupings are // available to the importer with the defined prefix. Module *Module }
An Import is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.5
func (*Import) ParentNode ¶
type Include ¶
type Include struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` RevisionDate *Value `yang:"revision-date"` // Module is the included module. The types and groupings are // available to the importer with the defined prefix. Module *Module }
An Include is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.6
func (*Include) ParentNode ¶
type Input ¶
type Input struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Anyxml []*AnyXML `yang:"anyxml"` Choice []*Choice `yang:"choice"` Container []*Container `yang:"container"` Grouping []*Grouping `yang:"grouping"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Typedef []*Typedef `yang:"typedef"` Uses []*Uses `yang:"uses"` }
An Input is defined in: http://tools.ietf.org/html/rfc6020#section-7.13.2
func (*Input) ParentNode ¶
type Leaf ¶
type Leaf struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Config *Value `yang:"config"` Default *Value `yang:"default"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Mandatory *Value `yang:"mandatory"` Must []*Must `yang:"must"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Type *Type `yang:"type,required"` Units *Value `yang:"units"` When *Value `yang:"when"` }
A Leaf is defined in: http://tools.ietf.org/html/rfc6020#section-7.6
func (*Leaf) ParentNode ¶
type LeafList ¶
type LeafList struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Config *Value `yang:"config"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` MaxElements *Value `yang:"max-elements"` MinElements *Value `yang:"min-elements"` Must []*Must `yang:"must"` OrderedBy *Value `yang:"ordered-by"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Type *Type `yang:"type,required"` Units *Value `yang:"units"` When *Value `yang:"when"` }
A LeafList is defined in: http://tools.ietf.org/html/rfc6020#section-7.7 It this is supposed to be an array of nodes..
func (*LeafList) ParentNode ¶
type Length ¶
type Length struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` ErrorAppTag *Value `yang:"error-app-tag"` ErrorMessage *Value `yang:"error-message"` Reference *Value `yang:"reference"` }
A Length is defined in: http://tools.ietf.org/html/rfc6020#section-9.4.4
func (*Length) ParentNode ¶
type List ¶
type List struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Action []*Action `yang:"action"` Anyxml []*AnyXML `yang:"anyxml"` Choice []*Choice `yang:"choice"` Config *Value `yang:"config"` Container []*Container `yang:"container"` Description *Value `yang:"description"` Grouping []*Grouping `yang:"grouping"` IfFeature []*Value `yang:"if-feature"` Key *Value `yang:"key"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` MaxElements *Value `yang:"max-elements"` MinElements *Value `yang:"min-elements"` Must []*Must `yang:"must"` OrderedBy *Value `yang:"ordered-by"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Typedef []*Typedef `yang:"typedef"` Unique []*Value `yang:"unique"` Uses []*Uses `yang:"uses"` When *Value `yang:"when"` }
A List is defined in: http://tools.ietf.org/html/rfc6020#section-7.8 and http://tools.ietf.org/html/rfc7950#section-7.8 ("action" sub-statement)
func (*List) ParentNode ¶
type ListAttr ¶
type ListAttr struct { MinElements *Value // leaf-list or list MUST have at least min-elements MaxElements *Value // leaf-list or list has at most max-elements OrderedBy *Value // order of entries determined by "system" or "user" }
A ListAttr is associated with an Entry that represents a List node
type Module ¶
type Module struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Anyxml []*AnyXML `yang:"anyxml"` Augment []*Augment `yang:"augment"` BelongsTo *BelongsTo `yang:"belongs-to,required=submodule,nomerge"` Choice []*Choice `yang:"choice"` Contact *Value `yang:"contact,nomerge"` Container []*Container `yang:"container"` Description *Value `yang:"description,nomerge"` Deviation []*Deviation `yang:"deviation"` Extension []*Extension `yang:"extension"` Feature []*Feature `yang:"feature"` Grouping []*Grouping `yang:"grouping"` Identity []*Identity `yang:"identity"` Import []*Import `yang:"import"` Include []*Include `yang:"include"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Namespace *Value `yang:"namespace,required=module,nomerge"` Notification []*Notification `yang:"notification"` Organization *Value `yang:"organization,nomerge"` Prefix *Value `yang:"prefix,required=module,nomerge"` Reference *Value `yang:"reference,nomerge"` Revision []*Revision `yang:"revision,nomerge"` RPC []*RPC `yang:"rpc"` Typedef []*Typedef `yang:"typedef"` Uses []*Uses `yang:"uses"` YangVersion *Value `yang:"yang-version,nomerge"` // contains filtered or unexported fields }
A Module is defined in: http://tools.ietf.org/html/rfc6020#section-7.1
A SubModule is defined in: http://tools.ietf.org/html/rfc6020#section-7.2
func FindModuleByPrefix ¶
FindModuleByPrefix finds the module or submodule with the provided prefix relative to where n was defined. If the prefix cannot be resolved then nil is returned.
func (*Module) Current ¶
Current returns the most recent revision of this module, or "" if the module has no revisions.
func (*Module) FullName ¶
FullName returns the full name of the module including the most recent revision, if any.
func (*Module) GetPrefix ¶
GetPrefix returns the proper prefix of m. Useful when looking up types in modules found by FindModuleByPrefix.
func (*Module) Identities ¶
func (*Module) ParentNode ¶
type Modules ¶
type Modules struct { Modules map[string]*Module // All "module" nodes SubModules map[string]*Module // All "submodule" nodes // contains filtered or unexported fields }
Modules contains information about all the top level modules and submodules that are read into it via its Read method.
func NewModules ¶
func NewModules() *Modules
NewModules returns a newly created and initialized Modules.
func (*Modules) FindModule ¶
FindModule returns the Module/Submodule specified by n, which must be a *Include or *Import. If n is a *Include then a submodule is returned. If n is a *Import then a module is returned.
func (*Modules) FindModuleByNamespace ¶
FindModuleByNamespace either returns the Module specified by the namespace or returns an error.
func (*Modules) FindModuleByPrefix ¶
FindModuleByPrefix either returns the Module specified by prefix or returns an error.
func (*Modules) GetModule ¶
GetModule returns the Entry of the module named by name. GetModule will search for and read the file named name + ".yang" if it cannot satisfy the request from what it has currntly read.
GetModule is a convience function for calling Read and Process, and then looking up the module name. It is safe to call Read and Process prior to calling GetModule.
func (*Modules) Parse ¶
Parse parses data as YANG source and adds it to ms. The name should reflect the source of data.
func (*Modules) Process ¶
Process processes all the modules and submodules that have been read into ms. While processing, if an include or import is found for which there is no matching module, Process attempts to locate the source file (using Path) and automatically load them. If a file cannot be found then an error is returned. When looking for a source file, Process searches for a file using the module's or submodule's name with ".yang" appended. After searching the current directory, the directories in Path are searched.
Process builds Entry trees for each modules and submodules in ms. These trees are accessed using the ToEntry function. Process does augmentation on Entry trees once all the modules and submodules in ms have been built. Following augmentation, Process inserts implied case statements. I.e.,
choice interface-type { container ethernet { ... } }
has a case statement inserted to become:
choice interface-type { case ethernet { container ethernet { ... } } }
Process may return multiple errors if multiple errors were encountered while processing. Even though multiple errors may be returned, this does not mean these are all the errors. Process will terminate processing early based on the type and location of the error.
type Must ¶
type Must struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` ErrorAppTag *Value `yang:"error-app-tag"` ErrorMessage *Value `yang:"error-message"` Reference *Value `yang:"reference"` }
A Must is defined in: http://tools.ietf.org/html/rfc6020#section-7.5.3
func (*Must) ParentNode ¶
type Node ¶
type Node interface { // Kind returns the kind of yang statement (the keyword). Kind() string // NName returns the node's name (the argument) NName() string // Statement returns the original Statement of this Node. Statement() *Statement // ParentNode returns the parent of this Node, or nil if the // Node has no parent. ParentNode() Node // Exts returns the list of extension statements found. Exts() []*Statement }
A Node contains a yang statement and all attributes and sub-statements. Only pointers to structures should implement Node.
func BuildAST ¶
BuildAST builds an abstract syntax tree based on the yang statement s. Normally it should return a *Module.
func ChildNode ¶
ChildNode finds n's child node named name. It returns nil if the node could not be found. ChildNode looks at every direct Node pointer in n as well as every node in all slices of Node pointers. Names must be non-ambiguous, otherwise ChildNode has a non-deterministic result.
type Notification ¶
type Notification struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Anyxml []*AnyXML `yang:"anyxml"` Choice []*Choice `yang:"choice"` Container []*Container `yang:"container"` Description *Value `yang:"description"` Grouping []*Grouping `yang:"grouping"` IfFeature []*Value `yang:"if-feature"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Typedef []*Typedef `yang:"typedef"` Uses []*Uses `yang:"uses"` }
A Notification is defined in: http://tools.ietf.org/html/rfc6020#section-7.14
func (*Notification) Exts ¶
func (s *Notification) Exts() []*Statement
func (*Notification) Groupings ¶
func (s *Notification) Groupings() []*Grouping
func (Notification) Kind ¶
func (Notification) Kind() string
func (*Notification) NName ¶
func (s *Notification) NName() string
func (*Notification) ParentNode ¶
func (s *Notification) ParentNode() Node
func (*Notification) Statement ¶
func (s *Notification) Statement() *Statement
func (*Notification) Typedefs ¶
func (s *Notification) Typedefs() []*Typedef
type Number ¶
type Number struct { // Kind is the kind of number (+/-ve, min/max). Kind NumberKind // Absolute value of the number. Value uint64 // Number of fractional digits. FractionDigits uint8 }
A Number is either an integer the range of [-(1<<64) - 1, (1<<64)-1], or a YANG decimal conforming to https://tools.ietf.org/html/rfc6020#section-9.3.4.
func DecimalValueFromString ¶
DecimalValueFromString returns a decimal Number representation of inStr. If fracDigRequired is >= 0, the number is represented with fracDigRequired fractional digits, regardless of the precision of numStr, otherwise the precision of numStr is used to set the number of fractional digits. numStr must conform to Section 9.3.4.
func FromFloat ¶
FromFloat creates a Number from a float64. Input values with absolute value larger than MaxInt64/MinInt64 are converted into maxNumber/minNumber.
func ParseNumber ¶
ParseNumber returns s as a Number. Numbers may be represented in decimal, octal, or hexadecimal using the standard prefix notations (e.g., 0 and 0x)
func (Number) Int ¶
Int returns n as an int64. It returns an error if n overflows an int64 or the number is decimal.
type NumberKind ¶
type NumberKind int
type Options ¶
type Options struct { // IgnoreSubmoduleCircularDependencies specifies whether circular dependencies // between submodules. Setting this value to true will ensure that this // package will explicitly ignore the case where a submodule will include // itself through a circular reference. IgnoreSubmoduleCircularDependencies bool }
Options defines the options that should be used when parsing YANG modules, including specific overrides for potentially problematic YANG constructs.
type Output ¶
type Output struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Anydata []*AnyData `yang:"anydata"` Anyxml []*AnyXML `yang:"anyxml"` Choice []*Choice `yang:"choice"` Container []*Container `yang:"container"` Grouping []*Grouping `yang:"grouping"` Leaf []*Leaf `yang:"leaf"` LeafList []*LeafList `yang:"leaf-list"` List []*List `yang:"list"` Typedef []*Typedef `yang:"typedef"` Uses []*Uses `yang:"uses"` }
An Output is defined in: http://tools.ietf.org/html/rfc6020#section-7.13.3
func (*Output) ParentNode ¶
type Pattern ¶
type Pattern struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` ErrorAppTag *Value `yang:"error-app-tag"` ErrorMessage *Value `yang:"error-message"` Reference *Value `yang:"reference"` }
A Pattern is defined in: http://tools.ietf.org/html/rfc6020#section-9.4.6
func (*Pattern) ParentNode ¶
type RPC ¶
type RPC struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` Grouping []*Grouping `yang:"grouping"` IfFeature []*Value `yang:"if-feature"` Input *Input `yang:"input"` Output *Output `yang:"output"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Typedef []*Typedef `yang:"typedef"` }
An RPC is defined in: http://tools.ietf.org/html/rfc6020#section-7.13
func (*RPC) ParentNode ¶
type Range ¶
type Range struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` ErrorAppTag *Value `yang:"error-app-tag"` ErrorMessage *Value `yang:"error-message"` Reference *Value `yang:"reference"` }
A Range is defined in: http://tools.ietf.org/html/rfc6020#section-9.2.4
func (*Range) ParentNode ¶
type Refine ¶
type Refine struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Default *Value `yang:"default"` Description *Value `yang:"description"` Reference *Value `yang:"reference"` Config *Value `yang:"config"` Mandatory *Value `yang:"mandatory"` Presence *Value `yang:"presence"` Must []*Must `yang:"must"` MaxElements *Value `yang:"max-elements"` MinElements *Value `yang:"min-elements"` }
A Refine is defined in: http://tools.ietf.org/html/rfc6020#section-7.12.2
func (*Refine) ParentNode ¶
type Revision ¶
type Revision struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Description *Value `yang:"description"` Reference *Value `yang:"reference"` }
A Revision is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.9
func (*Revision) ParentNode ¶
type Statement ¶
type Statement struct { Keyword string HasArgument bool Argument string // contains filtered or unexported fields }
A Statement is a generic YANG statement. A Statement may have optional sub-statement (i.e., a Statement is a tree).
func FakeStatement ¶
FakeStatement returns a statement filled in with keyword, file, line and col.
func Parse ¶
Parse parses the input as generic YANG and returns the statements parsed. The path parameter should be the source name where input was read from (e.g., the file name the input was read from). If one more more errors are encountered, nil and an error are returned. The error's text includes all errors encountered.
func (*Statement) Arg ¶
Arg returns the optional argument to s. It returns false if s has no argument.
func (*Statement) ParentNode ¶
func (*Statement) SubStatements ¶
SubStatements returns a slice of Statements found in s.
type Type ¶
type Type struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` IdentityBase *Value `yang:"base"` // Name == identityref Bit []*Bit `yang:"bit"` Enum []*Enum `yang:"enum"` FractionDigits *Value `yang:"fraction-digits"` // Name == decimal64 Length *Length `yang:"length"` Path *Value `yang:"path"` Pattern []*Pattern `yang:"pattern"` Range *Range `yang:"range"` RequireInstance *Value `yang:"require-instance"` Type []*Type `yang:"type"` // len > 1 only when Name is "union" YangType *YangType }
A Type is defined in: http://tools.ietf.org/html/rfc6020#section-7.4 Note that Name is the name of the type we want, it is what must be looked up and resolved.
func (*Type) ParentNode ¶
type TypeKind ¶
type TypeKind uint
TypeKind is the enumeration of the base types available in YANG. It is analogous to reflect.Kind.
type Typedef ¶
type Typedef struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Default *Value `yang:"default"` Description *Value `yang:"description"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` Type *Type `yang:"type,required"` Units *Value `yang:"units"` YangType *YangType `json:"-"` }
A Typedef is defined in: http://tools.ietf.org/html/rfc6020#section-7.3
func (*Typedef) ParentNode ¶
type Uses ¶
type Uses struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge"` Parent Node `yang:"Parent,nomerge"` Extensions []*Statement `yang:"Ext"` Augment *Augment `yang:"augment"` Description *Value `yang:"description"` IfFeature []*Value `yang:"if-feature"` Refine []*Refine `yang:"refine"` Reference *Value `yang:"reference"` Status *Value `yang:"status"` When *Value `yang:"when"` }
A Uses is defined in: http://tools.ietf.org/html/rfc6020#section-7.12
func (*Uses) ParentNode ¶
type Value ¶
type Value struct { Name string `yang:"Name,nomerge"` Source *Statement `yang:"Statement,nomerge" json:",omitempty"` Parent Node `yang:"Parent,nomerge" json:"-"` Extensions []*Statement `yang:"Ext" json:",omitempty"` Description *Value `yang:"description" json:",omitempty"` }
A Value is just a string that can have extensions.
func (*Value) ParentNode ¶
type YRange ¶
YRange is a single range of consecutive numbers, inclusive.
type YangRange ¶
type YangRange []YRange
A YangRange is a set of non-overlapping ranges.
func ParseRanges ¶
ParseRanges parses s into a series of ranges. Each individual range is in s is separated by the pipe character (|). The min and max value of a range are separated by "..". An error is returned if the range is invalid. The resulting range is sorted and coalesced.
func (YangRange) Contains ¶
Contains returns true if all possible values in s are also possible values in r. An empty range is assumed to be min..max.
func (YangRange) Equal ¶
Equal returns true if ranges r and q are identically equivalent. TODO(borman): should we coalesce ranges in the comparison?
type YangType ¶
type YangType struct { Name string Kind TypeKind // Ynone if not a base type Base *Type `json:"-"` // Base type for non-builtin types IdentityBase *Identity `json:",omitempty"` // Base statement for a type using identityref Root *YangType `json:"-"` // root of this type that is the same Bit *EnumType `json:",omitempty"` // bit position, "status" is lost Enum *EnumType `json:",omitempty"` // enum name to value, "status" is lost Units string `json:",omitempty"` // units to be used for this type Default string `json:",omitempty"` // default value, if any FractionDigits int `json:",omitempty"` // decimal64 fixed point precision Length YangRange `json:",omitempty"` // this should be processed by section 12 OptionalInstance bool `json:",omitempty"` // !require-instances which defaults to true Path string `json:",omitempty"` // the path in a leafref Pattern []string `json:",omitempty"` // limiting XSD-TYPES expressions on strings Range YangRange `json:",omitempty"` // range for integers Type []*YangType `json:",omitempty"` // for unions }
A YangType is the internal representation of a type in YANG. It may refer to either a builtin type or type specified with typedef. Not all fields in YangType are used for all types.
Notes ¶
Bugs ¶
I think a deviate statement might trigger this.