putwatch

package
v8.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 12 Imported by: 4

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

Constants

This section is empty.

Variables

View Source
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

type NewPutWatch func(id string) *PutWatch

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

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

func (r *PutWatch) Active(active bool) *PutWatch

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

func (r PutWatch) Do(providedCtx context.Context) (*Response, error)

Do runs the request through the transport, handle the response and returns a putwatch.Response

func (*PutWatch) ErrorTrace added in v8.14.0

func (r *PutWatch) ErrorTrace(errortrace bool) *PutWatch

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

func (r *PutWatch) FilterPath(filterpaths ...string) *PutWatch

FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path

func (*PutWatch) Header

func (r *PutWatch) Header(key, value string) *PutWatch

Header set a key, value pair in the PutWatch headers map.

func (*PutWatch) HttpRequest

func (r *PutWatch) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*PutWatch) Human added in v8.14.0

func (r *PutWatch) Human(human bool) *PutWatch

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

func (r *PutWatch) IfPrimaryTerm(ifprimaryterm string) *PutWatch

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

func (r *PutWatch) IfSeqNo(sequencenumber string) *PutWatch

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

func (r *PutWatch) Metadata(metadata types.Metadata) *PutWatch

Metadata Metadata JSON that will be copied into the history entries. API name: metadata

func (PutWatch) Perform added in v8.7.0

func (r PutWatch) Perform(providedCtx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*PutWatch) Pretty added in v8.14.0

func (r *PutWatch) Pretty(pretty bool) *PutWatch

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

func (r *PutWatch) Raw(raw io.Reader) *PutWatch

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) Request

func (r *PutWatch) Request(req *Request) *PutWatch

Request allows to set the request property with the appropriate payload.

func (*PutWatch) ThrottlePeriod added in v8.9.0

func (r *PutWatch) ThrottlePeriod(duration types.Duration) *PutWatch

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

func (r *PutWatch) ThrottlePeriodInMillis(durationvalueunitmillis int64) *PutWatch

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

func (*PutWatch) Trigger added in v8.9.0

func (r *PutWatch) Trigger(trigger *types.TriggerContainer) *PutWatch

Trigger The trigger that defines when the watch should run. API name: trigger

func (*PutWatch) Version

func (r *PutWatch) Version(versionnumber string) *PutWatch

Version Explicit version number for concurrency control API name: version

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

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/watcher/put_watch/WatcherPutWatchRequest.ts#L31-L110

func NewRequest added in v8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON added in v8.5.0

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON added in v8.12.1

func (s *Request) UnmarshalJSON(data []byte) error

type Response added in v8.7.0

type Response struct {
	Created      bool   `json:"created"`
	Id_          string `json:"_id"`
	PrimaryTerm_ int64  `json:"_primary_term"`
	SeqNo_       int64  `json:"_seq_no"`
	Version_     int64  `json:"_version"`
}

Response holds the response body struct for the package putwatch

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/watcher/put_watch/WatcherPutWatchResponse.ts#L23-L31

func NewResponse added in v8.7.0

func NewResponse() *Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL