From db1af5b07a5bf8e93f2629604f01cd1b935609d7 Mon Sep 17 00:00:00 2001 From: Carl Montanari Date: Thu, 25 Nov 2021 09:05:06 -0800 Subject: [PATCH] bare rpc --- netconf/payload.go | 9 +++++++++ netconf/rpc.go | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 netconf/rpc.go diff --git a/netconf/payload.go b/netconf/payload.go index 5fe44e3..3a09db6 100644 --- a/netconf/payload.go +++ b/netconf/payload.go @@ -50,6 +50,15 @@ func (d *Driver) BuildPayload(payload interface{}) *Message { return baseElem } +// BuildRPCElem creates an element for a rpc operation. +func (d *Driver) BuildRPCElem( + filter string, +) (*Message, error) { + netconfInput := d.BuildPayload(filter) + + return netconfInput, nil +} + // datastore source // SourceElement struct representing the individual source message element. diff --git a/netconf/rpc.go b/netconf/rpc.go new file mode 100644 index 0000000..f454ad3 --- /dev/null +++ b/netconf/rpc.go @@ -0,0 +1,13 @@ +package netconf + +// RPC sends a "bare" rpc to the device. +func (d *Driver) RPC(o ...Option) (*Response, error) { + finalOpts := d.ParseNetconfOptions(o) + netconfMessage, err := d.BuildRPCElem(finalOpts.Filter) + + if err != nil { + return nil, err + } + + return d.finalizeAndSendMessage(netconfMessage) +}