Documentation ¶
Overview ¶
Package node gives you base structures to capture how to read, write, execute and listen for events from your application.
Index ¶
- Variables
- func EncodeKey(v []val.Value) string
- func NewValue(typ *meta.Type, v interface{}) (val.Value, error)
- func NewValues(m []meta.Leafable, objs ...interface{}) ([]val.Value, error)
- func NewValuesByString(m []meta.Leafable, objs ...string) ([]val.Value, error)
- type ActionPostConstraint
- type ActionPreConstraint
- type ActionRequest
- type Browser
- type CheckWhen
- type ChildRequest
- type ConstraintHandler
- type Constraints
- func (self *Constraints) AddConstraint(id string, weight int, priority int, constraint interface{})
- func (self *Constraints) CheckActionPostConstraints(r ActionRequest) (bool, error)
- func (self *Constraints) CheckActionPreConstraints(r *ActionRequest) (bool, error)
- func (self *Constraints) CheckContainerPostConstraints(r ChildRequest, child *Selection) (bool, error)
- func (self *Constraints) CheckContainerPreConstraints(r *ChildRequest) (bool, error)
- func (self *Constraints) CheckFieldPostConstraints(r FieldRequest, hnd *ValueHandle) (bool, error)
- func (self *Constraints) CheckFieldPreConstraints(r *FieldRequest, hnd *ValueHandle) (bool, error)
- func (self *Constraints) CheckListPostConstraints(r ListRequest, child *Selection, key []val.Value) (bool, bool, error)
- func (self *Constraints) CheckListPreConstraints(r *ListRequest) (bool, error)
- func (self *Constraints) CheckNotifyFilterConstraints(msg *Selection) (bool, error)
- func (self *Constraints) Constraint(id string) interface{}
- func (self *Constraints) ContextConstraint(s *Selection) context.Context
- type ContainerPostConstraint
- type ContainerPreConstraint
- type ContentConstraint
- type ContextConstraint
- type ErrorNode
- func (e ErrorNode) Action(ActionRequest) (Node, error)
- func (e ErrorNode) BeginEdit(r NodeRequest) error
- func (e ErrorNode) Child(r ChildRequest) (Node, error)
- func (e ErrorNode) Choose(*Selection, *meta.Choice) (*meta.ChoiceCase, error)
- func (ErrorNode) Context(s *Selection) context.Context
- func (e ErrorNode) Delete(r NodeRequest) error
- func (e ErrorNode) EndEdit(r NodeRequest) error
- func (e ErrorNode) Error() string
- func (e ErrorNode) Field(FieldRequest, *ValueHandle) error
- func (e ErrorNode) Next(ListRequest) (Node, []val.Value, error)
- func (e ErrorNode) Notify(NotifyRequest) (NotifyCloser, error)
- func (e ErrorNode) Peek(sel *Selection, consumer interface{}) interface{}
- func (ErrorNode) Release(s *Selection)
- func (e ErrorNode) String() string
- type Event
- type EventType
- type FieldPostConstraint
- type FieldPreConstraint
- type FieldRequest
- type FieldsMatcher
- type Index
- type KeyListBuilder
- type ListItem
- type ListPostConstraint
- type ListPreConstraint
- type ListRange
- type ListRequest
- type MaxDepth
- type MaxNode
- type Node
- type NodeRequest
- type Notification
- type NotifyCloser
- type NotifyFilterConstraint
- type NotifyRequest
- type NotifyStream
- type Path
- type PathMatchExpression
- type PathMatcher
- type PathSlice
- type Request
- type Selection
- func (sel *Selection) Action(input Node) (*Selection, error)
- func (sel *Selection) ClearField(m meta.Leafable) error
- func (sel *Selection) Constrain(params string) (*Selection, error)
- func (sel *Selection) Delete() (err error)
- func (sel *Selection) Find(path string) (*Selection, error)
- func (sel *Selection) FindUrl(url *url.URL) (*Selection, error)
- func (sel *Selection) First() (ListItem, error)
- func (sel *Selection) Get() (val.Value, error)
- func (sel *Selection) InsertFrom(fromNode Node) error
- func (sel *Selection) InsertInto(toNode Node) error
- func (sel *Selection) Key() []val.Value
- func (sel *Selection) Meta() meta.Definition
- func (sel *Selection) Notifications(stream NotifyStream) (NotifyCloser, error)
- func (sel *Selection) Peek(consumer interface{}) interface{}
- func (sel *Selection) Release()
- func (sel *Selection) ReplaceFrom(fromNode Node) error
- func (sel *Selection) Set(v val.Value) error
- func (sel *Selection) SetValue(value interface{}) error
- func (sel *Selection) Split(node Node) *Selection
- func (sel *Selection) UpdateFrom(fromNode Node) error
- func (sel *Selection) UpdateInto(toNode Node) error
- func (sel *Selection) UpsertFrom(fromNode Node) error
- func (sel *Selection) UpsertFromSetDefaults(fromNode Node) error
- func (sel *Selection) UpsertInto(toNode Node) error
- func (sel *Selection) UpsertIntoSetDefaults(toNode Node) error
- func (sel *Selection) XFind(path xpath.Path) (*Selection, error)
- func (sel *Selection) XPredicate(p xpath.Path) (bool, error)
- type Trigger
- type TriggerFunc
- type TriggerTable
- type ValueHandle
- type Where
- type WithDefaults
Constants ¶
This section is empty.
Variables ¶
var ErrNilSelection = errors.New("selection is nil")
var NO_VALUE reflect.Value
Functions ¶
Types ¶
type ActionPostConstraint ¶
type ActionPostConstraint interface {
CheckActionPostConstraints(r ActionRequest) (bool, error)
}
type ActionPreConstraint ¶
type ActionPreConstraint interface {
CheckActionPreConstraints(r *ActionRequest) (bool, error)
}
type Browser ¶
type Browser struct { // Information model of browser Meta *meta.Module // Regsitry of listeners when data model under browser is modified Triggers *TriggerTable // True if you want no leaf data checks like pattern, length, range, etc // you would only want to do this if you had a good reason DisableConstraints bool // contains filtered or unexported fields }
Browser is a handle to a data source and starting point for interfacing with any freeconf enabled interface. It's the starting point to the top-most selection, or the Root().
func NewBrowser ¶
NewBrowser obviously does not resolve the source node for each new selection so the state of at least the root node is shared for all subsequent operations. In short, either do not keep a copy of this very browser for very long or know what you're doing
func NewBrowserSource ¶
NewBrowserSource unites a model (MetaList) with a data source (Node). Here the node instance is requested for each browse operation allowing the node state to be fresh for each request.
type CheckWhen ¶
type CheckWhen struct { }
func (CheckWhen) CheckContainerPostConstraints ¶
func (y CheckWhen) CheckContainerPostConstraints(r ChildRequest, s *Selection) (bool, error)
func (CheckWhen) CheckFieldPreConstraints ¶
func (y CheckWhen) CheckFieldPreConstraints(r *FieldRequest, hnd *ValueHandle) (bool, error)
func (CheckWhen) CheckListPostConstraints ¶
type ChildRequest ¶
type ChildRequest struct { Request From *Selection New bool Delete bool Meta meta.HasDataDefinitions }
func (*ChildRequest) IsNavigation ¶
func (r *ChildRequest) IsNavigation() bool
type ConstraintHandler ¶
func (*ConstraintHandler) ConstraintViolation ¶
func (self *ConstraintHandler) ConstraintViolation(violation error) error
func (*ConstraintHandler) IncompleteResponse ¶
func (self *ConstraintHandler) IncompleteResponse(location *Path)
func (*ConstraintHandler) LocatableNode ¶
func (self *ConstraintHandler) LocatableNode(location *Path)
type Constraints ¶
type Constraints struct {
// contains filtered or unexported fields
}
func NewConstraints ¶
func NewConstraints(parent *Constraints) *Constraints
func (*Constraints) AddConstraint ¶
func (self *Constraints) AddConstraint(id string, weight int, priority int, constraint interface{})
func (*Constraints) CheckActionPostConstraints ¶
func (self *Constraints) CheckActionPostConstraints(r ActionRequest) (bool, error)
func (*Constraints) CheckActionPreConstraints ¶
func (self *Constraints) CheckActionPreConstraints(r *ActionRequest) (bool, error)
func (*Constraints) CheckContainerPostConstraints ¶
func (self *Constraints) CheckContainerPostConstraints(r ChildRequest, child *Selection) (bool, error)
func (*Constraints) CheckContainerPreConstraints ¶
func (self *Constraints) CheckContainerPreConstraints(r *ChildRequest) (bool, error)
func (*Constraints) CheckFieldPostConstraints ¶
func (self *Constraints) CheckFieldPostConstraints(r FieldRequest, hnd *ValueHandle) (bool, error)
func (*Constraints) CheckFieldPreConstraints ¶
func (self *Constraints) CheckFieldPreConstraints(r *FieldRequest, hnd *ValueHandle) (bool, error)
func (*Constraints) CheckListPostConstraints ¶
func (self *Constraints) CheckListPostConstraints(r ListRequest, child *Selection, key []val.Value) (bool, bool, error)
func (*Constraints) CheckListPreConstraints ¶
func (self *Constraints) CheckListPreConstraints(r *ListRequest) (bool, error)
func (*Constraints) CheckNotifyFilterConstraints ¶
func (self *Constraints) CheckNotifyFilterConstraints(msg *Selection) (bool, error)
func (*Constraints) Constraint ¶
func (self *Constraints) Constraint(id string) interface{}
func (*Constraints) ContextConstraint ¶
func (self *Constraints) ContextConstraint(s *Selection) context.Context
type ContainerPostConstraint ¶
type ContainerPostConstraint interface {
CheckContainerPostConstraints(r ChildRequest, child *Selection) (bool, error)
}
type ContainerPreConstraint ¶
type ContainerPreConstraint interface {
CheckContainerPreConstraints(r *ChildRequest) (bool, error)
}
type ContentConstraint ¶
type ContentConstraint int
const ( ContentAll ContentConstraint = iota ContentOperational ContentConfig )
func NewContentConstraint ¶
func NewContentConstraint(initialPath *Path, expression string) (c ContentConstraint, err error)
func (ContentConstraint) CheckContainerPreConstraints ¶
func (self ContentConstraint) CheckContainerPreConstraints(r *ChildRequest) (bool, error)
func (ContentConstraint) CheckFieldPreConstraints ¶
func (self ContentConstraint) CheckFieldPreConstraints(r *FieldRequest, hnd *ValueHandle) (bool, error)
type ContextConstraint ¶
type ErrorNode ¶
type ErrorNode struct {
Err error
}
Useful when you want to return an error from Data.Node(). Any call to get data will return same error
func (d *MyData) Node { return ErrorNode(errors.New("bang")) }
func (ErrorNode) BeginEdit ¶
func (e ErrorNode) BeginEdit(r NodeRequest) error
func (ErrorNode) Delete ¶
func (e ErrorNode) Delete(r NodeRequest) error
func (ErrorNode) EndEdit ¶
func (e ErrorNode) EndEdit(r NodeRequest) error
func (ErrorNode) Field ¶
func (e ErrorNode) Field(FieldRequest, *ValueHandle) error
func (ErrorNode) Notify ¶
func (e ErrorNode) Notify(NotifyRequest) (NotifyCloser, error)
type FieldPostConstraint ¶
type FieldPostConstraint interface {
CheckFieldPostConstraints(r FieldRequest, hnd *ValueHandle) (bool, error)
}
type FieldPreConstraint ¶
type FieldPreConstraint interface {
CheckFieldPreConstraints(r *FieldRequest, hnd *ValueHandle) (bool, error)
}
type FieldRequest ¶
func (*FieldRequest) IsNavigation ¶
func (r *FieldRequest) IsNavigation() bool
type FieldsMatcher ¶
type FieldsMatcher struct {
// contains filtered or unexported fields
}
func NewExcludeFieldsMatcher ¶
func NewExcludeFieldsMatcher(expression string) (fm *FieldsMatcher, err error)
NewExcludeFieldsMatcher excludes fields that match pattern
func NewFieldsMatcher ¶
func NewFieldsMatcher(expression string) (fm *FieldsMatcher, err error)
func (*FieldsMatcher) CheckContainerPreConstraints ¶
func (self *FieldsMatcher) CheckContainerPreConstraints(r *ChildRequest) (bool, error)
func (*FieldsMatcher) CheckFieldPreConstraints ¶
func (self *FieldsMatcher) CheckFieldPreConstraints(r *FieldRequest, hnd *ValueHandle) (bool, error)
type KeyListBuilder ¶
type KeyListBuilder struct {
// contains filtered or unexported fields
}
func NewKeyListBuilder ¶
func NewKeyListBuilder(listPath string) *KeyListBuilder
func (*KeyListBuilder) List ¶
func (klb *KeyListBuilder) List() []string
func (*KeyListBuilder) ParseKey ¶
func (klb *KeyListBuilder) ParseKey(path string) bool
type ListItem ¶
type ListPostConstraint ¶
type ListPreConstraint ¶
type ListPreConstraint interface {
CheckListPreConstraints(r *ListRequest) (bool, error)
}
type ListRange ¶
type ListRange struct { Selector PathMatcher CurrentRow int64 StartRow int64 EndRow int64 }
func NewListRange ¶
func (*ListRange) CheckListPreConstraints ¶
func (self *ListRange) CheckListPreConstraints(r *ListRequest) (bool, error)
type ListRequest ¶
type ListRequest struct { Request From *Selection New bool Delete bool StartRow int // We make row available as a 32bit value for convenience but in theory // could be 64bit. If you know you're list could not exceed 2 billion then // it's safe to use this value Row int StartRow64 int64 Row64 int64 First bool Meta *meta.List Key []val.Value }
func (*ListRequest) IncrementRow ¶
func (r *ListRequest) IncrementRow()
func (*ListRequest) IsNavigation ¶
func (r *ListRequest) IsNavigation() bool
func (*ListRequest) SetRow ¶
func (r *ListRequest) SetRow(row int64)
func (*ListRequest) SetStartRow ¶
func (r *ListRequest) SetStartRow(row int64)
type MaxDepth ¶
type MaxDepth struct {
MaxDepth int
}
func (MaxDepth) CheckContainerPreConstraints ¶
func (md MaxDepth) CheckContainerPreConstraints(r *ChildRequest) (bool, error)
func (MaxDepth) CheckFieldPreConstraints ¶
func (md MaxDepth) CheckFieldPreConstraints(r *FieldRequest, hnd *ValueHandle) (bool, error)
type MaxNode ¶
func (MaxNode) CheckContainerPreConstraints ¶
func (self MaxNode) CheckContainerPreConstraints(r *ChildRequest) (bool, error)
type Node ¶
type Node interface { // Child is called when navigating, creating or deleting a "container" or "list". // The request fields contain the nature of the request. // // Params: // ChildRequest - contains the nature (e.g. get, delete, new) and details of the // request (e.g. identity name of the container or list ) // // Return: // Node - Return nil entity does not exist otherwise node implementation of the underlying // node requested Child(r ChildRequest) (child Node, err error) // Next is called for items in a list when navigating, creating or deleting items in the // "list". // // Params: // ListRequest - contains the nature (e.g. get, delete, new) and details of the // request (e.g. key, row number) // // Return: // Node - Return nil entity does not exist otherwise node implementation of the underlying // node requested // []val.Value - If a key was defined in YANG, AND the request is for the next item // in the list, then you must also return the key expressed in val.Value array Next(r ListRequest) (next Node, key []val.Value, err error) // Field is called to read or write "leaf" or "leaf-list" items on container/list items or // even root module. // // Params: // FieldRequest - identity of the field and the contains the nature (e.g. read or write) // tip: if the YANG defines the field as config:false, you can assume the field is // only called for reading and you can ignore the flag for read v.s. write // // *ValueHandle - contains a single the "Val" that with either: // a.) contain the value to be set or // b.) be expected to be set to the requested value to be read Field(r FieldRequest, hnd *ValueHandle) error // Choose is only called when there is a need to know which single case between several "choice/case" // sets are currently true. This is only called when reading. // // Params: // Selection - current selection that is handling the choice investigation // *Choice - name for the choice (there could be several in a given container) // // Return: // *ChoiceCase - which case is currently valid (there can be only one) // Choose(sel *Selection, choice *meta.Choice) (m *meta.ChoiceCase, err error) // BeginEdit is called simply to inform a node when it is about to be edited including deleting or creating. // While there is nothing required of nodes to do anything on this call, implementations might have // very important, internal operations they need to perform like obtaining write locks for example. It is // also an opportunity to reject the edit for whatever reason by returning an error. // // It important to know this is called on **every** parent node for any edit to any of their children. // This is known as "event bubbling" and can be helpful when parents are in a better position to handle // operations for children. You can easily distinguish this situation from the NodeRequest parameter. // See https://github.com/freeconf/restconf/wiki/Edit-Node-Traversal for details on when this is called // in particular in the order // // Params: // NodeRequest - contains the nature (e.g. get, delete, new) BeginEdit(r NodeRequest) error // EndEdit is called simply to inform a node after it has been edited including deleting or creating. // While there is nothing required of nodes to do anything on this call, implementations might have // very important, internal operations they need to perform like release write locks for example. It is // also an opportunity to apply changes to live application or persist data to permanent storage. // // It important to know this is called on **every** parent node for any edit to any of their children. // This is known as "event bubbling" and can be helpful when parents are in a better position to handle // operations for children. You can easily distinguish this situation from the NodeRequest parameter. // See https://github.com/freeconf/restconf/wiki/Edit-Node-Traversal for details on when this is called // in particular in the order // // Params: // NodeRequest - contains the nature (e.g. get, delete, new) EndEdit(r NodeRequest) error // Action(rpc/action) is called when caller wished to run a 'action' or 'rpc' definition. Input can // be found in request if an input is defined. Output only has to be returned for // definitions that declare an output. // // Params: // ActionRequest - In addition to the identity name of the action or rpc, it may contains the "input" // to the action if one was defined in the YANG. // // Return: // Node - If there is an expected response from action ("output" defined in YANG) then this would be // the Node implementation of that data. Action(r ActionRequest) (output Node, err error) // Notificationsare unique with respect to resources are allocated that survive the original // request so implementation should try not keep references to any more resources than neccessary // to ensure they do not reference objects that become stale or that impose large chunks of memory // unknowningly and unneccesarily. // // Params: // NotifyRequest - In addition to the identity name of the notification, this contains the stream // to write events to. // // Return: // NotifyCloser - Function to called to stop streaming events. This will be called for example when // client closes the event stream socket either naturally or because of a network disconnect. // Notify(r NotifyRequest) (NotifyCloser, error) // Peek give an opportunity for API callers to gain access to the objects behind a node. // // Params: // Selection - current selection that is handling the peeking // interface{} - Who (or under what context) is attempting to peek. This can be used by // node implementation to decide what is returned or if anything at all is returned. // It may also be ingored. This is up to // // Return: // interface{} - Can be anything. // // This can be considered a violation of abstraction so implementation is not gauranteed and // can vary w/o any compiler warnings. This can be useful in unit testing but uses outside this // should be used judicously. Peek(sel *Selection, consumer interface{}) interface{} // Context provides an opportunity to add/change values in the request context that is passed to // operations on this node and operations to children of this node. FreeCONF does not put or // require anything in the context, it is meant as a way to make application or request specific // data available to nodes. // // A popular use of context is to store the user and or user roles making the request so // operations can authorize or log user operations. See RESTCONF request filters for one // way to implement that. // // In addition, if you want to obtain a read-lock on your object that will be released in // Release when there are no more references to you object, this would be where to do that Context(sel *Selection) context.Context // Underlying object is no longer being references. Release read-lock if you obtained one // in call to Context Release(sel *Selection) }
Node is at the root of where your application's data management and functionality is contained and made available.
When building your application management logic, you will register a single instance of a node representing the root of the module that will lead to all of nodes, functions and event streams. Each of these nodes, functions and event streams will align with the definitions in the YANG file.
You can use data structures nodeutil.Basic, nodeutil.Extend or nodeutil.Reflect that implement this interface to reduce the amount of required coding.
The root Node together with the meta.Module represent the top most node and can be obtained using node.Browser's Root() function to return a node.Selection data structure that links the Node and the Module. This root Selection then be used to navigate you manament application thru a series of nested Selections of meta.Meta and node.Node pairings. See https://freeconf.org/docs/reference/basic-components/ for how Node works with other objects
Node are constructed as needed so two separate requests to the same management function would have different Node instances. This means you can keep temporary state like lazy list indexes or references to request specific data in your node implementation. The only time a Node is not garage collected after a request is finished is if it is Root node or there is an active event stream via a Notification subscription.
type NodeRequest ¶
type Notification ¶
func NewNotification ¶
func NewNotification(msg *Selection) Notification
func NewNotificationWhen ¶
func NewNotificationWhen(msg *Selection, t time.Time) Notification
type NotifyCloser ¶
type NotifyCloser func() error
NotifyCloser callback when caller is not interested in events anymore. Typically this is where you remove listeners
type NotifyFilterConstraint ¶
type NotifyFilterConstraint interface {
CheckNotifyFilterConstraints(msg *Selection) (bool, error)
}
func NewFilterConstraint ¶
func NewFilterConstraint(filter string) (NotifyFilterConstraint, error)
type NotifyRequest ¶
type NotifyRequest struct { Request Meta *meta.Notification Stream NotifyStream }
func (NotifyRequest) Send ¶
func (r NotifyRequest) Send(n Node)
type Path ¶
type Path struct { Meta meta.Definition Key []val.Value Parent *Path }
Path in data tree (not meta) resembling a RESTCONF URL when printed to a string
func (*Path) EqualNoKey ¶
func (*Path) StringNoModule ¶
type PathMatchExpression ¶
type PathMatchExpression struct {
// contains filtered or unexported fields
}
func ParsePathExpression ¶
func ParsePathExpression(selector string) (*PathMatchExpression, error)
func (*PathMatchExpression) PathMatches ¶
func (self *PathMatchExpression) PathMatches(base *Path, candidate *Path) bool
func (*PathMatchExpression) String ¶
func (self *PathMatchExpression) String() string
type PathMatcher ¶
type PathSlice ¶
func NewPathSlice ¶
func NewPathSlice(path string, m meta.HasDefinitions) (p PathSlice)
func ParseUrlPath ¶
type Request ¶
type Request struct { Selection *Selection // Path to meta item requested, including leaf requests Path *Path Target *Path Base *Path }
Request is base class for all other node requests. There are two basic modes: 1. Navigation where NavTarget is set and 2.)Editing where WalkBase is set
type Selection ¶
type Selection struct { // Browser that this selection ultimately spawned from Browser *Browser // Underlying node that implements management functions Node Node // Meta path in YANG module tied to this node Path *Path // Potentialy stores external data made available to all requests Context context.Context // Useful when navigating lists, True if this selector is List node, False if // this is for an item in List node. InsideList bool // Constraints hold list of things to check when walking or editing a node. Constraints *Constraints // contains filtered or unexported fields }
Selection give you access to all management operations on an manamagent API. It combines a single data node (node.Node) with a single model definition (meta.Meta) to represent a single location on a management API (including the root location).
From here you can perform many operations from the underlying nodes including the following:
- Find/navigate to any other point in the management API
- Get data (i.e. export)
- Write data (i.e perform an edit)
- Run an Action/RPC
- Subscribe to an event stream
- Delete data
You can chan
Example: var err error root := browser.Root() jay := root.Find("birds=bluejay") myCheckErr(dim.LastErr) // write err = jay.UpsertFrom(nodeutil.ReadJSON(`{"dimensions":55}`)).LastErr // read err = jay.UpsertInto(someOtherNode) // action _, err = jay.Find("fly").Action(nil) // subscribe reportRareBird := func(msg node.Selection) { fmt.Println(nodeutil.ReadJSON(msg)) } unsubscribe, err := root.Find("rareSighting").Notify(reportRareBird) // unsubscribe unsubscribe()
func (*Selection) Action ¶
Action let's to call a procedure potentially passing on data and potentially recieving data back.
func (*Selection) ClearField ¶
ClearField write nil/empty value to field.
func (*Selection) Constrain ¶
Apply constraints in the form of url parameters. Original selector and constraints will remain unaltered Example:
sel2 = sel.Constrain("content=config&depth=4") sel will not have content or depth constraints applies, but sel 2 will
func (*Selection) Find ¶
Find navigates to another selector automatically applying constraints to returned selector. This supports paths that start with any number of "../" where FindUrl does not.
func (*Selection) FindUrl ¶
FindUrl navigates to another selection with possible constraints as url parameters. Constraints are added to any existing contraints. Original selector and constraints will remain unaltered
func (*Selection) Get ¶
GetValue let's you get the leaf value as a Value instance. Returns null if value is null
func (*Selection) InsertFrom ¶
InsertFrom Copy given node into current node. If there are any existing containers of list items then this will fail by design.
func (*Selection) InsertInto ¶
InsertInto Copy current node into given node. If there are any existing containers of list items then this will fail by design.
func (*Selection) Meta ¶
func (sel *Selection) Meta() meta.Definition
func (*Selection) Notifications ¶
func (sel *Selection) Notifications(stream NotifyStream) (NotifyCloser, error)
Notifications let's caller subscribe to a node. Node must be a 'notification' node.
func (*Selection) ReplaceFrom ¶
func (*Selection) Set ¶
When you've selected a leaf field, this will set the value. Value must be in correct type according to YANG
func (*Selection) SetValue ¶
When you've selected a leaf field, this will coerse the data into correct value type then set. Error if coersion is not successful
func (*Selection) Split ¶
Create a new independant selection with a different browser from this point in the tree based on a whole new data node
func (*Selection) UpdateFrom ¶
Copy given node into current node. There must be matching containers of list items or this will fail by design.
func (*Selection) UpdateInto ¶
Copy current node into given node. There must be matching containers of list items or this will fail by design.
func (*Selection) UpsertFrom ¶
Merge given node into current node. If there are any existing containers of list items then data will be merged.
func (*Selection) UpsertFromSetDefaults ¶
UpsertFromSetDefauls is like UpsertFrom but top container will have defaults set from YANG
func (*Selection) UpsertInto ¶
UpsertInto Merge current node into given node. If there are any existing containers of list items then data will be merged.
func (*Selection) UpsertIntoSetDefaults ¶
UpsertIntoSetDefaults is like UpsertInto but top container will have defaults set from YANG
type Trigger ¶
type Trigger struct { // OnBegin will be called on the start of any edit. Return error to stop edit OnBegin TriggerFunc // OnEnd will be called at the end of any edit. Return error to mark edit as failed OnEnd TriggerFunc // contains filtered or unexported fields }
Trigger for registering global listeners on a data model. Useful for triggering on save or push notifications
type TriggerFunc ¶
type TriggerFunc func(t *Trigger, r NodeRequest) error
TriggerFunc callback for triggers
type TriggerTable ¶
type TriggerTable struct {
// contains filtered or unexported fields
}
TriggerTable is registry of all trigger functions for a browser
func NewTriggerTable ¶
func NewTriggerTable() *TriggerTable
NewTriggerTable creates new registry of all trigger functions for a browser
func (*TriggerTable) Install ¶
func (self *TriggerTable) Install(t *Trigger)
Install will register new trigger functions
func (*TriggerTable) Remove ¶
func (self *TriggerTable) Remove(t *Trigger)
Remove will no longer call trigger funcs
type ValueHandle ¶
type ValueHandle struct { // Readers do not set this, Writers will always have a valid value here Val val.Value }
Used to pass values in/out of calls to Node.Field
type Where ¶
type Where struct { Filter string // XPath filter // contains filtered or unexported fields }
func (*Where) CheckListPostConstraints ¶
type WithDefaults ¶
type WithDefaults int
Field level filter that let's you see the differences in values from the default values.
For more information, see:
https://tools.ietf.org/html/draft-ietf-netconf-restconf-16#section-4.8.9
const ( // Show all values, default and otherwise. This is really the same as not specifying // any constraint WithDefaultsAll WithDefaults = iota // Hide values that match the default whether the user has explicitly set or not WithDefaultsTrim // See https://tools.ietf.org/html/rfc6243#section-3.3 // This is really about returning the values the "happen" to match the default. Not all // implementations will be able to distinguish this. // Example: if leaf x has a default of 5 and user never sets the value to 5, then using // this default will NOT return a value for x. If however the user set the value to exactly // and explicitly to 5, then using this paramaeter WILL return a value for x as 5. // // While a very useful flag, this not supported yet only because there are no data node // implementations that support this yet. In addition, user interfaces would have to allow the user // to "clear" a value to assume the default v.s. setting a value to the default to pin the value to // that value in case the model default value changes. WithDefaultsExplicit // Not supported // See https://tools.ietf.org/html/rfc6243#section-3.4 // This mangles the JSON output so instead of // "x" : 10 // you have soemthing like this // "x" : 10, // "ietf-netconf-with-defaults" : { // "x" : 5 // } // although i'm not 100% positive, either way, this is not supported yet WithDefaultsAllTagged )
func NewWithDefaultsConstraint ¶
func NewWithDefaultsConstraint(expression string) (WithDefaults, error)
func (WithDefaults) CheckFieldPostConstraints ¶
func (self WithDefaults) CheckFieldPostConstraints(r FieldRequest, hnd *ValueHandle) (bool, error)
Source Files ¶
- browser.go
- check_when.go
- constraint_handler.go
- constraints.go
- container_meta_list.go
- content_param.go
- doc.go
- edit.go
- err_node.go
- event.go
- field_constraints.go
- fields_matcher.go
- filter.go
- find.go
- index.go
- key_list_builder.go
- list_range.go
- max_depth.go
- max_node.go
- node.go
- path.go
- path_matcher.go
- path_slice.go
- request.go
- selection.go
- trigger.go
- value.go
- where.go
- with_defaults_param.go
- xpath.go
- xpath_impl.go