diff --git a/client/rest-high-level/build.gradle b/client/rest-high-level/build.gradle
index e0b168c29fa..6cfcebff290 100644
--- a/client/rest-high-level/build.gradle
+++ b/client/rest-high-level/build.gradle
@@ -51,7 +51,6 @@ dependencies {
compile "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
compile "org.elasticsearch.plugin:rank-eval-client:${version}"
compile "org.elasticsearch.plugin:lang-mustache-client:${version}"
- bundle project(':x-pack:protocol')
testCompile "org.elasticsearch.client:test:${version}"
testCompile "org.elasticsearch.test:framework:${version}"
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphClient.java
index 5099bf8d51d..3d5365fedde 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphClient.java
@@ -20,8 +20,8 @@
package org.elasticsearch.client;
import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse;
+import org.elasticsearch.client.graph.GraphExploreRequest;
+import org.elasticsearch.client.graph.GraphExploreResponse;
import java.io.IOException;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java
index f5387047db1..fae987fb337 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java
@@ -20,7 +20,7 @@
package org.elasticsearch.client;
import org.apache.http.client.methods.HttpGet;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
+import org.elasticsearch.client.graph.GraphExploreRequest;
import java.io.IOException;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationClient.java
index 8717943d797..15bf71bc8db 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationClient.java
@@ -19,8 +19,8 @@
package org.elasticsearch.client;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse;
+import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
+import org.elasticsearch.client.migration.IndexUpgradeInfoResponse;
import java.io.IOException;
import java.util.Collections;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationRequestConverters.java
index ddd1a2a4345..50d21f844d4 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationRequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationRequestConverters.java
@@ -20,7 +20,7 @@
package org.elasticsearch.client;
import org.apache.http.client.methods.HttpGet;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
+import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
final class MigrationRequestConverters {
@@ -28,7 +28,7 @@ final class MigrationRequestConverters {
static Request getMigrationAssistance(IndexUpgradeInfoRequest indexUpgradeInfoRequest) {
RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack/migration/assistance")
+ .addPathPartAsIs("_xpack", "migration", "assistance")
.addCommaSeparatedPathParts(indexUpgradeInfoRequest.indices());
String endpoint = endpointBuilder.build();
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherClient.java
index a2b11772c12..71247764566 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherClient.java
@@ -28,10 +28,10 @@ import org.elasticsearch.client.watcher.AckWatchRequest;
import org.elasticsearch.client.watcher.AckWatchResponse;
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
+import org.elasticsearch.client.watcher.DeleteWatchRequest;
+import org.elasticsearch.client.watcher.DeleteWatchResponse;
+import org.elasticsearch.client.watcher.PutWatchRequest;
+import org.elasticsearch.client.watcher.PutWatchResponse;
import java.io.IOException;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java
index 49764025273..57e817e083a 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java
@@ -30,8 +30,8 @@ import org.elasticsearch.client.watcher.AckWatchRequest;
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
import org.elasticsearch.common.bytes.BytesReference;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
+import org.elasticsearch.client.watcher.DeleteWatchRequest;
+import org.elasticsearch.client.watcher.PutWatchRequest;
final class WatcherRequestConverters {
@@ -59,9 +59,7 @@ final class WatcherRequestConverters {
static Request putWatch(PutWatchRequest putWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("watcher")
- .addPathPartAsIs("watch")
+ .addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPart(putWatchRequest.getId())
.build();
@@ -89,9 +87,7 @@ final class WatcherRequestConverters {
static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("watcher")
- .addPathPartAsIs("watch")
+ .addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPart(deleteWatchRequest.getId())
.build();
@@ -101,9 +97,7 @@ final class WatcherRequestConverters {
public static Request ackWatch(AckWatchRequest ackWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("watcher")
- .addPathPartAsIs("watch")
+ .addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPart(ackWatchRequest.getWatchId())
.addPathPartAsIs("_ack")
.addCommaSeparatedPathParts(ackWatchRequest.getActionIds())
@@ -114,9 +108,7 @@ final class WatcherRequestConverters {
static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
- .addPathPartAsIs("_xpack")
- .addPathPartAsIs("watcher")
- .addPathPartAsIs("watch")
+ .addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPart(activateWatchRequest.getWatchId())
.addPathPartAsIs("_activate")
.build();
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Connection.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Connection.java
similarity index 89%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Connection.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Connection.java
index 455434f7ac4..07aff3888d2 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Connection.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Connection.java
@@ -16,22 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
import com.carrotsearch.hppc.ObjectIntHashMap;
import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.protocol.xpack.graph.Vertex.VertexId;
+import org.elasticsearch.client.graph.Vertex.VertexId;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import java.util.Objects;
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
@@ -55,25 +52,9 @@ public class Connection {
this.docCount = docCount;
}
- public Connection(StreamInput in, Map vertices) throws IOException {
- from = vertices.get(new VertexId(in.readString(), in.readString()));
- to = vertices.get(new VertexId(in.readString(), in.readString()));
- weight = in.readDouble();
- docCount = in.readVLong();
- }
-
Connection() {
}
- void writeTo(StreamOutput out) throws IOException {
- out.writeString(from.getField());
- out.writeString(from.getTerm());
- out.writeString(to.getField());
- out.writeString(to.getTerm());
- out.writeDouble(weight);
- out.writeVLong(docCount);
- }
-
public ConnectionId getId() {
return new ConnectionId(from.getId(), to.getId());
}
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreRequest.java
similarity index 82%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreRequest.java
index 495ea5fd28a..4d2a000a00c 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreRequest.java
@@ -16,13 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
-import org.elasticsearch.action.ActionRequest;
-import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
-import org.elasticsearch.action.ValidateActions;
import org.elasticsearch.action.support.IndicesOptions;
+import org.elasticsearch.client.Validatable;
+import org.elasticsearch.client.ValidationException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -37,14 +36,14 @@ import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
+import java.util.Optional;
/**
* Holds the criteria required to guide the exploration of connected terms which
* can be returned as a graph.
*/
-public class GraphExploreRequest extends ActionRequest implements IndicesRequest.Replaceable, ToXContentObject {
+public class GraphExploreRequest implements IndicesRequest.Replaceable, ToXContentObject, Validatable {
public static final String NO_HOPS_ERROR_MESSAGE = "Graph explore request must have at least one hop";
public static final String NO_VERTICES_ERROR_MESSAGE = "Graph explore hop must have at least one VertexRequest";
@@ -74,15 +73,15 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest
}
@Override
- public ActionRequestValidationException validate() {
- ActionRequestValidationException validationException = null;
+ public Optional validate() {
+ ValidationException validationException = new ValidationException();
if (hops.size() == 0) {
- validationException = ValidateActions.addValidationError(NO_HOPS_ERROR_MESSAGE, validationException);
+ validationException.addValidationError(NO_HOPS_ERROR_MESSAGE);
}
for (Hop hop : hops) {
- validationException = hop.validate(validationException);
+ hop.validate(validationException);
}
- return validationException;
+ return validationException.validationErrors().isEmpty() ? Optional.empty() : Optional.of(validationException);
}
@Override
@@ -159,55 +158,6 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest
return this;
}
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
-
- indices = in.readStringArray();
- indicesOptions = IndicesOptions.readIndicesOptions(in);
- types = in.readStringArray();
- routing = in.readOptionalString();
- timeout = in.readOptionalTimeValue();
- sampleSize = in.readInt();
- sampleDiversityField = in.readOptionalString();
- maxDocsPerDiversityValue = in.readInt();
-
- useSignificance = in.readBoolean();
- returnDetailedInfo = in.readBoolean();
-
- int numHops = in.readInt();
- Hop parentHop = null;
- for (int i = 0; i < numHops; i++) {
- Hop hop = new Hop(parentHop);
- hop.readFrom(in);
- hops.add(hop);
- parentHop = hop;
- }
-
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeStringArray(indices);
- indicesOptions.writeIndicesOptions(out);
- out.writeStringArray(types);
- out.writeOptionalString(routing);
- out.writeOptionalTimeValue(timeout);
-
- out.writeInt(sampleSize);
- out.writeOptionalString(sampleDiversityField);
- out.writeInt(maxDocsPerDiversityValue);
-
- out.writeBoolean(useSignificance);
- out.writeBoolean(returnDetailedInfo);
- out.writeInt(hops.size());
- for (Iterator iterator = hops.iterator(); iterator.hasNext();) {
- Hop hop = iterator.next();
- hop.writeTo(out);
- }
- }
-
@Override
public String toString() {
return "graph explore [" + Arrays.toString(indices) + "][" + Arrays.toString(types) + "]";
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreResponse.java
similarity index 77%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreResponse.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreResponse.java
index baaaedf0163..2b5d1c7ecf4 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreResponse.java
@@ -16,24 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
import com.carrotsearch.hppc.ObjectIntHashMap;
-import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.protocol.xpack.graph.Connection.ConnectionId;
-import org.elasticsearch.protocol.xpack.graph.Connection.UnresolvedConnection;
-import org.elasticsearch.protocol.xpack.graph.Vertex.VertexId;
+import org.elasticsearch.client.graph.Connection.ConnectionId;
+import org.elasticsearch.client.graph.Connection.UnresolvedConnection;
+import org.elasticsearch.client.graph.Vertex.VertexId;
import java.io.IOException;
import java.util.Collection;
@@ -41,7 +38,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.elasticsearch.action.search.ShardSearchFailure.readShardSearchFailure;
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
@@ -51,7 +47,7 @@ import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optiona
*
* @see GraphExploreRequest
*/
-public class GraphExploreResponse extends ActionResponse implements ToXContentObject {
+public class GraphExploreResponse implements ToXContentObject {
private long tookInMillis;
private boolean timedOut = false;
@@ -94,41 +90,6 @@ public class GraphExploreResponse extends ActionResponse implements ToXContentOb
return shardFailures;
}
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- tookInMillis = in.readVLong();
- timedOut = in.readBoolean();
-
- int size = in.readVInt();
- if (size == 0) {
- shardFailures = ShardSearchFailure.EMPTY_ARRAY;
- } else {
- shardFailures = new ShardSearchFailure[size];
- for (int i = 0; i < shardFailures.length; i++) {
- shardFailures[i] = readShardSearchFailure(in);
- }
- }
- // read vertices
- size = in.readVInt();
- vertices = new HashMap<>();
- for (int i = 0; i < size; i++) {
- Vertex n = Vertex.readFrom(in);
- vertices.put(n.getId(), n);
- }
-
- size = in.readVInt();
-
- connections = new HashMap<>();
- for (int i = 0; i < size; i++) {
- Connection e = new Connection(in, vertices);
- connections.put(e.getId(), e);
- }
-
- returnDetailedInfo = in.readBoolean();
-
- }
-
public Collection getConnections() {
return connections.values();
}
@@ -141,31 +102,6 @@ public class GraphExploreResponse extends ActionResponse implements ToXContentOb
return vertices.get(id);
}
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeVLong(tookInMillis);
- out.writeBoolean(timedOut);
-
- out.writeVInt(shardFailures.length);
- for (ShardOperationFailedException shardSearchFailure : shardFailures) {
- shardSearchFailure.writeTo(out);
- }
-
- out.writeVInt(vertices.size());
- for (Vertex vertex : vertices.values()) {
- vertex.writeTo(out);
- }
-
- out.writeVInt(connections.size());
- for (Connection connection : connections.values()) {
- connection.writeTo(out);
- }
-
- out.writeBoolean(returnDetailedInfo);
-
- }
-
private static final ParseField TOOK = new ParseField("took");
private static final ParseField TIMED_OUT = new ParseField("timed_out");
private static final ParseField VERTICES = new ParseField("vertices");
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Hop.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Hop.java
similarity index 76%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Hop.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Hop.java
index 70ec61067f5..83196aada70 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Hop.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Hop.java
@@ -16,12 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
-import org.elasticsearch.action.ActionRequestValidationException;
-import org.elasticsearch.action.ValidateActions;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.client.ValidationException;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.query.QueryBuilder;
@@ -56,7 +53,7 @@ import java.util.List;
*
*
*/
-public class Hop implements ToXContentFragment{
+public class Hop implements ToXContentFragment {
final Hop parentHop;
List vertices = null;
QueryBuilder guidingQuery = null;
@@ -65,44 +62,16 @@ public class Hop implements ToXContentFragment{
this.parentHop = parent;
}
- public ActionRequestValidationException validate(ActionRequestValidationException validationException) {
-
+ public void validate(ValidationException validationException) {
if (getEffectiveVertexRequests().size() == 0) {
- validationException = ValidateActions.addValidationError(GraphExploreRequest.NO_VERTICES_ERROR_MESSAGE, validationException);
+ validationException.addValidationError(GraphExploreRequest.NO_VERTICES_ERROR_MESSAGE);
}
- return validationException;
-
}
public Hop getParentHop() {
return parentHop;
}
- void writeTo(StreamOutput out) throws IOException {
- out.writeOptionalNamedWriteable(guidingQuery);
- if (vertices == null) {
- out.writeVInt(0);
- } else {
- out.writeVInt(vertices.size());
- for (VertexRequest vr : vertices) {
- vr.writeTo(out);
- }
- }
- }
-
- void readFrom(StreamInput in) throws IOException {
- guidingQuery = in.readOptionalNamedWriteable(QueryBuilder.class);
- int size = in.readVInt();
- if (size > 0) {
- vertices = new ArrayList<>();
- for (int i = 0; i < size; i++) {
- VertexRequest vr = new VertexRequest();
- vr.readFrom(in);
- vertices.add(vr);
- }
- }
- }
-
public QueryBuilder guidingQuery() {
if (guidingQuery != null) {
return guidingQuery;
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Vertex.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Vertex.java
similarity index 93%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Vertex.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Vertex.java
index cfc26f44fac..852372209da 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/Vertex.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Vertex.java
@@ -16,11 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -64,19 +62,6 @@ public class Vertex implements ToXContentFragment {
this.bg = bg;
this.fg = fg;
}
-
- static Vertex readFrom(StreamInput in) throws IOException {
- return new Vertex(in.readString(), in.readString(), in.readDouble(), in.readVInt(), in.readVLong(), in.readVLong());
- }
-
- void writeTo(StreamOutput out) throws IOException {
- out.writeString(field);
- out.writeString(term);
- out.writeDouble(weight);
- out.writeVInt(depth);
- out.writeVLong(bg);
- out.writeVLong(fg);
- }
@Override
public int hashCode() {
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/VertexRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/VertexRequest.java
similarity index 78%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/VertexRequest.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/graph/VertexRequest.java
index 116497fe230..4947244a6c8 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/VertexRequest.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/VertexRequest.java
@@ -16,13 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest.TermBoost;
+import org.elasticsearch.client.graph.GraphExploreRequest.TermBoost;
import java.io.IOException;
import java.util.HashMap;
@@ -52,57 +50,6 @@ public class VertexRequest implements ToXContentObject {
}
- void readFrom(StreamInput in) throws IOException {
- fieldName = in.readString();
- size = in.readVInt();
- minDocCount = in.readVInt();
- shardMinDocCount = in.readVInt();
-
- int numIncludes = in.readVInt();
- if (numIncludes > 0) {
- includes = new HashMap<>();
- for (int i = 0; i < numIncludes; i++) {
- TermBoost tb = new TermBoost();
- tb.readFrom(in);
- includes.put(tb.term, tb);
- }
- }
-
- int numExcludes = in.readVInt();
- if (numExcludes > 0) {
- excludes = new HashSet<>();
- for (int i = 0; i < numExcludes; i++) {
- excludes.add(in.readString());
- }
- }
-
- }
-
- void writeTo(StreamOutput out) throws IOException {
- out.writeString(fieldName);
- out.writeVInt(size);
- out.writeVInt(minDocCount);
- out.writeVInt(shardMinDocCount);
-
- if (includes != null) {
- out.writeVInt(includes.size());
- for (TermBoost tb : includes.values()) {
- tb.writeTo(out);
- }
- } else {
- out.writeVInt(0);
- }
-
- if (excludes != null) {
- out.writeVInt(excludes.size());
- for (String term : excludes) {
- out.writeString(term);
- }
- } else {
- out.writeVInt(0);
- }
- }
-
public String fieldName() {
return fieldName;
}
@@ -224,7 +171,7 @@ public class VertexRequest implements ToXContentObject {
if (shardMinDocCount != DEFAULT_SHARD_MIN_DOC_COUNT) {
builder.field("shard_min_doc_count", shardMinDocCount);
}
- if(includes!=null) {
+ if (includes != null) {
builder.startArray("include");
for (TermBoost tb : includes.values()) {
builder.startObject();
@@ -234,7 +181,7 @@ public class VertexRequest implements ToXContentObject {
}
builder.endArray();
}
- if(excludes!=null) {
+ if (excludes != null) {
builder.startArray("exclude");
for (String value : excludes) {
builder.value(value);
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/package-info.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/package-info.java
similarity index 94%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/package-info.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/graph/package-info.java
index f4f666074a1..27cfb29d381 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/graph/package-info.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/package-info.java
@@ -21,4 +21,4 @@
* Request and Response objects for the default distribution's Graph
* APIs.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/IndexUpgradeInfoRequest.java
similarity index 65%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequest.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/migration/IndexUpgradeInfoRequest.java
index ae26bc4de8d..fb37a449435 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequest.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/IndexUpgradeInfoRequest.java
@@ -16,21 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.migration;
+package org.elasticsearch.client.migration;
-import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.action.support.master.MasterNodeReadRequest;
+import org.elasticsearch.client.TimedRequest;
import org.elasticsearch.common.Strings;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
-public class IndexUpgradeInfoRequest extends MasterNodeReadRequest implements IndicesRequest.Replaceable {
+public class IndexUpgradeInfoRequest extends TimedRequest implements IndicesRequest.Replaceable {
private String[] indices = Strings.EMPTY_ARRAY;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true);
@@ -39,19 +35,6 @@ public class IndexUpgradeInfoRequest extends MasterNodeReadRequest actions;
-
- public IndexUpgradeInfoResponse() {
-
- }
+ private final Map actions;
public IndexUpgradeInfoResponse(Map actions) {
this.actions = actions;
}
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- actions = in.readMap(StreamInput::readString, UpgradeActionRequired::readFromStream);
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeMap(actions, StreamOutput::writeString, (out1, value) -> value.writeTo(out1));
- }
-
public Map getActions() {
return actions;
}
- @Override
- public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
- builder.startObject();
- {
- builder.startObject(INDICES.getPreferredName());
- for (Map.Entry entry : actions.entrySet()) {
- builder.startObject(entry.getKey());
- {
- builder.field(ACTION_REQUIRED.getPreferredName(), entry.getValue().toString());
- }
- builder.endObject();
- }
- builder.endObject();
- }
- builder.endObject();
- return builder;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/UpgradeActionRequired.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/UpgradeActionRequired.java
similarity index 97%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/UpgradeActionRequired.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/migration/UpgradeActionRequired.java
index c87e37be7a5..e743d10529e 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/UpgradeActionRequired.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/UpgradeActionRequired.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.migration;
+package org.elasticsearch.client.migration;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/package-info.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/package-info.java
similarity index 94%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/package-info.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/migration/package-info.java
index 12dc8eebc17..dcb29a3776e 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/migration/package-info.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/package-info.java
@@ -21,4 +21,4 @@
* Request and Response objects for the default distribution's Migration
* APIs.
*/
-package org.elasticsearch.protocol.xpack.migration;
+package org.elasticsearch.client.migration;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchRequest.java
index 1381544744d..8c36caf9dbd 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchRequest.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/AckWatchRequest.java
@@ -21,7 +21,6 @@ package org.elasticsearch.client.watcher;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
import java.util.Locale;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchRequest.java
index 7f2849ff39c..e242ea4f20b 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchRequest.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/ActivateWatchRequest.java
@@ -20,7 +20,6 @@
package org.elasticsearch.client.watcher;
import org.elasticsearch.client.Validatable;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
import java.util.Objects;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeactivateWatchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeactivateWatchRequest.java
index b20a56c361f..ccbd64358e1 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeactivateWatchRequest.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeactivateWatchRequest.java
@@ -19,7 +19,7 @@
package org.elasticsearch.client.watcher;
import org.elasticsearch.client.Validatable;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
+import org.elasticsearch.client.watcher.PutWatchRequest;
import java.util.Objects;
@@ -27,7 +27,6 @@ public class DeactivateWatchRequest implements Validatable {
private final String watchId;
public DeactivateWatchRequest(String watchId) {
-
Objects.requireNonNull(watchId, "watch id is missing");
if (PutWatchRequest.isValidId(watchId) == false) {
throw new IllegalArgumentException("watch id contains whitespace");
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeleteWatchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeleteWatchRequest.java
new file mode 100644
index 00000000000..3abee6fb47e
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeleteWatchRequest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to Elasticsearch under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.elasticsearch.client.watcher;
+
+import org.elasticsearch.client.Validatable;
+
+import java.util.Objects;
+
+/**
+ * A delete watch request to delete an watch by name (id)
+ */
+public class DeleteWatchRequest implements Validatable {
+
+ private final String id;
+
+ public DeleteWatchRequest(String id) {
+ Objects.requireNonNull(id, "watch id is missing");
+ if (PutWatchRequest.isValidId(id) == false) {
+ throw new IllegalArgumentException("watch id contains whitespace");
+ }
+ this.id = id;
+ }
+
+ /**
+ * @return The name of the watch to be deleted
+ */
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return "delete [" + id + "]";
+ }
+}
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeleteWatchResponse.java
similarity index 81%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponse.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeleteWatchResponse.java
index b644a6a854c..4e946ad459c 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/DeleteWatchResponse.java
@@ -16,12 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.watcher;
+package org.elasticsearch.client.watcher;
-import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -30,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.Objects;
-public class DeleteWatchResponse extends ActionResponse implements ToXContentObject {
+public class DeleteWatchResponse implements ToXContentObject {
private static final ObjectParser PARSER
= new ObjectParser<>("x_pack_delete_watch_response", DeleteWatchResponse::new);
@@ -92,22 +89,6 @@ public class DeleteWatchResponse extends ActionResponse implements ToXContentObj
return Objects.hash(id, version, found);
}
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- id = in.readString();
- version = in.readVLong();
- found = in.readBoolean();
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeString(id);
- out.writeVLong(version);
- out.writeBoolean(found);
- }
-
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return builder.startObject()
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/PutWatchRequest.java
similarity index 51%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchRequest.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/PutWatchRequest.java
index 0bfa7dc7d34..88f47aeaeee 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchRequest.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/PutWatchRequest.java
@@ -16,67 +16,43 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.watcher;
+package org.elasticsearch.client.watcher;
-import org.elasticsearch.action.ActionRequest;
-import org.elasticsearch.action.ActionRequestValidationException;
-import org.elasticsearch.action.ValidateActions;
+import org.elasticsearch.client.Validatable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.xcontent.XContentType;
-import java.io.IOException;
+import java.util.Objects;
import java.util.regex.Pattern;
/**
* This request class contains the data needed to create a watch along with the name of the watch.
* The name of the watch will become the ID of the indexed document.
*/
-public final class PutWatchRequest extends ActionRequest {
+public final class PutWatchRequest implements Validatable {
private static final Pattern NO_WS_PATTERN = Pattern.compile("\\S+");
- private String id;
- private BytesReference source;
- private XContentType xContentType = XContentType.JSON;
+ private final String id;
+ private final BytesReference source;
+ private final XContentType xContentType;
private boolean active = true;
private long version = Versions.MATCH_ANY;
- public PutWatchRequest() {}
-
- public PutWatchRequest(StreamInput in) throws IOException {
- readFrom(in);
- }
-
public PutWatchRequest(String id, BytesReference source, XContentType xContentType) {
+ Objects.requireNonNull(id, "watch id is missing");
+ if (isValidId(id) == false) {
+ throw new IllegalArgumentException("watch id contains whitespace");
+ }
+ Objects.requireNonNull(source, "watch source is missing");
+ Objects.requireNonNull(xContentType, "request body is missing");
this.id = id;
this.source = source;
this.xContentType = xContentType;
}
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- id = in.readString();
- source = in.readBytesReference();
- active = in.readBoolean();
- xContentType = in.readEnum(XContentType.class);
- version = in.readZLong();
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeString(id);
- out.writeBytesReference(source);
- out.writeBoolean(active);
- out.writeEnum(xContentType);
- out.writeZLong(version);
- }
-
/**
* @return The name that will be the ID of the indexed document
*/
@@ -84,13 +60,6 @@ public final class PutWatchRequest extends ActionRequest {
return id;
}
- /**
- * Set the watch name
- */
- public void setId(String id) {
- this.id = id;
- }
-
/**
* @return The source of the watch
*/
@@ -98,14 +67,6 @@ public final class PutWatchRequest extends ActionRequest {
return source;
}
- /**
- * Set the source of the watch
- */
- public void setSource(BytesReference source, XContentType xContentType) {
- this.source = source;
- this.xContentType = xContentType;
- }
-
/**
* @return The initial active state of the watch (defaults to {@code true}, e.g. "active")
*/
@@ -135,23 +96,6 @@ public final class PutWatchRequest extends ActionRequest {
this.version = version;
}
- @Override
- public ActionRequestValidationException validate() {
- ActionRequestValidationException validationException = null;
- if (id == null) {
- validationException = ValidateActions.addValidationError("watch id is missing", validationException);
- } else if (isValidId(id) == false) {
- validationException = ValidateActions.addValidationError("watch id contains whitespace", validationException);
- }
- if (source == null) {
- validationException = ValidateActions.addValidationError("watch source is missing", validationException);
- }
- if (xContentType == null) {
- validationException = ValidateActions.addValidationError("request body is missing", validationException);
- }
- return validationException;
- }
-
public static boolean isValidId(String id) {
return Strings.isEmpty(id) == false && NO_WS_PATTERN.matcher(id).matches();
}
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/PutWatchResponse.java
similarity index 74%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchResponse.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/PutWatchResponse.java
index 98467f32dd8..5c8d7bde9b1 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/PutWatchResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/PutWatchResponse.java
@@ -16,12 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.watcher;
+package org.elasticsearch.client.watcher;
-import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -30,14 +27,15 @@ import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.Objects;
-public class PutWatchResponse extends ActionResponse implements ToXContentObject {
+public class PutWatchResponse implements ToXContentObject {
private static final ObjectParser PARSER
= new ObjectParser<>("x_pack_put_watch_response", PutWatchResponse::new);
+
static {
- PARSER.declareString(PutWatchResponse::setId, new ParseField("_id"));
- PARSER.declareLong(PutWatchResponse::setVersion, new ParseField("_version"));
- PARSER.declareBoolean(PutWatchResponse::setCreated, new ParseField("created"));
+ PARSER.declareString(PutWatchResponse::setId, new ParseField("_id"));
+ PARSER.declareLong(PutWatchResponse::setVersion, new ParseField("_version"));
+ PARSER.declareBoolean(PutWatchResponse::setCreated, new ParseField("created"));
}
private String id;
@@ -92,22 +90,6 @@ public class PutWatchResponse extends ActionResponse implements ToXContentObject
return Objects.hash(id, version, created);
}
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeString(id);
- out.writeVLong(version);
- out.writeBoolean(created);
- }
-
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- id = in.readString();
- version = in.readVLong();
- created = in.readBoolean();
- }
-
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return builder.startObject()
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/package-info.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/package-info.java
similarity index 94%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/package-info.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/package-info.java
index d34fd598ab1..cadd7d7558f 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/package-info.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/package-info.java
@@ -21,4 +21,4 @@
* Request and Response objects for the default distribution's Watcher
* APIs.
*/
-package org.elasticsearch.protocol.xpack.watcher;
+package org.elasticsearch.client.watcher;
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/GrapRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/GrapRequestConvertersTests.java
index 6598800d76e..965f1f627af 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/GrapRequestConvertersTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/GrapRequestConvertersTests.java
@@ -24,17 +24,16 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
-import org.elasticsearch.protocol.xpack.graph.Hop;
+import org.elasticsearch.client.graph.GraphExploreRequest;
+import org.elasticsearch.client.graph.Hop;
import org.elasticsearch.test.ESTestCase;
-import org.junit.Assert;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.Matchers.is;
-public class GrapRequestConvertersTests extends ESTestCase{
+public class GrapRequestConvertersTests extends ESTestCase {
public void testGraphExplore() throws Exception {
Map expectedParams = new HashMap<>();
@@ -43,14 +42,14 @@ public class GrapRequestConvertersTests extends ESTestCase{
graphExploreRequest.sampleDiversityField("diversity");
graphExploreRequest.indices("index1", "index2");
graphExploreRequest.types("type1", "type2");
- int timeout = ESTestCase.randomIntBetween(10000, 20000);
+ int timeout = randomIntBetween(10000, 20000);
graphExploreRequest.timeout(TimeValue.timeValueMillis(timeout));
- graphExploreRequest.useSignificance(ESTestCase.randomBoolean());
- int numHops = ESTestCase.randomIntBetween(1, 5);
+ graphExploreRequest.useSignificance(randomBoolean());
+ int numHops = randomIntBetween(1, 5);
for (int i = 0; i < numHops; i++) {
int hopNumber = i + 1;
QueryBuilder guidingQuery = null;
- if (ESTestCase.randomBoolean()) {
+ if (randomBoolean()) {
guidingQuery = new TermQueryBuilder("field" + hopNumber, "value" + hopNumber);
}
Hop hop = graphExploreRequest.createNextHop(guidingQuery);
@@ -58,10 +57,10 @@ public class GrapRequestConvertersTests extends ESTestCase{
hop.getVertexRequest(0).addInclude("value" + hopNumber, hopNumber);
}
Request request = GraphRequestConverters.explore(graphExploreRequest);
- Assert.assertEquals(HttpGet.METHOD_NAME, request.getMethod());
- Assert.assertEquals("/index1,index2/type1,type2/_xpack/graph/_explore", request.getEndpoint());
- Assert.assertEquals(expectedParams, request.getParameters());
- Assert.assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
+ assertEquals(HttpGet.METHOD_NAME, request.getMethod());
+ assertEquals("/index1,index2/type1,type2/_xpack/graph/_explore", request.getEndpoint());
+ assertEquals(expectedParams, request.getParameters());
+ assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
RequestConvertersTests.assertToXContentBody(graphExploreRequest, request.getEntity());
}
}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/GraphIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/GraphIT.java
index 4376b47d737..3673afa1389 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/GraphIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/GraphIT.java
@@ -23,11 +23,11 @@ import org.apache.http.client.methods.HttpPut;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse;
-import org.elasticsearch.protocol.xpack.graph.Hop;
-import org.elasticsearch.protocol.xpack.graph.Vertex;
-import org.elasticsearch.protocol.xpack.graph.VertexRequest;
+import org.elasticsearch.client.graph.GraphExploreRequest;
+import org.elasticsearch.client.graph.GraphExploreResponse;
+import org.elasticsearch.client.graph.Hop;
+import org.elasticsearch.client.graph.Vertex;
+import org.elasticsearch.client.graph.VertexRequest;
import org.hamcrest.Matchers;
import org.junit.Before;
@@ -136,4 +136,4 @@ public class GraphIT extends ESRestHighLevelClientTestCase {
}
-}
\ No newline at end of file
+}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationIT.java
index 03614537bfe..f83986829d5 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationIT.java
@@ -20,8 +20,8 @@
package org.elasticsearch.client;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse;
+import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
+import org.elasticsearch.client.migration.IndexUpgradeInfoResponse;
import java.io.IOException;
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationRequestConvertersTests.java
index 97a2cc16a7e..e3adefcb262 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationRequestConvertersTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationRequestConvertersTests.java
@@ -20,7 +20,7 @@
package org.elasticsearch.client;
import org.apache.http.client.methods.HttpGet;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
+import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
import org.elasticsearch.test.ESTestCase;
import java.util.HashMap;
@@ -28,7 +28,7 @@ import java.util.Map;
public class MigrationRequestConvertersTests extends ESTestCase {
- public static void testGetMigrationAssistance() {
+ public void testGetMigrationAssistance() {
IndexUpgradeInfoRequest upgradeInfoRequest = new IndexUpgradeInfoRequest();
String expectedEndpoint = "/_xpack/migration/assistance";
if (randomBoolean()) {
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java
index b069d211b2e..c4a2242f901 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java
@@ -35,10 +35,10 @@ import org.elasticsearch.client.watcher.StopWatchServiceRequest;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
+import org.elasticsearch.client.watcher.DeleteWatchRequest;
+import org.elasticsearch.client.watcher.DeleteWatchResponse;
+import org.elasticsearch.client.watcher.PutWatchRequest;
+import org.elasticsearch.client.watcher.PutWatchResponse;
import org.elasticsearch.rest.RestStatus;
import static org.hamcrest.Matchers.is;
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java
index df6f697fb97..b0b04fd0e5b 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java
@@ -29,8 +29,8 @@ import org.elasticsearch.client.watcher.StartWatchServiceRequest;
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
+import org.elasticsearch.client.watcher.DeleteWatchRequest;
+import org.elasticsearch.client.watcher.PutWatchRequest;
import org.elasticsearch.test.ESTestCase;
import java.io.ByteArrayOutputStream;
@@ -56,11 +56,9 @@ public class WatcherRequestConvertersTests extends ESTestCase {
}
public void testPutWatch() throws Exception {
- PutWatchRequest putWatchRequest = new PutWatchRequest();
String watchId = randomAlphaOfLength(10);
- putWatchRequest.setId(watchId);
String body = randomAlphaOfLength(20);
- putWatchRequest.setSource(new BytesArray(body), XContentType.JSON);
+ PutWatchRequest putWatchRequest = new PutWatchRequest(watchId, new BytesArray(body), XContentType.JSON);
Map expectedParams = new HashMap<>();
if (randomBoolean()) {
@@ -94,9 +92,8 @@ public class WatcherRequestConvertersTests extends ESTestCase {
}
public void testDeleteWatch() {
- DeleteWatchRequest deleteWatchRequest = new DeleteWatchRequest();
String watchId = randomAlphaOfLength(10);
- deleteWatchRequest.setId(watchId);
+ DeleteWatchRequest deleteWatchRequest = new DeleteWatchRequest(watchId);
Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest);
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/GraphDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/GraphDocumentationIT.java
index 8631e18b873..bf507242bc8 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/GraphDocumentationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/GraphDocumentationIT.java
@@ -26,12 +26,12 @@ import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.index.query.TermQueryBuilder;
-import org.elasticsearch.protocol.xpack.graph.Connection;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
-import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse;
-import org.elasticsearch.protocol.xpack.graph.Hop;
-import org.elasticsearch.protocol.xpack.graph.Vertex;
-import org.elasticsearch.protocol.xpack.graph.VertexRequest;
+import org.elasticsearch.client.graph.Connection;
+import org.elasticsearch.client.graph.GraphExploreRequest;
+import org.elasticsearch.client.graph.GraphExploreResponse;
+import org.elasticsearch.client.graph.Hop;
+import org.elasticsearch.client.graph.Vertex;
+import org.elasticsearch.client.graph.VertexRequest;
import org.junit.Before;
import java.io.IOException;
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationClientDocumentationIT.java
index c8310be8053..57f8a8314fa 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationClientDocumentationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationClientDocumentationIT.java
@@ -24,9 +24,9 @@ import org.elasticsearch.client.ESRestHighLevelClientTestCase;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.Strings;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
-import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse;
-import org.elasticsearch.protocol.xpack.migration.UpgradeActionRequired;
+import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
+import org.elasticsearch.client.migration.IndexUpgradeInfoResponse;
+import org.elasticsearch.client.migration.UpgradeActionRequired;
import java.io.IOException;
import java.util.Map;
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java
index 165bda95dfc..ac4fca82b2e 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java
@@ -40,10 +40,10 @@ import org.elasticsearch.client.watcher.WatchStatus;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
+import org.elasticsearch.client.watcher.DeleteWatchRequest;
+import org.elasticsearch.client.watcher.DeleteWatchResponse;
+import org.elasticsearch.client.watcher.PutWatchRequest;
+import org.elasticsearch.client.watcher.PutWatchResponse;
import org.elasticsearch.rest.RestStatus;
import java.util.concurrent.CountDownLatch;
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/graph/GraphExploreResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/graph/GraphExploreResponseTests.java
similarity index 98%
rename from x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/graph/GraphExploreResponseTests.java
rename to client/rest-high-level/src/test/java/org/elasticsearch/client/graph/GraphExploreResponseTests.java
index 2e6e325c4a0..b161eb2513b 100644
--- a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/graph/GraphExploreResponseTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/graph/GraphExploreResponseTests.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.graph;
+package org.elasticsearch.client.graph;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ShardOperationFailedException;
@@ -35,7 +35,7 @@ import java.util.function.Supplier;
import static org.hamcrest.Matchers.equalTo;
-public class GraphExploreResponseTests extends AbstractXContentTestCase< GraphExploreResponse> {
+public class GraphExploreResponseTests extends AbstractXContentTestCase {
@Override
protected GraphExploreResponse createTestInstance() {
diff --git a/x-pack/protocol/build.gradle b/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoRequestTests.java
similarity index 63%
rename from x-pack/protocol/build.gradle
rename to client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoRequestTests.java
index 7ca81c05e39..23750772201 100644
--- a/x-pack/protocol/build.gradle
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoRequestTests.java
@@ -17,13 +17,16 @@
* under the License.
*/
-apply plugin: 'elasticsearch.build'
+package org.elasticsearch.client.migration;
-description = 'Request and Response objects for x-pack that are used by the' +
- ' high level rest client and x-pack itself'
+import org.elasticsearch.test.ESTestCase;
-dependencies {
- compileOnly "org.elasticsearch:elasticsearch:${version}"
+public class IndexUpgradeInfoRequestTests extends ESTestCase {
- testCompile "org.elasticsearch.test:framework:${version}"
+ // TODO: add to cross XPack-HLRC serialization test
+
+ public void testNullIndices() {
+ expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest((String[])null));
+ expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest().indices((String[])null));
+ }
}
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/package-info.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoResponseTests.java
similarity index 79%
rename from x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/package-info.java
rename to client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoResponseTests.java
index fab18ccc637..8106043c08b 100644
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/package-info.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoResponseTests.java
@@ -17,7 +17,10 @@
* under the License.
*/
-/**
- * Request and Response objects for miscellaneous X-Pack APIs.
- */
-package org.elasticsearch.protocol.xpack;
+package org.elasticsearch.client.migration;
+
+import org.elasticsearch.test.ESTestCase;
+
+public class IndexUpgradeInfoResponseTests extends ESTestCase {
+ // TODO: add to cross XPack-HLRC serialization test
+}
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/DeleteWatchResponseTests.java
similarity index 96%
rename from x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponseTests.java
rename to client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/DeleteWatchResponseTests.java
index 1dbc4cec321..3017b188292 100644
--- a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponseTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/DeleteWatchResponseTests.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.watcher;
+package org.elasticsearch.client.watcher;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.AbstractXContentTestCase;
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/watcher/PutWatchResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/PutWatchResponseTests.java
similarity index 96%
rename from x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/watcher/PutWatchResponseTests.java
rename to client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/PutWatchResponseTests.java
index d0aadef1611..e82ccd11cb2 100644
--- a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/watcher/PutWatchResponseTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/PutWatchResponseTests.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.elasticsearch.protocol.xpack.watcher;
+package org.elasticsearch.client.watcher;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.AbstractXContentTestCase;
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/WatchRequestValidationTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/WatchRequestValidationTests.java
index d75e36f7a36..1fea3bccb62 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/WatchRequestValidationTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/WatchRequestValidationTests.java
@@ -19,19 +19,15 @@
package org.elasticsearch.client.watcher;
-import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.client.ValidationException;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
-import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
import org.elasticsearch.test.ESTestCase;
import java.util.Optional;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
public class WatchRequestValidationTests extends ESTestCase {
@@ -61,38 +57,38 @@ public class WatchRequestValidationTests extends ESTestCase {
}
public void testDeleteWatchInvalidWatchId() {
- ActionRequestValidationException e = new DeleteWatchRequest("id with whitespaces").validate();
- assertThat(e, is(notNullValue()));
- assertThat(e.validationErrors(), hasItem("watch id contains whitespace"));
+ final IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
+ () -> new DeleteWatchRequest("id with whitespaces"));
+ assertThat(exception.getMessage(), is("watch id contains whitespace"));
}
public void testDeleteWatchNullId() {
- ActionRequestValidationException e = new DeleteWatchRequest(null).validate();
- assertThat(e, is(notNullValue()));
- assertThat(e.validationErrors(), hasItem("watch id is missing"));
+ final NullPointerException exception = expectThrows(NullPointerException.class,
+ () -> new DeleteWatchRequest(null));
+ assertThat(exception.getMessage(), is("watch id is missing"));
}
public void testPutWatchInvalidWatchId() {
- ActionRequestValidationException e = new PutWatchRequest("id with whitespaces", BytesArray.EMPTY, XContentType.JSON).validate();
- assertThat(e, is(notNullValue()));
- assertThat(e.validationErrors(), hasItem("watch id contains whitespace"));
+ final IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
+ () -> new PutWatchRequest("id with whitespaces", BytesArray.EMPTY, XContentType.JSON));
+ assertThat(exception.getMessage(), is("watch id contains whitespace"));
}
public void testPutWatchNullId() {
- ActionRequestValidationException e = new PutWatchRequest(null, BytesArray.EMPTY, XContentType.JSON).validate();
- assertThat(e, is(notNullValue()));
- assertThat(e.validationErrors(), hasItem("watch id is missing"));
+ final NullPointerException exception = expectThrows(NullPointerException.class,
+ () -> new PutWatchRequest(null, BytesArray.EMPTY, XContentType.JSON));
+ assertThat(exception.getMessage(), is("watch id is missing"));
}
public void testPutWatchSourceNull() {
- ActionRequestValidationException e = new PutWatchRequest("foo", null, XContentType.JSON).validate();
- assertThat(e, is(notNullValue()));
- assertThat(e.validationErrors(), hasItem("watch source is missing"));
+ final NullPointerException exception = expectThrows(NullPointerException.class,
+ () -> new PutWatchRequest("foo", null, XContentType.JSON));
+ assertThat(exception.getMessage(), is("watch source is missing"));
}
public void testPutWatchContentNull() {
- ActionRequestValidationException e = new PutWatchRequest("foo", BytesArray.EMPTY, null).validate();
- assertThat(e, is(notNullValue()));
- assertThat(e.validationErrors(), hasItem("request body is missing"));
+ final NullPointerException exception = expectThrows(NullPointerException.class,
+ () -> new PutWatchRequest("foo", BytesArray.EMPTY, null));
+ assertThat(exception.getMessage(), is("request body is missing"));
}
}
diff --git a/x-pack/build.gradle b/x-pack/build.gradle
index d2a19be2136..0b140651968 100644
--- a/x-pack/build.gradle
+++ b/x-pack/build.gradle
@@ -16,19 +16,17 @@ subprojects {
project.esplugin.licenseFile = rootProject.file('licenses/ELASTIC-LICENSE.txt')
project.esplugin.noticeFile = xpackRootProject.file('NOTICE.txt')
}
-
- if (project.name != 'protocol') {
- tasks.withType(LicenseHeadersTask.class) {
- approvedLicenses = ['Elastic License', 'Generated']
- additionalLicense 'ELAST', 'Elastic License', 'Licensed under the Elastic License'
- }
-
- ext.licenseName = 'Elastic License'
- ext.licenseUrl = ext.elasticLicenseUrl
-
- project.ext.licenseFile = rootProject.file('licenses/ELASTIC-LICENSE.txt')
- project.ext.noticeFile = xpackRootProject.file('NOTICE.txt')
+
+ tasks.withType(LicenseHeadersTask.class) {
+ approvedLicenses = ['Elastic License', 'Generated']
+ additionalLicense 'ELAST', 'Elastic License', 'Licensed under the Elastic License'
}
+
+ ext.licenseName = 'Elastic License'
+ ext.licenseUrl = ext.elasticLicenseUrl
+
+ project.ext.licenseFile = rootProject.file('licenses/ELASTIC-LICENSE.txt')
+ project.ext.noticeFile = xpackRootProject.file('NOTICE.txt')
}
subprojects {
diff --git a/x-pack/protocol/LICENSE.txt b/x-pack/protocol/LICENSE.txt
deleted file mode 100644
index d6456956733..00000000000
--- a/x-pack/protocol/LICENSE.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchRequest.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchRequest.java
deleted file mode 100644
index 1ec83a8c05a..00000000000
--- a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchRequest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.elasticsearch.protocol.xpack.watcher;
-
-import org.elasticsearch.action.ActionRequest;
-import org.elasticsearch.action.ActionRequestValidationException;
-import org.elasticsearch.action.ValidateActions;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.lucene.uid.Versions;
-
-import java.io.IOException;
-
-/**
- * A delete watch request to delete an watch by name (id)
- */
-public class DeleteWatchRequest extends ActionRequest {
-
- private String id;
- private long version = Versions.MATCH_ANY;
-
- public DeleteWatchRequest() {
- this(null);
- }
-
- public DeleteWatchRequest(String id) {
- this.id = id;
- }
-
- /**
- * @return The name of the watch to be deleted
- */
- public String getId() {
- return id;
- }
-
- /**
- * Sets the name of the watch to be deleted
- */
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public ActionRequestValidationException validate() {
- ActionRequestValidationException validationException = null;
- if (id == null){
- validationException = ValidateActions.addValidationError("watch id is missing", validationException);
- } else if (PutWatchRequest.isValidId(id) == false) {
- validationException = ValidateActions.addValidationError("watch id contains whitespace", validationException);
- }
- return validationException;
- }
-
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- id = in.readString();
- version = in.readLong();
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeString(id);
- out.writeLong(version);
- }
-
- @Override
- public String toString() {
- return "delete [" + id + "]";
- }
-}
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequestTests.java b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequestTests.java
deleted file mode 100644
index a4daa395664..00000000000
--- a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequestTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.protocol.xpack.migration;
-
-import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.common.io.stream.Writeable;
-import org.elasticsearch.test.AbstractWireSerializingTestCase;
-
-public class IndexUpgradeInfoRequestTests extends AbstractWireSerializingTestCase {
- @Override
- protected IndexUpgradeInfoRequest createTestInstance() {
- int indexCount = randomInt(4);
- String[] indices = new String[indexCount];
- for (int i = 0; i < indexCount; i++) {
- indices[i] = randomAlphaOfLength(10);
- }
- IndexUpgradeInfoRequest request = new IndexUpgradeInfoRequest(indices);
- if (randomBoolean()) {
- request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
- }
- return request;
- }
-
- @Override
- protected Writeable.Reader instanceReader() {
- return IndexUpgradeInfoRequest::new;
- }
-
- public void testNullIndices() {
- expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest((String[])null));
- expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest().indices((String[])null));
- }
-}
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponseTests.java b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponseTests.java
deleted file mode 100644
index 42de1ae6090..00000000000
--- a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponseTests.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.protocol.xpack.migration;
-
-import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.test.AbstractStreamableXContentTestCase;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class IndexUpgradeInfoResponseTests extends AbstractStreamableXContentTestCase {
- @Override
- protected IndexUpgradeInfoResponse doParseInstance(XContentParser parser) {
- return IndexUpgradeInfoResponse.fromXContent(parser);
- }
-
- @Override
- protected IndexUpgradeInfoResponse createBlankInstance() {
- return new IndexUpgradeInfoResponse();
- }
-
- @Override
- protected IndexUpgradeInfoResponse createTestInstance() {
- return randomIndexUpgradeInfoResponse(randomIntBetween(0, 10));
- }
-
- private static IndexUpgradeInfoResponse randomIndexUpgradeInfoResponse(int numIndices) {
- Map actions = new HashMap<>();
- for (int i = 0; i < numIndices; i++) {
- actions.put(randomAlphaOfLength(5), randomFrom(UpgradeActionRequired.values()));
- }
- return new IndexUpgradeInfoResponse(actions);
- }
-
- @Override
- protected IndexUpgradeInfoResponse mutateInstance(IndexUpgradeInfoResponse instance) {
- if (instance.getActions().size() == 0) {
- return randomIndexUpgradeInfoResponse(1);
- }
- Map actions = new HashMap<>(instance.getActions());
- if (randomBoolean()) {
- Iterator> iterator = actions.entrySet().iterator();
- iterator.next();
- iterator.remove();
- } else {
- actions.put(randomAlphaOfLength(5), randomFrom(UpgradeActionRequired.values()));
- }
- return new IndexUpgradeInfoResponse(actions);
- }
-}