From 582508943b4f5800c53754932ff5b717aa185a56 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 3 Oct 2024 16:29:04 -0400 Subject: [PATCH 1/4] Add deprecation warning Signed-off-by: Derek Ho --- .../dlic/rest/api/FlushCacheApiAction.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java index 2f579ecbd9..a611ebdcf9 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java @@ -19,6 +19,7 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.core.action.ActionListener; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; @@ -29,6 +30,7 @@ import org.opensearch.threadpool.ThreadPool; import static org.opensearch.security.dlic.rest.api.Responses.internalServerError; +import static org.opensearch.security.dlic.rest.api.Responses.methodNotImplemented; import static org.opensearch.security.dlic.rest.api.Responses.ok; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; @@ -36,6 +38,8 @@ public class FlushCacheApiAction extends AbstractApiAction { private final static Logger LOGGER = LogManager.getLogger(FlushCacheApiAction.class); + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(FlushCacheApiAction.class); + private static final List routes = addRoutesPrefix( ImmutableList.of( new Route(Method.DELETE, "/cache"), @@ -91,7 +95,23 @@ public void onFailure(final Exception e) { } ) - ); + ) + .override(Method.GET, (channel, request, client) -> { + deprecationLogger.deprecate("GET", "GET is not supported on this endpoint and will be removed in the next major release."); + methodNotImplemented(channel, Method.GET); + }) + .override(Method.POST, (channel, request, client) -> { + deprecationLogger.deprecate( + "POST", + "POST is not supported on this endpoint and will be removed in the next major release." + ); + methodNotImplemented(channel, Method.GET); + }) + .override(Method.PUT, (channel, request, client) -> { + deprecationLogger.deprecate("PUT", "PUT is not supported on this endpoint and will be removed in the next major release."); + methodNotImplemented(channel, Method.PUT); + }); + } @Override From 18fb63424931ea43d1f050f7327009e3ca578054 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 3 Oct 2024 16:29:54 -0400 Subject: [PATCH 2/4] Fix POST Signed-off-by: Derek Ho --- .../opensearch/security/dlic/rest/api/FlushCacheApiAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java index a611ebdcf9..1ae723ff28 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java @@ -105,7 +105,7 @@ public void onFailure(final Exception e) { "POST", "POST is not supported on this endpoint and will be removed in the next major release." ); - methodNotImplemented(channel, Method.GET); + methodNotImplemented(channel, Method.POST); }) .override(Method.PUT, (channel, request, client) -> { deprecationLogger.deprecate("PUT", "PUT is not supported on this endpoint and will be removed in the next major release."); From fc499c9f6899dd2a6757150720ce3a56c6e29eeb Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 3 Oct 2024 16:55:29 -0400 Subject: [PATCH 3/4] Change to deprecatedroute Signed-off-by: Derek Ho --- .../dlic/rest/api/FlushCacheApiAction.java | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java index 1ae723ff28..838911796e 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java @@ -30,7 +30,6 @@ import org.opensearch.threadpool.ThreadPool; import static org.opensearch.security.dlic.rest.api.Responses.internalServerError; -import static org.opensearch.security.dlic.rest.api.Responses.methodNotImplemented; import static org.opensearch.security.dlic.rest.api.Responses.ok; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; @@ -43,9 +42,21 @@ public class FlushCacheApiAction extends AbstractApiAction { private static final List routes = addRoutesPrefix( ImmutableList.of( new Route(Method.DELETE, "/cache"), - new Route(Method.GET, "/cache"), - new Route(Method.PUT, "/cache"), - new Route(Method.POST, "/cache") + new DeprecatedRoute( + Method.GET, + "/cache", + "GET is not supported for /cache endpoint and will be removed in the next major version." + ), + new DeprecatedRoute( + Method.PUT, + "/cache", + "PUT is not supported for /cache endpoint and will be removed in the next major version." + ), + new DeprecatedRoute( + Method.POST, + "/cache", + "POST is not supported for /cache endpoint and will be removed in the next major version." + ) ) ); @@ -95,23 +106,7 @@ public void onFailure(final Exception e) { } ) - ) - .override(Method.GET, (channel, request, client) -> { - deprecationLogger.deprecate("GET", "GET is not supported on this endpoint and will be removed in the next major release."); - methodNotImplemented(channel, Method.GET); - }) - .override(Method.POST, (channel, request, client) -> { - deprecationLogger.deprecate( - "POST", - "POST is not supported on this endpoint and will be removed in the next major release." - ); - methodNotImplemented(channel, Method.POST); - }) - .override(Method.PUT, (channel, request, client) -> { - deprecationLogger.deprecate("PUT", "PUT is not supported on this endpoint and will be removed in the next major release."); - methodNotImplemented(channel, Method.PUT); - }); - + ); } @Override From 7f39b07a3b0bf04110aef6de03cdbbbb7114f6e4 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 3 Oct 2024 16:56:36 -0400 Subject: [PATCH 4/4] Remove deprecation logger Signed-off-by: Derek Ho --- .../opensearch/security/dlic/rest/api/FlushCacheApiAction.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java index 838911796e..e583947ca2 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java @@ -19,7 +19,6 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.core.action.ActionListener; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; @@ -37,8 +36,6 @@ public class FlushCacheApiAction extends AbstractApiAction { private final static Logger LOGGER = LogManager.getLogger(FlushCacheApiAction.class); - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(FlushCacheApiAction.class); - private static final List routes = addRoutesPrefix( ImmutableList.of( new Route(Method.DELETE, "/cache"),