Documentation ¶
Index ¶
- Constants
- func ValidateXML(data string, dataStruct interface{})
- type CloseSession
- type Commit
- type CreateSubscription
- type CreateSubscriptionData
- type Datastore
- type EditConfig
- type EstablishSubscription
- type Filter
- type Get
- type GetConfig
- type Hello
- type KillSession
- type Lock
- type Notification
- type RPC
- type RPCError
- type RPCMethod
- type RPCReply
- type Unlock
- type Validate
Constants ¶
const ( // FilterTypeSubtree represent the filter for get operation FilterTypeSubtree string = "subtree" // DatastoreRunning represents the running datastore DatastoreRunning string = "running" // DatastoreCandidate represents the candidate datastore DatastoreCandidate string = "candidate" // NetconfVersion10 is the XMLNS representing NETCONF 1.0 version NetconfVersion10 string = "urn:ietf:params:netconf:base:1.0" // NetconfVersion11 is the XMLNS representing NETCONF 1.1 version NetconfVersion11 string = "urn:ietf:params:netconf:base:1.1" )
const ( // DefaultOperationTypeMerge represents the default operation to apply when doing an edit-config operation DefaultOperationTypeMerge string = "merge" // DefaultOperationTypeReplace represents the default operation to apply when doing an edit-config operation DefaultOperationTypeReplace string = "replace" // DefaultOperationTypeNone represents the default operation to apply when doing an edit-config operation DefaultOperationTypeNone string = "none" )
const ( // NetconfNotificationXmlns is the XMLNS for the YANG model supporting NETCONF notification NetconfNotificationXmlns = "urn:ietf:params:xml:ns:netconf:notification:1.0" // NetconfNotificationStreamHandler identifies the callback registration for a `create-subscription` NetconfNotificationStreamHandler = "DEFAULT_NOTIFICATION_STREAM" NotificationMessageRegex = ".*notification" )
const RpcReplyRegex = ".*rpc-reply"
Variables ¶
This section is empty.
Functions ¶
func ValidateXML ¶ added in v1.0.6
func ValidateXML(data string, dataStruct interface{})
ValidateXML checks a provided string can be properly unmarshall in the specified struct
Types ¶
type CloseSession ¶
type CloseSession struct { RPC CloseSession interface{} `xml:"close-session"` }
CloseSession represents the NETCONF `close-session` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.8
func NewCloseSession ¶
func NewCloseSession() *CloseSession
NewCloseSession can be used to create a `close-session` message.
type Commit ¶
type Commit struct { RPC Commit interface{} `xml:"commit"` }
Commit represents the NETCONF `commit` message. https://datatracker.ietf.org/doc/html/rfc6241#section-8.3.4.1
type CreateSubscription ¶
type CreateSubscription struct { RPC Subscription CreateSubscriptionData `xml:"create-subscription"` }
CreateSubscription represents the NETCONF `create-subscription` message. https://datatracker.ietf.org/doc/html/rfc5277#section-2.1.1
func NewCreateSubscription ¶
func NewCreateSubscription(stopTime string, startTime string, stream string) *CreateSubscription
NewCreateSubscription can be used to create a `create-subscription` message.
func NewCreateSubscriptionDefault ¶
func NewCreateSubscriptionDefault() *CreateSubscription
NewCreateSubscriptionDefault can be used to create a `create-subscription` message for the NETCONF stream.
type CreateSubscriptionData ¶
type CreateSubscriptionData struct { XMLNS string `xml:"xmlns,attr"` Stream string `xml:"stream,omitempty"` // default is NETCONF StartTime string `xml:"startTime,omitempty"` StopTime string `xml:"stopTime,omitempty"` }
CreateSubscriptionData is the struct to create a `create-subscription` message
type Datastore ¶
type Datastore struct { Candidate interface{} `xml:"candidate,omitempty"` Running interface{} `xml:"running,omitempty"` }
Datastore represents a NETCONF data store element
type EditConfig ¶
type EditConfig struct { RPC Target *Datastore `xml:"edit-config>target"` DefaultOperation string `xml:"edit-config>default-operation,omitempty"` Config *config `xml:"edit-config>config"` }
EditConfig represents the NETCONF `edit-config` operation. https://datatracker.ietf.org/doc/html/rfc6241#section-7.2
func NewEditConfig ¶
func NewEditConfig(datastoreType string, operationType string, data string) *EditConfig
NewEditConfig can be used to create a `edit-config` message.
type EstablishSubscription ¶
EstablishSubscription represents the NETCONF `establish-subscription` message. https://datatracker.ietf.org/doc/html/rfc8639#section-2.4.2 FIXME very very weak implementation: there is no validation made on the schema
func NewEstablishSubscription ¶
func NewEstablishSubscription(data string) *EstablishSubscription
NewEstablishSubscription can be used to create a `establish-subscription` message.
type Filter ¶
type Filter struct { XMLName xml.Name `xml:"filter,omitempty"` // Type defines the filter to use. Defaults to "subtree" and can support "XPath" if the server supports it. Type string `xml:"type,attr,omitempty"` Data interface{} `xml:",innerxml"` }
Filter represents the filter parameter of `get` message. Find examples here: https://datatracker.ietf.org/doc/html/rfc6241#section-6.4
type Get ¶
Get represents the NETCONF `get` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.7
type GetConfig ¶
type GetConfig struct { RPC Source *Datastore `xml:"get-config>source"` Filter *Filter `xml:"get-config>filter"` }
GetConfig represents the NETCONF `get-config` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.1
type Hello ¶
type Hello struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 hello"` Capabilities []string `xml:"capabilities>capability"` SessionID int `xml:"session-id,omitempty"` }
Hello is the message sent when a new NETCONF session is established. https://datatracker.ietf.org/doc/html/rfc6241#section-8.1
type KillSession ¶
KillSession represents the NETCONF `kill-session` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.8
func NewKillSession ¶
func NewKillSession(sessionID string) *KillSession
NewKillSession can be used to create a `kill-session` message.
type Lock ¶
Lock represents the NETCONF `lock` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.5
type Notification ¶
type Notification struct { XMLName xml.Name `xml:"notification"` XMLNS string `xml:"xmlns,attr"` EventTime string `xml:"eventTime"` EventData string `xml:"eventData,omitempty"` // The ietf-yang-push model cisco is using isn't following rfc8641, hence accommodating here. // https://github.com/YangModels/yang/blob/master/vendor/cisco/xe/1761/ietf-yang-push.yang#L367 SubscriptionIDCisco string `xml:"push-update>subscription-id,omitempty"` SubscriptionID string `xml:"push-update>id,omitempty"` RawReply string `xml:"-"` Data string `xml:",innerxml"` }
Notification defines a reply to a Notification
func NewNotification ¶
func NewNotification(rawXML []byte) (*Notification, error)
NewNotification creates an instance of an Notification based on what was received
func (*Notification) GetSubscriptionID ¶
func (notification *Notification) GetSubscriptionID() string
GetSubscriptionID returns the subscriptionID
type RPC ¶
type RPC struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc"` MessageID string `xml:"message-id,attr"` Data interface{} `xml:",innerxml"` }
RPC is used as a wrapper for any sent RPC
func (*RPC) GetMessageID ¶
GetMessageID returns the message-id of the RPC
type RPCError ¶
type RPCError struct { Type string `xml:"error-type"` Tag string `xml:"error-tag"` Severity string `xml:"error-severity"` Path string `xml:"error-path"` Message string `xml:"error-message"` Info string `xml:",innerxml"` }
RPCError defines an error reply to a RPC request
type RPCMethod ¶
type RPCMethod interface {
GetMessageID() string
}
RPCMethod defines the interface for creating an RPC method. This is mostly a marker interface to abstract all RPCs
type RPCReply ¶
type RPCReply struct { XMLName xml.Name `xml:"rpc-reply"` //urn:ietf:params:xml:ns:netconf:base:1.0 MessageID string `xml:"message-id,attr"` Errors []RPCError `xml:"rpc-error,omitempty"` Data string `xml:",innerxml"` Ok bool `xml:"ok,omitempty"` RawReply string `xml:"-"` // this is in the case we are receiving a reply to a NETCONF notification subscription SubscriptionID string `xml:"subscription-id,omitempty"` }
RPCReply defines a reply to a RPC request
func NewRPCReply ¶
NewRPCReply creates an instance of an RPCReply based on what was received
type Unlock ¶
Unlock represents the NETCONF `unlock` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.6
type Validate ¶
Validate represents the NETCONF `validate` message. https://datatracker.ietf.org/doc/html/rfc6241#section-8.6.4.1
func NewValidate ¶
NewValidate can be used to create a `lock` message.