Documentation
¶
Overview ¶
Create or update a watch. When a watch is registered, a new document that represents the watch is added to the `.watches` index and its trigger is immediately registered with the relevant trigger engine. Typically for the `schedule` trigger, the scheduler is the trigger engine.
IMPORTANT: You must use Kibana or this API to create a watch. Do not add a watch directly to the `.watches` index by using the Elasticsearch index API. If Elasticsearch security features are enabled, do not give users write privileges on the `.watches` index.
When you add a watch you can also define its initial active state by setting the *active* parameter.
When Elasticsearch security features are enabled, your watch can index or search only on indices for which the user that stored the watch has privileges. If the user is able to read index `a`, but not index `b`, the same will apply when the watch runs.
Index ¶
- Variables
- type NewPutWatch
- type PutWatch
- func (r *PutWatch) Actions(actions map[string]types.WatcherAction) *PutWatch
- func (r *PutWatch) Active(active bool) *PutWatch
- func (r *PutWatch) Condition(condition *types.WatcherCondition) *PutWatch
- func (r PutWatch) Do(providedCtx context.Context) (*Response, error)
- func (r *PutWatch) ErrorTrace(errortrace bool) *PutWatch
- func (r *PutWatch) FilterPath(filterpaths ...string) *PutWatch
- func (r *PutWatch) Header(key, value string) *PutWatch
- func (r *PutWatch) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *PutWatch) Human(human bool) *PutWatch
- func (r *PutWatch) IfPrimaryTerm(ifprimaryterm string) *PutWatch
- func (r *PutWatch) IfSeqNo(sequencenumber string) *PutWatch
- func (r *PutWatch) Input(input *types.WatcherInput) *PutWatch
- func (r *PutWatch) Metadata(metadata types.Metadata) *PutWatch
- func (r PutWatch) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *PutWatch) Pretty(pretty bool) *PutWatch
- func (r *PutWatch) Raw(raw io.Reader) *PutWatch
- func (r *PutWatch) Request(req *Request) *PutWatch
- func (r *PutWatch) ThrottlePeriod(duration types.Duration) *PutWatch
- func (r *PutWatch) ThrottlePeriodInMillis(durationvalueunitmillis int64) *PutWatch
- func (r *PutWatch) Transform(transform *types.TransformContainer) *PutWatch
- func (r *PutWatch) Trigger(trigger *types.TriggerContainer) *PutWatch
- func (r *PutWatch) Version(versionnumber string) *PutWatch
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")
ErrBuildPath is returned in case of missing parameters within the build of the request.
Functions ¶
This section is empty.
Types ¶
type NewPutWatch ¶
NewPutWatch type alias for index.
func NewPutWatchFunc ¶
func NewPutWatchFunc(tp elastictransport.Interface) NewPutWatch
NewPutWatchFunc returns a new instance of PutWatch with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.
type PutWatch ¶
type PutWatch struct {
// contains filtered or unexported fields
}
func New ¶
func New(tp elastictransport.Interface) *PutWatch
Create or update a watch. When a watch is registered, a new document that represents the watch is added to the `.watches` index and its trigger is immediately registered with the relevant trigger engine. Typically for the `schedule` trigger, the scheduler is the trigger engine.
IMPORTANT: You must use Kibana or this API to create a watch. Do not add a watch directly to the `.watches` index by using the Elasticsearch index API. If Elasticsearch security features are enabled, do not give users write privileges on the `.watches` index.
When you add a watch you can also define its initial active state by setting the *active* parameter.
When Elasticsearch security features are enabled, your watch can index or search only on indices for which the user that stored the watch has privileges. If the user is able to read index `a`, but not index `b`, the same will apply when the watch runs.
https://www.elastic.co/docs/api/doc/elasticsearch/v8/operation/operation-watcher-put-watch
func (*PutWatch) Actions ¶ added in v8.9.0
func (r *PutWatch) Actions(actions map[string]types.WatcherAction) *PutWatch
Actions The list of actions that will be run if the condition matches. API name: actions
func (*PutWatch) Active ¶
Active The initial state of the watch. The default value is `true`, which means the watch is active by default. API name: active
func (*PutWatch) Condition ¶ added in v8.9.0
func (r *PutWatch) Condition(condition *types.WatcherCondition) *PutWatch
Condition The condition that defines if the actions should be run. API name: condition
func (PutWatch) Do ¶
Do runs the request through the transport, handle the response and returns a putwatch.Response
func (*PutWatch) ErrorTrace ¶ added in v8.14.0
ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace
func (*PutWatch) FilterPath ¶ added in v8.14.0
FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path
func (*PutWatch) HttpRequest ¶
HttpRequest returns the http.Request object built from the given parameters.
func (*PutWatch) Human ¶ added in v8.14.0
Human When set to `true` will return statistics in a format suitable for humans. For example `"exists_time": "1h"` for humans and `"eixsts_time_in_millis": 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. API name: human
func (*PutWatch) IfPrimaryTerm ¶
IfPrimaryTerm only update the watch if the last operation that has changed the watch has the specified primary term API name: if_primary_term
func (*PutWatch) IfSeqNo ¶
IfSeqNo only update the watch if the last operation that has changed the watch has the specified sequence number API name: if_seq_no
func (*PutWatch) Input ¶ added in v8.9.0
func (r *PutWatch) Input(input *types.WatcherInput) *PutWatch
Input The input that defines the input that loads the data for the watch. API name: input
func (*PutWatch) Metadata ¶ added in v8.9.0
Metadata Metadata JSON that will be copied into the history entries. API name: metadata
func (PutWatch) Perform ¶ added in v8.7.0
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*PutWatch) Pretty ¶ added in v8.14.0
Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty
func (*PutWatch) Raw ¶
Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.
func (*PutWatch) ThrottlePeriod ¶ added in v8.9.0
ThrottlePeriod The minimum time between actions being run. The default is 5 seconds. This default can be changed in the config file with the setting `xpack.watcher.throttle.period.default_period`. If both this value and the `throttle_period_in_millis` parameter are specified, Watcher uses the last parameter included in the request. API name: throttle_period
func (*PutWatch) ThrottlePeriodInMillis ¶ added in v8.18.0
ThrottlePeriodInMillis Minimum time in milliseconds between actions being run. Defaults to 5000. If both this value and the throttle_period parameter are specified, Watcher uses the last parameter included in the request. API name: throttle_period_in_millis
func (*PutWatch) Transform ¶ added in v8.9.0
func (r *PutWatch) Transform(transform *types.TransformContainer) *PutWatch
Transform The transform that processes the watch payload to prepare it for the watch actions. API name: transform
type Request ¶
type Request struct { // Actions The list of actions that will be run if the condition matches. Actions map[string]types.WatcherAction `json:"actions,omitempty"` // Condition The condition that defines if the actions should be run. Condition *types.WatcherCondition `json:"condition,omitempty"` // Input The input that defines the input that loads the data for the watch. Input *types.WatcherInput `json:"input,omitempty"` // Metadata Metadata JSON that will be copied into the history entries. Metadata types.Metadata `json:"metadata,omitempty"` // ThrottlePeriod The minimum time between actions being run. // The default is 5 seconds. // This default can be changed in the config file with the setting // `xpack.watcher.throttle.period.default_period`. // If both this value and the `throttle_period_in_millis` parameter are // specified, Watcher uses the last parameter included in the request. ThrottlePeriod types.Duration `json:"throttle_period,omitempty"` // ThrottlePeriodInMillis Minimum time in milliseconds between actions being run. Defaults to 5000. If // both this value and the throttle_period parameter are specified, Watcher uses // the last parameter included in the request. ThrottlePeriodInMillis *int64 `json:"throttle_period_in_millis,omitempty"` // Transform The transform that processes the watch payload to prepare it for the watch // actions. Transform *types.TransformContainer `json:"transform,omitempty"` // Trigger The trigger that defines when the watch should run. Trigger *types.TriggerContainer `json:"trigger,omitempty"` }
Request holds the request body struct for the package putwatch
func (*Request) FromJSON ¶ added in v8.5.0
FromJSON allows to load an arbitrary json into the request structure