diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index d9b2684677f..d2812085728 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -31,12 +31,8 @@
-
-
-
-
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
deleted file mode 100644
index 32f7cb140e5..00000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationClient.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.client;
-
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.client.migration.DeprecationInfoRequest;
-import org.elasticsearch.client.migration.DeprecationInfoResponse;
-
-import java.io.IOException;
-import java.util.Collections;
-
-/**
- * A wrapper for the {@link RestHighLevelClient} that provides methods for
- * accessing the Elastic License-related methods
- *
- * See the
- * X-Pack Migration APIs on elastic.co for more information.
- */
-public final class MigrationClient {
-
- private final RestHighLevelClient restHighLevelClient;
-
- MigrationClient(RestHighLevelClient restHighLevelClient) {
- this.restHighLevelClient = restHighLevelClient;
- }
-
- /**
- * Get deprecation info for one or more indices
- * @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 DeprecationInfoResponse getDeprecationInfo(DeprecationInfoRequest request, RequestOptions options) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(request, MigrationRequestConverters::getDeprecationInfo, options,
- DeprecationInfoResponse::fromXContent, Collections.emptySet());
- }
-
- /**
- * Asynchronously get deprecation info for one or more indices
- * @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
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable getDeprecationInfoAsync(DeprecationInfoRequest request, RequestOptions options,
- ActionListener listener) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(request, MigrationRequestConverters::getDeprecationInfo, options,
- DeprecationInfoResponse::fromXContent, listener, Collections.emptySet());
- }
-}
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
deleted file mode 100644
index 77d38c13bc0..00000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/MigrationRequestConverters.java
+++ /dev/null
@@ -1,38 +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.client;
-
-import org.apache.http.client.methods.HttpGet;
-import org.elasticsearch.client.migration.DeprecationInfoRequest;
-
-final class MigrationRequestConverters {
-
- private MigrationRequestConverters() {
- }
-
- static Request getDeprecationInfo(DeprecationInfoRequest deprecationInfoRequest) {
- String endpoint = new RequestConverters.EndpointBuilder()
- .addCommaSeparatedPathParts(deprecationInfoRequest.getIndices())
- .addPathPartAsIs("_migration", "deprecations")
- .build();
-
- return new Request(HttpGet.METHOD_NAME, endpoint);
- }
-}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
index 12229a92707..a3e3e8b4de9 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
@@ -261,7 +261,6 @@ public class RestHighLevelClient implements Closeable {
private final SnapshotClient snapshotClient = new SnapshotClient(this);
private final TasksClient tasksClient = new TasksClient(this);
private final WatcherClient watcherClient = new WatcherClient(this);
- private final MigrationClient migrationClient = new MigrationClient(this);
private final IndexLifecycleClient ilmClient = new IndexLifecycleClient(this);
private final TransformClient transformClient = new TransformClient(this);
@@ -375,18 +374,6 @@ public class RestHighLevelClient implements Closeable {
return ilmClient;
}
- /**
- * Provides methods for accessing the Elastic Licensed Migration APIs that
- * are shipped with the default distribution of Elasticsearch. All of
- * these APIs will 404 if run against the OSS distribution of Elasticsearch.
- *
- * See the
- * Migration APIs on elastic.co for more information.
- */
- public MigrationClient migration() {
- return migrationClient;
- }
-
/**
* Provides methods for accessing the Elastic Licensed Data Frame APIs that
* are shipped with the Elastic Stack distribution of Elasticsearch. All of
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoRequest.java
deleted file mode 100644
index a56d0501275..00000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoRequest.java
+++ /dev/null
@@ -1,43 +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.client.migration;
-
-import org.elasticsearch.client.Validatable;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-public class DeprecationInfoRequest implements Validatable {
-
- private final List indices;
-
- public DeprecationInfoRequest(List indices) {
- this.indices = Collections.unmodifiableList(Objects.requireNonNull(indices, "indices cannot be null"));
- }
-
- public DeprecationInfoRequest() {
- this.indices = Collections.unmodifiableList(Collections.emptyList());
- }
-
- public List getIndices() {
- return indices;
- }
-}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java
deleted file mode 100644
index 6d2cf450773..00000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java
+++ /dev/null
@@ -1,218 +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.client.migration;
-
-import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.xcontent.ConstructingObjectParser;
-import org.elasticsearch.common.xcontent.XContentParser;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-
-public class DeprecationInfoResponse {
-
- private static final ParseField CLUSTER_SETTINGS = new ParseField("cluster_settings");
- private static final ParseField NODE_SETTINGS = new ParseField("node_settings");
- private static final ParseField INDEX_SETTINGS = new ParseField("index_settings");
- private static final ParseField ML_SETTINGS = new ParseField("ml_settings");
-
- private final List clusterSettingsIssues;
- private final List nodeSettingsIssues;
- private final Map> indexSettingsIssues;
- private final List mlSettingsIssues;
-
- public DeprecationInfoResponse(List clusterSettingsIssues, List nodeSettingsIssues,
- Map> indexSettingsIssues, List mlSettingsIssues) {
- this.clusterSettingsIssues = Objects.requireNonNull(clusterSettingsIssues, "cluster settings issues cannot be null");
- this.nodeSettingsIssues = Objects.requireNonNull(nodeSettingsIssues, "node settings issues cannot be null");
- this.indexSettingsIssues = Objects.requireNonNull(indexSettingsIssues, "index settings issues cannot be null");
- this.mlSettingsIssues = Objects.requireNonNull(mlSettingsIssues, "ml settings issues cannot be null");
- }
-
- public List getClusterSettingsIssues() {
- return clusterSettingsIssues;
- }
-
- public List getNodeSettingsIssues() {
- return nodeSettingsIssues;
- }
-
- public Map> getIndexSettingsIssues() {
- return indexSettingsIssues;
- }
-
- public List getMlSettingsIssues() {
- return mlSettingsIssues;
- }
-
- private static List parseDeprecationIssues(XContentParser parser) throws IOException {
- List issues = new ArrayList<>();
- XContentParser.Token token = null;
- while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
- if (token == XContentParser.Token.START_OBJECT) {
- issues.add(DeprecationIssue.PARSER.parse(parser, null));
- }
- }
- return issues;
- }
-
- public static DeprecationInfoResponse fromXContent(XContentParser parser) throws IOException {
- Map> indexSettings = new HashMap<>();
- List clusterSettings = new ArrayList<>();
- List nodeSettings = new ArrayList<>();
- List mlSettings = new ArrayList<>();
- String fieldName = null;
- XContentParser.Token token;
- while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
- if (token == XContentParser.Token.FIELD_NAME) {
- fieldName = parser.currentName();
- } else if (CLUSTER_SETTINGS.getPreferredName().equals(fieldName)) {
- clusterSettings.addAll(parseDeprecationIssues(parser));
- } else if (NODE_SETTINGS.getPreferredName().equals(fieldName)) {
- nodeSettings.addAll(parseDeprecationIssues(parser));
- } else if (ML_SETTINGS.getPreferredName().equals(fieldName)) {
- mlSettings.addAll(parseDeprecationIssues(parser));
- } else if (INDEX_SETTINGS.getPreferredName().equals(fieldName)) {
- // parse out the key/value pairs
- while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
- String key = parser.currentName();
- List value = parseDeprecationIssues(parser);
- if (value.size() > 0) { // only add indices that contain deprecation issues
- indexSettings.put(key, value);
- }
- }
- }
- }
- return new DeprecationInfoResponse(clusterSettings, nodeSettings, indexSettings, mlSettings);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- DeprecationInfoResponse that = (DeprecationInfoResponse) o;
- return Objects.equals(clusterSettingsIssues, that.clusterSettingsIssues) &&
- Objects.equals(nodeSettingsIssues, that.nodeSettingsIssues) &&
- Objects.equals(mlSettingsIssues, that.mlSettingsIssues) &&
- Objects.equals(indexSettingsIssues, that.indexSettingsIssues);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(clusterSettingsIssues, nodeSettingsIssues, indexSettingsIssues, mlSettingsIssues);
- }
-
- @Override
- public String toString() {
- return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString() +
- ":" + mlSettingsIssues.toString();
- }
-
- /**
- * Information about deprecated items
- */
- public static class DeprecationIssue {
-
- private static final ParseField LEVEL = new ParseField("level");
- private static final ParseField MESSAGE = new ParseField("message");
- private static final ParseField URL = new ParseField("url");
- private static final ParseField DETAILS = new ParseField("details");
-
- static final ConstructingObjectParser PARSER =
- new ConstructingObjectParser<>("deprecation_issue", true,
- a -> new DeprecationIssue(Level.fromString((String) a[0]), (String) a[1], (String) a[2], (String) a[3]));
-
- static {
- PARSER.declareString(ConstructingObjectParser.constructorArg(), LEVEL);
- PARSER.declareString(ConstructingObjectParser.constructorArg(), MESSAGE);
- PARSER.declareString(ConstructingObjectParser.constructorArg(), URL);
- PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), DETAILS);
- }
-
- public enum Level {
- WARNING,
- CRITICAL
- ;
-
- public static Level fromString(String value) {
- return Level.valueOf(value.toUpperCase(Locale.ROOT));
- }
-
- @Override
- public String toString() {
- return name().toLowerCase(Locale.ROOT);
- }
- }
-
- private Level level;
- private String message;
- private String url;
- private String details;
-
- public DeprecationIssue(Level level, String message, String url, @Nullable String details) {
- this.level = level;
- this.message = message;
- this.url = url;
- this.details = details;
- }
-
- public Level getLevel() {
- return level;
- }
-
- public String getMessage() {
- return message;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getDetails() {
- return details;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- DeprecationIssue that = (DeprecationIssue) o;
- return Objects.equals(level, that.level) &&
- Objects.equals(message, that.message) &&
- Objects.equals(url, that.url) &&
- Objects.equals(details, that.details);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(level, message, url, details);
- }
- }
-}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/package-info.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/package-info.java
deleted file mode 100644
index dcb29a3776e..00000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/package-info.java
+++ /dev/null
@@ -1,24 +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.
- */
-
-/**
- * Request and Response objects for the default distribution's Migration
- * APIs.
- */
-package org.elasticsearch.client.migration;
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
deleted file mode 100644
index 3396f3352e2..00000000000
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationIT.java
+++ /dev/null
@@ -1,43 +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.client;
-
-import org.elasticsearch.client.migration.DeprecationInfoRequest;
-import org.elasticsearch.client.migration.DeprecationInfoResponse;
-import org.elasticsearch.common.settings.Settings;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import static org.hamcrest.Matchers.equalTo;
-
-public class MigrationIT extends ESRestHighLevelClientTestCase {
-
- public void testGetDeprecationInfo() throws IOException {
- createIndex("test", Settings.EMPTY);
- DeprecationInfoRequest request = new DeprecationInfoRequest(Collections.singletonList("test"));
- DeprecationInfoResponse response = highLevelClient().migration().getDeprecationInfo(request, RequestOptions.DEFAULT);
- // a test like this cannot test actual deprecations
- assertThat(response.getClusterSettingsIssues().size(), equalTo(0));
- assertThat(response.getIndexSettingsIssues().size(), equalTo(0));
- assertThat(response.getNodeSettingsIssues().size(), equalTo(0));
- assertThat(response.getMlSettingsIssues().size(), equalTo(0));
- }
-}
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
deleted file mode 100644
index 88936eff024..00000000000
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MigrationRequestConvertersTests.java
+++ /dev/null
@@ -1,43 +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.client;
-
-import org.apache.http.client.methods.HttpGet;
-import org.elasticsearch.client.migration.DeprecationInfoRequest;
-import org.elasticsearch.test.ESTestCase;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class MigrationRequestConvertersTests extends ESTestCase {
-
- public void testGetDeprecationInfo() {
- DeprecationInfoRequest deprecationInfoRequest = new DeprecationInfoRequest();
- String expectedEndpoint = "/_migration/deprecations";
-
- Map expectedParams = new HashMap<>();
- Request request = MigrationRequestConverters.getDeprecationInfo(deprecationInfoRequest);
- assertEquals(HttpGet.METHOD_NAME, request.getMethod());
- assertEquals(expectedEndpoint, request.getEndpoint());
- assertNull(request.getEntity());
- assertEquals(expectedParams, request.getParameters());
- }
-
-}
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
deleted file mode 100644
index ea6fb8d864a..00000000000
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationClientDocumentationIT.java
+++ /dev/null
@@ -1,116 +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.client.documentation;
-
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.LatchedActionListener;
-import org.elasticsearch.client.ESRestHighLevelClientTestCase;
-import org.elasticsearch.client.RequestOptions;
-import org.elasticsearch.client.RestHighLevelClient;
-import org.elasticsearch.client.migration.DeprecationInfoRequest;
-import org.elasticsearch.client.migration.DeprecationInfoResponse;
-import org.elasticsearch.common.settings.Settings;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * This class is used to generate the Java Migration API documentation.
- * You need to wrap your code between two tags like:
- * // tag::example
- * // end::example
- *
- * Where example is your tag name.
- *
- * Then in the documentation, you can extract what is between tag and end tags with
- * ["source","java",subs="attributes,callouts,macros"]
- * --------------------------------------------------
- * include-tagged::{doc-tests}/MigrationClientDocumentationIT.java[example]
- * --------------------------------------------------
- *
- * The column width of the code block is 84. If the code contains a line longer
- * than 84, the line will be cut and a horizontal scroll bar will be displayed.
- * (the code indentation of the tag is not included in the width)
- */
-public class MigrationClientDocumentationIT extends ESRestHighLevelClientTestCase {
-
- public void testGetDeprecationInfo() throws IOException, InterruptedException {
- RestHighLevelClient client = highLevelClient();
- createIndex("test", Settings.EMPTY);
-
- //tag::get-deprecation-info-request
- List indices = new ArrayList<>();
- indices.add("test");
- DeprecationInfoRequest deprecationInfoRequest = new DeprecationInfoRequest(indices); // <1>
- //end::get-deprecation-info-request
-
- // tag::get-deprecation-info-execute
- DeprecationInfoResponse deprecationInfoResponse =
- client.migration().getDeprecationInfo(deprecationInfoRequest, RequestOptions.DEFAULT);
- // end::get-deprecation-info-execute
-
- // tag::get-deprecation-info-response
- List clusterIssues =
- deprecationInfoResponse.getClusterSettingsIssues(); // <1>
- List nodeIssues =
- deprecationInfoResponse.getNodeSettingsIssues(); // <2>
- Map> indexIssues =
- deprecationInfoResponse.getIndexSettingsIssues(); // <3>
- List mlIssues =
- deprecationInfoResponse.getMlSettingsIssues(); // <4>
- // end::get-deprecation-info-response
-
- // tag::get-deprecation-info-execute-listener
- ActionListener listener =
- new ActionListener() {
- @Override
- public void onResponse(DeprecationInfoResponse deprecationInfoResponse1) { // <1>
- List clusterIssues =
- deprecationInfoResponse.getClusterSettingsIssues();
- List nodeIssues =
- deprecationInfoResponse.getNodeSettingsIssues();
- Map> indexIssues =
- deprecationInfoResponse.getIndexSettingsIssues();
- List mlIssues =
- deprecationInfoResponse.getMlSettingsIssues();
- }
-
- @Override
- public void onFailure(Exception e) {
- // <2>
- }
- };
- // end::get-deprecation-info-execute-listener
-
- final CountDownLatch latch = new CountDownLatch(1);
- listener = new LatchedActionListener<>(listener, latch);
-
- // tag::get-deprecation-info-execute-async
- client.migration().getDeprecationInfoAsync(deprecationInfoRequest,
- RequestOptions.DEFAULT, listener); // <1>
- // end::get-deprecation-info-execute-async
-
- assertTrue(latch.await(30L, TimeUnit.SECONDS));
- }
-}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java
deleted file mode 100644
index ff75cc32ae4..00000000000
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java
+++ /dev/null
@@ -1,119 +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.client.documentation;
-
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.delete.DeleteRequest;
-import org.elasticsearch.action.delete.DeleteResponse;
-import org.elasticsearch.action.get.GetRequest;
-import org.elasticsearch.action.index.IndexRequest;
-import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.client.ESRestHighLevelClientTestCase;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.RequestOptions;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestHighLevelClient;
-import org.elasticsearch.cluster.health.ClusterHealthStatus;
-import org.elasticsearch.common.xcontent.XContentHelper;
-import org.elasticsearch.common.xcontent.XContentType;
-import org.elasticsearch.rest.RestStatus;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-/**
- * This class is used to generate the documentation for the
- * docs/java-rest/high-level/migration.asciidoc page.
- *
- * You need to wrap your code between two tags like:
- * // tag::example[]
- * // end::example[]
- *
- * Where example is your tag name.
- *
- * Then in the documentation, you can extract what is between tag and end tags with
- * ["source","java",subs="attributes,callouts,macros"]
- * --------------------------------------------------
- * include-tagged::{doc-tests}/MigrationDocumentationIT.java[example]
- * --------------------------------------------------
- */
-public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
- public void testClusterHealth() throws IOException {
- RestHighLevelClient client = highLevelClient();
- {
- //tag::migration-cluster-health
- Request request = new Request("GET", "/_cluster/health");
- request.addParameter("wait_for_status", "green"); // <1>
- Response response = client.getLowLevelClient().performRequest(request); // <2>
-
- ClusterHealthStatus healthStatus;
- try (InputStream is = response.getEntity().getContent()) { // <3>
- Map map = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true); // <4>
- healthStatus = ClusterHealthStatus.fromString((String) map.get("status")); // <5>
- }
-
- if (healthStatus != ClusterHealthStatus.GREEN) {
- // <6>
- }
- //end::migration-cluster-health
- assertSame(ClusterHealthStatus.GREEN, healthStatus);
- }
- }
-
- public void testRequests() throws Exception {
- RestHighLevelClient client = highLevelClient();
- {
- //tag::migration-request-ctor
- IndexRequest request = new IndexRequest("index").id("id"); // <1>
- request.source("{\"field\":\"value\"}", XContentType.JSON);
- //end::migration-request-ctor
-
- //tag::migration-request-ctor-execution
- IndexResponse response = client.index(request, RequestOptions.DEFAULT);
- //end::migration-request-ctor-execution
- assertEquals(RestStatus.CREATED, response.status());
- }
- {
- //tag::migration-request-async-execution
- DeleteRequest request = new DeleteRequest("index", "id"); // <1>
- client.deleteAsync(request, RequestOptions.DEFAULT, new ActionListener() { // <2>
- @Override
- public void onResponse(DeleteResponse deleteResponse) {
- // <3>
- }
-
- @Override
- public void onFailure(Exception e) {
- // <4>
- }
- });
- //end::migration-request-async-execution
- assertBusy(() -> assertFalse(client.exists(new GetRequest("index", "id"), RequestOptions.DEFAULT)));
- }
- {
- //tag::migration-request-sync-execution
- DeleteRequest request = new DeleteRequest("index", "id");
- DeleteResponse response = client.delete(request, RequestOptions.DEFAULT); // <1>
- //end::migration-request-sync-execution
- assertEquals(RestStatus.NOT_FOUND, response.status());
- }
- }
-}
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/DeprecationInfoResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/DeprecationInfoResponseTests.java
deleted file mode 100644
index 052066e8106..00000000000
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/migration/DeprecationInfoResponseTests.java
+++ /dev/null
@@ -1,161 +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.client.migration;
-
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.EqualsHashCodeTestUtils;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.elasticsearch.client.migration.DeprecationInfoResponse.DeprecationIssue.Level.CRITICAL;
-import static org.elasticsearch.client.migration.DeprecationInfoResponse.DeprecationIssue.Level.WARNING;
-import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester;
-
-public class DeprecationInfoResponseTests extends ESTestCase {
-
- private void toXContent(DeprecationInfoResponse response, XContentBuilder builder) throws IOException {
- builder.startObject();
- {
- builder.startArray("cluster_settings");
- for (DeprecationInfoResponse.DeprecationIssue issue : response.getClusterSettingsIssues()) {
- toXContent(issue, builder);
- }
- builder.endArray();
-
- builder.startArray("node_settings");
- for (DeprecationInfoResponse.DeprecationIssue issue : response.getNodeSettingsIssues()) {
- toXContent(issue, builder);
- }
- builder.endArray();
-
- builder.field("index_settings");
- builder.startObject();
- {
- for (Map.Entry> entry :
- response.getIndexSettingsIssues().entrySet()) {
- builder.field(entry.getKey());
- builder.startArray();
- for (DeprecationInfoResponse.DeprecationIssue issue : entry.getValue()) {
- toXContent(issue, builder);
- }
- builder.endArray();
- }
- }
- builder.endObject();
-
- builder.startArray("ml_settings");
- for (DeprecationInfoResponse.DeprecationIssue issue : response.getMlSettingsIssues()) {
- toXContent(issue, builder);
- }
- builder.endArray();
- }
- builder.endObject();
- }
-
- private void toXContent(DeprecationInfoResponse.DeprecationIssue issue, XContentBuilder builder) throws IOException {
- builder.startObject()
- .field("level", issue.getLevel())
- .field("message", issue.getMessage())
- .field("url", issue.getUrl());
- if (issue.getDetails()!= null) {
- builder.field("details", issue.getDetails());
- }
- builder.endObject();
- }
-
-
- private Map> createIndexSettingsIssues() {
- Map> indexSettingsIssues =
- new HashMap<>();
- for (int i = 0; i < randomIntBetween(1, 3); i++) {
- indexSettingsIssues.put(randomAlphaOfLengthBetween(1, 5), createRandomIssues(false));
- }
- return indexSettingsIssues;
- }
-
- private List createRandomIssues(boolean canBeEmpty) {
- List list = new ArrayList<>();
- // the list of index settings cannot be zero, but the other lists can be, so this boolean is used to make the min number
- // of elements for this list.
- int startingRandomNumber = canBeEmpty ? 0: 1;
- for (int i =0; i < randomIntBetween(startingRandomNumber, 2); i++) {
- list.add(new DeprecationInfoResponse.DeprecationIssue(randomFrom(WARNING, CRITICAL),
- randomAlphaOfLength(5),
- randomAlphaOfLength(5),
- randomBoolean() ? randomAlphaOfLength(5) : null));
- }
- return list;
- }
-
- private DeprecationInfoResponse createInstance() {
- return new DeprecationInfoResponse(createRandomIssues(true), createRandomIssues(true), createIndexSettingsIssues(),
- createRandomIssues(true));
- }
-
- private DeprecationInfoResponse copyInstance(DeprecationInfoResponse req) {
- return new DeprecationInfoResponse(new ArrayList<>(req.getClusterSettingsIssues()),
- new ArrayList<>(req.getNodeSettingsIssues()), new HashMap<>(req.getIndexSettingsIssues()),
- new ArrayList<>(req.getMlSettingsIssues()));
- }
-
- private DeprecationInfoResponse mutateInstance(DeprecationInfoResponse req) {
- return createInstance();
- }
-
- public void testFromXContent() throws IOException {
- xContentTester(
- this::createParser,
- this::createInstance,
- this::toXContent,
- DeprecationInfoResponse::fromXContent)
- .supportsUnknownFields(false) // old school parsing
- .test();
- }
-
- public void testNullFailedIndices() {
- NullPointerException exception = expectThrows(NullPointerException.class,
- () -> new DeprecationInfoResponse(null, null, null, null));
- assertEquals("cluster settings issues cannot be null", exception.getMessage());
-
- exception = expectThrows(NullPointerException.class,
- () -> new DeprecationInfoResponse(Collections.emptyList(), null, null, null));
- assertEquals("node settings issues cannot be null", exception.getMessage());
-
- exception = expectThrows(NullPointerException.class,
- () -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), null, null));
- assertEquals("index settings issues cannot be null", exception.getMessage());
-
- exception = expectThrows(NullPointerException.class,
- () -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), Collections.emptyMap(), null));
- assertEquals("ml settings issues cannot be null", exception.getMessage());
- }
-
- public void testEqualsAndHashCode() {
- for (int count = 0; count < 100; ++count) {
- EqualsHashCodeTestUtils.checkEqualsAndHashCode(createInstance(), this::copyInstance, this::mutateInstance);
- }
- }
-}