Documentation ¶
Index ¶
- func NewContextWithDeviceConnection(ctx context.Context, con *RequestDeviceConnection) context.Context
- func URLEscapePath(unescaped string) string
- func ValidateSNMPv3AuthProtocol(protocol string) error
- func ValidateSNMPv3PrivProtocol(protocol string) error
- type CommonOIDs
- type ConnectionData
- type HTTPClient
- func (h *HTTPClient) GetHostname() string
- func (h *HTTPClient) GetProtocolString() string
- func (h *HTTPClient) GetSuccessfulCachedRequests() map[string]cachedRequestResult
- func (h *HTTPClient) InsecureSSLCert(b bool)
- func (h *HTTPClient) Request(ctx context.Context, method, path, body string, ...) (*resty.Response, error)
- func (h *HTTPClient) SetFormat(format string) error
- func (h *HTTPClient) SetPort(port int)
- func (h *HTTPClient) SetTimeout(timeout time.Duration)
- func (h *HTTPClient) SetUsernameAndPassword(username, password string) error
- func (h *HTTPClient) UseCache(b bool)
- func (h *HTTPClient) UseDefaultPort()
- func (h *HTTPClient) UseHTTPS(useHTTPS bool)
- type HTTPConnectionData
- type OID
- type RequestDeviceConnection
- type RequestDeviceConnectionHTTP
- type RequestDeviceConnectionSNMP
- type SNMPClient
- func NewSNMPClient(ctx context.Context, ipAddress, snmpVersion, community string, ...) (*SNMPClient, error)
- func NewSNMPClientByConnectionData(ctx context.Context, ipAddress string, data *SNMPConnectionData) (*SNMPClient, error)
- func NewSNMPv3Client(ctx context.Context, ipAddress string, port, timeout, retries int, ...) (*SNMPClient, error)
- func (s *SNMPClient) Disconnect() error
- func (s *SNMPClient) GetCommunity() string
- func (s *SNMPClient) GetMaxRepetitions() uint8
- func (s *SNMPClient) GetPort() int
- func (s *SNMPClient) GetSuccessfulCachedRequests() map[string]cachedRequestResult
- func (s *SNMPClient) GetV3AuthKey() *string
- func (s *SNMPClient) GetV3AuthProto() *string
- func (s *SNMPClient) GetV3ContextName() *string
- func (s *SNMPClient) GetV3Level() *string
- func (s *SNMPClient) GetV3PrivKey() *string
- func (s *SNMPClient) GetV3PrivProto() *string
- func (s *SNMPClient) GetV3User() *string
- func (s *SNMPClient) GetVersion() string
- func (s *SNMPClient) SNMPGet(ctx context.Context, oid ...string) ([]SNMPResponse, error)
- func (s *SNMPClient) SNMPWalk(ctx context.Context, oid string) ([]SNMPResponse, error)
- func (s *SNMPClient) SetCommunity(community string)
- func (s *SNMPClient) SetMaxRepetitions(maxRepetitions uint32)
- func (s *SNMPClient) UseCache(b bool)
- type SNMPConnectionData
- type SNMPCredentials
- type SNMPGetConfiguration
- type SNMPResponse
- func (s *SNMPResponse) GetOID() string
- func (s *SNMPResponse) GetSNMPType() gosnmp.Asn1BER
- func (s *SNMPResponse) GetValue() (interface{}, error)
- func (s *SNMPResponse) GetValueBySNMPGetConfiguration(snmpgetConfig SNMPGetConfiguration) (string, error)
- func (s *SNMPResponse) GetValueString() (string, error)
- func (s *SNMPResponse) GetValueStringRaw() (string, error)
- func (s *SNMPResponse) WasSuccessful() bool
- type SNMPv3ConnectionData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContextWithDeviceConnection ¶
func NewContextWithDeviceConnection(ctx context.Context, con *RequestDeviceConnection) context.Context
NewContextWithDeviceConnection returns a new context with the device connection
func URLEscapePath ¶
URLEscapePath url-escapes a file path.
Types ¶
type CommonOIDs ¶
CommonOIDs represents the common oids
type ConnectionData ¶
type ConnectionData struct { // Data of the snmp connection to the device SNMP *SNMPConnectionData `json:"snmp" xml:"snmp" yaml:"snmp"` // Data of the http connection to the device HTTP *HTTPConnectionData `json:"http" xml:"http" yaml:"http"` }
ConnectionData
ConnectionData includes all connection data for a device.
swagger:model
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is used for communication over HTTP(s).
func NewHTTPClient ¶
func NewHTTPClient(URI string) (*HTTPClient, error)
NewHTTPClient returns a new HTTP client.
func (*HTTPClient) GetHostname ¶
func (h *HTTPClient) GetHostname() string
GetHostname returns the hostname.
func (*HTTPClient) GetProtocolString ¶
func (h *HTTPClient) GetProtocolString() string
GetProtocolString returns the protocol as a string.
func (*HTTPClient) GetSuccessfulCachedRequests ¶
func (h *HTTPClient) GetSuccessfulCachedRequests() map[string]cachedRequestResult
GetSuccessfulCachedRequests returns all successful cached requests.
func (*HTTPClient) InsecureSSLCert ¶
func (h *HTTPClient) InsecureSSLCert(b bool)
InsecureSSLCert defines weather insecure ssl certificates are allowed.
func (*HTTPClient) Request ¶
func (h *HTTPClient) Request(ctx context.Context, method, path, body string, header, queryParams map[string]string) (*resty.Response, error)
Request sends an http request.
func (*HTTPClient) SetFormat ¶
func (h *HTTPClient) SetFormat(format string) error
SetFormat sets the format header which is used in requests.
func (*HTTPClient) SetTimeout ¶
func (h *HTTPClient) SetTimeout(timeout time.Duration)
SetTimeout sets a timeout for the http client.
func (*HTTPClient) SetUsernameAndPassword ¶
func (h *HTTPClient) SetUsernameAndPassword(username, password string) error
SetUsernameAndPassword sets username and password for an http client.
func (*HTTPClient) UseCache ¶
func (h *HTTPClient) UseCache(b bool)
UseCache configures whether the http cache should be used or not.
func (*HTTPClient) UseDefaultPort ¶
func (h *HTTPClient) UseDefaultPort()
UseDefaultPort sets HTTP(S) port to its default port.
type HTTPConnectionData ¶
type HTTPConnectionData struct { // The http port(s) of the device. // // example: [80] HTTPPorts []int `json:"http_ports" xml:"http_ports" yaml:"http_ports"` // The https port(s) of the device. // // example: [443] HTTPSPorts []int `json:"https_ports" xml:"https_ports" yaml:"https_ports"` // The username for authorization on the device. // // example: username AuthUsername *string `json:"auth_username" xml:"auth_username" yaml:"auth_username"` // The password for authorization on the device. // // example: password AuthPassword *string `json:"auth_password" xml:"auth_password" yaml:"auth_password"` }
HTTPConnectionData
HTTPConnectionData includes all http connection data for a device.
swagger:model
type RequestDeviceConnection ¶
type RequestDeviceConnection struct { RawConnectionData ConnectionData HTTP *RequestDeviceConnectionHTTP SNMP *RequestDeviceConnectionSNMP }
RequestDeviceConnection represents the request device connection
func DeviceConnectionFromContext ¶
func DeviceConnectionFromContext(ctx context.Context) (*RequestDeviceConnection, bool)
DeviceConnectionFromContext gets the device connection from the context
func (*RequestDeviceConnection) CloseConnections ¶
func (r *RequestDeviceConnection) CloseConnections()
CloseConnections closes the connection to the device
func (*RequestDeviceConnection) GetIdealConnectionData ¶
func (r *RequestDeviceConnection) GetIdealConnectionData() ConnectionData
GetIdealConnectionData returns the ideal connection data.
type RequestDeviceConnectionHTTP ¶
type RequestDeviceConnectionHTTP struct { HTTPClient *HTTPClient ConnectionData *HTTPConnectionData }
RequestDeviceConnectionHTTP represents the http request device connection
type RequestDeviceConnectionSNMP ¶
type RequestDeviceConnectionSNMP struct { SnmpClient *SNMPClient CommonOIDs CommonOIDs }
RequestDeviceConnectionSNMP represents the snmp request device connection
func (*RequestDeviceConnectionSNMP) GetSysDescription ¶
func (r *RequestDeviceConnectionSNMP) GetSysDescription(ctx context.Context) (string, error)
GetSysDescription returns the sysDescription.
func (*RequestDeviceConnectionSNMP) GetSysObjectID ¶
func (r *RequestDeviceConnectionSNMP) GetSysObjectID(ctx context.Context) (string, error)
GetSysObjectID returns the sysObjectID.
type SNMPClient ¶
type SNMPClient struct {
// contains filtered or unexported fields
}
SNMPClient is used to communicate via snmp.
func NewSNMPClient ¶
func NewSNMPClient(ctx context.Context, ipAddress, snmpVersion, community string, port, timeout, retries int) (*SNMPClient, error)
NewSNMPClient creates a new SNMP Client
func NewSNMPClientByConnectionData ¶
func NewSNMPClientByConnectionData(ctx context.Context, ipAddress string, data *SNMPConnectionData) (*SNMPClient, error)
NewSNMPClientByConnectionData tries to create a new snmp client by SNMPConnectionData and returns it.
func NewSNMPv3Client ¶
func NewSNMPv3Client(ctx context.Context, ipAddress string, port, timeout, retries int, v3Data SNMPv3ConnectionData) (*SNMPClient, error)
NewSNMPv3Client creates a new SNMP v3 Client.
func (*SNMPClient) Disconnect ¶
func (s *SNMPClient) Disconnect() error
Disconnect closes an snmp connection.
func (*SNMPClient) GetCommunity ¶
func (s *SNMPClient) GetCommunity() string
GetCommunity returns the community string
func (*SNMPClient) GetMaxRepetitions ¶
func (s *SNMPClient) GetMaxRepetitions() uint8
GetMaxRepetitions returns the max repetitions.
func (*SNMPClient) GetSuccessfulCachedRequests ¶
func (s *SNMPClient) GetSuccessfulCachedRequests() map[string]cachedRequestResult
GetSuccessfulCachedRequests returns all successful cached requests.
func (*SNMPClient) GetV3AuthKey ¶
func (s *SNMPClient) GetV3AuthKey() *string
GetV3AuthKey returns the auth key of the snmp v3 connection. Return value is nil if no snmp v3 is being used.
func (*SNMPClient) GetV3AuthProto ¶
func (s *SNMPClient) GetV3AuthProto() *string
GetV3AuthProto returns the auth protocol of the snmp v3 connection. Return value is nil if no snmp v3 is being used.
func (*SNMPClient) GetV3ContextName ¶
func (s *SNMPClient) GetV3ContextName() *string
GetV3ContextName returns the context name of the snmp v3 connection. Return value is nil if no snmp v3 is being used.
func (*SNMPClient) GetV3Level ¶
func (s *SNMPClient) GetV3Level() *string
GetV3Level returns the security level of the snmp v3 connection. Return value is nil if no snmp v3 is being used.
func (*SNMPClient) GetV3PrivKey ¶
func (s *SNMPClient) GetV3PrivKey() *string
GetV3PrivKey returns the priv key of the snmp v3 connection. Return value is nil if no snmp v3 is being used.
func (*SNMPClient) GetV3PrivProto ¶
func (s *SNMPClient) GetV3PrivProto() *string
GetV3PrivProto returns the priv protocol of the snmp v3 connection. Return value is nil if no snmp v3 is being used.
func (*SNMPClient) GetV3User ¶
func (s *SNMPClient) GetV3User() *string
GetV3User returns the user of the snmp v3 connection. Return value is nil if no snmp v3 is being used.
func (*SNMPClient) GetVersion ¶
func (s *SNMPClient) GetVersion() string
GetVersion returns the snmp version.
func (*SNMPClient) SNMPGet ¶
func (s *SNMPClient) SNMPGet(ctx context.Context, oid ...string) ([]SNMPResponse, error)
SNMPGet sends one or more simple snmpget requests to the target host and returns the result.
func (*SNMPClient) SNMPWalk ¶
func (s *SNMPClient) SNMPWalk(ctx context.Context, oid string) ([]SNMPResponse, error)
SNMPWalk sends a snmpwalk request to the specified oid.
func (*SNMPClient) SetCommunity ¶
func (s *SNMPClient) SetCommunity(community string)
SetCommunity updates the community string. This function is not thread safe!
func (*SNMPClient) SetMaxRepetitions ¶
func (s *SNMPClient) SetMaxRepetitions(maxRepetitions uint32)
SetMaxRepetitions sets the maximum repetitions.
func (*SNMPClient) UseCache ¶
func (s *SNMPClient) UseCache(b bool)
UseCache configures whether the snmp cache should be used or not
type SNMPConnectionData ¶
type SNMPConnectionData struct { // The snmp community string(s) for the device. // // example: ["public"] Communities []string `json:"communities" xml:"communities" yaml:"communities"` // The snmp version(s) of the device. // // example: ["2c"] Versions []string `json:"versions" xml:"versions" yaml:"versions"` // The snmp port(s) of the device. // // example: [161] Ports []int `json:"ports" xml:"ports" yaml:"ports"` // The amount of parallel connection requests used while trying to get a valid SNMP connection. // // example: 5 DiscoverParallelRequests *int `json:"discoverParallelRequests" xml:"discoverParallelRequests" yaml:"discoverParallelRequests"` // The timeout in seconds used while trying to get a valid SNMP connection. // // example: 2 DiscoverTimeout *int `json:"discoverTimeout" xml:"discoverTimeout" yaml:"discoverTimeout"` // The retries used while trying to get a valid SNMP connection. // // example: 0 DiscoverRetries *int `json:"discoverRetries" xml:"discoverRetries" yaml:"discoverRetries"` // The data required for an SNMP v3 connection. V3Data SNMPv3ConnectionData `json:"v3_data" xml:"v3_data" yaml:"v3_data"` }
SNMPConnectionData
SNMPConnectionData includes all snmp connection data for a device.
swagger:model
type SNMPCredentials ¶
type SNMPCredentials struct { Version string `yaml:"version" json:"version" xml:"version"` Community string `yaml:"community" json:"community" xml:"community"` Port int `yaml:"port" json:"port" xml:"port"` V3Level string `yaml:"v3Level" json:"v3Level" xml:"v3Level"` V3ContextName string `yaml:"v3ContextName" json:"v3ContextName" xml:"v3ContextName"` }
SNMPCredentials includes all credential information of the snmp connection.
type SNMPGetConfiguration ¶
type SNMPGetConfiguration struct { OID OID `yaml:"oid" mapstructure:"oid"` UseRawResult bool `yaml:"use_raw_result" mapstructure:"use_raw_result"` }
SNMPGetConfiguration represents the configuration needed to get a value.
type SNMPResponse ¶
type SNMPResponse struct {
// contains filtered or unexported fields
}
SNMPResponse is the response returned for a single snmp request.
func (*SNMPResponse) GetOID ¶
func (s *SNMPResponse) GetOID() string
GetOID returns the oid of the response.
func (*SNMPResponse) GetSNMPType ¶
func (s *SNMPResponse) GetSNMPType() gosnmp.Asn1BER
GetSNMPType returns the snmp type of the response.
func (*SNMPResponse) GetValue ¶
func (s *SNMPResponse) GetValue() (interface{}, error)
GetValue returns the value of the snmp response.
func (*SNMPResponse) GetValueBySNMPGetConfiguration ¶
func (s *SNMPResponse) GetValueBySNMPGetConfiguration(snmpgetConfig SNMPGetConfiguration) (string, error)
GetValueBySNMPGetConfiguration returns the value of the snmp response according to the snmpgetConfig
func (*SNMPResponse) GetValueString ¶
func (s *SNMPResponse) GetValueString() (string, error)
GetValueString returns the value string of the snmp response.
func (*SNMPResponse) GetValueStringRaw ¶
func (s *SNMPResponse) GetValueStringRaw() (string, error)
GetValueStringRaw returns the raw value string of the snmp response.
func (*SNMPResponse) WasSuccessful ¶
func (s *SNMPResponse) WasSuccessful() bool
WasSuccessful returns if the snmp request was successful.
type SNMPv3ConnectionData ¶
type SNMPv3ConnectionData struct { // The security level of the SNMP connection. // // example: authPriv Level *string `json:"level" xml:"level" yaml:"level"` // The context name of the SNMP connection. // // example: bridge1 ContextName *string `json:"context_name" xml:"context_name" yaml:"context_name"` // The user of the SNMP connection. // // example: user User *string `json:"user" xml:"user" yaml:"user"` // The authentication protocol passphrase of the SNMP connection. // // example: passphrase AuthKey *string `json:"auth_key" xml:"auth_key" yaml:"auth_key"` // The authentication protocol of the SNMP connection. // // example: MD5 AuthProtocol *string `json:"auth_protocol" xml:"auth_protocol" yaml:"auth_protocol"` // The privacy protocol passphrase of the SNMP connection. // // example: passphrase PrivKey *string `json:"priv_key" xml:"priv_key" yaml:"priv_key"` // The privacy protocol of the SNMP connection. // // example: DES PrivProtocol *string `json:"priv_protocol" xml:"priv_protocol" yaml:"priv_protocol"` }
SNMPv3ConnectionData
SNMPv3ConnectionData includes all snmp v3 specific connection data.
swagger:model