Documentation ¶
Overview ¶
Kapacitor HTTP API client written in Go
Index ¶
- Constants
- type AuthenticationMethod
- type Client
- func (c *Client) BaseURL() url.URL
- func (c *Client) CreateReplay(opt CreateReplayOptions) (Replay, error)
- func (c *Client) CreateTask(opt CreateTaskOptions) (Task, error)
- func (c *Client) CreateTemplate(opt CreateTemplateOptions) (Template, error)
- func (c *Client) DebugVars() (DebugVars, error)
- func (c *Client) DeleteRecording(link Link) error
- func (c *Client) DeleteReplay(link Link) error
- func (c *Client) DeleteTask(link Link) error
- func (c *Client) DeleteTemplate(link Link) error
- func (c *Client) Do(req *http.Request, result interface{}, codes ...int) (*http.Response, error)
- func (c *Client) ListRecordings(opt *ListRecordingsOptions) ([]Recording, error)
- func (c *Client) ListReplays(opt *ListReplaysOptions) ([]Replay, error)
- func (c *Client) ListTasks(opt *ListTasksOptions) ([]Task, error)
- func (c *Client) ListTemplates(opt *ListTemplatesOptions) ([]Template, error)
- func (c *Client) LogLevel(level string) error
- func (c *Client) Ping() (time.Duration, string, error)
- func (c *Client) RecordBatch(opt RecordBatchOptions) (Recording, error)
- func (c *Client) RecordQuery(opt RecordQueryOptions) (Recording, error)
- func (c *Client) RecordStream(opt RecordStreamOptions) (Recording, error)
- func (c *Client) Recording(link Link) (Recording, error)
- func (c *Client) RecordingLink(id string) Link
- func (c *Client) Replay(link Link) (Replay, error)
- func (c *Client) ReplayBatch(opt ReplayBatchOptions) (Replay, error)
- func (c *Client) ReplayLink(id string) Link
- func (c *Client) ReplayQuery(opt ReplayQueryOptions) (Replay, error)
- func (c *Client) Task(link Link, opt *TaskOptions) (Task, error)
- func (c *Client) TaskLink(id string) Link
- func (c *Client) TaskOutput(link Link, name string) (*influxql.Result, error)
- func (c *Client) Template(link Link, opt *TemplateOptions) (Template, error)
- func (c *Client) TemplateLink(id string) Link
- func (c *Client) URL() string
- func (c *Client) UpdateTask(link Link, opt UpdateTaskOptions) (Task, error)
- func (c *Client) UpdateTemplate(link Link, opt UpdateTemplateOptions) (Template, error)
- type Clock
- type Config
- type CreateReplayOptions
- type CreateTaskOptions
- type CreateTemplateOptions
- type Credentials
- type DBRP
- type DebugVars
- type ExecutionStats
- type Link
- type ListRecordingsOptions
- type ListReplaysOptions
- type ListTasksOptions
- type ListTemplatesOptions
- type LogLevelOptions
- type RecordBatchOptions
- type RecordQueryOptions
- type RecordStreamOptions
- type Recording
- type Relation
- type Replay
- type ReplayBatchOptions
- type ReplayQueryOptions
- type Stat
- type Status
- type Task
- type TaskOptions
- type TaskStatus
- type TaskType
- type Template
- type TemplateOptions
- type UpdateTaskOptions
- type UpdateTemplateOptions
- type Var
- type VarType
- type Vars
Constants ¶
const DefaultUserAgent = "KapacitorClient"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationMethod ¶ added in v1.0.0
type AuthenticationMethod int
AuthenticationMethod defines the type of authentication used.
const ( UserAuthentication AuthenticationMethod BearerAuthentication )
Supported authentication methods.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Basic HTTP client
func (*Client) CreateReplay ¶
func (c *Client) CreateReplay(opt CreateReplayOptions) (Replay, error)
Replay a recording for a task.
func (*Client) CreateTask ¶
func (c *Client) CreateTask(opt CreateTaskOptions) (Task, error)
Create a new task. Errors if the task already exists.
func (*Client) CreateTemplate ¶ added in v1.0.0
func (c *Client) CreateTemplate(opt CreateTemplateOptions) (Template, error)
Create a new template. Errors if the template already exists.
func (*Client) DeleteRecording ¶
Delete a recording.
func (*Client) DeleteReplay ¶
Delete a replay. This will cancel a running replay.
func (*Client) DeleteTemplate ¶ added in v1.0.0
Delete a template.
func (*Client) Do ¶ added in v1.0.0
Perform the request. If result is not nil the response body is JSON decoded into result. Codes is a list of valid response codes.
func (*Client) ListRecordings ¶
func (c *Client) ListRecordings(opt *ListRecordingsOptions) ([]Recording, error)
Get information about recordings. If rids is empty than all recordings are returned.
func (*Client) ListReplays ¶
func (c *Client) ListReplays(opt *ListReplaysOptions) ([]Replay, error)
Get information about replays. If rids is empty than all replays are returned.
func (*Client) ListTasks ¶
func (c *Client) ListTasks(opt *ListTasksOptions) ([]Task, error)
Get tasks.
func (*Client) ListTemplates ¶ added in v1.0.0
func (c *Client) ListTemplates(opt *ListTemplatesOptions) ([]Template, error)
Get templates.
func (*Client) LogLevel ¶
Set the logging level. Level must be one of DEBUG, INFO, WARN, ERROR, or OFF
func (*Client) Ping ¶
Ping the server for a response. Ping returns how long the request took, the version of the server it connected to, and an error if one occurred.
func (*Client) RecordBatch ¶
func (c *Client) RecordBatch(opt RecordBatchOptions) (Recording, error)
Record the batch queries for a task. Returns once the recording is started.
func (*Client) RecordQuery ¶
func (c *Client) RecordQuery(opt RecordQueryOptions) (Recording, error)
Record the results of a query. The recordingType must be one of "stream", or "batch". Returns once the recording is started.
func (*Client) RecordStream ¶
func (c *Client) RecordStream(opt RecordStreamOptions) (Recording, error)
Record the stream for a task. Returns once the recording is started.
func (*Client) RecordingLink ¶
func (*Client) ReplayBatch ¶ added in v1.0.0
func (c *Client) ReplayBatch(opt ReplayBatchOptions) (Replay, error)
Replay a query against a task.
func (*Client) ReplayLink ¶
func (*Client) ReplayQuery ¶ added in v1.0.0
func (c *Client) ReplayQuery(opt ReplayQueryOptions) (Replay, error)
Replay a query against a task.
func (*Client) Task ¶
func (c *Client) Task(link Link, opt *TaskOptions) (Task, error)
Get information about a task. Options can be nil and the default options will be used. By default the DOT content will use attributes for stats. Use DotView="labels" to generate a purley labels based DOT content, which can accurately be rendered but is less readable. By default the TICKscript contents are formatted, use ScriptFormat="raw" to return the TICKscript unmodified.
func (*Client) TaskOutput ¶
func (*Client) Template ¶ added in v1.0.0
func (c *Client) Template(link Link, opt *TemplateOptions) (Template, error)
Get information about a template. Options can be nil and the default options will be used. By default the TICKscript contents are formatted, use ScriptFormat="raw" to return the TICKscript unmodified.
func (*Client) TemplateLink ¶ added in v1.0.0
func (*Client) UpdateTask ¶
func (c *Client) UpdateTask(link Link, opt UpdateTaskOptions) (Task, error)
Update an existing task. Only fields that are not their default value will be updated.
func (*Client) UpdateTemplate ¶ added in v1.0.0
func (c *Client) UpdateTemplate(link Link, opt UpdateTemplateOptions) (Template, error)
Update an existing template. Only fields that are not their default value will be updated.
type Config ¶
type Config struct { // The URL of the Kapacitor server. URL string // Timeout for API requests, defaults to no timeout. Timeout time.Duration // UserAgent is the http User Agent, defaults to "KapacitorClient". UserAgent string // InsecureSkipVerify gets passed to the http client, if true, it will // skip https certificate verification. Defaults to false. InsecureSkipVerify bool // TLSConfig allows the user to set their own TLS config for the HTTP // Client. If set, this option overrides InsecureSkipVerify. TLSConfig *tls.Config // Optional credentials for authenticating with the server. Credentials *Credentials }
HTTP configuration for connecting to Kapacitor
type CreateReplayOptions ¶
type CreateReplayOptions struct { ID string `json:"id"` Recording string `json:"recording"` Task string `json:"task"` RecordingTime bool `json:"recording-time"` Clock Clock `json:"clock"` }
func (*CreateReplayOptions) Default ¶
func (o *CreateReplayOptions) Default()
type CreateTaskOptions ¶
type CreateTaskOptions struct { ID string `json:"id,omitempty"` TemplateID string `json:"template-id,omitempty"` Type TaskType `json:"type,omitempty"` DBRPs []DBRP `json:"dbrps,omitempty"` TICKscript string `json:"script,omitempty"` Status TaskStatus `json:"status,omitempty"` Vars Vars `json:"vars,omitempty"` }
type CreateTemplateOptions ¶ added in v1.0.0
type Credentials ¶ added in v1.0.0
type Credentials struct { Method AuthenticationMethod Username string Password string Token string }
Set of credentials depending on the authentication method
func (Credentials) Validate ¶ added in v1.0.0
func (c Credentials) Validate() error
type DebugVars ¶ added in v1.0.0
type DebugVars struct { ClusterID string `json:"cluster_id"` ServerID string `json:"server_id"` Host string `json:"host"` Stats map[string]Stat `json:"kapacitor"` Cmdline []string `json:"cmdline"` NumEnabledTasks int `json:"num_enabled_tasks"` NumSubscriptions int `json:"num_subscriptions"` NumTasks int `json:"num_tasks"` Memstats map[string]interface{} `json:"memstats"` Version string `json:"version"` }
type ExecutionStats ¶
type ExecutionStats struct { // Summary stats about the entire task TaskStats map[string]interface{} `json:"task-stats"` // Stats for each node in the task NodeStats map[string]map[string]interface{} `json:"node-stats"` }
Statistics about the execution of a task.
type ListRecordingsOptions ¶
func (*ListRecordingsOptions) Default ¶
func (o *ListRecordingsOptions) Default()
func (*ListRecordingsOptions) Values ¶
func (o *ListRecordingsOptions) Values() *url.Values
type ListReplaysOptions ¶
func (*ListReplaysOptions) Default ¶
func (o *ListReplaysOptions) Default()
func (*ListReplaysOptions) Values ¶
func (o *ListReplaysOptions) Values() *url.Values
type ListTasksOptions ¶
type ListTasksOptions struct { TaskOptions Pattern string Fields []string Offset int Limit int }
func (*ListTasksOptions) Default ¶
func (o *ListTasksOptions) Default()
func (*ListTasksOptions) Values ¶
func (o *ListTasksOptions) Values() *url.Values
type ListTemplatesOptions ¶ added in v1.0.0
type ListTemplatesOptions struct { TemplateOptions Pattern string Fields []string Offset int Limit int }
func (*ListTemplatesOptions) Default ¶ added in v1.0.0
func (o *ListTemplatesOptions) Default()
func (*ListTemplatesOptions) Values ¶ added in v1.0.0
func (o *ListTemplatesOptions) Values() *url.Values
type LogLevelOptions ¶
type LogLevelOptions struct {
Level string `json:"level"`
}
type RecordBatchOptions ¶
type RecordQueryOptions ¶
type RecordStreamOptions ¶
type Recording ¶
type Recording struct { Link Link `json:"link"` ID string `json:"id"` Type TaskType `json:"type"` Size int64 `json:"size"` Date time.Time `json:"date"` Error string `json:"error"` Status Status `json:"status"` Progress float64 `json:"progress"` }
Information about a recording.
type Replay ¶
type Replay struct { Link Link `json:"link"` ID string `json:"id"` Task string `json:"task"` Recording string `json:"recording"` RecordingTime bool `json:"recording-time"` Clock Clock `json:"clock"` Date time.Time `json:"date"` Error string `json:"error"` Status Status `json:"status"` Progress float64 `json:"progress"` }
Information about a replay.
type ReplayBatchOptions ¶ added in v1.0.0
type ReplayQueryOptions ¶ added in v1.0.0
type Task ¶
type Task struct { Link Link `json:"link"` ID string `json:"id"` TemplateID string `json:"template-id"` Type TaskType `json:"type"` DBRPs []DBRP `json:"dbrps"` TICKscript string `json:"script"` Vars Vars `json:"vars"` Dot string `json:"dot"` Status TaskStatus `json:"status"` Executing bool `json:"executing"` Error string `json:"error"` ExecutionStats ExecutionStats `json:"stats"` Created time.Time `json:"created"` Modified time.Time `json:"modified"` LastEnabled time.Time `json:"last-enabled,omitempty"` }
A Task plus its read-only attributes.
type TaskOptions ¶
func (*TaskOptions) Default ¶
func (o *TaskOptions) Default()
func (*TaskOptions) Values ¶
func (o *TaskOptions) Values() *url.Values
type TaskStatus ¶
type TaskStatus int
const ( Disabled TaskStatus = 1 Enabled TaskStatus = 2 )
func (TaskStatus) MarshalText ¶
func (ts TaskStatus) MarshalText() ([]byte, error)
func (TaskStatus) String ¶
func (ts TaskStatus) String() string
func (*TaskStatus) UnmarshalText ¶
func (ts *TaskStatus) UnmarshalText(text []byte) error
type Template ¶ added in v1.0.0
type Template struct { Link Link `json:"link"` ID string `json:"id"` Type TaskType `json:"type"` TICKscript string `json:"script"` Vars Vars `json:"vars"` Dot string `json:"dot"` Error string `json:"error"` Created time.Time `json:"created"` Modified time.Time `json:"modified"` }
A Template plus its read-only attributes.
type TemplateOptions ¶ added in v1.0.0
type TemplateOptions struct {
ScriptFormat string
}
func (*TemplateOptions) Default ¶ added in v1.0.0
func (o *TemplateOptions) Default()
func (*TemplateOptions) Values ¶ added in v1.0.0
func (o *TemplateOptions) Values() *url.Values
type UpdateTaskOptions ¶
type UpdateTaskOptions struct { ID string `json:"id,omitempty"` TemplateID string `json:"template-id,omitempty"` Type TaskType `json:"type,omitempty"` DBRPs []DBRP `json:"dbrps,omitempty"` TICKscript string `json:"script,omitempty"` Status TaskStatus `json:"status,omitempty"` Vars Vars `json:"vars,omitempty"` }
type UpdateTemplateOptions ¶ added in v1.0.0
type VarType ¶ added in v1.0.0
type VarType int