response

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 9 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiOperationError

type MultiOperationError struct {
	Operations []*OperationError
}

MultiOperationError is an error object for scrapli *multi* operations.

func (*MultiOperationError) Error

func (e *MultiOperationError) Error() string

Error returns an error string for the MultiOperationError object.

type MultiResponse

type MultiResponse struct {
	Host        string
	StartTime   time.Time
	EndTime     time.Time
	ElapsedTime float64
	Responses   []*Response
	Failed      error
}

MultiResponse defines a response object for plural operations -- contains a slice of `Responses` for each operation.

func NewMultiResponse

func NewMultiResponse(host string) *MultiResponse

NewMultiResponse creates a new MultiResponse object.

func (*MultiResponse) AppendResponse

func (mr *MultiResponse) AppendResponse(r *Response)

AppendResponse appends a response to the `Responses` attribute of the MultiResponse object.

func (*MultiResponse) JoinedResult

func (mr *MultiResponse) JoinedResult() string

JoinedResult is a convenience method to print out a single unified/joined result -- this is basically all the channel output for each individual response in the MultiResponse joined by newline characters.

type NetconfResponse

type NetconfResponse struct {
	Host                 string
	Port                 int
	Input                []byte
	FramedInput          []byte
	RawResult            []byte
	Result               string
	StartTime            time.Time
	EndTime              time.Time
	ElapsedTime          float64
	FailedWhenContains   [][]byte
	Failed               error
	StripNamespaces      bool
	NetconfVersion       string
	ErrorMessages        []string
	WarningErrorMessages []string
	SubscriptionID       int
}

NetconfResponse is a struct returned from all netconf driver operations.

func NewNetconfResponse

func NewNetconfResponse(
	input,
	framedInput []byte,
	host string,
	port int,
	version string,
) *NetconfResponse

NewNetconfResponse prepares a new NetconfResponse object.

func (*NetconfResponse) Record

func (r *NetconfResponse) Record(b []byte)

Record records the output of a NETCONF operation.

type OperationError

type OperationError struct {
	Input       string
	Output      string
	ErrorString string
}

OperationError is an error object returned when a scrapli operation completes "successfully" -- as in does not have an EOF/timeout or otherwise unrecoverable error -- but contains output in the device's response indicating that an input was bad/invalid or device failed to process it at that time.

func (*OperationError) Error

func (e *OperationError) Error() string

Error returns an error string for the OperationError object.

type Response

type Response struct {
	Host               string
	Port               int
	Input              string
	RawResult          []byte
	Result             string
	StartTime          time.Time
	EndTime            time.Time
	ElapsedTime        float64
	FailedWhenContains []string
	// Failed returns an error if any of the `FailedWhenContains` substrings are seen in the output
	// returned from the device. This error indicates that the operation has completed successfully,
	// but that an input was bad/invalid or device failed to process it at that time
	Failed error
}

Response is a struct returned from most (all?) generic and network driver "single" operations.

func NewResponse

func NewResponse(
	input,
	host string,
	port int,
	failedWhenContains []string,
) *Response

NewResponse prepares a new Response object.

func (*Response) Record

func (r *Response) Record(b []byte)

Record records the output of an operation.

func (*Response) TextFsmParse

func (r *Response) TextFsmParse(path string) ([]map[string]interface{}, error)

TextFsmParse parses recorded output w/ a provided textfsm template. the argument is interpreted as URL or filesystem path, for example: response.TextFsmParse("http://example.com/textfsm.template") or response.TextFsmParse("./local/textfsm.template").

Jump to

Keyboard shortcuts

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