Skip to content

Commit

Permalink
undo deprecrate with removal in v9 for some API's
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Sep 23, 2024
1 parent c759f36 commit 0d0a425
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestCancellableNodeClient;
Expand All @@ -34,11 +34,18 @@ public class RestKnnSearchAction extends BaseRestHandler {

public RestKnnSearchAction() {}

@UpdateForV9 // these routes were ".deprecated" in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// this API in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {

return List.of(
Route.builder(GET, "{index}/_knn_search").deprecated(DEPRECATION_MESSAGE, RestApiVersion.V_8).build(),
Route.builder(POST, "{index}/_knn_search").deprecated(DEPRECATION_MESSAGE, RestApiVersion.V_8).build()
// Route.builder(GET, "{index}/_knn_search").deprecated(DEPRECATION_MESSAGE, RestApiVersion.V_8).build(),
// Route.builder(POST, "{index}/_knn_search").deprecated(DEPRECATION_MESSAGE, RestApiVersion.V_8).build()
Route.builder(GET, "{index}/_knn_search").deprecateAndKeep(DEPRECATION_MESSAGE).build(),
Route.builder(POST, "{index}/_knn_search").deprecateAndKeep(DEPRECATION_MESSAGE).build()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.protocol.xpack.frozen.FreezeRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
Expand All @@ -37,11 +38,17 @@ public final class RestFreezeIndexAction extends BaseRestHandler {
private static final String UNFREEZE_DEPRECATED = "Frozen indices are deprecated because they provide no benefit given improvements "
+ "in heap memory utilization. They will be removed in a future release.";

@UpdateForV9
// these routes were ".deprecated" in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// this API in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {
return List.of(
Route.builder(POST, "/{index}/_freeze").deprecated(FREEZE_REMOVED, RestApiVersion.V_7).build(),
Route.builder(POST, "/{index}/_unfreeze").deprecated(UNFREEZE_DEPRECATED, RestApiVersion.V_8).build()
// Route.builder(POST, "/{index}/_unfreeze").deprecated(UNFREEZE_DEPRECATED, RestApiVersion.V_8).build()
Route.builder(POST, "/{index}/_unfreeze").deprecateAndKeep(UNFREEZE_DEPRECATED).build()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import org.elasticsearch.action.support.master.AcknowledgedRequest;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.Scope;
Expand All @@ -28,11 +28,19 @@
@ServerlessScope(Scope.PUBLIC)
public class RestDeleteTrainedModelAction extends BaseRestHandler {

@UpdateForV9 // one or more ".replaces" another in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// that route in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {
return List.of(
Route.builder(DELETE, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}")
.replaces(DELETE, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}", RestApiVersion.V_8)
// Route.builder(DELETE, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}")
// .replaces(DELETE, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}", RestApiVersion.V_8)
// .build()
new Route(DELETE, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}"),
Route.builder(DELETE, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}")
.deprecateAndKeep("Use the trained_models API instead.")
.build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestRequest;
Expand Down Expand Up @@ -49,13 +49,24 @@ public class RestGetTrainedModelsAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetTrainedModelsAction.class);
private static final String INCLUDE_MODEL_DEFINITION = "include_model_definition";

@UpdateForV9
// one or more ".replaces" another in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// that route in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {
return List.of(
Route.builder(GET, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}")
.replaces(GET, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}", RestApiVersion.V_8)
// Route.builder(GET, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}")
// .replaces(GET, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}", RestApiVersion.V_8)
// .build(),
// Route.builder(GET, BASE_PATH + "trained_models").replaces(GET, BASE_PATH + "inference", RestApiVersion.V_8).build()
new Route(GET, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}"),
Route.builder(GET, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}")
.deprecateAndKeep("Use the trained_models API instead.")
.build(),
Route.builder(GET, BASE_PATH + "trained_models").replaces(GET, BASE_PATH + "inference", RestApiVersion.V_8).build()
new Route(GET, BASE_PATH + "trained_models"),
Route.builder(GET, BASE_PATH + "inference").deprecateAndKeep("Use the trained_models API instead.").build()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.Scope;
Expand All @@ -30,15 +30,26 @@
@ServerlessScope(Scope.PUBLIC)
public class RestGetTrainedModelsStatsAction extends BaseRestHandler {

@UpdateForV9
// one or more ".replaces" another in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// that route in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {
return List.of(
Route.builder(GET, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}/_stats")
.replaces(GET, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}/_stats", RestApiVersion.V_8)
// Route.builder(GET, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}/_stats")
// .replaces(GET, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}/_stats", RestApiVersion.V_8)
// .build(),
// Route.builder(GET, BASE_PATH + "trained_models/_stats")
// .replaces(GET, BASE_PATH + "inference/_stats", RestApiVersion.V_8)
// .build()
new Route(GET, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}/_stats"),
Route.builder(GET, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}/_stats")
.deprecateAndKeep("Use the trained_models API instead.")
.build(),
Route.builder(GET, BASE_PATH + "trained_models/_stats")
.replaces(GET, BASE_PATH + "inference/_stats", RestApiVersion.V_8)
.build()
new Route(GET, BASE_PATH + "trained_models/_stats"),
Route.builder(GET, BASE_PATH + "inference/_stats").deprecateAndKeep("Use the trained_models API instead.").build()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package org.elasticsearch.xpack.ml.rest.inference;

import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.Scope;
Expand All @@ -27,11 +27,19 @@
@ServerlessScope(Scope.PUBLIC)
public class RestPutTrainedModelAction extends BaseRestHandler {

@UpdateForV9 // one or more ".replaces" another in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// that route in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {
return List.of(
Route.builder(PUT, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}")
.replaces(PUT, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}", RestApiVersion.V_8)
// Route.builder(PUT, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}")
// .replaces(PUT, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}", RestApiVersion.V_8)
// .build()
new Route(PUT, BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID + "}"),
Route.builder(PUT, BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID + "}")
.deprecateAndKeep("Use the trained_models API instead.")
.build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
Expand All @@ -27,12 +28,17 @@ public class RestPostDataAction extends BaseRestHandler {
private static final String DEFAULT_RESET_START = "";
private static final String DEFAULT_RESET_END = "";

@UpdateForV9 // these routes were ".deprecated" in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// this API in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {
final String msg = "Posting data directly to anomaly detection jobs is deprecated, "
+ "in a future major version it will be compulsory to use a datafeed";
return List.of(
Route.builder(POST, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/_data").deprecated(msg, RestApiVersion.V_8).build(),
// Route.builder(POST, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/_data").deprecated(msg, RestApiVersion.V_8).build(),
Route.builder(POST, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/_data").deprecateAndKeep(msg).build(),
Route.builder(POST, PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/_data").deprecated(msg, RestApiVersion.V_7).build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.Scope;
Expand All @@ -27,10 +27,16 @@
@ServerlessScope(Scope.INTERNAL)
public class RestFindStructureAction extends BaseRestHandler {

@UpdateForV9 // one or more ".replaces" another in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
// that route in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
@Override
public List<Route> routes() {
return List.of(
Route.builder(POST, BASE_PATH + "find_structure").replaces(POST, "/_ml/find_file_structure", RestApiVersion.V_8).build()
// Route.builder(POST, BASE_PATH + "find_structure").replaces(POST, "/_ml/find_file_structure", RestApiVersion.V_8).build()
new Route(POST, BASE_PATH + "find_structure"),
Route.builder(POST, "/_ml/find_file_structure").deprecateAndKeep("Use the _text_structure API instead.").build()
);
}

Expand Down

0 comments on commit 0d0a425

Please sign in to comment.