From ecf4c30979117eca307218fdb9f1e3847500f9b6 Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Tue, 17 May 2016 18:23:27 -0400 Subject: [PATCH] Rename /_x-pack/monitoring/* to /_xpack/monitoring/* This PR just drops the - in the existing REST API name by changing the base MonitoringRestHandler to extend XPackRestHandler instead of BaseRestHandler directly, and using its URI_BASE. Original commit: elastic/x-pack-elasticsearch@1bed2dba3125d6a7c8de503ce3ba229734162b0d --- .../marvel/rest/MonitoringRestHandler.java | 19 +++---------------- .../rest/action/RestMonitoringBulkAction.java | 6 +++--- .../api/xpack.monitoring.bulk.json | 4 ++-- .../xpack/rest/XPackRestHandler.java | 2 +- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/MonitoringRestHandler.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/MonitoringRestHandler.java index ab67bb39016..11901f1b3b7 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/MonitoringRestHandler.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/MonitoringRestHandler.java @@ -7,26 +7,13 @@ package org.elasticsearch.marvel.rest; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.client.MonitoringClient; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.rest.XPackRestHandler; -import java.util.Locale; +public abstract class MonitoringRestHandler extends XPackRestHandler { -public abstract class MonitoringRestHandler extends BaseRestHandler { - - protected static String URI_BASE = String.format(Locale.ROOT, "/_%s/monitoring", XPackPlugin.NAME); + protected static String URI_BASE = XPackRestHandler.URI_BASE + "/monitoring"; public MonitoringRestHandler(Settings settings, Client client) { super(settings, client); } - - @Override - protected final void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { - handleRequest(request, channel, new MonitoringClient(client)); - } - - protected abstract void handleRequest(RestRequest request, RestChannel channel, MonitoringClient client) throws Exception; } diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/action/RestMonitoringBulkAction.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/action/RestMonitoringBulkAction.java index 22be3e57bd7..b7bfe9e462e 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/action/RestMonitoringBulkAction.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/rest/action/RestMonitoringBulkAction.java @@ -13,7 +13,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.marvel.action.MonitoringBulkRequestBuilder; import org.elasticsearch.marvel.action.MonitoringBulkResponse; -import org.elasticsearch.marvel.client.MonitoringClient; import org.elasticsearch.marvel.rest.MonitoringRestHandler; import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestChannel; @@ -22,6 +21,7 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestBuilderListener; +import org.elasticsearch.xpack.XPackClient; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestRequest.Method.PUT; @@ -41,7 +41,7 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler { } @Override - protected void handleRequest(RestRequest request, RestChannel channel, MonitoringClient client) throws Exception { + protected void handleRequest(RestRequest request, RestChannel channel, XPackClient client) throws Exception { String defaultType = request.param("type"); String id = request.param(MONITORING_ID); @@ -57,7 +57,7 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler { throw new ElasticsearchParseException("no body content for monitoring bulk request"); } - MonitoringBulkRequestBuilder requestBuilder = client.prepareMonitoringBulk(); + MonitoringBulkRequestBuilder requestBuilder = client.monitoring().prepareMonitoringBulk(); requestBuilder.add(request.content(), id, version, defaultType); requestBuilder.execute(new RestBuilderListener(channel) { @Override diff --git a/elasticsearch/x-pack/marvel/src/test/resources/rest-api-spec/api/xpack.monitoring.bulk.json b/elasticsearch/x-pack/marvel/src/test/resources/rest-api-spec/api/xpack.monitoring.bulk.json index 6b3519a8c65..0364bbef636 100644 --- a/elasticsearch/x-pack/marvel/src/test/resources/rest-api-spec/api/xpack.monitoring.bulk.json +++ b/elasticsearch/x-pack/marvel/src/test/resources/rest-api-spec/api/xpack.monitoring.bulk.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/marvel/current/appendix-api-bulk.html", "methods": ["POST", "PUT"], "url": { - "path": "/_x-pack/monitoring/_bulk", - "paths": ["/_x-pack/monitoring/_bulk", "/_x-pack/monitoring/{type}/_bulk"], + "path": "/_xpack/monitoring/_bulk", + "paths": ["/_xpack/monitoring/_bulk", "/_xpack/monitoring/{type}/_bulk"], "parts": { "type": { "type" : "string", diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java index 76ce0f4a458..1cc5767a140 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java @@ -17,7 +17,7 @@ import org.elasticsearch.xpack.XPackClient; */ public abstract class XPackRestHandler extends BaseRestHandler { - protected static String URI_BASE = "_xpack"; + protected static String URI_BASE = "/_xpack"; public XPackRestHandler(Settings settings, Client client) { super(settings, client);