rpc

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: BSD-2-Clause Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelCommit

type CancelCommit struct {
	PersistID string
}

func (CancelCommit) Exec

func (rpc CancelCommit) Exec(ctx context.Context, session *netconf.Session) error

func (CancelCommit) MarshalXML

func (rpc CancelCommit) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Commit

type Commit struct {
	// Confirmed indicates that the commit must be confirmed with a follow-up
	// commit within the confirm-timeout period (default 600 seconds).  If not
	// confirmed, the commit will be reverted.
	//
	// Device must support :confirmed-commit:1.1 capability.
	Confirmed bool

	// ConfirmTimeout is the time in seconds to wait before reverting a
	// confirmed commit.
	//
	// Device must support :confirmed-commit:1.1 capability.
	ConfirmTimeout int64

	// Persist indicates that the confirmed commit can be persisted across
	// sessions and confirmed in a different session.
	//
	// If Confirmed is set this expands to the <persist> element.
	//
	// If Confirmed is not set this expands to the <persist-id> element to
	// confirm a previous commit with the same id.
	PersistID string
}

Commit represents the `<commit>` operation defined in RFC6241 8.5 for committing candidate configuration to the running datastore.

func (Commit) Exec

func (rpc Commit) Exec(ctx context.Context, session *netconf.Session) error

func (Commit) MarshalXML

func (rpc Commit) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type CopyConfig

type CopyConfig struct {
	Source any
	Target any
}

CopyConfig issues the `<copy-config>` operation as defined in [RFC6241 7.3] for copying an entire config to/from a source and target datastore.

A `<config>` element defining a full config can be used as the source.

If a device supports the `:url` capability than a URL object can be used for the source or target datastore.

[RFC6241 7.3] https://www.rfc-editor.org/rfc/rfc6241.html#section-7.3

func (CopyConfig) Exec

func (rpc CopyConfig) Exec(ctx context.Context, session *netconf.Session) error

func (CopyConfig) MarshalXML

func (rpc CopyConfig) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type CreateSubscription

type CreateSubscription struct {
	// Stream indicates which notification stream to subscribe to.
	// If empty, the default NETCONF stream is used.
	Stream string

	// Filter selects a subset of notifications.
	Filter Filter

	// StartTime triggers replay of notifications from the specified time.
	// Requires server support for notification replay.
	StartTime *time.Time

	// StopTime automatically terminates the subscription at the specified time.
	// Requires StartTime to be set.
	StopTime *time.Time
}

CreateSubscription represents the `<create-subscription>` operation defined in RFC 5277 Section 2.1.1 for initiating a notification subscription.

The subscription will cause the server to begin sending event notifications to the client as they occur. If StartTime is specified, the server will first replay historical events from that time (if supported).

func (*CreateSubscription) Exec

func (rpc *CreateSubscription) Exec(ctx context.Context, session *netconf.Session) error

func (*CreateSubscription) MarshalXML

func (rpc *CreateSubscription) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Datastore

type Datastore string

Datastore represents a NETCONF configuration datastore as defined in RFC6241 section 7.1

const (
	// Running configuration datastore. Required by RFC6241
	Running Datastore = "running"

	// Candidate configuration configuration datastore.  Supported with the
	// `:candidate` capability defined in RFC6241 section 8.3
	Candidate Datastore = "candidate"

	// Startup configuration configuration datastore.  Supported with the
	// `:startup` capability defined in RFC6241 section 8.7
	Startup Datastore = "startup"
)

func (Datastore) MarshalXML

func (d Datastore) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type DefaultOperation

type DefaultOperation string

DefaultOperation defines the strategies for merging configuration in a `<edit-config> operation`.

const (
	// MergeConfig configuration elements are merged together at the level at
	// which this specified.  Can be used for config elements as well as default.
	MergeConfig DefaultOperation = "merge"

	// ReplaceConfig defines that the incoming config change should replace the
	// existing config at the level which it is specified.  This can be
	// specified on individual config elements or set as the default strategy.
	ReplaceConfig DefaultOperation = "replace"

	// NoneOperation indicates that no default operation should be applied and
	// nothing is applied to the target configuration unless there are
	// operations defined on the configs subelements.
	NoneOperation DefaultOperation = "none"
)

type DeleteConfig

type DeleteConfig struct {
	Target Datastore
}

DeleteConfigReq represents the `<delete-config>` operation defined in RFC6241 7.4 for deleting a configuration datastore.

func (DeleteConfig) Exec

func (rpc DeleteConfig) Exec(ctx context.Context, session *netconf.Session) error

func (DeleteConfig) MarshalXML

func (rpc DeleteConfig) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type DiscardChanges

type DiscardChanges struct{}

DiscardChanges represents the `<discard-changes>` operation defined in RFC6241 8.3.4.2 for reverting the candidate configuration to the current running configuration.

This operation discards any uncommitted changes by resetting the candidate configuration with the content of the running configuration.

