Documentation ¶
Overview ¶
Package to handle Geneos Gateway specific XPaths
These are a subset of the W3C XPath 1.0 standard and this package is only interested in absolute paths and no matching is done. Geneos XPaths are of a particular hierarchy and the ones we are interesting in here are those used to communicate with the Gateway REST command API.
The two types of path handled are for headline or table cells, which have the form:
/geneos/gateway/directory/probe/managedEntity/sampler/dataview/ ...
... headlines/cell or ... rows/row/cell
Each component except "geneos", "directory", "headlines" and "rows" can have a name and other predicates. The path can terminate at any level that can carry a name. Apart from names, only attributes in managedEntities are currently handled in anyway.
Index ¶
- Variables
- type Column
- type Dataview
- type Entity
- type Gateway
- type Headline
- type Probe
- type Row
- type Sampler
- type XPath
- func (x *XPath) IsDataview() bool
- func (x *XPath) IsEmpty() bool
- func (x *XPath) IsEntity() bool
- func (x *XPath) IsGateway() bool
- func (x *XPath) IsHeadline() bool
- func (x *XPath) IsProbe() bool
- func (x *XPath) IsSampler() bool
- func (x *XPath) IsTableCell() bool
- func (x *XPath) LookupValues() (lookup map[string]string)
- func (x XPath) MarshalJSON() ([]byte, error)
- func (x *XPath) ResolveTo(element interface{}) *XPath
- func (x *XPath) SetGatewayName(gateway string)
- func (x *XPath) String() (p string)
- func (x *XPath) UnmarshalJSON(b []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPath = errors.New("invalid Geneos XPath")
var ErrRelativePath = errors.New("unsupported relative Geneos XPath")
Functions ¶
This section is empty.
Types ¶
type XPath ¶
type XPath struct { Gateway *Gateway `json:"gateway,omitempty"` Probe *Probe `json:"probe,omitempty"` Entity *Entity `json:"entity,omitempty"` Sampler *Sampler `json:"sampler,omitempty"` Dataview *Dataview `json:"dataview,omitempty"` Rows bool `json:"-"` Headline *Headline `json:"headline,omitempty"` Row *Row `json:"row,omitempty"` Column *Column `json:"column,omitempty"` }
XPath represents a Geneos Gateway XPath
Each field (except Rows) is a pointer, which if nil means the Xpath terminates at that point, not that the value is unset. The "Rows" boolean indicates in lower level components are rows or headlines
func New ¶
func New(element interface{}) *XPath
New returns an XPath to the level of the element passed, which can be populated with fields.
func NewDataviewPath ¶
NewDataviewPath returns an xpath populated to the dataview, with name dv if no name is passed, create a wildcard dataview path
func NewHeadlinePath ¶
NewHeadlinePath returns an xpath populated to the headline cell, identified by headline
func NewTableCellPath ¶
NewTableCellPath returns an xpath populated to the table cell identifies by row and column
func Parse ¶
Parse takes an absolute Geneos XPath and returns an XPath structure.
A leading double slash, e.g. //probe[(@name="myprobe")], results in preceding levels being filled-in and further processing continuing from there. Because of the general purpose nature of the function only levels down to //rows and //headlines are supported. If you need a general path to a cell then you must use either //rows/row/cell or //headlines/cell to ensure the returned path uses the correct structure.
Full wildcards, e.g. `//*`, are not supported as it is not possible to determine the terminating level.
Support for predicates is limited. Currently all components understand "name", e.g. //probe[(@name="probeName")], while "managedEntity" supports multiple "attribute" predicates and table cells (under "rows/row/cell") support "column" (which is used instead of "name").
func (*XPath) IsDataview ¶
func (*XPath) IsHeadline ¶
func (*XPath) IsTableCell ¶
IsTableCell returns true if x represents a table cell
func (*XPath) LookupValues ¶ added in v1.11.0
LookupValues returns a map of the components of x to their values, suitable for use as an Expand LookupTable. Only components of x that are set are added to the returned map and processing stops as soon as an XPath struct field is nil. The returned map is always initialised.
The potential keys set are gateway, probe, entity, sampler, type, dataview, row, column, headline. Entity attributes in the XPath are ignored.
func (*XPath) ResolveTo ¶
ResolveTo will, given an element type, return a new XPath to that element, removing lower level elements or adding empty elements to the level required. If the XPath does not contain an element of the type given then use the argument (which can include populated fields), but if empty then any existing element will be left as-is and not cleaned.
e.g.
x := x.ResolveTo(&Dataview{}) y := xpath.ResolveTo(&Headline{Name: "headlineName"})
func (*XPath) SetGatewayName ¶
SetGatewayName sets the Gateway name
?do we need setters? validation?
func (*XPath) UnmarshalJSON ¶
return an xpath parsed from a string