
co.elastic.clients.elasticsearch.watcher.ElasticsearchWatcherAsyncClient Maven / Gradle / Ivy
Show all versions of org.apache.servicemix.bundles.elasticsearch-java
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.clients.elasticsearch.watcher;
import co.elastic.clients.ApiClient;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.Endpoint;
import co.elastic.clients.transport.JsonEndpoint;
import co.elastic.clients.transport.Transport;
import co.elastic.clients.transport.TransportOptions;
import co.elastic.clients.util.ObjectBuilder;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import javax.annotation.Nullable;
//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------
/**
* Client for the watcher namespace.
*/
public class ElasticsearchWatcherAsyncClient
extends
ApiClient {
public ElasticsearchWatcherAsyncClient(ElasticsearchTransport transport) {
super(transport, null);
}
public ElasticsearchWatcherAsyncClient(ElasticsearchTransport transport,
@Nullable TransportOptions transportOptions) {
super(transport, transportOptions);
}
@Override
public ElasticsearchWatcherAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) {
return new ElasticsearchWatcherAsyncClient(this.transport, transportOptions);
}
// ----- Endpoint: watcher.ack_watch
/**
* Acknowledge a watch. Acknowledging a watch enables you to manually throttle
* the execution of the watch's actions.
*
* The acknowledgement state of an action is stored in the
* status.actions.<id>.ack.state
structure.
*
* IMPORTANT: If the specified watch is currently being executed, this API will
* return an error The reason for this behavior is to prevent overwriting the
* watch status from a watch execution.
*
* Acknowledging an action throttles further executions of that action until its
* ack.state
is reset to awaits_successful_execution
.
* This happens when the condition of the watch is not met (the condition
* evaluates to false). To demonstrate how throttling works in practice and how
* it can be configured for individual actions within a watch, refer to External
* documentation.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture ackWatch(AckWatchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) AckWatchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Acknowledge a watch. Acknowledging a watch enables you to manually throttle
* the execution of the watch's actions.
*
* The acknowledgement state of an action is stored in the
* status.actions.<id>.ack.state
structure.
*
* IMPORTANT: If the specified watch is currently being executed, this API will
* return an error The reason for this behavior is to prevent overwriting the
* watch status from a watch execution.
*
* Acknowledging an action throttles further executions of that action until its
* ack.state
is reset to awaits_successful_execution
.
* This happens when the condition of the watch is not met (the condition
* evaluates to false). To demonstrate how throttling works in practice and how
* it can be configured for individual actions within a watch, refer to External
* documentation.
*
* @param fn
* a function that initializes a builder to create the
* {@link AckWatchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture ackWatch(
Function> fn) {
return ackWatch(fn.apply(new AckWatchRequest.Builder()).build());
}
// ----- Endpoint: watcher.activate_watch
/**
* Activate a watch. A watch can be either active or inactive.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture activateWatch(ActivateWatchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) ActivateWatchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Activate a watch. A watch can be either active or inactive.
*
* @param fn
* a function that initializes a builder to create the
* {@link ActivateWatchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture activateWatch(
Function> fn) {
return activateWatch(fn.apply(new ActivateWatchRequest.Builder()).build());
}
// ----- Endpoint: watcher.deactivate_watch
/**
* Deactivate a watch. A watch can be either active or inactive.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture deactivateWatch(DeactivateWatchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) DeactivateWatchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Deactivate a watch. A watch can be either active or inactive.
*
* @param fn
* a function that initializes a builder to create the
* {@link DeactivateWatchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture deactivateWatch(
Function> fn) {
return deactivateWatch(fn.apply(new DeactivateWatchRequest.Builder()).build());
}
// ----- Endpoint: watcher.delete_watch
/**
* Delete a watch. When the watch is removed, the document representing the
* watch in the .watches
index is gone and it will never be run
* again.
*
* Deleting a watch does not delete any watch execution records related to this
* watch from the watch history.
*
* IMPORTANT: Deleting a watch must be done by using only this API. Do not
* delete the watch directly from the .watches
index using the
* Elasticsearch delete document API When Elasticsearch security features are
* enabled, make sure no write privileges are granted to anyone for the
* .watches
index.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture deleteWatch(DeleteWatchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) DeleteWatchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Delete a watch. When the watch is removed, the document representing the
* watch in the .watches
index is gone and it will never be run
* again.
*
* Deleting a watch does not delete any watch execution records related to this
* watch from the watch history.
*
* IMPORTANT: Deleting a watch must be done by using only this API. Do not
* delete the watch directly from the .watches
index using the
* Elasticsearch delete document API When Elasticsearch security features are
* enabled, make sure no write privileges are granted to anyone for the
* .watches
index.
*
* @param fn
* a function that initializes a builder to create the
* {@link DeleteWatchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture deleteWatch(
Function> fn) {
return deleteWatch(fn.apply(new DeleteWatchRequest.Builder()).build());
}
// ----- Endpoint: watcher.execute_watch
/**
* Run a watch. This API can be used to force execution of the watch outside of
* its triggering logic or to simulate the watch execution for debugging
* purposes.
*
* For testing and debugging purposes, you also have fine-grained control on how
* the watch runs. You can run the watch without running all of its actions or
* alternatively by simulating them. You can also force execution by ignoring
* the watch condition and control whether a watch record would be written to
* the watch history after it runs.
*
* You can use the run watch API to run watches that are not yet registered by
* specifying the watch definition inline. This serves as great tool for testing
* and debugging your watches prior to adding them to Watcher.
*
* When Elasticsearch security features are enabled on your cluster, watches are
* run with the privileges of the user that stored the watches. If your user is
* allowed to read index a
, but not index b
, then the
* exact same set of rules will apply during execution of a watch.
*
* When using the run watch API, the authorization data of the user that called
* the API will be used as a base, instead of the information who stored the
* watch. Refer to the external documentation for examples of watch execution
* requests, including existing, customized, and inline watches.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture executeWatch(ExecuteWatchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) ExecuteWatchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Run a watch. This API can be used to force execution of the watch outside of
* its triggering logic or to simulate the watch execution for debugging
* purposes.
*
* For testing and debugging purposes, you also have fine-grained control on how
* the watch runs. You can run the watch without running all of its actions or
* alternatively by simulating them. You can also force execution by ignoring
* the watch condition and control whether a watch record would be written to
* the watch history after it runs.
*
* You can use the run watch API to run watches that are not yet registered by
* specifying the watch definition inline. This serves as great tool for testing
* and debugging your watches prior to adding them to Watcher.
*
* When Elasticsearch security features are enabled on your cluster, watches are
* run with the privileges of the user that stored the watches. If your user is
* allowed to read index a
, but not index b
, then the
* exact same set of rules will apply during execution of a watch.
*
* When using the run watch API, the authorization data of the user that called
* the API will be used as a base, instead of the information who stored the
* watch. Refer to the external documentation for examples of watch execution
* requests, including existing, customized, and inline watches.
*
* @param fn
* a function that initializes a builder to create the
* {@link ExecuteWatchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture executeWatch(
Function> fn) {
return executeWatch(fn.apply(new ExecuteWatchRequest.Builder()).build());
}
/**
* Run a watch. This API can be used to force execution of the watch outside of
* its triggering logic or to simulate the watch execution for debugging
* purposes.
*
* For testing and debugging purposes, you also have fine-grained control on how
* the watch runs. You can run the watch without running all of its actions or
* alternatively by simulating them. You can also force execution by ignoring
* the watch condition and control whether a watch record would be written to
* the watch history after it runs.
*
* You can use the run watch API to run watches that are not yet registered by
* specifying the watch definition inline. This serves as great tool for testing
* and debugging your watches prior to adding them to Watcher.
*
* When Elasticsearch security features are enabled on your cluster, watches are
* run with the privileges of the user that stored the watches. If your user is
* allowed to read index a
, but not index b
, then the
* exact same set of rules will apply during execution of a watch.
*
* When using the run watch API, the authorization data of the user that called
* the API will be used as a base, instead of the information who stored the
* watch. Refer to the external documentation for examples of watch execution
* requests, including existing, customized, and inline watches.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture executeWatch() {
return this.transport.performRequestAsync(new ExecuteWatchRequest.Builder().build(),
ExecuteWatchRequest._ENDPOINT, this.transportOptions);
}
// ----- Endpoint: watcher.get_settings
/**
* Get Watcher index settings. Get settings for the Watcher internal index
* (.watches
). Only a subset of settings are shown, for example
* index.auto_expand_replicas
and
* index.number_of_replicas
.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture getSettings(GetWatcherSettingsRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) GetWatcherSettingsRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Get Watcher index settings. Get settings for the Watcher internal index
* (.watches
). Only a subset of settings are shown, for example
* index.auto_expand_replicas
and
* index.number_of_replicas
.
*
* @param fn
* a function that initializes a builder to create the
* {@link GetWatcherSettingsRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture getSettings(
Function> fn) {
return getSettings(fn.apply(new GetWatcherSettingsRequest.Builder()).build());
}
/**
* Get Watcher index settings. Get settings for the Watcher internal index
* (.watches
). Only a subset of settings are shown, for example
* index.auto_expand_replicas
and
* index.number_of_replicas
.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture getSettings() {
return this.transport.performRequestAsync(new GetWatcherSettingsRequest.Builder().build(),
GetWatcherSettingsRequest._ENDPOINT, this.transportOptions);
}
// ----- Endpoint: watcher.get_watch
/**
* Get a watch.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture getWatch(GetWatchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) GetWatchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Get a watch.
*
* @param fn
* a function that initializes a builder to create the
* {@link GetWatchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture getWatch(
Function> fn) {
return getWatch(fn.apply(new GetWatchRequest.Builder()).build());
}
// ----- Endpoint: watcher.put_watch
/**
* 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.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture putWatch(PutWatchRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) PutWatchRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* 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.
*
* @param fn
* a function that initializes a builder to create the
* {@link PutWatchRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture putWatch(
Function> fn) {
return putWatch(fn.apply(new PutWatchRequest.Builder()).build());
}
// ----- Endpoint: watcher.query_watches
/**
* Query watches. Get all registered watches in a paginated manner and
* optionally filter watches by a query.
*
* Note that only the _id
and metadata.*
fields are
* queryable or sortable.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture queryWatches(QueryWatchesRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) QueryWatchesRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Query watches. Get all registered watches in a paginated manner and
* optionally filter watches by a query.
*
* Note that only the _id
and metadata.*
fields are
* queryable or sortable.
*
* @param fn
* a function that initializes a builder to create the
* {@link QueryWatchesRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture queryWatches(
Function> fn) {
return queryWatches(fn.apply(new QueryWatchesRequest.Builder()).build());
}
/**
* Query watches. Get all registered watches in a paginated manner and
* optionally filter watches by a query.
*
* Note that only the _id
and metadata.*
fields are
* queryable or sortable.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture queryWatches() {
return this.transport.performRequestAsync(new QueryWatchesRequest.Builder().build(),
QueryWatchesRequest._ENDPOINT, this.transportOptions);
}
// ----- Endpoint: watcher.start
/**
* Start the watch service. Start the Watcher service if it is not already
* running.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture start(StartWatcherRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) StartWatcherRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Start the watch service. Start the Watcher service if it is not already
* running.
*
* @param fn
* a function that initializes a builder to create the
* {@link StartWatcherRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture start(
Function> fn) {
return start(fn.apply(new StartWatcherRequest.Builder()).build());
}
/**
* Start the watch service. Start the Watcher service if it is not already
* running.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture start() {
return this.transport.performRequestAsync(new StartWatcherRequest.Builder().build(),
StartWatcherRequest._ENDPOINT, this.transportOptions);
}
// ----- Endpoint: watcher.stats
/**
* Get Watcher statistics. This API always returns basic metrics. You retrieve
* more metrics by using the metric parameter.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture stats(WatcherStatsRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) WatcherStatsRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Get Watcher statistics. This API always returns basic metrics. You retrieve
* more metrics by using the metric parameter.
*
* @param fn
* a function that initializes a builder to create the
* {@link WatcherStatsRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture stats(
Function> fn) {
return stats(fn.apply(new WatcherStatsRequest.Builder()).build());
}
/**
* Get Watcher statistics. This API always returns basic metrics. You retrieve
* more metrics by using the metric parameter.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture stats() {
return this.transport.performRequestAsync(new WatcherStatsRequest.Builder().build(),
WatcherStatsRequest._ENDPOINT, this.transportOptions);
}
// ----- Endpoint: watcher.stop
/**
* Stop the watch service. Stop the Watcher service if it is running.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture stop(StopWatcherRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) StopWatcherRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Stop the watch service. Stop the Watcher service if it is running.
*
* @param fn
* a function that initializes a builder to create the
* {@link StopWatcherRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture stop(
Function> fn) {
return stop(fn.apply(new StopWatcherRequest.Builder()).build());
}
/**
* Stop the watch service. Stop the Watcher service if it is running.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture stop() {
return this.transport.performRequestAsync(new StopWatcherRequest.Builder().build(),
StopWatcherRequest._ENDPOINT, this.transportOptions);
}
// ----- Endpoint: watcher.update_settings
/**
* Update Watcher index settings. Update settings for the Watcher internal index
* (.watches
). Only a subset of settings can be modified. This
* includes index.auto_expand_replicas
,
* index.number_of_replicas
,
* index.routing.allocation.exclude.*
,
* index.routing.allocation.include.*
and
* index.routing.allocation.require.*
. Modification of
* index.routing.allocation.include._tier_preference
is an
* exception and is not allowed as the Watcher shards must always be in the
* data_content
tier.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture updateSettings(UpdateSettingsRequest request) {
@SuppressWarnings("unchecked")
JsonEndpoint endpoint = (JsonEndpoint) UpdateSettingsRequest._ENDPOINT;
return this.transport.performRequestAsync(request, endpoint, this.transportOptions);
}
/**
* Update Watcher index settings. Update settings for the Watcher internal index
* (.watches
). Only a subset of settings can be modified. This
* includes index.auto_expand_replicas
,
* index.number_of_replicas
,
* index.routing.allocation.exclude.*
,
* index.routing.allocation.include.*
and
* index.routing.allocation.require.*
. Modification of
* index.routing.allocation.include._tier_preference
is an
* exception and is not allowed as the Watcher shards must always be in the
* data_content
tier.
*
* @param fn
* a function that initializes a builder to create the
* {@link UpdateSettingsRequest}
* @see Documentation
* on elastic.co
*/
public final CompletableFuture updateSettings(
Function> fn) {
return updateSettings(fn.apply(new UpdateSettingsRequest.Builder()).build());
}
/**
* Update Watcher index settings. Update settings for the Watcher internal index
* (.watches
). Only a subset of settings can be modified. This
* includes index.auto_expand_replicas
,
* index.number_of_replicas
,
* index.routing.allocation.exclude.*
,
* index.routing.allocation.include.*
and
* index.routing.allocation.require.*
. Modification of
* index.routing.allocation.include._tier_preference
is an
* exception and is not allowed as the Watcher shards must always be in the
* data_content
tier.
*
* @see Documentation
* on elastic.co
*/
public CompletableFuture updateSettings() {
return this.transport.performRequestAsync(new UpdateSettingsRequest.Builder().build(),
UpdateSettingsRequest._ENDPOINT, this.transportOptions);
}
}