mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
use client instead of transport action directly in rest actions
Original commit: elastic/x-pack-elasticsearch@4c3380ceb9
This commit is contained in:
parent
d9a75424d0
commit
40332c7e1c
@ -21,12 +21,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestCloseJobAction extends BaseRestHandler {
|
||||
|
||||
private final CloseJobAction.TransportAction closeJobAction;
|
||||
|
||||
@Inject
|
||||
public RestCloseJobAction(Settings settings, RestController controller, CloseJobAction.TransportAction closeJobAction) {
|
||||
public RestCloseJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.closeJobAction = closeJobAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_close", this);
|
||||
}
|
||||
@ -37,6 +34,6 @@ public class RestCloseJobAction extends BaseRestHandler {
|
||||
if (restRequest.hasParam("close_timeout")) {
|
||||
request.setCloseTimeout(TimeValue.parseTimeValue(restRequest.param("close_timeout"), "close_timeout"));
|
||||
}
|
||||
return channel -> closeJobAction.execute(request, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(CloseJobAction.INSTANCE, request, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestDeleteJobAction extends BaseRestHandler {
|
||||
|
||||
private final DeleteJobAction.TransportAction transportDeleteJobAction;
|
||||
|
||||
@Inject
|
||||
public RestDeleteJobAction(Settings settings, RestController controller, DeleteJobAction.TransportAction transportDeleteJobAction) {
|
||||
public RestDeleteJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportDeleteJobAction = transportDeleteJobAction;
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MlPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
@ -33,6 +30,6 @@ public class RestDeleteJobAction extends BaseRestHandler {
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
DeleteJobAction.Request deleteJobRequest = new DeleteJobAction.Request(restRequest.param(Job.ID.getPreferredName()));
|
||||
return channel -> transportDeleteJobAction.execute(deleteJobRequest, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(DeleteJobAction.INSTANCE, deleteJobRequest, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,9 @@ public class RestFlushJobAction extends BaseRestHandler {
|
||||
private final String DEFAULT_END = "";
|
||||
private final String DEFAULT_ADVANCE_TIME = "";
|
||||
|
||||
private final FlushJobAction.TransportAction flushJobAction;
|
||||
|
||||
@Inject
|
||||
public RestFlushJobAction(Settings settings, RestController controller,
|
||||
FlushJobAction.TransportAction flushJobAction) {
|
||||
public RestFlushJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.flushJobAction = flushJobAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_flush", this);
|
||||
}
|
||||
@ -53,6 +49,6 @@ public class RestFlushJobAction extends BaseRestHandler {
|
||||
request.setAdvanceTime(restRequest.param(FlushJobAction.Request.ADVANCE_TIME.getPreferredName(), DEFAULT_ADVANCE_TIME));
|
||||
}
|
||||
|
||||
return channel -> flushJobAction.execute(request, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(FlushJobAction.INSTANCE, request, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetJobsAction extends BaseRestHandler {
|
||||
|
||||
private final GetJobsAction.TransportAction transportGetJobAction;
|
||||
|
||||
@Inject
|
||||
public RestGetJobsAction(Settings settings, RestController controller, GetJobsAction.TransportAction transportGetJobAction) {
|
||||
public RestGetJobsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportGetJobAction = transportGetJobAction;
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
@ -34,6 +31,6 @@ public class RestGetJobsAction extends BaseRestHandler {
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
GetJobsAction.Request request = new GetJobsAction.Request(restRequest.param(Job.ID.getPreferredName()));
|
||||
return channel -> transportGetJobAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetJobsAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetJobsStatsAction extends BaseRestHandler {
|
||||
|
||||
private final GetJobsStatsAction.TransportAction transportGetJobsStatsAction;
|
||||
|
||||
@Inject
|
||||
public RestGetJobsStatsAction(Settings settings, RestController controller,
|
||||
GetJobsStatsAction.TransportAction transportGetJobsStatsAction) {
|
||||
public RestGetJobsStatsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportGetJobsStatsAction = transportGetJobsStatsAction;
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats", this);
|
||||
}
|
||||
@ -35,6 +30,6 @@ public class RestGetJobsStatsAction extends BaseRestHandler {
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
GetJobsStatsAction.Request request = new GetJobsStatsAction.Request(restRequest.param(Job.ID.getPreferredName()));
|
||||
return channel -> transportGetJobsStatsAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetJobsStatsAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -14,20 +14,17 @@ import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.action.PostDataAction;
|
||||
import org.elasticsearch.xpack.ml.action.OpenJobAction;
|
||||
import org.elasticsearch.xpack.ml.action.PostDataAction;
|
||||
import org.elasticsearch.xpack.ml.job.Job;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RestOpenJobAction extends BaseRestHandler {
|
||||
|
||||
private final OpenJobAction.TransportAction openJobAction;
|
||||
|
||||
@Inject
|
||||
public RestOpenJobAction(Settings settings, RestController controller, OpenJobAction.TransportAction openJobAction) {
|
||||
public RestOpenJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.openJobAction = openJobAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_open", this);
|
||||
}
|
||||
@ -41,6 +38,6 @@ public class RestOpenJobAction extends BaseRestHandler {
|
||||
restRequest.param(OpenJobAction.Request.OPEN_TIMEOUT.getPreferredName()),
|
||||
OpenJobAction.Request.OPEN_TIMEOUT.getPreferredName()));
|
||||
}
|
||||
return channel -> openJobAction.execute(request, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(OpenJobAction.INSTANCE, request, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,9 @@ public class RestPostDataAction extends BaseRestHandler {
|
||||
private static final String DEFAULT_RESET_START = "";
|
||||
private static final String DEFAULT_RESET_END = "";
|
||||
|
||||
private final PostDataAction.TransportAction transportPostDataAction;
|
||||
|
||||
@Inject
|
||||
public RestPostDataAction(Settings settings, RestController controller, PostDataAction.TransportAction transportPostDataAction) {
|
||||
public RestPostDataAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportPostDataAction = transportPostDataAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_data", this);
|
||||
}
|
||||
@ -43,6 +40,6 @@ public class RestPostDataAction extends BaseRestHandler {
|
||||
request.setResetEnd(restRequest.param(PostDataAction.Request.RESET_END.getPreferredName(), DEFAULT_RESET_END));
|
||||
request.setContent(restRequest.content());
|
||||
|
||||
return channel -> transportPostDataAction.execute(request, new RestStatusToXContentListener<>(channel));
|
||||
return channel -> client.execute(PostDataAction.INSTANCE, request, new RestStatusToXContentListener<>(channel));
|
||||
}
|
||||
}
|
@ -21,12 +21,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestPutJobAction extends BaseRestHandler {
|
||||
|
||||
private final PutJobAction.TransportAction transportPutJobAction;
|
||||
|
||||
@Inject
|
||||
public RestPutJobAction(Settings settings, RestController controller, PutJobAction.TransportAction transportPutJobAction) {
|
||||
public RestPutJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportPutJobAction = transportPutJobAction;
|
||||
controller.registerHandler(RestRequest.Method.PUT,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
@ -38,7 +35,7 @@ public class RestPutJobAction extends BaseRestHandler {
|
||||
PutJobAction.Request putJobRequest = PutJobAction.Request.parseRequest(jobId, parser);
|
||||
boolean overwrite = restRequest.paramAsBoolean("overwrite", false);
|
||||
putJobRequest.setOverwrite(overwrite);
|
||||
return channel -> transportPutJobAction.execute(putJobRequest, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(PutJobAction.INSTANCE, putJobRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,12 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestDeleteListAction extends BaseRestHandler {
|
||||
|
||||
private final DeleteListAction.TransportAction transportAction;
|
||||
|
||||
@Inject
|
||||
public RestDeleteListAction(Settings settings, RestController controller, DeleteListAction.TransportAction transportAction) {
|
||||
public RestDeleteListAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.DELETE,
|
||||
MlPlugin.BASE_PATH + "lists/{" + Request.LIST_ID.getPreferredName() + "}", this);
|
||||
}
|
||||
@ -33,7 +30,7 @@ public class RestDeleteListAction extends BaseRestHandler {
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
Request request = new Request(restRequest.param(Request.LIST_ID.getPreferredName()));
|
||||
return channel -> transportAction.execute(request, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(DeleteListAction.INSTANCE, request, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,12 +22,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetListAction extends BaseRestHandler {
|
||||
|
||||
private final GetListAction.TransportAction transportGetListAction;
|
||||
|
||||
@Inject
|
||||
public RestGetListAction(Settings settings, RestController controller, GetListAction.TransportAction transportGetListAction) {
|
||||
public RestGetListAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportGetListAction = transportGetListAction;
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "lists/{" + ListDocument.ID.getPreferredName() + "}",
|
||||
this);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "lists/", this);
|
||||
@ -46,7 +43,7 @@ public class RestGetListAction extends BaseRestHandler {
|
||||
getListRequest.setPageParams(new PageParams(restRequest.paramAsInt(PageParams.FROM.getPreferredName(), PageParams.DEFAULT_FROM),
|
||||
restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), PageParams.DEFAULT_SIZE)));
|
||||
}
|
||||
return channel -> transportGetListAction.execute(getListRequest, new RestStatusToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetListAction.INSTANCE, getListRequest, new RestStatusToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,12 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestPutListAction extends BaseRestHandler {
|
||||
|
||||
private final PutListAction.TransportAction transportCreateListAction;
|
||||
|
||||
@Inject
|
||||
public RestPutListAction(Settings settings, RestController controller, PutListAction.TransportAction transportCreateListAction) {
|
||||
public RestPutListAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportCreateListAction = transportCreateListAction;
|
||||
controller.registerHandler(RestRequest.Method.PUT, MlPlugin.BASE_PATH + "lists", this);
|
||||
}
|
||||
|
||||
@ -33,7 +30,7 @@ public class RestPutListAction extends BaseRestHandler {
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
XContentParser parser = restRequest.contentOrSourceParamParser();
|
||||
PutListAction.Request putListRequest = PutListAction.Request.parseRequest(parser);
|
||||
return channel -> transportCreateListAction.execute(putListRequest, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(PutListAction.INSTANCE, putListRequest, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,13 +21,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestDeleteModelSnapshotAction extends BaseRestHandler {
|
||||
|
||||
private final DeleteModelSnapshotAction.TransportAction transportAction;
|
||||
|
||||
@Inject
|
||||
public RestDeleteModelSnapshotAction(Settings settings, RestController controller,
|
||||
DeleteModelSnapshotAction.TransportAction transportAction) {
|
||||
public RestDeleteModelSnapshotAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots/{" + ModelSnapshot.SNAPSHOT_ID.getPreferredName() + "}", this);
|
||||
}
|
||||
@ -38,6 +34,6 @@ public class RestDeleteModelSnapshotAction extends BaseRestHandler {
|
||||
restRequest.param(Job.ID.getPreferredName()),
|
||||
restRequest.param(ModelSnapshot.SNAPSHOT_ID.getPreferredName()));
|
||||
|
||||
return channel -> transportAction.execute(deleteModelSnapshot, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(DeleteModelSnapshotAction.INSTANCE, deleteModelSnapshot, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,9 @@ public class RestGetModelSnapshotsAction extends BaseRestHandler {
|
||||
private final String DEFAULT_DESCRIPTION = null;
|
||||
private final boolean DEFAULT_DESC_ORDER = true;
|
||||
|
||||
private final GetModelSnapshotsAction.TransportAction transportGetModelSnapshotsAction;
|
||||
|
||||
@Inject
|
||||
public RestGetModelSnapshotsAction(Settings settings, RestController controller,
|
||||
GetModelSnapshotsAction.TransportAction transportGetModelSnapshotsAction) {
|
||||
public RestGetModelSnapshotsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportGetModelSnapshotsAction = transportGetModelSnapshotsAction;
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots/", this);
|
||||
// endpoints that support body parameters must also accept POST
|
||||
@ -70,6 +66,6 @@ public class RestGetModelSnapshotsAction extends BaseRestHandler {
|
||||
restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), PageParams.DEFAULT_SIZE)));
|
||||
}
|
||||
|
||||
return channel -> transportGetModelSnapshotsAction.execute(getModelSnapshots, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetModelSnapshotsAction.INSTANCE, getModelSnapshots, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -21,18 +21,14 @@ import java.io.IOException;
|
||||
|
||||
public class RestRevertModelSnapshotAction extends BaseRestHandler {
|
||||
|
||||
private final RevertModelSnapshotAction.TransportAction transportAction;
|
||||
|
||||
private final String TIME_DEFAULT = null;
|
||||
private final String SNAPSHOT_ID_DEFAULT = null;
|
||||
private final String DESCRIPTION_DEFAULT = null;
|
||||
private final boolean DELETE_INTERVENING_DEFAULT = false;
|
||||
|
||||
@Inject
|
||||
public RestRevertModelSnapshotAction(Settings settings, RestController controller,
|
||||
RevertModelSnapshotAction.TransportAction transportAction) {
|
||||
public RestRevertModelSnapshotAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/model_snapshots/_revert",
|
||||
this);
|
||||
@ -54,6 +50,6 @@ public class RestRevertModelSnapshotAction extends BaseRestHandler {
|
||||
request.setDeleteInterveningResults(restRequest
|
||||
.paramAsBoolean(RevertModelSnapshotAction.Request.DELETE_INTERVENING.getPreferredName(), DELETE_INTERVENING_DEFAULT));
|
||||
}
|
||||
return channel -> transportAction.execute(request, new RestStatusToXContentListener<>(channel));
|
||||
return channel -> client.execute(RevertModelSnapshotAction.INSTANCE, request, new RestStatusToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -22,14 +22,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestUpdateModelSnapshotAction extends BaseRestHandler {
|
||||
|
||||
private final UpdateModelSnapshotAction.TransportAction transportAction;
|
||||
|
||||
@Inject
|
||||
public RestUpdateModelSnapshotAction(Settings settings, RestController controller,
|
||||
UpdateModelSnapshotAction.TransportAction transportAction) {
|
||||
public RestUpdateModelSnapshotAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots/{" + ModelSnapshot.SNAPSHOT_ID +"}/_update",
|
||||
this);
|
||||
@ -43,6 +38,7 @@ public class RestUpdateModelSnapshotAction extends BaseRestHandler {
|
||||
restRequest.param(ModelSnapshot.SNAPSHOT_ID.getPreferredName()),
|
||||
parser);
|
||||
|
||||
return channel -> transportAction.execute(getModelSnapshots, new RestStatusToXContentListener<>(channel));
|
||||
return channel ->
|
||||
client.execute(UpdateModelSnapshotAction.INSTANCE, getModelSnapshots, new RestStatusToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetBucketsAction extends BaseRestHandler {
|
||||
|
||||
private final GetBucketsAction.TransportAction transportAction;
|
||||
|
||||
@Inject
|
||||
public RestGetBucketsAction(Settings settings, RestController controller, GetBucketsAction.TransportAction transportAction) {
|
||||
public RestGetBucketsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName()
|
||||
+ "}/results/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
|
||||
@ -90,6 +87,6 @@ public class RestGetBucketsAction extends BaseRestHandler {
|
||||
request.setIncludeInterim(restRequest.paramAsBoolean(GetBucketsAction.Request.INCLUDE_INTERIM.getPreferredName(), false));
|
||||
}
|
||||
|
||||
return channel -> transportAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetBucketsAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetCategoriesAction extends BaseRestHandler {
|
||||
|
||||
private final GetCategoriesDefinitionAction.TransportAction transportAction;
|
||||
|
||||
@Inject
|
||||
public RestGetCategoriesAction(Settings settings, RestController controller,
|
||||
GetCategoriesDefinitionAction.TransportAction transportAction) {
|
||||
public RestGetCategoriesAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categorydefinitions/{"
|
||||
+ Request.CATEGORY_ID.getPreferredName() + "}", this);
|
||||
@ -73,7 +69,7 @@ public class RestGetCategoriesAction extends BaseRestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return channel -> transportAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetCategoriesDefinitionAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,12 +23,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetInfluencersAction extends BaseRestHandler {
|
||||
|
||||
private final GetInfluencersAction.TransportAction transportAction;
|
||||
|
||||
@Inject
|
||||
public RestGetInfluencersAction(Settings settings, RestController controller, GetInfluencersAction.TransportAction transportAction) {
|
||||
public RestGetInfluencersAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", this);
|
||||
// endpoints that support body parameters must also accept POST
|
||||
@ -59,6 +56,6 @@ public class RestGetInfluencersAction extends BaseRestHandler {
|
||||
request.setDecending(restRequest.paramAsBoolean(GetInfluencersAction.Request.DESCENDING_SORT.getPreferredName(), true));
|
||||
}
|
||||
|
||||
return channel -> transportAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetInfluencersAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetRecordsAction extends BaseRestHandler {
|
||||
|
||||
private final GetRecordsAction.TransportAction transportAction;
|
||||
|
||||
@Inject
|
||||
public RestGetRecordsAction(Settings settings, RestController controller, GetRecordsAction.TransportAction transportAction) {
|
||||
public RestGetRecordsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportAction = transportAction;
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/results/records", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
@ -63,6 +60,6 @@ public class RestGetRecordsAction extends BaseRestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return channel -> transportAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetRecordsAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestDeleteSchedulerAction extends BaseRestHandler {
|
||||
|
||||
private final DeleteSchedulerAction.TransportAction transportDeleteSchedulerAction;
|
||||
|
||||
@Inject
|
||||
public RestDeleteSchedulerAction(Settings settings, RestController controller,
|
||||
DeleteSchedulerAction.TransportAction transportDeleteSchedulerAction) {
|
||||
public RestDeleteSchedulerAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportDeleteSchedulerAction = transportDeleteSchedulerAction;
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MlPlugin.BASE_PATH + "schedulers/{"
|
||||
+ SchedulerConfig.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
@ -35,7 +31,7 @@ public class RestDeleteSchedulerAction extends BaseRestHandler {
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
String schedulerId = restRequest.param(SchedulerConfig.ID.getPreferredName());
|
||||
DeleteSchedulerAction.Request deleteSchedulerRequest = new DeleteSchedulerAction.Request(schedulerId);
|
||||
return channel -> transportDeleteSchedulerAction.execute(deleteSchedulerRequest, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(DeleteSchedulerAction.INSTANCE, deleteSchedulerRequest, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,14 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetSchedulersAction extends BaseRestHandler {
|
||||
|
||||
private final GetSchedulersAction.TransportAction transportGetSchedulersAction;
|
||||
|
||||
@Inject
|
||||
public RestGetSchedulersAction(Settings settings, RestController controller,
|
||||
GetSchedulersAction.TransportAction transportGetSchedulersAction) {
|
||||
public RestGetSchedulersAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportGetSchedulersAction = transportGetSchedulersAction;
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
+ "schedulers/{" + SchedulerConfig.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
@ -35,6 +30,6 @@ public class RestGetSchedulersAction extends BaseRestHandler {
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
GetSchedulersAction.Request request = new GetSchedulersAction.Request(restRequest.param(SchedulerConfig.ID.getPreferredName()));
|
||||
return channel -> transportGetSchedulersAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetSchedulersAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestGetSchedulersStatsAction extends BaseRestHandler {
|
||||
|
||||
private final GetSchedulersStatsAction.TransportAction transportGetSchedulersStatsAction;
|
||||
|
||||
@Inject
|
||||
public RestGetSchedulersStatsAction(Settings settings, RestController controller,
|
||||
GetSchedulersStatsAction.TransportAction transportGetSchedulersStatsAction) {
|
||||
public RestGetSchedulersStatsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportGetSchedulersStatsAction = transportGetSchedulersStatsAction;
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
+ "schedulers/{" + SchedulerConfig.ID.getPreferredName() + "}/_stats", this);
|
||||
}
|
||||
@ -36,6 +31,6 @@ public class RestGetSchedulersStatsAction extends BaseRestHandler {
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
GetSchedulersStatsAction.Request request = new GetSchedulersStatsAction.Request(
|
||||
restRequest.param(SchedulerConfig.ID.getPreferredName()));
|
||||
return channel -> transportGetSchedulersStatsAction.execute(request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(GetSchedulersStatsAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestPutSchedulerAction extends BaseRestHandler {
|
||||
|
||||
private final PutSchedulerAction.TransportAction transportPutSchedulerAction;
|
||||
|
||||
@Inject
|
||||
public RestPutSchedulerAction(Settings settings, RestController controller,
|
||||
PutSchedulerAction.TransportAction transportPutSchedulerAction) {
|
||||
public RestPutSchedulerAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportPutSchedulerAction = transportPutSchedulerAction;
|
||||
controller.registerHandler(RestRequest.Method.PUT, MlPlugin.BASE_PATH + "schedulers/{"
|
||||
+ SchedulerConfig.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
@ -37,7 +33,7 @@ public class RestPutSchedulerAction extends BaseRestHandler {
|
||||
String schedulerId = restRequest.param(SchedulerConfig.ID.getPreferredName());
|
||||
XContentParser parser = restRequest.contentParser();
|
||||
PutSchedulerAction.Request putSchedulerRequest = PutSchedulerAction.Request.parseRequest(schedulerId, parser);
|
||||
return channel -> transportPutSchedulerAction.execute(putSchedulerRequest, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(PutSchedulerAction.INSTANCE, putSchedulerRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,13 +21,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestStopSchedulerAction extends BaseRestHandler {
|
||||
|
||||
private final StopSchedulerAction.TransportAction transportJobSchedulerAction;
|
||||
|
||||
@Inject
|
||||
public RestStopSchedulerAction(Settings settings, RestController controller,
|
||||
StopSchedulerAction.TransportAction transportJobSchedulerAction) {
|
||||
public RestStopSchedulerAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportJobSchedulerAction = transportJobSchedulerAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "schedulers/{"
|
||||
+ SchedulerConfig.ID.getPreferredName() + "}/_stop", this);
|
||||
}
|
||||
@ -39,6 +35,6 @@ public class RestStopSchedulerAction extends BaseRestHandler {
|
||||
if (restRequest.hasParam("stop_timeout")) {
|
||||
jobSchedulerRequest.setStopTimeout(TimeValue.parseTimeValue(restRequest.param("stop_timeout"), "stop_timeout"));
|
||||
}
|
||||
return channel -> transportJobSchedulerAction.execute(jobSchedulerRequest, new AcknowledgedRestListener<>(channel));
|
||||
return channel -> client.execute(StopSchedulerAction.INSTANCE, jobSchedulerRequest, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestValidateDetectorAction extends BaseRestHandler {
|
||||
|
||||
private ValidateDetectorAction.TransportAction transportValidateAction;
|
||||
|
||||
@Inject
|
||||
public RestValidateDetectorAction(Settings settings, RestController controller,
|
||||
ValidateDetectorAction.TransportAction transportValidateAction) {
|
||||
public RestValidateDetectorAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportValidateAction = transportValidateAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "_validate/detector", this);
|
||||
}
|
||||
|
||||
@ -34,8 +30,8 @@ public class RestValidateDetectorAction extends BaseRestHandler {
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
XContentParser parser = restRequest.contentOrSourceParamParser();
|
||||
ValidateDetectorAction.Request validateDetectorRequest = ValidateDetectorAction.Request.parseRequest(parser);
|
||||
return channel -> transportValidateAction.execute(validateDetectorRequest,
|
||||
new AcknowledgedRestListener<ValidateDetectorAction.Response>(channel));
|
||||
return channel ->
|
||||
client.execute(ValidateDetectorAction.INSTANCE, validateDetectorRequest, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,13 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestValidateTransformAction extends BaseRestHandler {
|
||||
|
||||
private ValidateTransformAction.TransportAction transportValidateAction;
|
||||
|
||||
@Inject
|
||||
public RestValidateTransformAction(Settings settings, RestController controller,
|
||||
ValidateTransformAction.TransportAction transportValidateAction) {
|
||||
public RestValidateTransformAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportValidateAction = transportValidateAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "_validate/transform", this);
|
||||
}
|
||||
|
||||
@ -34,8 +30,8 @@ public class RestValidateTransformAction extends BaseRestHandler {
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
XContentParser parser = restRequest.contentOrSourceParamParser();
|
||||
ValidateTransformAction.Request validateDetectorRequest = ValidateTransformAction.Request.parseRequest(parser);
|
||||
return channel -> transportValidateAction.execute(validateDetectorRequest,
|
||||
new AcknowledgedRestListener<ValidateTransformAction.Response>(channel));
|
||||
return channel ->
|
||||
client.execute(ValidateTransformAction.INSTANCE, validateDetectorRequest, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,13 +20,9 @@ import java.io.IOException;
|
||||
|
||||
public class RestValidateTransformsAction extends BaseRestHandler {
|
||||
|
||||
private ValidateTransformsAction.TransportAction transportValidateAction;
|
||||
|
||||
@Inject
|
||||
public RestValidateTransformsAction(Settings settings, RestController controller,
|
||||
ValidateTransformsAction.TransportAction transportValidateAction) {
|
||||
public RestValidateTransformsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
this.transportValidateAction = transportValidateAction;
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "_validate/transforms", this);
|
||||
}
|
||||
|
||||
@ -34,7 +30,8 @@ public class RestValidateTransformsAction extends BaseRestHandler {
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
|
||||
XContentParser parser = restRequest.contentOrSourceParamParser();
|
||||
ValidateTransformsAction.Request validateDetectorRequest = ValidateTransformsAction.Request.PARSER.apply(parser, null);
|
||||
return channel -> transportValidateAction.execute(validateDetectorRequest, new AcknowledgedRestListener<>(channel));
|
||||
return channel ->
|
||||
client.execute(ValidateTransformsAction.INSTANCE, validateDetectorRequest, new AcknowledgedRestListener<>(channel));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user