Re-pluralize Endpoints :) (elastic/elasticsearch#363)

Putting the various endpoints back to their plural form (and adjusting Java class names as necessary).

Original commit: elastic/x-pack-elasticsearch@5c8f3c7341
This commit is contained in:
Zachary Tong 2016-11-23 10:34:49 -05:00 committed by GitHub
parent b11e5dbf4a
commit 4dc20467cb
24 changed files with 126 additions and 126 deletions

View File

@ -29,10 +29,10 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.elasticsearch.xpack.prelert.action.DeleteJobAction;
import org.elasticsearch.xpack.prelert.action.DeleteModelSnapshotAction;
import org.elasticsearch.xpack.prelert.action.GetBucketAction;
import org.elasticsearch.xpack.prelert.action.GetCategoryDefinitionAction;
import org.elasticsearch.xpack.prelert.action.GetBucketsAction;
import org.elasticsearch.xpack.prelert.action.GetCategoriesDefinitionAction;
import org.elasticsearch.xpack.prelert.action.GetInfluencersAction;
import org.elasticsearch.xpack.prelert.action.GetJobAction;
import org.elasticsearch.xpack.prelert.action.GetJobsAction;
import org.elasticsearch.xpack.prelert.action.GetListAction;
import org.elasticsearch.xpack.prelert.action.GetModelSnapshotsAction;
import org.elasticsearch.xpack.prelert.action.GetRecordsAction;
@ -76,7 +76,7 @@ import org.elasticsearch.xpack.prelert.rest.data.RestPostDataCloseAction;
import org.elasticsearch.xpack.prelert.rest.data.RestPostDataFlushAction;
import org.elasticsearch.xpack.prelert.rest.influencers.RestGetInfluencersAction;
import org.elasticsearch.xpack.prelert.rest.job.RestDeleteJobAction;
import org.elasticsearch.xpack.prelert.rest.job.RestGetJobAction;
import org.elasticsearch.xpack.prelert.rest.job.RestGetJobsAction;
import org.elasticsearch.xpack.prelert.rest.job.RestPauseJobAction;
import org.elasticsearch.xpack.prelert.rest.job.RestPutJobsAction;
import org.elasticsearch.xpack.prelert.rest.job.RestResumeJobAction;
@ -86,8 +86,8 @@ import org.elasticsearch.xpack.prelert.rest.modelsnapshots.RestDeleteModelSnapsh
import org.elasticsearch.xpack.prelert.rest.modelsnapshots.RestGetModelSnapshotsAction;
import org.elasticsearch.xpack.prelert.rest.modelsnapshots.RestPutModelSnapshotDescriptionAction;
import org.elasticsearch.xpack.prelert.rest.modelsnapshots.RestRevertModelSnapshotAction;
import org.elasticsearch.xpack.prelert.rest.results.RestGetBucketAction;
import org.elasticsearch.xpack.prelert.rest.results.RestGetCategoryAction;
import org.elasticsearch.xpack.prelert.rest.results.RestGetBucketsAction;
import org.elasticsearch.xpack.prelert.rest.results.RestGetCategoriesAction;
import org.elasticsearch.xpack.prelert.rest.results.RestGetRecordsAction;
import org.elasticsearch.xpack.prelert.rest.schedulers.RestStartJobSchedulerAction;
import org.elasticsearch.xpack.prelert.rest.schedulers.RestStopJobSchedulerAction;
@ -184,7 +184,7 @@ public class PrelertPlugin extends Plugin implements ActionPlugin {
@Override
public List<Class<? extends RestHandler>> getRestHandlers() {
return Arrays.asList(
RestGetJobAction.class,
RestGetJobsAction.class,
RestPutJobsAction.class,
RestDeleteJobAction.class,
RestPauseJobAction.class,
@ -193,14 +193,14 @@ public class PrelertPlugin extends Plugin implements ActionPlugin {
RestPutListAction.class,
RestGetInfluencersAction.class,
RestGetRecordsAction.class,
RestGetBucketAction.class,
RestGetBucketsAction.class,
RestPostDataAction.class,
RestPostDataCloseAction.class,
RestPostDataFlushAction.class,
RestValidateDetectorAction.class,
RestValidateTransformAction.class,
RestValidateTransformsAction.class,
RestGetCategoryAction.class,
RestGetCategoriesAction.class,
RestGetModelSnapshotsAction.class,
RestRevertModelSnapshotAction.class,
RestPutModelSnapshotDescriptionAction.class,
@ -213,7 +213,7 @@ public class PrelertPlugin extends Plugin implements ActionPlugin {
@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return Arrays.asList(
new ActionHandler<>(GetJobAction.INSTANCE, GetJobAction.TransportAction.class),
new ActionHandler<>(GetJobsAction.INSTANCE, GetJobsAction.TransportAction.class),
new ActionHandler<>(PutJobAction.INSTANCE, PutJobAction.TransportAction.class),
new ActionHandler<>(DeleteJobAction.INSTANCE, DeleteJobAction.TransportAction.class),
new ActionHandler<>(PauseJobAction.INSTANCE, PauseJobAction.TransportAction.class),
@ -222,7 +222,7 @@ public class PrelertPlugin extends Plugin implements ActionPlugin {
new ActionHandler<>(UpdateJobSchedulerStatusAction.INSTANCE, UpdateJobSchedulerStatusAction.TransportAction.class),
new ActionHandler<>(GetListAction.INSTANCE, GetListAction.TransportAction.class),
new ActionHandler<>(PutListAction.INSTANCE, PutListAction.TransportAction.class),
new ActionHandler<>(GetBucketAction.INSTANCE, GetBucketAction.TransportAction.class),
new ActionHandler<>(GetBucketsAction.INSTANCE, GetBucketsAction.TransportAction.class),
new ActionHandler<>(GetInfluencersAction.INSTANCE, GetInfluencersAction.TransportAction.class),
new ActionHandler<>(GetRecordsAction.INSTANCE, GetRecordsAction.TransportAction.class),
new ActionHandler<>(PostDataAction.INSTANCE, PostDataAction.TransportAction.class),
@ -231,7 +231,7 @@ public class PrelertPlugin extends Plugin implements ActionPlugin {
new ActionHandler<>(ValidateDetectorAction.INSTANCE, ValidateDetectorAction.TransportAction.class),
new ActionHandler<>(ValidateTransformAction.INSTANCE, ValidateTransformAction.TransportAction.class),
new ActionHandler<>(ValidateTransformsAction.INSTANCE, ValidateTransformsAction.TransportAction.class),
new ActionHandler<>(GetCategoryDefinitionAction.INSTANCE, GetCategoryDefinitionAction.TransportAction.class),
new ActionHandler<>(GetCategoriesDefinitionAction.INSTANCE, GetCategoriesDefinitionAction.TransportAction.class),
new ActionHandler<>(GetModelSnapshotsAction.INSTANCE, GetModelSnapshotsAction.TransportAction.class),
new ActionHandler<>(RevertModelSnapshotAction.INSTANCE, RevertModelSnapshotAction.TransportAction.class),
new ActionHandler<>(PutModelSnapshotDescriptionAction.INSTANCE, PutModelSnapshotDescriptionAction.TransportAction.class),

View File

@ -45,12 +45,12 @@ import java.util.Objects;
import static org.elasticsearch.action.ValidateActions.addValidationError;
public class GetBucketAction extends Action<GetBucketAction.Request, GetBucketAction.Response, GetBucketAction.RequestBuilder> {
public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucketsAction.Response, GetBucketsAction.RequestBuilder> {
public static final GetBucketAction INSTANCE = new GetBucketAction();
public static final String NAME = "indices:admin/prelert/results/bucket/get";
public static final GetBucketsAction INSTANCE = new GetBucketsAction();
public static final String NAME = "indices:admin/prelert/results/buckets/get";
private GetBucketAction() {
private GetBucketsAction() {
super(NAME);
}

View File

@ -35,13 +35,13 @@ import org.elasticsearch.xpack.prelert.utils.ExceptionsHelper;
import java.io.IOException;
import java.util.Objects;
public class GetCategoryDefinitionAction extends
Action<GetCategoryDefinitionAction.Request, GetCategoryDefinitionAction.Response, GetCategoryDefinitionAction.RequestBuilder> {
public class GetCategoriesDefinitionAction extends
Action<GetCategoriesDefinitionAction.Request, GetCategoriesDefinitionAction.Response, GetCategoriesDefinitionAction.RequestBuilder> {
public static final GetCategoryDefinitionAction INSTANCE = new GetCategoryDefinitionAction();
private static final String NAME = "cluster:admin/prelert/categorydefinition/get";
public static final GetCategoriesDefinitionAction INSTANCE = new GetCategoriesDefinitionAction();
private static final String NAME = "cluster:admin/prelert/categorydefinitions/get";
private GetCategoryDefinitionAction() {
private GetCategoriesDefinitionAction() {
super(NAME);
}
@ -129,7 +129,7 @@ Action<GetCategoryDefinitionAction.Request, GetCategoryDefinitionAction.Response
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder> {
public RequestBuilder(ElasticsearchClient client, GetCategoryDefinitionAction action) {
public RequestBuilder(ElasticsearchClient client, GetCategoriesDefinitionAction action) {
super(client, action, new Request());
}
}

View File

@ -57,12 +57,12 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
public class GetJobAction extends Action<GetJobAction.Request, GetJobAction.Response, GetJobAction.RequestBuilder> {
public class GetJobsAction extends Action<GetJobsAction.Request, GetJobsAction.Response, GetJobsAction.RequestBuilder> {
public static final GetJobAction INSTANCE = new GetJobAction();
public static final String NAME = "cluster:admin/prelert/job/get";
public static final GetJobsAction INSTANCE = new GetJobsAction();
public static final String NAME = "cluster:admin/prelert/jobs/get";
private GetJobAction() {
private GetJobsAction() {
super(NAME);
}
@ -238,7 +238,7 @@ public class GetJobAction extends Action<GetJobAction.Request, GetJobAction.Resp
public static class RequestBuilder extends MasterNodeReadOperationRequestBuilder<Request, Response, RequestBuilder> {
public RequestBuilder(ElasticsearchClient client, GetJobAction action) {
public RequestBuilder(ElasticsearchClient client, GetJobsAction action) {
super(client, action, new Request());
}
}
@ -409,7 +409,7 @@ public class GetJobAction extends Action<GetJobAction.Request, GetJobAction.Resp
public TransportAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
JobManager jobManager, AutodetectProcessManager processManager, ElasticsearchJobProvider jobProvider) {
super(settings, GetJobAction.NAME, transportService, clusterService, threadPool, actionFilters,
super(settings, GetJobsAction.NAME, transportService, clusterService, threadPool, actionFilters,
indexNameExpressionResolver, Request::new);
this.jobManager = jobManager;
this.processManager = processManager;

View File

@ -18,21 +18,21 @@ import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestActions;
import org.elasticsearch.rest.action.RestStatusToXContentListener;
import org.elasticsearch.xpack.prelert.PrelertPlugin;
import org.elasticsearch.xpack.prelert.action.GetJobAction;
import org.elasticsearch.xpack.prelert.action.GetJobsAction;
import org.elasticsearch.xpack.prelert.job.Job;
import org.elasticsearch.xpack.prelert.job.results.PageParams;
import java.io.IOException;
import java.util.Set;
public class RestGetJobAction extends BaseRestHandler {
public class RestGetJobsAction extends BaseRestHandler {
private static final int DEFAULT_FROM = 0;
private static final int DEFAULT_SIZE = 100;
private final GetJobAction.TransportAction transportGetJobAction;
private final GetJobsAction.TransportAction transportGetJobAction;
@Inject
public RestGetJobAction(Settings settings, RestController controller, GetJobAction.TransportAction transportGetJobAction) {
public RestGetJobsAction(Settings settings, RestController controller, GetJobsAction.TransportAction transportGetJobAction) {
super(settings);
this.transportGetJobAction = transportGetJobAction;
@ -51,16 +51,16 @@ public class RestGetJobAction extends BaseRestHandler {
@Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
final GetJobAction.Request request;
final GetJobsAction.Request request;
if (RestActions.hasBodyContent(restRequest)) {
BytesReference bodyBytes = RestActions.getRestContent(restRequest);
XContentParser parser = XContentFactory.xContent(bodyBytes).createParser(bodyBytes);
request = GetJobAction.Request.PARSER.apply(parser, () -> parseFieldMatcher);
request = GetJobsAction.Request.PARSER.apply(parser, () -> parseFieldMatcher);
} else {
request = new GetJobAction.Request();
request = new GetJobsAction.Request();
request.setJobId(restRequest.param(Job.ID.getPreferredName()));
Set<String> stats = Strings.splitStringByCommaToSet(
restRequest.param(GetJobAction.Request.METRIC.getPreferredName(), "config"));
restRequest.param(GetJobsAction.Request.METRIC.getPreferredName(), "config"));
request.setStats(stats);
request.setPageParams(new PageParams(restRequest.paramAsInt(PageParams.FROM.getPreferredName(), DEFAULT_FROM),
restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), DEFAULT_SIZE)));

View File

@ -16,53 +16,53 @@ import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestStatusToXContentListener;
import org.elasticsearch.xpack.prelert.PrelertPlugin;
import org.elasticsearch.xpack.prelert.action.GetBucketAction;
import org.elasticsearch.xpack.prelert.action.GetBucketsAction;
import org.elasticsearch.xpack.prelert.job.Job;
import org.elasticsearch.xpack.prelert.job.results.Bucket;
import org.elasticsearch.xpack.prelert.job.results.PageParams;
import java.io.IOException;
public class RestGetBucketAction extends BaseRestHandler {
public class RestGetBucketsAction extends BaseRestHandler {
private final GetBucketAction.TransportAction transportAction;
private final GetBucketsAction.TransportAction transportAction;
@Inject
public RestGetBucketAction(Settings settings, RestController controller, GetBucketAction.TransportAction transportAction) {
public RestGetBucketsAction(Settings settings, RestController controller, GetBucketsAction.TransportAction transportAction) {
super(settings);
this.transportAction = transportAction;
controller.registerHandler(RestRequest.Method.GET,
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName()
+ "}/bucket/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
+ "}/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
controller.registerHandler(RestRequest.Method.POST,
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName()
+ "}/bucket/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
+ "}/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
controller.registerHandler(RestRequest.Method.GET,
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/bucket", this);
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/buckets", this);
controller.registerHandler(RestRequest.Method.POST,
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/bucket", this);
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/buckets", this);
}
@Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
String jobId = restRequest.param(Job.ID.getPreferredName());
BytesReference bodyBytes = restRequest.content();
final GetBucketAction.Request request;
final GetBucketsAction.Request request;
if (bodyBytes != null && bodyBytes.length() > 0) {
XContentParser parser = XContentFactory.xContent(bodyBytes).createParser(bodyBytes);
request = GetBucketAction.Request.parseRequest(jobId, parser, () -> parseFieldMatcher);
request = GetBucketsAction.Request.parseRequest(jobId, parser, () -> parseFieldMatcher);
} else {
request = new GetBucketAction.Request(jobId);
String timestamp = restRequest.param(GetBucketAction.Request.TIMESTAMP.getPreferredName());
String start = restRequest.param(GetBucketAction.Request.START.getPreferredName());
String end = restRequest.param(GetBucketAction.Request.END.getPreferredName());
request = new GetBucketsAction.Request(jobId);
String timestamp = restRequest.param(GetBucketsAction.Request.TIMESTAMP.getPreferredName());
String start = restRequest.param(GetBucketsAction.Request.START.getPreferredName());
String end = restRequest.param(GetBucketsAction.Request.END.getPreferredName());
// Single bucket
if (timestamp != null && !timestamp.isEmpty()) {
request.setTimestamp(timestamp);
request.setExpand(restRequest.paramAsBoolean(GetBucketAction.Request.EXPAND.getPreferredName(), false));
request.setIncludeInterim(restRequest.paramAsBoolean(GetBucketAction.Request.INCLUDE_INTERIM.getPreferredName(), false));
request.setExpand(restRequest.paramAsBoolean(GetBucketsAction.Request.EXPAND.getPreferredName(), false));
request.setIncludeInterim(restRequest.paramAsBoolean(GetBucketsAction.Request.INCLUDE_INTERIM.getPreferredName(), false));
} else if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
// Multiple buckets
request.setStart(start);
@ -70,20 +70,20 @@ public class RestGetBucketAction extends BaseRestHandler {
request.setPageParams(new PageParams(restRequest.paramAsInt(PageParams.FROM.getPreferredName(), 0),
restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), 100)));
request.setAnomalyScore(
Double.parseDouble(restRequest.param(GetBucketAction.Request.ANOMALY_SCORE.getPreferredName(), "0.0")));
Double.parseDouble(restRequest.param(GetBucketsAction.Request.ANOMALY_SCORE.getPreferredName(), "0.0")));
request.setMaxNormalizedProbability(
Double.parseDouble(restRequest.param(
GetBucketAction.Request.MAX_NORMALIZED_PROBABILITY.getPreferredName(), "0.0")));
if (restRequest.hasParam(GetBucketAction.Request.PARTITION_VALUE.getPreferredName())) {
request.setPartitionValue(restRequest.param(GetBucketAction.Request.PARTITION_VALUE.getPreferredName()));
GetBucketsAction.Request.MAX_NORMALIZED_PROBABILITY.getPreferredName(), "0.0")));
if (restRequest.hasParam(GetBucketsAction.Request.PARTITION_VALUE.getPreferredName())) {
request.setPartitionValue(restRequest.param(GetBucketsAction.Request.PARTITION_VALUE.getPreferredName()));
}
} else {
throw new IllegalArgumentException("Either [timestamp] or [start, end] parameters must be set.");
}
// Common options
request.setExpand(restRequest.paramAsBoolean(GetBucketAction.Request.EXPAND.getPreferredName(), false));
request.setIncludeInterim(restRequest.paramAsBoolean(GetBucketAction.Request.INCLUDE_INTERIM.getPreferredName(), false));
request.setExpand(restRequest.paramAsBoolean(GetBucketsAction.Request.EXPAND.getPreferredName(), false));
request.setIncludeInterim(restRequest.paramAsBoolean(GetBucketsAction.Request.INCLUDE_INTERIM.getPreferredName(), false));
}
return channel -> transportAction.execute(request, new RestStatusToXContentListener<>(channel));

View File

@ -13,26 +13,26 @@ import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
import org.elasticsearch.xpack.prelert.PrelertPlugin;
import org.elasticsearch.xpack.prelert.action.GetCategoryDefinitionAction;
import org.elasticsearch.xpack.prelert.action.GetCategoryDefinitionAction.Request;
import org.elasticsearch.xpack.prelert.action.GetCategoriesDefinitionAction;
import org.elasticsearch.xpack.prelert.action.GetCategoriesDefinitionAction.Request;
import org.elasticsearch.xpack.prelert.job.Job;
import org.elasticsearch.xpack.prelert.job.results.PageParams;
import java.io.IOException;
public class RestGetCategoryAction extends BaseRestHandler {
public class RestGetCategoriesAction extends BaseRestHandler {
private final GetCategoryDefinitionAction.TransportAction transportAction;
private final GetCategoriesDefinitionAction.TransportAction transportAction;
@Inject
public RestGetCategoryAction(Settings settings, RestController controller,
GetCategoryDefinitionAction.TransportAction transportAction) {
public RestGetCategoriesAction(Settings settings, RestController controller,
GetCategoriesDefinitionAction.TransportAction transportAction) {
super(settings);
this.transportAction = transportAction;
controller.registerHandler(RestRequest.Method.GET,
PrelertPlugin.BASE_PATH + "results/{jobId}/categorydefinition/{categoryId}", this);
PrelertPlugin.BASE_PATH + "results/{jobId}/categorydefinitions/{categoryId}", this);
controller.registerHandler(RestRequest.Method.GET,
PrelertPlugin.BASE_PATH + "results/{jobId}/categorydefinition", this);
PrelertPlugin.BASE_PATH + "results/{jobId}/categorydefinitions", this);
}
@Override

View File

@ -7,15 +7,15 @@ package org.elasticsearch.xpack.prelert.action;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.prelert.action.GetBucketAction.Request;
import org.elasticsearch.xpack.prelert.action.GetBucketsAction.Request;
import org.elasticsearch.xpack.prelert.job.results.PageParams;
import org.elasticsearch.xpack.prelert.support.AbstractStreamableXContentTestCase;
public class GetBucketActionRequestTests extends AbstractStreamableXContentTestCase<GetBucketAction.Request> {
public class GetBucketActionRequestTests extends AbstractStreamableXContentTestCase<GetBucketsAction.Request> {
@Override
protected Request createTestInstance() {
GetBucketAction.Request request = new GetBucketAction.Request(randomAsciiOfLengthBetween(1, 20));
GetBucketsAction.Request request = new GetBucketsAction.Request(randomAsciiOfLengthBetween(1, 20));
if (randomBoolean()) {
request.setPartitionValue(randomAsciiOfLengthBetween(1, 20));
}
@ -60,12 +60,12 @@ public class GetBucketActionRequestTests extends AbstractStreamableXContentTestC
@Override
protected Request createBlankInstance() {
return new GetBucketAction.Request();
return new GetBucketsAction.Request();
}
@Override
protected Request parseInstance(XContentParser parser, ParseFieldMatcher matcher) {
return GetBucketAction.Request.parseRequest(null, parser, () -> matcher);
return GetBucketsAction.Request.parseRequest(null, parser, () -> matcher);
}
}

View File

@ -5,7 +5,7 @@
*/
package org.elasticsearch.xpack.prelert.action;
import org.elasticsearch.xpack.prelert.action.GetBucketAction.Response;
import org.elasticsearch.xpack.prelert.action.GetBucketsAction.Response;
import org.elasticsearch.xpack.prelert.job.persistence.QueryPage;
import org.elasticsearch.xpack.prelert.job.results.AnomalyRecord;
import org.elasticsearch.xpack.prelert.job.results.Bucket;
@ -21,7 +21,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GetBucketActionResponseTests extends AbstractStreamableTestCase<GetBucketAction.Response> {
public class GetBucketActionResponseTests extends AbstractStreamableTestCase<GetBucketsAction.Response> {
@Override
protected Response createTestInstance() {
@ -132,7 +132,7 @@ public class GetBucketActionResponseTests extends AbstractStreamableTestCase<Get
@Override
protected Response createBlankInstance() {
return new GetBucketAction.Response();
return new GetBucketsAction.Response();
}
}

View File

@ -8,12 +8,12 @@ package org.elasticsearch.xpack.prelert.action;
import org.elasticsearch.xpack.prelert.job.results.PageParams;
import org.elasticsearch.xpack.prelert.support.AbstractStreamableTestCase;
public class GetCategoryDefinitionRequestTests extends AbstractStreamableTestCase<GetCategoryDefinitionAction.Request> {
public class GetCategoryDefinitionRequestTests extends AbstractStreamableTestCase<GetCategoriesDefinitionAction.Request> {
@Override
protected GetCategoryDefinitionAction.Request createTestInstance() {
protected GetCategoriesDefinitionAction.Request createTestInstance() {
String jobId = randomAsciiOfLength(10);
GetCategoryDefinitionAction.Request request = new GetCategoryDefinitionAction.Request(jobId);
GetCategoriesDefinitionAction.Request request = new GetCategoriesDefinitionAction.Request(jobId);
if (randomBoolean()) {
request.setCategoryId(randomAsciiOfLength(10));
} else {
@ -26,7 +26,7 @@ public class GetCategoryDefinitionRequestTests extends AbstractStreamableTestCas
}
@Override
protected GetCategoryDefinitionAction.Request createBlankInstance() {
return new GetCategoryDefinitionAction.Request();
protected GetCategoriesDefinitionAction.Request createBlankInstance() {
return new GetCategoriesDefinitionAction.Request();
}
}

View File

@ -11,17 +11,17 @@ import org.elasticsearch.xpack.prelert.support.AbstractStreamableTestCase;
import java.util.Collections;
public class GetCategoryDefinitionResponseTests extends AbstractStreamableTestCase<GetCategoryDefinitionAction.Response> {
public class GetCategoryDefinitionResponseTests extends AbstractStreamableTestCase<GetCategoriesDefinitionAction.Response> {
@Override
protected GetCategoryDefinitionAction.Response createTestInstance() {
protected GetCategoriesDefinitionAction.Response createTestInstance() {
QueryPage<CategoryDefinition> queryPage =
new QueryPage<>(Collections.singletonList(new CategoryDefinition(randomAsciiOfLength(10))), 1L);
return new GetCategoryDefinitionAction.Response(queryPage);
return new GetCategoriesDefinitionAction.Response(queryPage);
}
@Override
protected GetCategoryDefinitionAction.Response createBlankInstance() {
return new GetCategoryDefinitionAction.Response();
protected GetCategoriesDefinitionAction.Response createBlankInstance() {
return new GetCategoriesDefinitionAction.Response();
}
}

View File

@ -5,11 +5,11 @@
*/
package org.elasticsearch.xpack.prelert.action;
import org.elasticsearch.xpack.prelert.action.GetJobAction.Request;
import org.elasticsearch.xpack.prelert.action.GetJobsAction.Request;
import org.elasticsearch.xpack.prelert.job.results.PageParams;
import org.elasticsearch.xpack.prelert.support.AbstractStreamableTestCase;
public class GetJobActionRequestTests extends AbstractStreamableTestCase<GetJobAction.Request> {
public class GetJobActionRequestTests extends AbstractStreamableTestCase<GetJobsAction.Request> {
@Override
protected Request createTestInstance() {

View File

@ -5,7 +5,7 @@
*/
package org.elasticsearch.xpack.prelert.action;
import org.elasticsearch.xpack.prelert.action.GetJobAction.Response;
import org.elasticsearch.xpack.prelert.action.GetJobsAction.Response;
import org.elasticsearch.xpack.prelert.job.AnalysisConfig;
import org.elasticsearch.xpack.prelert.job.AnalysisLimits;
import org.elasticsearch.xpack.prelert.job.DataCounts;
@ -32,7 +32,7 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Map;
public class GetJobActionResponseTests extends AbstractStreamableTestCase<GetJobAction.Response> {
public class GetJobActionResponseTests extends AbstractStreamableTestCase<GetJobsAction.Response> {
@Override
protected Response createTestInstance() {

View File

@ -173,32 +173,32 @@ public class PrelertJobIT extends ESRestTestCase {
params.put("end", "1400"); // exclusive
ResponseException e = expectThrows(ResponseException.class,
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/bucket", params));
() -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets", params));
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
assertThat(e.getMessage(), containsString("No known job with id '1'"));
addBucketResult("1", "1234");
addBucketResult("1", "1235");
addBucketResult("1", "1236");
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/bucket", params);
Response response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets", params);
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
String responseAsString = responseEntityToString(response);
assertThat(responseAsString, containsString("\"hitCount\":3"));
params.put("end", "1235");
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/bucket", params);
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets", params);
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
responseAsString = responseEntityToString(response);
assertThat(responseAsString, containsString("\"hitCount\":1"));
e = expectThrows(ResponseException.class, () -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/2/bucket/1234"));
e = expectThrows(ResponseException.class, () -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/2/buckets/1234"));
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
assertThat(e.getMessage(), containsString("No known job with id '2'"));
e = expectThrows(ResponseException.class, () -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/bucket/1"));
e = expectThrows(ResponseException.class, () -> client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets/1"));
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/bucket/1234");
response = client().performRequest("get", PrelertPlugin.BASE_PATH + "results/1/buckets/1234");
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
responseAsString = responseEntityToString(response);
assertThat(responseAsString, not(isEmptyString()));

View File

@ -1,11 +1,11 @@
{
"xpack.prelert.get_bucket": {
"xpack.prelert.get_buckets": {
"methods": [ "GET", "POST" ],
"url": {
"path": "/_xpack/prelert/results/{jobId}/bucket/{timestamp}",
"path": "/_xpack/prelert/results/{jobId}/buckets/{timestamp}",
"paths": [
"/_xpack/prelert/results/{jobId}/bucket/{timestamp}",
"/_xpack/prelert/results/{jobId}/bucket"
"/_xpack/prelert/results/{jobId}/buckets/{timestamp}",
"/_xpack/prelert/results/{jobId}/buckets"
],
"parts": {
"jobId": {

View File

@ -1,11 +1,11 @@
{
"xpack.prelert.get_category": {
"xpack.prelert.get_categories": {
"methods": [ "GET" ],
"url": {
"path": "/_xpack/prelert/results/{jobId}/categorydefinition/{categoryId}",
"path": "/_xpack/prelert/results/{jobId}/categorydefinitions/{categoryId}",
"paths": [
"/_xpack/prelert/results/{jobId}/categorydefinition/{categoryId}",
"/_xpack/prelert/results/{jobId}/categorydefinition/"
"/_xpack/prelert/results/{jobId}/categorydefinitions/{categoryId}",
"/_xpack/prelert/results/{jobId}/categorydefinitions/"
],
"parts": {
"jobId": {

View File

@ -1,5 +1,5 @@
{
"xpack.prelert.get_job": {
"xpack.prelert.get_jobs": {
"methods": [ "GET", "POST" ],
"url": {
"path": "/_xpack/prelert/jobs/{job_id}",

View File

@ -1,5 +1,5 @@
{
"xpack.prelert.get_list": {
"xpack.prelert.get_lists": {
"methods": [ "GET" ],
"url": {
"path": "/_xpack/prelert/lists/{list_id}",

View File

@ -24,14 +24,14 @@
- is_true: "prelertresults-farequote"
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
from: 0
size: 100
- match: { hitCount: 1 }
- match: { hits.0.config.jobId: "farequote" }
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "farequote"
- match: { hitCount: 1 }
- match: { hits.0.config.jobId: "farequote" }
@ -43,7 +43,7 @@
- do:
catch: missing
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "farequote"
- do:
@ -55,7 +55,7 @@
"Test get job API with non existing job id":
- do:
catch: missing
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "non-existing"
---

View File

@ -22,7 +22,7 @@ setup:
---
"Test result buckets api":
- do:
xpack.prelert.get_bucket:
xpack.prelert.get_buckets:
jobId: "farequote"
start: "2016-05-01T00:00:00Z"
end: "2016-07-01T00:00:00Z"
@ -34,7 +34,7 @@ setup:
---
"Test result bucket api":
- do:
xpack.prelert.get_bucket:
xpack.prelert.get_buckets:
jobId: "farequote"
timestamp: "2016-06-01T00:00:00Z"

View File

@ -25,7 +25,7 @@ setup:
---
"Test result categories api":
- do:
xpack.prelert.get_category:
xpack.prelert.get_categories:
jobId: "farequote"
- match: { hitCount: 2 }
@ -37,7 +37,7 @@ setup:
---
"Test result category api":
- do:
xpack.prelert.get_category:
xpack.prelert.get_categories:
jobId: "farequote"
categoryId: "1"

View File

@ -43,7 +43,7 @@ setup:
---
"Test get job stats after uploading data prompting the creation of some stats":
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: job-stats-test
- is_true: hits.0.config
@ -66,7 +66,7 @@ setup:
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: job-stats-test
metric: data_counts
@ -78,7 +78,7 @@ setup:
# It's difficult to test for the presence of model_size_stats as they
# won't be created with such a small data sample
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "job-stats-test"
metric: "data_counts"
- is_false: hits.0.config
@ -87,7 +87,7 @@ setup:
- is_false: hits.0.scheduler_state
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "job-stats-test"
metric: "model_size_stats"
- is_false: hits.0.config
@ -95,14 +95,14 @@ setup:
- is_false: hits.0.scheduler_state
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "job-stats-test"
metric: "scheduler_state"
- is_false: hits.0.config
- is_false: hits.0.data_counts
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "job-stats-test"
metric: "status"
- is_false: hits.0.config
@ -112,7 +112,7 @@ setup:
- match: { hits.0.status: CLOSED }
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "job-stats-test"
metric: "_all"
- is_true: hits.0.config
@ -121,7 +121,7 @@ setup:
- match: { hits.0.status: CLOSED }
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: "scheduled-job"
metric: "scheduler_state"
- is_false: hits.0.config

View File

@ -16,7 +16,7 @@ setup:
- do:
catch: missing
xpack.prelert.get_list:
xpack.prelert.get_lists:
list_id: "do_not_exist"
- match: { exists: false }
@ -27,7 +27,7 @@ setup:
"Test get list API":
- do:
xpack.prelert.get_list:
xpack.prelert.get_lists:
list_id: "foo"
- match: { exists: true }
@ -49,7 +49,7 @@ setup:
- match: { acknowledged: true }
- do:
xpack.prelert.get_list:
xpack.prelert.get_lists:
list_id: "foo2"
- match: { exists: true }

View File

@ -190,7 +190,7 @@ setup:
---
"Test revert model with deleteInterveningResults":
- do:
xpack.prelert.get_bucket:
xpack.prelert.get_buckets:
jobId: "foo"
start: "2016-01-01T00:00:00Z"
end: "2016-12-01T00:00:00Z"
@ -208,7 +208,7 @@ setup:
index: prelertresults-foo
- do:
xpack.prelert.get_bucket:
xpack.prelert.get_buckets:
jobId: "foo"
start: "2016-01-01T00:00:00Z"
end: "2016-12-01T00:00:00Z"
@ -218,7 +218,7 @@ setup:
- match: { hits.0.timestamp: 1462060800000 }
- do:
xpack.prelert.get_job:
xpack.prelert.get_jobs:
job_id: foo
metric: data_counts