Documentation ¶
Index ¶
- Constants
- Variables
- func Password(p string) metaOp
- func Username(u string) metaOp
- type AddAgreementResult
- type AvailablePlugin
- type Client
- func (c *Client) AddAgreement(name string) *AddAgreementResult
- func (c *Client) CreateTask(s *Schedule, wf *wmap.WorkflowMap, name string, deadline string, ...) *CreateTaskResult
- func (c *Client) DeleteAgreement(name string) *DeleteAgreementResult
- func (c *Client) DeletePluginConfig(pluginType, name, version string, key string) *DeletePluginConfigResult
- func (c *Client) EnableTask(id string) *EnableTaskResult
- func (c *Client) FetchMetrics(ns string, ver int) *GetMetricsResult
- func (c *Client) GetAgreement(name string) *GetAgreementResult
- func (c *Client) GetMember(name string) *GetMemberResult
- func (c *Client) GetMetric(ns string, ver int) interface{}
- func (c *Client) GetMetricCatalog() *GetMetricsResult
- func (c *Client) GetMetricVersions(ns string) *GetMetricsResult
- func (c *Client) GetPlugin(typ, name string, ver int) *GetPluginResult
- func (c *Client) GetPluginConfig(pluginType, name, version string) *GetPluginConfigResult
- func (c *Client) GetPlugins(details bool) *GetPluginsResult
- func (c *Client) GetTask(id string) *GetTaskResult
- func (c *Client) GetTasks() *GetTasksResult
- func (c *Client) JoinAgreement(agreementName, memberName string) *JoinAgreementResult
- func (c *Client) LeaveAgreement(agreementName, memberName string) *LeaveAgreementResult
- func (c *Client) ListAgreements() *ListAgreementResult
- func (c *Client) ListMembers() *ListMembersResult
- func (c *Client) LoadPlugin(p []string) *LoadPluginResult
- func (c *Client) RemoveTask(id string) *RemoveTasksResult
- func (c *Client) SetPluginConfig(pluginType, name, version string, key string, value ctypes.ConfigValue) *SetPluginConfigResult
- func (c *Client) StartTask(id string) *StartTasksResult
- func (c *Client) StopTask(id string) *StopTasksResult
- func (c *Client) SwapPlugin(loadPath []string, unloadType, unloadName string, unloadVersion int) *SwapPluginsResult
- func (c *Client) TribeRequest() (*http.Response, error)
- func (c *Client) UnloadPlugin(pluginType, name string, version int) *UnloadPluginResult
- func (c *Client) WatchTask(id string) *WatchTasksResult
- type CreateTaskResult
- type DeleteAgreementResult
- type DeletePluginConfigResult
- type EnableTaskResult
- type GetAgreementResult
- type GetMemberResult
- type GetMetricResult
- type GetMetricsResult
- type GetPluginConfigResult
- type GetPluginResult
- type GetPluginsResult
- type GetTaskResult
- type GetTasksResult
- type JoinAgreementResult
- type LeaveAgreementResult
- type ListAgreementResult
- type ListMembersResult
- type LoadPluginResult
- type LoadedPlugin
- type RemoveTasksResult
- type ReturnedPlugin
- type Schedule
- type SetPluginConfigResult
- type StartTasksResult
- type StopTasksResult
- type SwapPluginsResult
- type UnloadPluginResult
- type WatchTasksResult
Constants ¶
const ( ContentTypeJSON contentType = iota ContentTypeBinary )
Variables ¶
var ( CompressUpload = true ErrUnknown = errors.New("Unknown error calling API") ErrNilResponse = errors.New("Nil response from JSON unmarshalling") ErrDirNotFile = errors.New("Provided plugin path is a directory not file") )
var ( // The default response error. ErrAPIResponseMetaType = errors.New("Received an invalid API response (META/TYPE)") )
Functions ¶
Types ¶
type AddAgreementResult ¶
type AddAgreementResult struct { *rbody.TribeAddAgreement Err error }
AddAgreementResult is the response from snap/client on a AddAgreement call.
type AvailablePlugin ¶
type AvailablePlugin struct {
*rbody.AvailablePlugin
}
The wrapper for AvailablePlugin struct defined inside rbody package.
type Client ¶
type Client struct { // URL specifies HTTP API request uniform resource locator. URL string // Version specifies the version of a HTTP client. Version string // Basic http auth username/password Username string Password string // contains filtered or unexported fields }
func New ¶
New returns a pointer to a snap api client if ver is an empty string, v1 is used by default
func (*Client) AddAgreement ¶
func (c *Client) AddAgreement(name string) *AddAgreementResult
AddAgreement adds a tribe agreement giving an agreement name into tribe agreement list through an HTTP POST call. A map of tribe agreements with the newly added named agreement returns if it succeeds. Otherwise, an error is returned. Note that the newly added agreement has no effect unless members join the agreement.
func (*Client) CreateTask ¶
func (c *Client) CreateTask(s *Schedule, wf *wmap.WorkflowMap, name string, deadline string, startTask bool, maxFailures int) *CreateTaskResult
CreateTask creates a task given the schedule, workflow, task name, and task state. If the startTask flag is true, the newly created task is started after the creation. Otherwise, it's in the Stopped state. CreateTask is accomplished through a POST HTTP JSON request. A ScheduledTask is returned if it succeeds, otherwise an error is returned.
func (*Client) DeleteAgreement ¶
func (c *Client) DeleteAgreement(name string) *DeleteAgreementResult
DeleteAgreement removes a tribe agreement giving an agreement name from the tribe agreement list through an HTTP DELETE call. A map of tribe agreements with the specified agreement removed returns if it succeeds. Otherwise, an error is returned. Note deleting an agreement removes the agreement from the tribe entirely for all the members of the agreement.
func (*Client) DeletePluginConfig ¶
func (c *Client) DeletePluginConfig(pluginType, name, version string, key string) *DeletePluginConfigResult
DeletePluginConfig removes the plugin config item given the plugin type, name and version.
func (*Client) EnableTask ¶
func (c *Client) EnableTask(id string) *EnableTaskResult
EnableTask enables a disabled task given a task id. The request is an HTTP PUT call. The enabled task id returns if it succeeds. Otherwise, an error is returned.
func (*Client) FetchMetrics ¶
func (c *Client) FetchMetrics(ns string, ver int) *GetMetricsResult
FetchMetrics retrieves the metric catalog given metric namespace and version through an HTTP GET request. It returns the corresponding metric catalog if succeeded. Otherwise, an error is returned.
func (*Client) GetAgreement ¶
func (c *Client) GetAgreement(name string) *GetAgreementResult
GetAgreement retrieves a tribe agreement given an agreement name through an HTTP GET call. A tribe agreement returns if it succeeded. Otherwise, an error is returned.
func (*Client) GetMember ¶
func (c *Client) GetMember(name string) *GetMemberResult
GetMember retrieves the tribe member given a member name. The request is an HTTP GET call. The corresponding tribe member object returns if it succeeds. Otherwise, an error is returned.
func (*Client) GetMetric ¶
GetMetric retrieves a metric at a given namespace and version. If the version is < 1, the latest version is returned. Returns an interface as several return types are possible (array of metrics).
func (*Client) GetMetricCatalog ¶
func (c *Client) GetMetricCatalog() *GetMetricsResult
GetMetricCatalog retrieves the metric catalog from a snap/client by issuing an HTTP GET request. A slice of metric catalogs returns if succeeded. Otherwise an error is returned.
func (*Client) GetMetricVersions ¶
func (c *Client) GetMetricVersions(ns string) *GetMetricsResult
GetMetricVersions retrieves all versions of a metric at a given namespace.
func (*Client) GetPlugin ¶
func (c *Client) GetPlugin(typ, name string, ver int) *GetPluginResult
GetPlugin returns the requested plugin through an HTTP GET request. An error returns if it failed.
func (*Client) GetPluginConfig ¶
func (c *Client) GetPluginConfig(pluginType, name, version string) *GetPluginConfigResult
GetPluginConfig retrieves the merged plugin config given the type of plugin, name and version. If plugin type, name and version are all empty strings the plugin config for "all" plugins will be returned. If the plugin type is provided and the name and version are empy strings the config for that plugin type will be returned. So on and so forth for the rest of the arguments.
func (*Client) GetPlugins ¶
func (c *Client) GetPlugins(details bool) *GetPluginsResult
GetPlugins returns the loaded and available plugins through an HTTP GET request. By specifying the details flag to tweak output info. An error returns if it failed.
func (*Client) GetTask ¶
func (c *Client) GetTask(id string) *GetTaskResult
GetTask retrieves the task given a task id through an HTTP GET call. A scheduled task returns if it succeeds. Otherwise, an error is returned.
func (*Client) GetTasks ¶
func (c *Client) GetTasks() *GetTasksResult
GetTasks retrieves a slice of tasks through an HTTP GET call. A list of scheduled tasks returns if it succeeds. Otherwise. an error is returned.
func (*Client) JoinAgreement ¶
func (c *Client) JoinAgreement(agreementName, memberName string) *JoinAgreementResult
JoinAgreement adds a tribe member into the agreement given the agreement name and the member name. It is an HTTP PUT request. The agreement with the newly added member returns if it succeeds. Otherwise, an error is returned. Note that dual directional agreement replication happens automatically through the gossip protocol between a newly joined member and existing members within the same agreement.
func (*Client) LeaveAgreement ¶
func (c *Client) LeaveAgreement(agreementName, memberName string) *LeaveAgreementResult
LeaveAgreement removes a member from the agreement given the agreement and member names through an HTTP DELETE call. The agreement with the removed member returns if it succeeds. Otherwise, an error is returned. For example, it is useful to leave an agreement for a member node repair.
func (*Client) ListAgreements ¶
func (c *Client) ListAgreements() *ListAgreementResult
ListAgreements retrieves a list of a tribe agreements through an HTTP GET call. A list of tribe agreement map returns if it succeeds. Otherwise, an error is returned.
func (*Client) ListMembers ¶
func (c *Client) ListMembers() *ListMembersResult
ListMembers retrieves a list of tribe members through an HTTP GET call. A list of tribe member returns if it succeeds. Otherwise, an error is returned.
func (*Client) LoadPlugin ¶
func (c *Client) LoadPlugin(p []string) *LoadPluginResult
LoadPlugin loads plugins for the given plugin names. A slide of loaded plugins returns if succeeded. Otherwise, an error is returned.
func (*Client) RemoveTask ¶
func (c *Client) RemoveTask(id string) *RemoveTasksResult
RemoveTask removes a task from the schedule tasks given a task id. It's through an HTTP DELETE call. The removed task id returns if it succeeds. Otherwise, an error is returned.
func (*Client) SetPluginConfig ¶
func (c *Client) SetPluginConfig(pluginType, name, version string, key string, value ctypes.ConfigValue) *SetPluginConfigResult
SetPluginConfig sets the plugin config given the type, name and version of a plugin. Like GetPluginConfig if the type, name and version are all empty strings the plugin config is set for all plugins. When config data is set it is merged with the existing data if present.
func (*Client) StartTask ¶
func (c *Client) StartTask(id string) *StartTasksResult
StartTask starts a task given a task id. The scheduled task will be in the started state if it succeeds. Otherwise, an error is returned.
func (*Client) StopTask ¶
func (c *Client) StopTask(id string) *StopTasksResult
StopTask stops a running task given a task id. It uses an HTTP PUT call. The stopped task id returns if it succeeds. Otherwise, an error is returned.
func (*Client) SwapPlugin ¶
func (c *Client) SwapPlugin(loadPath []string, unloadType, unloadName string, unloadVersion int) *SwapPluginsResult
SwapPlugin swaps two plugins with the same type and name e.g. collector:mock:1 with collector:mock:2
func (*Client) TribeRequest ¶
Passthrough for tribe request to allow use of client auth.
func (*Client) UnloadPlugin ¶
func (c *Client) UnloadPlugin(pluginType, name string, version int) *UnloadPluginResult
UnloadPlugin unloads a plugin given plugin type, name, and version through an HTTP DELETE request. The unloaded plugin returns if succeeded. Otherwise, an error is returned.
func (*Client) WatchTask ¶
func (c *Client) WatchTask(id string) *WatchTasksResult
WatchTask retrieves running tasks by running a goroutine to interactive with Event and Done channels. An HTTP GET request retrieves tasks. StreamedTaskEvent returns if it succeeds. Otherwise, an error is returned.
type CreateTaskResult ¶
type CreateTaskResult struct { *rbody.AddScheduledTask Err error }
CreateTaskResult is the response from snap/client on a CreateTask call.
type DeleteAgreementResult ¶
type DeleteAgreementResult struct { *rbody.TribeDeleteAgreement Err error }
DeleteAgreementResult is the response from snap/client on a DeleteAgreement call.
type DeletePluginConfigResult ¶
type DeletePluginConfigResult struct { *rbody.DeletePluginConfigItem Err error }
DeletePluginConfigResult is the response from snap/client on a DeletePluginConfig call.
type EnableTaskResult ¶
type EnableTaskResult struct { *rbody.ScheduledTaskEnabled Err error }
EnableTasksResult is the response from snap/client on a EnableTask call.
type GetAgreementResult ¶
type GetAgreementResult struct { *rbody.TribeGetAgreement Err error }
GetAgreementResult is the response from snap/client on a GetAgreement call.
type GetMemberResult ¶
type GetMemberResult struct { *rbody.TribeMemberShow Err error }
GetMemberResult is the response from snap/client on a GetMember call.
type GetMetricResult ¶
GetMetricResult is the response from snap/client on a GetMetricCatalog call.
type GetMetricsResult ¶
GetMetricsResult is the response from snap/client on a GetMetricCatalog call.
func (*GetMetricsResult) Len ¶
func (g *GetMetricsResult) Len() int
Len returns the slice's length of GetMetricsResult.Catalog.
type GetPluginConfigResult ¶
type GetPluginConfigResult struct { *rbody.PluginConfigItem Err error }
GetPluginConfigResult is the response from snap/client on a GetPluginConfig call.
type GetPluginResult ¶
type GetPluginResult struct { ReturnedPlugin ReturnedPlugin Err error }
GetPluginResult
type GetPluginsResult ¶
type GetPluginsResult struct { LoadedPlugins []LoadedPlugin AvailablePlugins []AvailablePlugin Err error }
GetPluginsResult is the response from snap/client on a GetPlugins call.
type GetTaskResult ¶
type GetTaskResult struct { *rbody.ScheduledTaskReturned Err error }
GetTaskResult is the response from snap/client on a GetTask call.
type GetTasksResult ¶
type GetTasksResult struct { *rbody.ScheduledTaskListReturned Err error }
GetTasksResult is the response from snap/client on a GetTasks call.
type JoinAgreementResult ¶
type JoinAgreementResult struct { *rbody.TribeJoinAgreement Err error }
JoinAgreementResult is the response from snap/client on a JoinAgreement call.
type LeaveAgreementResult ¶
type LeaveAgreementResult struct { *rbody.TribeLeaveAgreement Err error }
LeaveAgreementResult is the response from snap/client on a LeaveAgreement call.
type ListAgreementResult ¶
type ListAgreementResult struct { *rbody.TribeListAgreement Err error }
ListAgreementResult is the response from snap/client on a ListAgreements call.
type ListMembersResult ¶
type ListMembersResult struct { *rbody.TribeMemberList Err error }
ListMembersResult is the response from snap/client on a ListMembers call.
type LoadPluginResult ¶
type LoadPluginResult struct { LoadedPlugins []LoadedPlugin Err serror.SnapError }
LoadPluginResult is the response from snap/client on a LoadPlugin call.
type LoadedPlugin ¶
type LoadedPlugin struct {
*rbody.LoadedPlugin
}
We wrap this so we can provide some functionality (like LoadedTime)
func (*LoadedPlugin) LoadedTime ¶
func (l *LoadedPlugin) LoadedTime() time.Time
LoadedTime returns a unix time.
type RemoveTasksResult ¶
type RemoveTasksResult struct { *rbody.ScheduledTaskRemoved Err error }
RemoveTasksResult is the response from snap/client on a RemoveTask call.
type ReturnedPlugin ¶
type ReturnedPlugin struct {
*rbody.PluginReturned
}
The wrapper for ReturnedPlugin struct defined inside rbody package.
type Schedule ¶
type Schedule struct { // Type specifies the type of the schedule. Currently, the type of "simple", "windowed" and "cron" are supported. Type string // Interval specifies the time duration. Interval string // StartTime specifies the beginning time. StartTime *time.Time // StopTime specifies the end time. StopTime *time.Time }
type SetPluginConfigResult ¶
type SetPluginConfigResult struct { *rbody.SetPluginConfigItem Err error }
SetPluginConfigResult is the response from snap/client on a SetPluginConfig call.
type StartTasksResult ¶
type StartTasksResult struct { *rbody.ScheduledTaskStarted Err error }
StartTasksResult is the response from snap/client on a StartTask call.
type StopTasksResult ¶
type StopTasksResult struct { *rbody.ScheduledTaskStopped Err error }
StopTasksResult is the response from snap/client on a StopTask call.
type SwapPluginsResult ¶
type SwapPluginsResult struct { LoadedPlugin LoadedPlugin UnloadedPlugin *rbody.PluginUnloaded Err error }
type UnloadPluginResult ¶
type UnloadPluginResult struct { *rbody.PluginUnloaded Err error }
UnloadPluginResponse is the response from snap/client on an UnloadPlugin call.
type WatchTasksResult ¶
type WatchTasksResult struct { Err error EventChan chan *rbody.StreamedTaskEvent DoneChan chan struct{} // contains filtered or unexported fields }
WatchTaskResult is the response from snap/client on a WatchTask call.
func (*WatchTasksResult) Close ¶
func (w *WatchTasksResult) Close()