commands

package
v1.0.1-pre Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 11 Imported by: 0

README

Geneos Commands

This package is intended to provide access to Geneos commands in the Gateway via the REST interface.

Gateway documentation is here

REST commands must be enabled in the Gateway configuration under the top level Commands section Advanced tab.

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

Based on https://docs.itrsgroup.com/docs/geneos/current/Gateway_Reference_Guide/geneos_commands_tr.html#REST_Service

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

View Source
const (
	None = iota
	Basic
	SSO
)

Variables

This section is empty.

Functions

func AuthBasic

func AuthBasic(c *http.Request, username, password string) (err error)

func AuthSSO

func AuthSSO()

try to authentication using SSO

Types

type ArgOptions

type ArgOptions func(*Args)

func Arg

func Arg(index int, value string) ArgOptions

type Args

type Args map[string]string

type Command

type Command struct {
	Name   string `json:"command"`
	Target string `json:"target"`
	Args   *Args  `json:"args,omitempty"`
}

A Command is made up of a Name, a Target and optional Args

type CommandOptions

type CommandOptions func(*Connection)

func AllowInsecureCertificates

func AllowInsecureCertificates(opt bool) CommandOptions

func SetBasicAuth

func SetBasicAuth(username, password string) CommandOptions

type CommandsResponse

type CommandsResponse struct {
	MimeType   map[string]string   `json:"mimetype"`
	Status     string              `json:"status"`
	StreamData map[string][]string `json:"streamdata"`
	Dataview   *Dataview           `json:"dataview"`
	XPaths     []string            `json:"xpaths"`
}

func CookResponse

func CookResponse(raw CommandsResponseRaw) (cr CommandsResponse)

Convert a raw response into a slightly more structured one where the interleaved stream messages are merged, in order, into slices for each stream

type CommandsResponseRaw

type CommandsResponseRaw struct {
	MimeType   []map[string]string `json:"mimetype"`
	Status     string              `json:"status"`
	StreamData []map[string]string `json:"streamdata"`
	Dataview   *Dataview           `json:"dataview`
	XPaths     []string            `json:"xpaths`
}

type Connection

type Connection struct {
	BaseURL            *url.URL
	AuthType           int
	Username           string
	Password           string
	SSO                SSOAuth
	InsecureSkipVerify bool
}

func Dial

func Dial(u *url.URL, options ...CommandOptions) (c *Connection, err error)

Set-up a Gateway REST command connection

func (*Connection) CommandTargets

func (c *Connection) CommandTargets(name string, target *xpath.XPath) (matches []*xpath.XPath)

func (*Connection) Do

func (c *Connection) Do(endpoint string, command interface{}) (cr CommandsResponse, err error)

execute a command, return the http response

func (*Connection) RunCommand

func (c *Connection) RunCommand(name string, target *xpath.XPath, options ...ArgOptions) (stdout, stderr, execlog string, err error)

run a command against exactly one valid target, returning stdout, stderr and execlog where applicable

func (*Connection) RunCommandAll

func (c *Connection) RunCommandAll(name string, target *xpath.XPath, options ...ArgOptions) (stdout, stderr, execlog map[string]string, err error)

run command against all matching data items, returning stdout, stderr and execlog (concatenated) where applicable

func (*Connection) Snapshot

func (c *Connection) Snapshot(target *xpath.XPath, scope ...Scope) (dataview *Dataview, err error)

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) (info map[string]string, err error)

func (*Connection) SnoozeManual

func (c *Connection) SnoozeManual(target *xpath.XPath, info string) (err error)

func (*Connection) Unsnooze

func (c *Connection) Unsnooze(target *xpath.XPath, info string) (err error)

type DataItem

type DataItem struct {
	Value    string `json:"value,omitempty"`
	Severity string `json:"severity,omitempty"`
	Snoozed  bool   `json:"snoozed,omitempty"`
	Assigned bool   `json:"assigned,omitempty"`
}

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 Fetch

type Fetch struct {
	Target string `json:"target"`
	Scope  Scope  `json:"scope,omitempty"`
}

type SSOAuth

type SSOAuth struct {
	AccessToken string `json:"access_token,omitempty"`
	Expires     int64  `json:"expires,omitempty"`
	TokenType   string `json:"token_type,omitempty"`
}

type Scope

type Scope struct {
	Value          bool `json:"value,omitempty"`
	Severity       bool `json:"severity,omitempty"`
	Snooze         bool `json:"snooze,omitempty"`
	UserAssignment bool `json:"user-assignment,omitempty"`
}

Jump to

Keyboard shortcuts

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