diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index 53ce2b3a5e2..9c776d419b2 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -103,27 +103,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -229,29 +208,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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 3d5365fedde..70912b094d0 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
@@ -44,7 +44,7 @@ public class GraphClient {
public final GraphExploreResponse explore(GraphExploreRequest graphExploreRequest,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
- options, GraphExploreResponse::fromXContext, emptySet());
+ options, GraphExploreResponse::fromXContent, emptySet());
}
/**
@@ -57,7 +57,7 @@ public class GraphClient {
RequestOptions options,
ActionListener listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
- options, GraphExploreResponse::fromXContext, listener, emptySet());
+ options, GraphExploreResponse::fromXContent, listener, emptySet());
}
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityClient.java
index e604814a3bc..5203306147f 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityClient.java
@@ -20,6 +20,8 @@
package org.elasticsearch.client;
import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.client.security.AuthenticateRequest;
+import org.elasticsearch.client.security.AuthenticateResponse;
import org.elasticsearch.client.security.ChangePasswordRequest;
import org.elasticsearch.client.security.ClearRolesCacheRequest;
import org.elasticsearch.client.security.ClearRolesCacheResponse;
@@ -210,6 +212,32 @@ public final class SecurityClient {
EmptyResponse::fromXContent, listener, emptySet());
}
+ /**
+ * Authenticate the current user and return all the information about the authenticated user.
+ * See
+ * the docs for more.
+ *
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @return the responsee from the authenticate user call
+ */
+ public AuthenticateResponse authenticate(RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(AuthenticateRequest.INSTANCE, AuthenticateRequest::getRequest, options,
+ AuthenticateResponse::fromXContent, emptySet());
+ }
+
+ /**
+ * Authenticate the current user asynchronously and return all the information about the authenticated user.
+ * See
+ * the docs for more.
+ *
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @param listener the listener to be notified upon request completion
+ */
+ public void authenticateAsync(RequestOptions options, ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(AuthenticateRequest.INSTANCE, AuthenticateRequest::getRequest, options,
+ AuthenticateResponse::fromXContent, listener, emptySet());
+ }
+
/**
* Clears the native roles cache for a set of roles.
* See
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreResponse.java
index 2b5d1c7ecf4..dddc4bedfe4 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreResponse.java
@@ -47,7 +47,7 @@ import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optiona
*
* @see GraphExploreRequest
*/
-public class GraphExploreResponse implements ToXContentObject {
+public class GraphExploreResponse implements ToXContentObject {
private long tookInMillis;
private boolean timedOut = false;
@@ -94,14 +94,30 @@ public class GraphExploreResponse implements ToXContentObject {
return connections.values();
}
+ public Collection getConnectionIds() {
+ return connections.keySet();
+ }
+
+ public Connection getConnection(ConnectionId connectionId) {
+ return connections.get(connectionId);
+ }
+
public Collection getVertices() {
return vertices.values();
}
-
+
+ public Collection getVertexIds() {
+ return vertices.keySet();
+ }
+
public Vertex getVertex(VertexId id) {
return vertices.get(id);
}
+ public boolean isReturnDetailedInfo() {
+ return 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");
@@ -190,7 +206,7 @@ public class GraphExploreResponse implements ToXContentObject {
PARSER.declareObjectArray(optionalConstructorArg(), (p, c) -> ShardSearchFailure.fromXContent(p), FAILURES);
}
- public static GraphExploreResponse fromXContext(XContentParser parser) throws IOException {
+ public static GraphExploreResponse fromXContent(XContentParser parser) throws IOException {
return PARSER.apply(parser, null);
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Vertex.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Vertex.java
index 852372209da..54b0b522327 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Vertex.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/Vertex.java
@@ -220,6 +220,14 @@ public class Vertex implements ToXContentFragment {
this.term = term;
}
+ public String getField() {
+ return field;
+ }
+
+ public String getTerm() {
+ return term;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o)
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/license/StartBasicResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/license/StartBasicResponse.java
index f6ab0264024..c2596f3e38a 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/license/StartBasicResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/license/StartBasicResponse.java
@@ -84,14 +84,13 @@ public class StartBasicResponse {
}
}
return new Tuple<>(message, acknowledgeMessages);
- },
- new ParseField("acknowledge"));
+ }, new ParseField("acknowledge"));
}
private Map acknowledgeMessages;
private String acknowledgeMessage;
- enum Status {
+ public enum Status {
GENERATED_BASIC(true, null, RestStatus.OK),
ALREADY_USING_BASIC(false, "Operation failed: Current license is basic.", RestStatus.FORBIDDEN),
NEED_ACKNOWLEDGEMENT(false, "Operation failed: Needs acknowledgement.", RestStatus.OK);
@@ -141,6 +140,10 @@ public class StartBasicResponse {
this.acknowledgeMessage = acknowledgeMessage;
}
+ public Status getStatus() {
+ return status;
+ }
+
public boolean isAcknowledged() {
return status != StartBasicResponse.Status.NEED_ACKNOWLEDGEMENT;
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/UpgradeActionRequired.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/UpgradeActionRequired.java
index e743d10529e..26b7b1e815d 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/UpgradeActionRequired.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/UpgradeActionRequired.java
@@ -18,17 +18,12 @@
*/
package org.elasticsearch.client.migration;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.io.stream.Writeable;
-
-import java.io.IOException;
import java.util.Locale;
/**
* Indicates the type of the upgrade required for the index
*/
-public enum UpgradeActionRequired implements Writeable {
+public enum UpgradeActionRequired {
NOT_APPLICABLE, // Indicates that the check is not applicable to this index type, the next check will be performed
UP_TO_DATE, // Indicates that the check finds this index to be up to date - no additional checks are required
REINDEX, // The index should be reindex
@@ -38,15 +33,6 @@ public enum UpgradeActionRequired implements Writeable {
return UpgradeActionRequired.valueOf(value.toUpperCase(Locale.ROOT));
}
- public static UpgradeActionRequired readFromStream(StreamInput in) throws IOException {
- return in.readEnum(UpgradeActionRequired.class);
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- out.writeEnum(this);
- }
-
@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoResponseTests.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/security/AuthenticateRequest.java
similarity index 55%
rename from client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoResponseTests.java
rename to client/rest-high-level/src/main/java/org/elasticsearch/client/security/AuthenticateRequest.java
index 8106043c08b..2aefa97cb8b 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/IndexUpgradeInfoResponseTests.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/security/AuthenticateRequest.java
@@ -17,10 +17,25 @@
* under the License.
*/
-package org.elasticsearch.client.migration;
+package org.elasticsearch.client.security;
-import org.elasticsearch.test.ESTestCase;
+import org.apache.http.client.methods.HttpGet;
+import org.elasticsearch.client.Request;
+import org.elasticsearch.client.Validatable;
+
+/**
+ * Empty request object required to make the authenticate call. The authenticate call
+ * retrieves metadata about the authenticated user.
+ */
+public final class AuthenticateRequest implements Validatable {
+
+ public static final AuthenticateRequest INSTANCE = new AuthenticateRequest();
+
+ private AuthenticateRequest() {
+ }
+
+ public Request getRequest() {
+ return new Request(HttpGet.METHOD_NAME, "/_xpack/security/_authenticate");
+ }
-public class IndexUpgradeInfoResponseTests extends ESTestCase {
- // TODO: add to cross XPack-HLRC serialization test
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/security/AuthenticateResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/security/AuthenticateResponse.java
new file mode 100644
index 00000000000..62f1cc0955b
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/security/AuthenticateResponse.java
@@ -0,0 +1,109 @@
+/*
+ * 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.security;
+
+import org.elasticsearch.client.security.user.User;
+import org.elasticsearch.common.ParseField;
+import org.elasticsearch.common.xcontent.ConstructingObjectParser;
+import org.elasticsearch.common.xcontent.XContentParser;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
+import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
+
+/**
+ * The response for the authenticate call. The response contains two fields: a
+ * user field and a boolean flag signaling if the user is enabled or not. The
+ * user object contains all user metadata which Elasticsearch uses to map roles,
+ * etc.
+ */
+public final class AuthenticateResponse {
+
+ static final ParseField USERNAME = new ParseField("username");
+ static final ParseField ROLES = new ParseField("roles");
+ static final ParseField METADATA = new ParseField("metadata");
+ static final ParseField FULL_NAME = new ParseField("full_name");
+ static final ParseField EMAIL = new ParseField("email");
+ static final ParseField ENABLED = new ParseField("enabled");
+
+ @SuppressWarnings("unchecked")
+ private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(
+ "client_security_authenticate_response",
+ a -> new AuthenticateResponse(new User((String) a[0], ((List) a[1]), (Map) a[2],
+ (String) a[3], (String) a[4]), (Boolean) a[5]));
+ static {
+ PARSER.declareString(constructorArg(), USERNAME);
+ PARSER.declareStringArray(constructorArg(), ROLES);
+ PARSER.