message

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
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"
)

Variables

This section is empty.

Functions

This section is empty.

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

func NewCommit

func NewCommit() *Commit

NewCommit can be used to create a `commit` message.

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 added in v1.1.5

func NewCreateSubscriptionDefault() *CreateSubscription

NewCreateSubscriptionDefault can be used to create a `create-subscription` message for the NETCONF stream.

type CreateSubscriptionData added in v1.1.5

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 added in v1.1.5

type EstablishSubscription struct {
	RPC
	Data string `xml:",innerxml"`
}

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 added in v1.1.5

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

type Get struct {
	RPC
	Get    interface{} `xml:"get"`
	Filter *Filter
}

Get represents the NETCONF `get` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.7

func NewGet

func NewGet(filterType string, data string) *Get

NewGet can be used to create a `get` message.

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

func NewGetConfig

func NewGetConfig(datastoreType string, filterType string, filterData string) *GetConfig

NewGetConfig can be used to create a `get-config` message.

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

type KillSession struct {
	RPC
	SessionID string `xml:"kill-session>session-id"`
}

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

type Lock struct {
	RPC
	Target *Datastore `xml:"lock>target"`
}

Lock represents the NETCONF `lock` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.5

func NewLock

func NewLock(datastoreType string) *Lock

NewLock can be used to create a `lock` message.

type Notification added in v1.1.5

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 added in v1.1.5

func NewNotification(rawXML []byte) (*Notification, error)

NewNotification creates an instance of an Notification based on what was received

func (*Notification) GetSubscriptionID added in v1.2.0

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 NewRPC added in v1.1.2

func NewRPC(data interface{}) *RPC

NewRPC formats an RPC message

func (*RPC) GetMessageID added in v1.2.0

func (rpc *RPC) GetMessageID() string

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

func (*RPCError) Error

func (re *RPCError) Error() string

Error generates a string representation of the provided RPC error

type RPCMethod added in v1.2.0

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"`
	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

func NewRPCReply(rawXML []byte) (*RPCReply, error)

NewRPCReply creates an instance of an RPCReply based on what was received

type Unlock

type Unlock struct {
	RPC
	Target *Datastore `xml:"unlock>target"`
}

Unlock represents the NETCONF `unlock` message. https://datatracker.ietf.org/doc/html/rfc6241#section-7.6

func NewUnlock

func NewUnlock(datastoreType string) *Unlock

NewUnlock can be used to create a `unlock` message.

type Validate

type Validate struct {
	RPC
	Source *Datastore `xml:"validate>source"`
}

Validate represents the NETCONF `validate` message. https://datatracker.ietf.org/doc/html/rfc6241#section-8.6.4.1

func NewValidate

func NewValidate(datastoreType string) *Validate

NewValidate can be used to create a `lock` message.

Jump to

Keyboard shortcuts

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