Device must support the `:candidate` capability.

func (DiscardChanges) Exec

func (rpc DiscardChanges) Exec(ctx context.Context, session *netconf.Session) error

func (DiscardChanges) MarshalXML

func (rpc DiscardChanges) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type EditConfig

type EditConfig struct {
	Target           Datastore
	DefaultOperation DefaultOperation
	TestOption       TestOption
	ErrorOption      ErrorOption
	Config           any
}

EditConfig issues the `<edit-config>` operation defined in RFC6241 7.2 for updating an existing target config datastore.

func (EditConfig) Exec

func (rpc EditConfig) Exec(ctx context.Context, session *netconf.Session) error

func (EditConfig) MarshalXML

func (rpc EditConfig) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type ErrorOption

type ErrorOption string

ErrorOption defines the behavior when an error is encountered during a `<edit-config>` operation.

const (
	// StopOnError will abort the `<edit-config>` operation on the first error.
	StopOnError ErrorOption = "stop-on-error"

	// ContinueOnError will continue to parse the configuration data even if an
	// error is encountered.  Errors are still recorded and reported in the
	// reply.
	ContinueOnError ErrorOption = "continue-on-error"

	// RollbackOnError will restore the configuration back to before the
	// `<edit-config>` operation took place.  This requires the device to
	// support the `:rollback-on-error` capability.
	RollbackOnError ErrorOption = "rollback-on-error"
)

type ExtantBool

type ExtantBool bool

func (ExtantBool) MarshalXML

func (b ExtantBool) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*ExtantBool) UnmarshalXML

func (b *ExtantBool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Filter

type Filter interface {
	xml.Marshaler
	// contains filtered or unexported methods
}

func SubtreeFilter

func SubtreeFilter(filter any) Filter

SubtreeFilter creates a filter matching the provided XML structure(s). Multiple arguments are merged into a single filter element as siblings.

func XPathFilter

func XPathFilter(path string, namespaces map[string]string) Filter

XPathFilter creates a filter using XPath 1.0 expression. namespaces map prefixes used in the path to their URIs.

type Get

type Get struct {
	Filter Filter `xml:"filter,omitempty"`
}

func (*Get) Exec

func (rpc *Get) Exec(ctx context.Context, session *netconf.Session) ([]byte, error)

func (*Get) MarshalXML

func (rpc *Get) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type GetConfig

type GetConfig struct {
	Source Datastore
	Filter Filter
}

GetConfig implements the <get-config> rpc operation defined in RFC6241 7.1. `source` is the datastore to query.

func (GetConfig) Exec

func (rpc GetConfig) Exec(ctx context.Context, session *netconf.Session) ([]byte, error)

func (GetConfig) MarshalXML

func (op GetConfig) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type GetConfigReply

type GetConfigReply struct {
	Config []byte
}

func (*GetConfigReply) UnmarshalXML

func (r *GetConfigReply) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type GetReply

type GetReply struct {
	netconf.RPCReply
	Data struct {
		XML []byte `xml:",innerxml"`
	} `xml:"data"`
}

type KillSession

type KillSession struct {
	SessionID uint
}

KillSessionReq represents the `<kill-session>` operation defined in RFC6241 7.6 for terminating a NETCONF session.

func (*KillSession) Exec

func (rpc *KillSession) Exec(ctx context.Context, session *netconf.Session) error

func (*KillSession) MarshalXML

func (rpc *KillSession) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Lock

type Lock struct {
	Target Datastore
}

LockReq represents the `<lock>` operation defined in RFC6241 7.5 for locking a configuration datastore.

func (Lock) Exec

func (rpc Lock) Exec(ctx context.Context, session *netconf.Session) error

func (Lock) MarshalXML

func (rpc Lock) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type OkReply

type OkReply struct {
	netconf.RPCReply
	OK ExtantBool `xml:"ok"`
}

type TestOption

type TestOption string

TestOption defines the behavior for testing configuration before applying it in a `<edit-config>` operation.

const (
	// TestThenSet will validate the configuration and only if is is valid then
	// apply the configuration to the datastore.
	TestThenSet TestOption = "test-then-set"

	// SetOnly will not do any testing before applying it.
	SetOnly TestOption = "set"

	// Test only will validatate the incoming configuration and return the
	// results without modifying the underlying store.
	TestOnly TestOption = "test-only"
)

type URL

type URL string

func (URL) MarshalXML

func (u URL) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Unlock

type Unlock struct {
	Target Datastore
}

func (Unlock) Exec

func (rpc Unlock) Exec(ctx context.Context, session *netconf.Session) error

func (Unlock) MarshalXML

func (rpc Unlock) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Validate

type Validate struct {
	Source any
}

func (Validate) Exec

func (rpc Validate) Exec(ctx context.Context, session *netconf.Session) error

func (Validate) MarshalXML

func (rpc Validate) MarshalXML(e *xml.Encoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

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