diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java
index fa36c02d02c..c6b7f1d4234 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java
@@ -22,6 +22,8 @@ package org.elasticsearch.client;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
import org.elasticsearch.client.rollup.DeleteRollupJobResponse;
+import org.elasticsearch.client.rollup.GetRollupIndexCapsRequest;
+import org.elasticsearch.client.rollup.GetRollupIndexCapsResponse;
import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.GetRollupJobResponse;
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
@@ -219,4 +221,40 @@ public class RollupClient {
listener,
Collections.emptySet());
}
+
+ /**
+ * Get the Rollup Index Capabilities of a rollup index or pattern
+ * See
+ * the docs for more.
+ * @param request the request
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @return the response
+ * @throws IOException in case there is a problem sending the request or parsing back the response
+ */
+ public GetRollupIndexCapsResponse getRollupIndexCapabilities(GetRollupIndexCapsRequest request,
+ RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(request,
+ RollupRequestConverters::getRollupIndexCaps,
+ options,
+ GetRollupIndexCapsResponse::fromXContent,
+ Collections.emptySet());
+ }
+
+ /**
+ * Asynchronously Get the Rollup Index Capabilities of a rollup index or pattern
+ * See
+ * the docs for more.
+ * @param request the request
+ * @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 getRollupIndexCapabilitiesAsync(GetRollupIndexCapsRequest request, RequestOptions options,
+ ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(request,
+ RollupRequestConverters::getRollupIndexCaps,
+ options,
+ GetRollupIndexCapsResponse::fromXContent,
+ listener,
+ Collections.emptySet());
+ }
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java
index f662d592d1a..f0fe801ae59 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java
@@ -24,6 +24,7 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
+import org.elasticsearch.client.rollup.GetRollupIndexCapsRequest;
import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.PutRollupJobRequest;
import org.elasticsearch.client.rollup.StartRollupJobRequest;
@@ -85,4 +86,14 @@ final class RollupRequestConverters {
request.setEntity(createEntity(getRollupCapsRequest, REQUEST_BODY_CONTENT_TYPE));
return request;
}
+
+ static Request getRollupIndexCaps(final GetRollupIndexCapsRequest getRollupIndexCapsRequest) throws IOException {
+ String endpoint = new RequestConverters.EndpointBuilder()
+ .addCommaSeparatedPathParts(getRollupIndexCapsRequest.indices())
+ .addPathPartAsIs("_xpack", "rollup", "data")
+ .build();
+ Request request = new Request(HttpGet.METHOD_NAME, endpoint);
+ request.setEntity(createEntity(getRollupIndexCapsRequest, REQUEST_BODY_CONTENT_TYPE));
+ return request;
+ }
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupCapsResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupCapsResponse.java
index 872dc7440a0..f4c516d015d 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupCapsResponse.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupCapsResponse.java
@@ -18,10 +18,6 @@
*/
package org.elasticsearch.client.rollup;
-import org.elasticsearch.common.Strings;
-import org.elasticsearch.common.xcontent.ToXContent;
-import org.elasticsearch.common.xcontent.ToXContentObject;
-import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
@@ -30,7 +26,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-public class GetRollupCapsResponse implements ToXContentObject {
+public class GetRollupCapsResponse {
private final Map jobs;
@@ -42,16 +38,6 @@ public class GetRollupCapsResponse implements ToXContentObject {
return jobs;
}
- @Override
- public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
- builder.startObject();
- for (Map.Entry entry : jobs.entrySet()) {
- entry.getValue().toXContent(builder, params);
- }
- builder.endObject();
- return builder;
- }
-
public static GetRollupCapsResponse fromXContent(final XContentParser parser) throws IOException {
Map jobs = new HashMap<>();
XContentParser.Token token = parser.nextToken();
@@ -84,9 +70,4 @@ public class GetRollupCapsResponse implements ToXContentObject {
GetRollupCapsResponse other = (GetRollupCapsResponse) obj;
return Objects.equals(jobs, other.jobs);
}
-
- @Override
- public final String toString() {
- return Strings.toString(this);
- }
}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupIndexCapsRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupIndexCapsRequest.java
new file mode 100644
index 00000000000..6bb0c9b48d6
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupIndexCapsRequest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.rollup;
+
+import org.elasticsearch.action.support.IndicesOptions;
+import org.elasticsearch.client.Validatable;
+import org.elasticsearch.common.Strings;
+import org.elasticsearch.common.xcontent.ToXContentObject;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Objects;
+
+public class GetRollupIndexCapsRequest implements Validatable, ToXContentObject {
+ private static final String INDICES = "indices";
+ private static final String INDICES_OPTIONS = "indices_options";
+
+ private String[] indices;
+ private IndicesOptions options;
+
+ public GetRollupIndexCapsRequest(final String... indices) {
+ this(indices, IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED);
+ }
+
+ public GetRollupIndexCapsRequest(final String[] indices, final IndicesOptions options) {
+ if (indices == null || indices.length == 0) {
+ throw new IllegalArgumentException("[indices] must not be null or empty");
+ }
+ for (String index : indices) {
+ if (Strings.isNullOrEmpty(index)) {
+ throw new IllegalArgumentException("[index] must not be null or empty");
+ }
+ }
+ this.indices = indices;
+ this.options = Objects.requireNonNull(options);
+ }
+
+ public IndicesOptions indicesOptions() {
+ return options;
+ }
+
+ public String[] indices() {
+ return indices;
+ }
+
+ @Override
+ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
+ builder.startObject();
+ {
+ builder.array(INDICES, indices);
+ builder.startObject(INDICES_OPTIONS);
+ {
+ options.toXContent(builder, params);
+ }
+ builder.endObject();
+ }
+ builder.endObject();
+ return builder;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.hashCode(indices), options);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ GetRollupIndexCapsRequest other = (GetRollupIndexCapsRequest) obj;
+ return Arrays.equals(indices, other.indices)
+ && Objects.equals(options, other.options);
+ }
+}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupIndexCapsResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupIndexCapsResponse.java
new file mode 100644
index 00000000000..831e10f1747
--- /dev/null
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupIndexCapsResponse.java
@@ -0,0 +1,73 @@
+/*
+ * 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.rollup;
+
+import org.elasticsearch.common.xcontent.XContentParser;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+public class GetRollupIndexCapsResponse {
+
+ private final Map jobs;
+
+ public GetRollupIndexCapsResponse(final Map jobs) {
+ this.jobs = Collections.unmodifiableMap(Objects.requireNonNull(jobs));
+ }
+
+ public Map getJobs() {
+ return jobs;
+ }
+
+ public static GetRollupIndexCapsResponse fromXContent(final XContentParser parser) throws IOException {
+ Map jobs = new HashMap<>();
+ XContentParser.Token token = parser.nextToken();
+ if (token.equals(XContentParser.Token.START_OBJECT)) {
+ while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
+ if (token.equals(XContentParser.Token.FIELD_NAME)) {
+ String pattern = parser.currentName();
+
+ RollableIndexCaps cap = RollableIndexCaps.PARSER.apply(pattern).apply(parser, null);
+ jobs.put(pattern, cap);
+ }
+ }
+ }
+ return new GetRollupIndexCapsResponse(jobs);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(jobs);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ GetRollupIndexCapsResponse other = (GetRollupIndexCapsResponse) obj;
+ return Objects.equals(jobs, other.jobs);
+ }
+}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupIT.java
index ffe75bfc1b1..213ca8710a4 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RollupIT.java
@@ -33,6 +33,8 @@ import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
import org.elasticsearch.client.rollup.DeleteRollupJobResponse;
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
import org.elasticsearch.client.rollup.GetRollupCapsResponse;
+import org.elasticsearch.client.rollup.GetRollupIndexCapsRequest;
+import org.elasticsearch.client.rollup.GetRollupIndexCapsResponse;
import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.GetRollupJobResponse;
import org.elasticsearch.client.rollup.GetRollupJobResponse.IndexerState;
@@ -348,4 +350,116 @@ public class RollupIT extends ESRestHighLevelClientTestCase {
List