Documentation
¶
Index ¶
- Variables
- type ColumnSpec
- func (c ColumnSpec) HasWidth() bool
- func (c ColumnSpec) MarshalJSON() ([]byte, error)
- func (c ColumnSpec) MarshalYAML() (any, error)
- func (c ColumnSpec) Matches(column string) bool
- func (c ColumnSpec) Selector() string
- func (c ColumnSpec) String() string
- func (c *ColumnSpec) UnmarshalJSON(data []byte) error
- func (c *ColumnSpec) UnmarshalYAML(node *yaml.Node) error
- func (c ColumnSpec) Validate() error
- type Columns
- type DataView
- func (v *DataView) ClearActiveView()
- func (v *DataView) GetActiveView() *Definition
- func (v *DataView) GetDefinitionByName(pattern string) (*Definition, error)
- func (v *DataView) GetDefinitions() []Definition
- func (v *DataView) GetView(r *ViewData) ([]string, error)
- func (v *DataView) GetViewByName(pattern string) ([]string, error)
- func (v *DataView) GetViews(pattern string) ([]Definition, error)
- func (v *DataView) LoadDefinitions() error
- func (v *DataView) SetActiveView(definition *Definition)
- type Definition
- type DefinitionCollection
- type ViewData
Constants ¶
This section is empty.
Variables ¶
var NamespaceSeparator = "::"
Functions ¶
This section is empty.
Types ¶
type ColumnSpec ¶ added in v2.57.0
type ColumnSpec struct {
// Name is an optional column alias
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Path is the selector of the property (or properties) to display
Path string `json:"path" yaml:"path"`
// Width is a fixed column width in characters
Width int `json:"width,omitempty" yaml:"width,omitempty"`
// MinWidth is the minimum column width in characters
MinWidth int `json:"minWidth,omitempty" yaml:"minWidth,omitempty"`
// MaxWidth is the maximum column width in characters
MaxWidth int `json:"maxWidth,omitempty" yaml:"maxWidth,omitempty"`
}
ColumnSpec is a single entry of a view's columns. It is either a selector string (the same syntax as the --select flag, e.g. "id", "tags.**" or the alias form "model:c8y_Hardware.model"), or an object which can also constrain the column width in table output:
{"name": "model", "path": "c8y_Hardware.model", "width": 20}
func NewColumnSpecs ¶ added in v2.57.0
func NewColumnSpecs(selectors ...string) []ColumnSpec
NewColumnSpecs creates column specs from selector strings
func (ColumnSpec) HasWidth ¶ added in v2.57.0
func (c ColumnSpec) HasWidth() bool
HasWidth checks if the column constrains the column width
func (ColumnSpec) MarshalJSON ¶ added in v2.57.0
func (c ColumnSpec) MarshalJSON() ([]byte, error)
MarshalJSON writes the column as a string if it does not use any object properties
func (ColumnSpec) MarshalYAML ¶ added in v2.57.0
func (c ColumnSpec) MarshalYAML() (any, error)
MarshalYAML writes the column as a string if it does not use any object properties
func (ColumnSpec) Matches ¶ added in v2.57.0
func (c ColumnSpec) Matches(column string) bool
Matches checks if a rendered table column was produced by the column spec. The column name is either the alias, the property path, or (for wildcard paths) any property path matching the wildcard, including the root of a wildcard, e.g. "tags" for "tags.**" (scalar arrays are displayed under the root)
func (ColumnSpec) Selector ¶ added in v2.57.0
func (c ColumnSpec) Selector() string
Selector returns the selector string used to select the column's properties
func (ColumnSpec) String ¶ added in v2.57.0
func (c ColumnSpec) String() string
String returns the selector string
func (*ColumnSpec) UnmarshalJSON ¶ added in v2.57.0
func (c *ColumnSpec) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts either a selector string or a column object
func (*ColumnSpec) UnmarshalYAML ¶ added in v2.57.0
func (c *ColumnSpec) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML accepts either a selector string or a column object
func (ColumnSpec) Validate ¶ added in v2.57.0
func (c ColumnSpec) Validate() error
Validate checks the column for invalid values
type Columns ¶ added in v2.57.0
type Columns []ColumnSpec
Columns is a list of view columns
func (Columns) HasWidthRules ¶ added in v2.57.0
HasWidthRules checks if any column constrains its width
type DataView ¶
type DataView struct {
Paths []string
Extension string
Pattern string
Definitions []Definition
Logger *logger.Logger
ActiveView *Definition
// contains filtered or unexported fields
}
DataView data view containing predefined views
func NewDataView ¶
func NewDataView(pattern string, extension string, log *logger.Logger, paths ...string) (*DataView, error)
NewDataView creates a new data view which selected a view based in json data
func (*DataView) ClearActiveView ¶
func (v *DataView) ClearActiveView()
ClearActiveView clear the active view
func (*DataView) GetActiveView ¶
func (v *DataView) GetActiveView() *Definition
GetActiveView get the active view
func (*DataView) GetDefinitionByName ¶ added in v2.57.0
func (v *DataView) GetDefinitionByName(pattern string) (*Definition, error)
GetDefinitionByName get the first view definition which matches the name. Accepts wildcard name
func (*DataView) GetDefinitions ¶
func (v *DataView) GetDefinitions() []Definition
func (*DataView) GetViewByName ¶
GetViewByName get view by name. Accepts wildcard name
func (*DataView) GetViews ¶
func (v *DataView) GetViews(pattern string) ([]Definition, error)
GetViews get a list of view names
func (*DataView) LoadDefinitions ¶
LoadDefinitions load the view definitions
func (*DataView) SetActiveView ¶ added in v2.57.0
func (v *DataView) SetActiveView(definition *Definition)
SetActiveView sets the active view, so it is used regardless of the response contents
type Definition ¶
type Definition struct {
FileName string `json:"-"`
Path string `json:"-"`
Extension string `json:"-"`
Name string `json:"name,omitempty"`
Priority int `json:"priority,omitempty"`
Fragments []string `json:"fragments,omitempty"`
Type string `json:"type,omitempty"`
RequestPath string `json:"requestPath,omitempty"`
RequestMethod string `json:"requestMethod,omitempty"`
ContentType string `json:"contentType,omitempty"`
Self string `json:"self,omitempty"`
Columns Columns `json:"columns,omitempty"`
// AutoMatch controls if the view is considered when automatically detecting a view.
// Set it to false for views which should only be used by name, e.g. via --view <name>,
// or from the view of an extension API command. Defaults to true
AutoMatch *bool `json:"autoMatch,omitempty"`
}
Definition contains the view definition of when to use a specific view
func (*Definition) FQDN ¶ added in v2.30.0
func (d *Definition) FQDN() string
func (*Definition) IsAutoMatch ¶ added in v2.57.0
func (d *Definition) IsAutoMatch() bool
IsAutoMatch checks if the view is considered when automatically detecting a view
type DefinitionCollection ¶
type DefinitionCollection struct {
Definitions []Definition `json:"definitions,omitempty"`
}
DefinitionCollection collection of view definitions