Documentation ¶
Index ¶
- func EachFile(libdirs []string, cb func(name string, path string) (br bool))
- func ValToDDLType(typedef string, val string) (res interface{}, err error)
- type Action
- func (a *Action) AggregateResult(result map[string]interface{}) error
- func (a *Action) AggregateResultJSON(jres []byte) error
- func (a *Action) AggregateSummaryFormattedStrings() (map[string][]string, error)
- func (a *Action) AggregateSummaryJSON() ([]byte, error)
- func (a *Action) AggregateSummaryStrings() (map[string]map[string]string, error)
- func (a *Action) InputNames() (names []string)
- func (a *Action) OutputNames() (names []string)
- func (a *Action) RequiresInput(input string) bool
- func (a *Action) SetOutputDefaults(results map[string]interface{})
- func (a *Action) ValidateAndConvertToDDLTypes(args map[string]string) (result map[string]interface{}, warnings []string, err error)
- func (a *Action) ValidateInputString(input string, val string) error
- func (a *Action) ValidateInputValue(input string, val interface{}) (warnings []string, err error)
- func (a *Action) ValidateRequestData(data map[string]interface{}) (warnings []string, err error)
- func (a *Action) ValidateRequestJSON(req json.RawMessage) (warnings []string, err error)
- type ActionAggregateItem
- type ActionInputItem
- type ActionOutputItem
- type DDL
- func (d *DDL) ActionInterface(action string) (*Action, error)
- func (d *DDL) ActionNames() []string
- func (d *DDL) HaveAction(action string) bool
- func (d *DDL) Timeout() time.Duration
- func (d *DDL) ToRuby() (string, error)
- func (d *DDL) ValidateAndConvertToDDLTypes(action string, args map[string]string) (result map[string]interface{}, warnings []string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EachFile ¶
EachFile calls cb with a path to every found agent DDL, stops looking when br is true
func ValToDDLType ¶ added in v0.8.0
ValToDDLType converts val into the type described in typedef where typedef is a typical choria DDL supported type
Types ¶
type Action ¶
type Action struct { Name string `json:"action"` Input map[string]*ActionInputItem `json:"input"` Output map[string]*ActionOutputItem `json:"output"` Display string `json:"display"` Description string `json:"description"` Aggregation []ActionAggregateItem `json:"aggregate,omitempty"` sync.Mutex // contains filtered or unexported fields }
Action describes an individual action in an agent
func (*Action) AggregateResult ¶ added in v0.6.0
AggregateResult receives a result and aggregate all the data found in it, most errors are squashed since aggregation are called during processing of replies and we do not want to fail a reply just because aggregation failed, thus this is basically a best efforts kind of thing on purpose
func (*Action) AggregateResultJSON ¶ added in v0.6.0
AggregateResultJSON receives a JSON reply and aggregate all the data found in it
func (*Action) AggregateSummaryFormattedStrings ¶ added in v0.6.0
AggregateSummaryFormattedStrings produce a formatted string for each output item that has a aggregate summary defined
func (*Action) AggregateSummaryJSON ¶ added in v0.6.0
AggregateSummaryJSON produce a JSON representation of aggregate results for every output item that has a aggregate summary defined
func (*Action) AggregateSummaryStrings ¶ added in v0.6.0
AggregateSummaryStrings produce a map of results for every output item that has a aggregate summary defined
func (*Action) InputNames ¶ added in v0.7.0
InputNames retrieves all valid input names
func (*Action) OutputNames ¶ added in v0.7.1
OutputNames retrieves all valid output names
func (*Action) RequiresInput ¶ added in v0.7.0
RequiresInput reports if an input is required
func (*Action) SetOutputDefaults ¶ added in v0.7.1
SetOutputDefaults adds items to results that have defaults declared in the DDL but not found in the result
func (*Action) ValidateAndConvertToDDLTypes ¶ added in v0.7.0
func (a *Action) ValidateAndConvertToDDLTypes(args map[string]string) (result map[string]interface{}, warnings []string, err error)
ValidateAndConvertToDDLTypes takes a map of strings like you might receive from the CLI, convert each item to the correct type according to the DDL type hints associated with inputs, validates its valid according to the DDL hints and returns a map of interface{} ready for conversion to JSON that would then have the correct types
func (*Action) ValidateInputString ¶ added in v0.7.0
ValidateInputString attempts to convert a string to the correct type and validate it based on the DDL spec
func (*Action) ValidateInputValue ¶ added in v0.7.0
ValidateInputValue validates the input matches requirements in the DDL
func (*Action) ValidateRequestData ¶ added in v0.8.0
ValidateRequestData validates request data against the DDL
func (*Action) ValidateRequestJSON ¶ added in v0.8.0
func (a *Action) ValidateRequestJSON(req json.RawMessage) (warnings []string, err error)
ValidateRequestJSON receives request data in JSON format and validates it against the DDL
type ActionAggregateItem ¶ added in v0.6.0
type ActionAggregateItem struct { Function string `json:"function"` Arguments json.RawMessage `json:"args"` }
ActionAggregateItem describes a aggregate function to summarize data
func (*ActionAggregateItem) OutputName ¶ added in v0.8.0
func (a *ActionAggregateItem) OutputName() string
OutputName is the name of the output being aggregated
type ActionInputItem ¶ added in v0.7.0
type ActionInputItem struct { Prompt string `json:"prompt"` Description string `json:"description"` Type string `json:"type"` Default interface{} `json:"default,omitempty"` Optional bool `json:"optional"` Validation string `json:"validation,omitempty"` MaxLength int `json:"maxlength,omitempty"` Enum []string `json:"list,omitempty"` }
ActionInputItem describes an individual input item
type ActionOutputItem ¶
type ActionOutputItem struct { Description string `json:"description"` DisplayAs string `json:"display_as"` Default interface{} `json:"default,omitempty"` Type string `json:"type,omitempty"` }
ActionOutputItem describes an individual output item
type DDL ¶
type DDL struct { Schema string `json:"$schema"` Metadata *agents.Metadata `json:"metadata"` Actions []*Action `json:"actions"` SourceLocation string `json:"-"` }
DDL represents the schema of a mcorpc agent and is at a basic level compatible with the mcollective agent ddl format
func (*DDL) ActionInterface ¶
ActionInterface looks up an Action by name
func (*DDL) ActionNames ¶
ActionNames is a list of known actions defined by a DDL
func (*DDL) HaveAction ¶
HaveAction determines if an action is known
func (*DDL) ValidateAndConvertToDDLTypes ¶ added in v0.7.0
func (d *DDL) ValidateAndConvertToDDLTypes(action string, args map[string]string) (result map[string]interface{}, warnings []string, err error)
ValidateAndConvertToDDLTypes converts args to the correct data types as declared in the DDL and validates everything