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) MarshalJSON() ([]byte, error)
- func (x *XPath) ResolveTo(element interface{}) *XPath
- func (x *XPath) SetGatewayName(gateway string)
- func (x *XPath) String() (path 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"` Headline *Headline `json:"headline,omitempty"` Rows bool `json:"-"` Row *Row `json:"row,omitempty"` Column *Column `json:"column,omitempty"` }
A Geneos Gateway XPath
Each field is a pointer, which if nil means the Xpath terminates at that point The "rows" boolean indicates in lower level components are headlines or rows
func New ¶
func New(element interface{}) *XPath
return an XPath to the level of the element passed, which can be populated with fields.
func NewDataviewPath ¶
return an xpath populated to the dataview, with name dv if no name is passed, create a wildcard dataview path
func NewHeadlinePath ¶
return an xpath populated to the headline cell, identified by headline
func NewTableCellPath ¶
return 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 ¶
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 ¶
do we need setters? validation?
func (*XPath) UnmarshalJSON ¶
return an xpath parsed from a string