Documentation ¶
Overview ¶
Provide authentication for REST commands. Currently only None and Basic supported.
TODO: + krb5 support using https://github.com/jcmturner/gokrb5/v8/...
Support for Geneos Gateway REST Commands ¶
Dataview Snapshot Support ¶
Only valid in GA5.14 and above ¶
In GA5.14.x the first column name is not exported and set to "rowname"
Index ¶
- Constants
- func AuthBasic(c *http.Request, username, password string) (err error)
- func AuthSSO()
- type ArgOptions
- type Args
- type Command
- type CommandsResponse
- type CommandsResponseRaw
- type Connection
- func (c *Connection) CommandTargets(name string, target *xpath.XPath) (matches []*xpath.XPath, err error)
- func (c *Connection) Do(endpoint string, command *Command) (cr CommandsResponse, err error)
- func (c *Connection) LastSampleInfo(target *xpath.XPath) (crs []CommandsResponse, err error)
- func (c *Connection) Match(target *xpath.XPath, limit int) (matches []*xpath.XPath, err error)
- func (c *Connection) Redial() (err error)
- func (c *Connection) RunCommand(name string, target *xpath.XPath, options ...ArgOptions) (cr CommandsResponse, err error)
- func (c *Connection) RunCommandAll(name string, target *xpath.XPath, options ...ArgOptions) (crs []CommandsResponse, err error)
- func (c *Connection) SampleNow(target *xpath.XPath) (err error)
- func (c *Connection) Snapshot(target *xpath.XPath, scope ...Scope) (dataview *Dataview, err error)
- func (c *Connection) SnoozeInfo(target *xpath.XPath) (crs []CommandsResponse, err error)
- func (c *Connection) SnoozeManual(target *xpath.XPath, info string) (err error)
- func (c *Connection) Unsnooze(target *xpath.XPath, info string) (err error)
- type DataItem
- type Dataview
- type GeneosRESTError
- type Options
- type SSOAuth
- type Scope
Constants ¶
const ( None = iota Basic SSO )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArgOptions ¶
type ArgOptions func(*Args)
func Arg ¶
func Arg(index int, value string) ArgOptions
type Command ¶
type Command struct { Name string `json:"command,omitempty"` Target *xpath.XPath `json:"target"` Args *Args `json:"args,omitempty"` Scope Scope `json:"scope,omitempty"` Limit int `json:"limit,omitempty"` }
A Command is made up of a Name, a Target and optional Args
type CommandsResponse ¶
type CommandsResponse struct { Target *xpath.XPath `json:"target"` MimeType map[string]string `json:"mimetype"` Status string `json:"status"` Stdout string `json:"stdout"` StdoutMimeType string `json:"stdout_mimetype"` Stderr string `json:"stderr"` ExecLog string `json:"execLog"` Dataview *Dataview `json:"dataview"` // for snapshots only XPaths []string `json:"xpaths"` }
type CommandsResponseRaw ¶
type Connection ¶
type Connection struct { BaseURL *url.URL AuthType int Username string Password string SSO SSOAuth InsecureSkipVerify bool Timeout time.Duration // contains filtered or unexported fields }
func DialGateway ¶
func DialGateway(u *url.URL, options ...Options) (c *Connection, err error)
Connect to a Geneos gateway on the given URL and check the connection. The connection is checked by trying a lightweight REST command (fetch gateway timezone and time) and if an error is returned then the connection should not be reused.
Options can be given to set authentication, ignore unverifiable certificates and to override the default "ping" to check the gateway connection
func DialGateways ¶
func DialGateways(urls []*url.URL, options ...Options) (c *Connection, err error)
Connect to a Geneos gateway given a slice of URLs. This is to support standby pairs. Each URL is checked in a random order and the first working one is returned. If all URLs fail the check then an error is returned.
Options are the same as for DialGateway()
func (*Connection) CommandTargets ¶
func (*Connection) Do ¶
func (c *Connection) Do(endpoint string, command *Command) (cr CommandsResponse, err error)
execute a command, return the http response
func (*Connection) LastSampleInfo ¶
func (c *Connection) LastSampleInfo(target *xpath.XPath) (crs []CommandsResponse, err error)
func (*Connection) Redial ¶
func (c *Connection) Redial() (err error)
Redial the connection, finding the next working endpoint using either the default ping function or the one provided when the connection was originally dialled.
An aggregated error is returned if all endpoints fail the connection test.
func (*Connection) RunCommand ¶
func (c *Connection) RunCommand(name string, target *xpath.XPath, options ...ArgOptions) (cr CommandsResponse, err error)
run a command against exactly one valid target, returning the response
func (*Connection) RunCommandAll ¶
func (c *Connection) RunCommandAll(name string, target *xpath.XPath, options ...ArgOptions) (crs []CommandsResponse, err error)
run command against all matching data items, returning stdout, stderr and execlog (concatenated) where applicable
func (*Connection) Snapshot ¶
Return the snapshot of the Dataview target with an option Scope. If no Scope is given then only Values are requested. If more than one Scope is given then only the first is used.
func (*Connection) SnoozeInfo ¶
func (c *Connection) SnoozeInfo(target *xpath.XPath) (crs []CommandsResponse, err error)
func (*Connection) SnoozeManual ¶
func (c *Connection) SnoozeManual(target *xpath.XPath, info string) (err error)
type Dataview ¶
type Dataview struct { SampleTime time.Time `json:"sample-time,omitempty"` Snoozed bool `json:"snoozed,omitempty"` SnoozedAncestors bool `json:"snoozed-ancestors,omitempty"` Headlines map[string]DataItem `json:"headlines,omitempty"` Table map[string]map[string]DataItem `json:"table,omitempty"` Columns []string `json:"-"` }
type GeneosRESTError ¶
type GeneosRESTError struct {
Error string `json:"error"`
}
type Options ¶
type Options func(*Connection)
func AllowInsecureCertificates ¶
allow unverified connections over TLS to the gateway
func Ping ¶
func Ping(ping func(*Connection) error) Options
override the ping() function used to test the availability of the gateway when used with DialGateways() and Redial()
func SetBasicAuth ¶
configure basic authentication on the connection, given a username and password