Core: Change the rest api url structure as if all operations are targetted for the `.alerts` index.

Closes elastic/elasticsearch#44

Original commit: elastic/x-pack-elasticsearch@0f1a9e23b1
This commit is contained in:
Martijn van Groningen 2014-11-17 12:09:22 +01:00
parent 6891702397
commit 532e5d7b35
18 changed files with 114 additions and 109 deletions

View File

@ -6,7 +6,7 @@ This is the elasticsearch alerting plugin repo.
Creating an alert :
````
PUT _alert/testalert
PUT /.alerts/alert/testalert
{
"request" : {
"indices" : [
@ -63,7 +63,7 @@ Expected response :
Viewing an existing alert :
````
GET _alert/testalert
GET /.alerts/alert/testalert
````
````
@ -119,7 +119,7 @@ GET _alert/testalert
Deleting an alert :
````
DELETE _alert/testalert
DELETE /.alerts/alert/testalert
````
Expected output :

View File

@ -13,11 +13,11 @@ import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.rest.RestAlertsStatsAction;
import org.elasticsearch.alerts.rest.RestDeleteAlertAction;
import org.elasticsearch.alerts.rest.RestGetAlertAction;
import org.elasticsearch.alerts.rest.RestIndexAlertAction;
import org.elasticsearch.alerts.rest.RestPutAlertAction;
import org.elasticsearch.alerts.scheduler.AlertScheduler;
import org.elasticsearch.alerts.transport.actions.delete.TransportDeleteAlertAction;
import org.elasticsearch.alerts.transport.actions.get.TransportGetAlertAction;
import org.elasticsearch.alerts.transport.actions.index.TransportIndexAlertAction;
import org.elasticsearch.alerts.transport.actions.put.TransportPutAlertAction;
import org.elasticsearch.alerts.transport.actions.stats.TransportAlertStatsAction;
import org.elasticsearch.alerts.triggers.TriggerManager;
import org.elasticsearch.common.inject.AbstractModule;
@ -37,14 +37,14 @@ public class AlertingModule extends AbstractModule {
bind(AlertActionRegistry.class).asEagerSingleton();
// Transport and client layer
bind(TransportIndexAlertAction.class).asEagerSingleton();
bind(TransportPutAlertAction.class).asEagerSingleton();
bind(TransportDeleteAlertAction.class).asEagerSingleton();
bind(TransportGetAlertAction.class).asEagerSingleton();
bind(TransportAlertStatsAction.class).asEagerSingleton();
bind(AlertsClient.class).to(NodeAlertsClient.class).asEagerSingleton();
// Rest layer
bind(RestIndexAlertAction.class).asEagerSingleton();
bind(RestPutAlertAction.class).asEagerSingleton();
bind(RestDeleteAlertAction.class).asEagerSingleton();
bind(RestAlertsStatsAction.class).asEagerSingleton();
bind(RestGetAlertAction.class).asEagerSingleton();

View File

@ -13,9 +13,9 @@ import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertResponse;
import org.elasticsearch.alerts.transport.actions.get.GetAlertRequest;
import org.elasticsearch.alerts.transport.actions.get.GetAlertRequestBuilder;
import org.elasticsearch.alerts.transport.actions.get.GetAlertResponse;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertRequest;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertRequestBuilder;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertResponse;
import org.elasticsearch.alerts.transport.actions.put.PutAlertRequest;
import org.elasticsearch.alerts.transport.actions.put.PutAlertRequestBuilder;
import org.elasticsearch.alerts.transport.actions.put.PutAlertResponse;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsRequest;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsRequestBuilder;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsResponse;
@ -93,14 +93,14 @@ public interface AlertsClient extends ElasticsearchClient<AlertsClient> {
* @param alertName The name of the alert to index
* @return The builder to create the alert
*/
IndexAlertRequestBuilder prepareIndexAlert(String alertName);
PutAlertRequestBuilder prepareIndexAlert(String alertName);
/**
* Creates a request builder to build a request to index an alert
*
* @return The builder
*/
IndexAlertRequestBuilder prepareIndexAlert();
PutAlertRequestBuilder prepareIndexAlert();
/**
* Indexes an alert and registers it with the scheduler
@ -108,7 +108,7 @@ public interface AlertsClient extends ElasticsearchClient<AlertsClient> {
* @param request The request containing the alert to index and register
* @param listener The listener for the response containing the IndexResponse for this alert
*/
void indexAlert(IndexAlertRequest request, ActionListener<IndexAlertResponse> listener);
void indexAlert(PutAlertRequest request, ActionListener<PutAlertResponse> listener);
/**
* Indexes an alert and registers it with the scheduler
@ -116,7 +116,7 @@ public interface AlertsClient extends ElasticsearchClient<AlertsClient> {
* @param request The request containing the alert to index and register
* @return The response containing the IndexResponse for this alert
*/
ActionFuture<IndexAlertResponse> indexAlert(IndexAlertRequest request);
ActionFuture<PutAlertResponse> indexAlert(PutAlertRequest request);
/**

View File

@ -9,7 +9,7 @@ import org.elasticsearch.action.*;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.alerts.transport.actions.delete.*;
import org.elasticsearch.alerts.transport.actions.get.*;
import org.elasticsearch.alerts.transport.actions.index.*;
import org.elasticsearch.alerts.transport.actions.put.*;
import org.elasticsearch.alerts.transport.actions.stats.*;
import org.elasticsearch.client.support.Headers;
import org.elasticsearch.common.collect.ImmutableMap;
@ -23,13 +23,13 @@ public class NodeAlertsClient implements AlertsClient {
private final ImmutableMap<GenericAction, TransportAction> internalActions;
@Inject
public NodeAlertsClient(ThreadPool threadPool, Headers headers, TransportIndexAlertAction transportIndexAlertAction,
public NodeAlertsClient(ThreadPool threadPool, Headers headers, TransportPutAlertAction transportPutAlertAction,
TransportGetAlertAction transportGetAlertAction, TransportDeleteAlertAction transportDeleteAlertAction,
TransportAlertStatsAction transportAlertStatsAction) {
this.headers = headers;
this.threadPool = threadPool;
internalActions = ImmutableMap.<GenericAction, TransportAction>builder()
.put(IndexAlertAction.INSTANCE, transportIndexAlertAction)
.put(PutAlertAction.INSTANCE, transportPutAlertAction)
.put(GetAlertAction.INSTANCE, transportGetAlertAction)
.put(DeleteAlertAction.INSTANCE, transportDeleteAlertAction)
.put(AlertsStatsAction.INSTANCE, transportAlertStatsAction)
@ -76,23 +76,23 @@ public class NodeAlertsClient implements AlertsClient {
}
@Override
public IndexAlertRequestBuilder prepareIndexAlert(String alertName) {
return new IndexAlertRequestBuilder(this, alertName);
public PutAlertRequestBuilder prepareIndexAlert(String alertName) {
return new PutAlertRequestBuilder(this, alertName);
}
@Override
public IndexAlertRequestBuilder prepareIndexAlert() {
return new IndexAlertRequestBuilder(this, null);
public PutAlertRequestBuilder prepareIndexAlert() {
return new PutAlertRequestBuilder(this, null);
}
@Override
public void indexAlert(IndexAlertRequest request, ActionListener<IndexAlertResponse> response) {
execute(IndexAlertAction.INSTANCE, request, response);
public void indexAlert(PutAlertRequest request, ActionListener<PutAlertResponse> response) {
execute(PutAlertAction.INSTANCE, request, response);
}
@Override
public ActionFuture<IndexAlertResponse> indexAlert(IndexAlertRequest request) {
return execute(IndexAlertAction.INSTANCE, request);
public ActionFuture<PutAlertResponse> indexAlert(PutAlertRequest request) {
return execute(PutAlertAction.INSTANCE, request);
}
@Override

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.alerts.rest;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsRequest;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsResponse;
@ -29,7 +30,7 @@ public class RestAlertsStatsAction extends BaseRestHandler {
protected RestAlertsStatsAction(Settings settings, RestController controller, Client client, AlertsClient alertsClient) {
super(settings, controller, client);
this.alertsClient = alertsClient;
controller.registerHandler(GET, "/_alert/_stats", this);
controller.registerHandler(GET, AlertsStore.ALERT_INDEX + "/alert/_stats", this);
}
@Override

View File

@ -6,6 +6,7 @@
package org.elasticsearch.alerts.rest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertRequest;
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertResponse;
@ -30,7 +31,7 @@ public class RestDeleteAlertAction extends BaseRestHandler {
public RestDeleteAlertAction(Settings settings, RestController controller, Client client, AlertsClient alertsClient) {
super(settings, controller, client);
this.alertsClient = alertsClient;
controller.registerHandler(DELETE, "/_alert/{name}", this);
controller.registerHandler(DELETE, AlertsStore.ALERT_INDEX + "/alert/{name}", this);
}
@Override

View File

@ -6,6 +6,7 @@
package org.elasticsearch.alerts.rest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.transport.actions.get.GetAlertRequest;
import org.elasticsearch.alerts.transport.actions.get.GetAlertResponse;
@ -31,7 +32,7 @@ public class RestGetAlertAction extends BaseRestHandler {
public RestGetAlertAction(Settings settings, RestController controller, Client client, AlertsClient alertsClient) {
super(settings, controller, client);
this.alertsClient = alertsClient;
controller.registerHandler(GET, "/_alert/{name}", this);
controller.registerHandler(GET, AlertsStore.ALERT_INDEX + "/alert/{name}", this);
}
@Override

View File

@ -6,9 +6,10 @@
package org.elasticsearch.alerts.rest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertRequest;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertResponse;
import org.elasticsearch.alerts.transport.actions.put.PutAlertRequest;
import org.elasticsearch.alerts.transport.actions.put.PutAlertResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -23,26 +24,26 @@ import static org.elasticsearch.rest.RestStatus.OK;
/**
*/
public class RestIndexAlertAction extends BaseRestHandler {
public class RestPutAlertAction extends BaseRestHandler {
private final AlertsClient alertsClient;
@Inject
public RestIndexAlertAction(Settings settings, RestController controller, Client client, AlertsClient alertsClient) {
public RestPutAlertAction(Settings settings, RestController controller, Client client, AlertsClient alertsClient) {
super(settings, controller, client);
this.alertsClient = alertsClient;
controller.registerHandler(POST, "/_alert/{name}", this);
controller.registerHandler(PUT, "/_alert/{name}", this);
controller.registerHandler(POST, AlertsStore.ALERT_INDEX + "/alert/{name}", this);
controller.registerHandler(PUT, AlertsStore.ALERT_INDEX + "/alert/{name}", this);
}
@Override
protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception {
IndexAlertRequest indexAlertRequest = new IndexAlertRequest();
indexAlertRequest.setAlertName(request.param("name"));
indexAlertRequest.setAlertSource(request.content(), request.contentUnsafe());
alertsClient.indexAlert(indexAlertRequest, new RestBuilderListener<IndexAlertResponse>(channel) {
PutAlertRequest putAlertRequest = new PutAlertRequest();
putAlertRequest.setAlertName(request.param("name"));
putAlertRequest.setAlertSource(request.content(), request.contentUnsafe());
alertsClient.indexAlert(putAlertRequest, new RestBuilderListener<PutAlertResponse>(channel) {
@Override
public RestResponse buildResponse(IndexAlertResponse response, XContentBuilder builder) throws Exception {
public RestResponse buildResponse(PutAlertResponse response, XContentBuilder builder) throws Exception {
IndexResponse indexResponse = response.indexResponse();
builder.startObject()
.field("_index", indexResponse.getIndex())

View File

@ -1,32 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.transport.actions.index;
import org.elasticsearch.alerts.client.AlertsClientAction;
import org.elasticsearch.alerts.client.AlertsClient;
/**
*/
public class IndexAlertAction extends AlertsClientAction<IndexAlertRequest, IndexAlertResponse, IndexAlertRequestBuilder> {
public static final IndexAlertAction INSTANCE = new IndexAlertAction();
public static final String NAME = "indices:data/write/alert/index";
private IndexAlertAction() {
super(NAME);
}
@Override
public IndexAlertRequestBuilder newRequestBuilder(AlertsClient client) {
return new IndexAlertRequestBuilder(client);
}
@Override
public IndexAlertResponse newResponse() {
return new IndexAlertResponse();
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.transport.actions.put;
import org.elasticsearch.alerts.client.AlertsClientAction;
import org.elasticsearch.alerts.client.AlertsClient;
/**
*/
public class PutAlertAction extends AlertsClientAction<PutAlertRequest, PutAlertResponse, PutAlertRequestBuilder> {
public static final PutAlertAction INSTANCE = new PutAlertAction();
public static final String NAME = "indices:data/write/alert/put";
private PutAlertAction() {
super(NAME);
}
@Override
public PutAlertRequestBuilder newRequestBuilder(AlertsClient client) {
return new PutAlertRequestBuilder(client);
}
@Override
public PutAlertResponse newResponse() {
return new PutAlertResponse();
}
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.transport.actions.index;
package org.elasticsearch.alerts.transport.actions.put;
import org.elasticsearch.action.ActionRequestValidationException;
@ -17,16 +17,16 @@ import java.io.IOException;
/**
*/
public class IndexAlertRequest extends MasterNodeOperationRequest<IndexAlertRequest> {
public class PutAlertRequest extends MasterNodeOperationRequest<PutAlertRequest> {
private String alertName;
private BytesReference alertSource;
private boolean alertSourceUnsafe;
public IndexAlertRequest() {
public PutAlertRequest() {
}
public IndexAlertRequest(BytesReference alertSource) {
public PutAlertRequest(BytesReference alertSource) {
this.alertSource = alertSource;
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.transport.actions.index;
package org.elasticsearch.alerts.transport.actions.put;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
@ -12,34 +12,34 @@ import org.elasticsearch.common.bytes.BytesReference;
/**
*/
public class IndexAlertRequestBuilder
extends MasterNodeOperationRequestBuilder<IndexAlertRequest, IndexAlertResponse,
IndexAlertRequestBuilder, AlertsClient> {
public class PutAlertRequestBuilder
extends MasterNodeOperationRequestBuilder<PutAlertRequest, PutAlertResponse,
PutAlertRequestBuilder, AlertsClient> {
public IndexAlertRequestBuilder(AlertsClient client) {
super(client, new IndexAlertRequest());
public PutAlertRequestBuilder(AlertsClient client) {
super(client, new PutAlertRequest());
}
public IndexAlertRequestBuilder(AlertsClient client, String alertName) {
super(client, new IndexAlertRequest());
public PutAlertRequestBuilder(AlertsClient client, String alertName) {
super(client, new PutAlertRequest());
request.setAlertName(alertName);
}
public IndexAlertRequestBuilder setAlertName(String alertName){
public PutAlertRequestBuilder setAlertName(String alertName){
request.setAlertName(alertName);
return this;
}
public IndexAlertRequestBuilder setAlertSource(BytesReference alertSource) {
public PutAlertRequestBuilder setAlertSource(BytesReference alertSource) {
request.setAlertSource(alertSource);
return this;
}
@Override
protected void doExecute(ActionListener<IndexAlertResponse> listener) {
protected void doExecute(ActionListener<PutAlertResponse> listener) {
client.indexAlert(request, listener);
}
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.transport.actions.index;
package org.elasticsearch.alerts.transport.actions.put;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.index.IndexResponse;
@ -14,14 +14,14 @@ import java.io.IOException;
/**
*/
public class IndexAlertResponse extends ActionResponse {
public class PutAlertResponse extends ActionResponse {
private IndexResponse indexResponse;
public IndexAlertResponse(IndexResponse indexResponse) {
public PutAlertResponse(IndexResponse indexResponse) {
this.indexResponse = indexResponse;
}
public IndexAlertResponse() {
public PutAlertResponse() {
indexResponse = null;
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.transport.actions.index;
package org.elasticsearch.alerts.transport.actions.put;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
@ -24,14 +24,14 @@ import org.elasticsearch.transport.TransportService;
/**
*/
public class TransportIndexAlertAction extends TransportMasterNodeOperationAction<IndexAlertRequest, IndexAlertResponse> {
public class TransportPutAlertAction extends TransportMasterNodeOperationAction<PutAlertRequest, PutAlertResponse> {
private final AlertManager alertManager;
@Inject
public TransportIndexAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, AlertManager alertManager) {
super(settings, IndexAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
public TransportPutAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, AlertManager alertManager) {
super(settings, PutAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
this.alertManager = alertManager;
}
@ -41,27 +41,27 @@ public class TransportIndexAlertAction extends TransportMasterNodeOperationActio
}
@Override
protected IndexAlertRequest newRequest() {
return new IndexAlertRequest();
protected PutAlertRequest newRequest() {
return new PutAlertRequest();
}
@Override
protected IndexAlertResponse newResponse() {
return new IndexAlertResponse();
protected PutAlertResponse newResponse() {
return new PutAlertResponse();
}
@Override
protected void masterOperation(IndexAlertRequest request, ClusterState state, ActionListener<IndexAlertResponse> listener) throws ElasticsearchException {
protected void masterOperation(PutAlertRequest request, ClusterState state, ActionListener<PutAlertResponse> listener) throws ElasticsearchException {
try {
IndexResponse indexResponse = alertManager.addAlert(request.getAlertName(), request.getAlertSource());
listener.onResponse(new IndexAlertResponse(indexResponse));
listener.onResponse(new PutAlertResponse(indexResponse));
} catch (Exception e) {
listener.onFailure(e);
}
}
@Override
protected ClusterBlockException checkBlock(IndexAlertRequest request, ClusterState state) {
protected ClusterBlockException checkBlock(PutAlertRequest request, ClusterState state) {
request.beforeLocalFork(); // This is the best place to make the alert source safe
return state.blocks().indicesBlockedException(ClusterBlockLevel.WRITE, new String[]{AlertsStore.ALERT_INDEX, AlertActionManager.ALERT_HISTORY_INDEX});

View File

@ -3,4 +3,4 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.transport.actions.index;
package org.elasticsearch.alerts.transport.actions.put;

View File

@ -58,6 +58,7 @@ public class TransportAlertStatsAction extends TransportMasterNodeOperationActio
statsResponse.setAlertActionManagerStarted(alertActionManager.started());
statsResponse.setAlertActionManagerQueueSize(alertActionManager.getQueueSize());
statsResponse.setNumberOfRegisteredAlerts(alertManager.getNumberOfAlerts());
listener.onResponse(statsResponse);
}
@Override

View File

@ -10,7 +10,7 @@ import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertRequest;
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertResponse;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertResponse;
import org.elasticsearch.alerts.transport.actions.put.PutAlertResponse;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.builder.SearchSourceBuilder;
@ -69,7 +69,7 @@ public class BasicAlertingTest extends AbstractAlertingTests {
client().prepareIndex("my-index", "my-type").setSource("field", "value").get();
SearchRequest searchRequest = new SearchRequest("my-index").source(searchSource().query(matchAllQuery()));
BytesReference alertSource = createAlertSource("0/5 * * * * ? *", searchRequest, "hits.total == 1");
IndexAlertResponse indexResponse = alertsClient.prepareIndexAlert("my-first-alert")
PutAlertResponse indexResponse = alertsClient.prepareIndexAlert("my-first-alert")
.setAlertSource(alertSource)
.get();
assertThat(indexResponse.indexResponse().isCreated(), is(true));

View File

@ -19,8 +19,8 @@ import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertRequest;
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertResponse;
import org.elasticsearch.alerts.transport.actions.get.GetAlertRequest;
import org.elasticsearch.alerts.transport.actions.get.GetAlertResponse;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertRequest;
import org.elasticsearch.alerts.transport.actions.index.IndexAlertResponse;
import org.elasticsearch.alerts.transport.actions.put.PutAlertRequest;
import org.elasticsearch.alerts.transport.actions.put.PutAlertResponse;
import org.elasticsearch.alerts.triggers.AlertTrigger;
import org.elasticsearch.alerts.triggers.ScriptedTrigger;
import org.elasticsearch.alerts.triggers.TriggerResult;
@ -198,8 +198,8 @@ public class AlertActionsTest extends ElasticsearchIntegrationTest {
AlertsClient alertsClient = internalCluster().getInstance(AlertsClient.class, internalCluster().getMasterName());
IndexAlertRequest alertRequest = alertsClient.prepareIndexAlert().setAlertName("my-first-alert").setAlertSource(jsonBuilder.bytes()).request();
IndexAlertResponse alertsResponse = alertsClient.indexAlert(alertRequest).actionGet();
PutAlertRequest alertRequest = alertsClient.prepareIndexAlert().setAlertName("my-first-alert").setAlertSource(jsonBuilder.bytes()).request();
PutAlertResponse alertsResponse = alertsClient.indexAlert(alertRequest).actionGet();
assertNotNull(alertsResponse.indexResponse());
assertTrue(alertsResponse.indexResponse().isCreated());