Forráskód Böngészése

Re-enable deprecated _xpack/license routes via REST compatibility (#73930)

Joe Gallo 4 éve
szülő
commit
cb84769d6d
15 módosított fájl, 277 hozzáadás és 8 törlés
  1. 12 0
      x-pack/plugin/build.gradle
  2. 5 1
      x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java
  3. 5 1
      x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetBasicStatus.java
  4. 5 1
      x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java
  5. 5 1
      x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java
  6. 5 1
      x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartBasicLicense.java
  7. 5 1
      x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java
  8. 6 2
      x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java
  9. 27 0
      x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.delete.json
  10. 38 0
      x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.get.json
  11. 28 0
      x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.get_basic_status.json
  12. 28 0
      x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.get_trial_status.json
  13. 38 0
      x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.post.json
  14. 33 0
      x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.post_start_basic.json
  15. 37 0
      x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.post_start_trial.json

+ 12 - 0
x-pack/plugin/build.gradle

@@ -94,6 +94,18 @@ tasks.named("yamlRestTest").configure {
   dependsOn "copyExtraResources"
 }
 
+tasks.named("transformV7RestTests").configure({ task ->
+  task.replaceKeyInDo("license.delete", "xpack-license.delete")
+  task.replaceKeyInDo("license.get", "xpack-license.get")
+  task.replaceKeyInDo("license.get_basic_status", "xpack-license.get_basic_status")
+  task.replaceKeyInDo("license.get_trial_status", "xpack-license.get_trial_status")
+  task.replaceKeyInDo("license.post", "xpack-license.post")
+  task.replaceKeyInDo("license.post_start_basic", "xpack-license.post_start_basic")
+  task.replaceKeyInDo("license.post_start_trial", "xpack-license.post_start_trial")
+
+  task.addAllowedWarningRegex(".*_xpack/license.* is deprecated.*")
+})
+
 tasks.named("yamlRestCompatTest").configure {
   /*
    * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each

+ 5 - 1
x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java

@@ -8,6 +8,7 @@
 package org.elasticsearch.license;
 
 import org.elasticsearch.client.node.NodeClient;
+import org.elasticsearch.core.RestApiVersion;
 import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
@@ -24,7 +25,10 @@ public class RestDeleteLicenseAction extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(DELETE, "/_license"));
+        return List.of(
+            Route.builder(DELETE, "/_license")
+                .replaces(DELETE, "/_xpack/license", RestApiVersion.V_7).build()
+        );
     }
 
     @Override

+ 5 - 1
x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetBasicStatus.java

@@ -8,6 +8,7 @@
 package org.elasticsearch.license;
 
 import org.elasticsearch.client.node.NodeClient;
+import org.elasticsearch.core.RestApiVersion;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.action.RestToXContentListener;
@@ -22,7 +23,10 @@ public class RestGetBasicStatus extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(GET, "/_license/basic_status"));
+        return List.of(
+            Route.builder(GET, "/_license/basic_status")
+                .replaces(GET, "/_xpack/license/basic_status", RestApiVersion.V_7).build()
+        );
     }
 
     @Override

+ 5 - 1
x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java

@@ -12,6 +12,7 @@ import org.elasticsearch.common.logging.DeprecationCategory;
 import org.elasticsearch.common.logging.DeprecationLogger;
 import org.elasticsearch.common.xcontent.ToXContent;
 import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.core.RestApiVersion;
 import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.BytesRestResponse;
@@ -36,7 +37,10 @@ public class RestGetLicenseAction extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(GET, "/_license"));
+        return List.of(
+            Route.builder(GET, "/_license")
+                .replaces(GET, "/_xpack/license", RestApiVersion.V_7).build()
+        );
     }
 
     @Override

+ 5 - 1
x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java

@@ -8,6 +8,7 @@
 package org.elasticsearch.license;
 
 import org.elasticsearch.client.node.NodeClient;
+import org.elasticsearch.core.RestApiVersion;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.action.RestToXContentListener;
@@ -22,7 +23,10 @@ public class RestGetTrialStatus extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(GET, "/_license/trial_status"));
+        return List.of(
+            Route.builder(GET, "/_license/trial_status")
+                .replaces(GET, "/_xpack/license/trial_status", RestApiVersion.V_7).build()
+        );
     }
 
     @Override

+ 5 - 1
x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartBasicLicense.java

@@ -8,6 +8,7 @@
 package org.elasticsearch.license;
 
 import org.elasticsearch.client.node.NodeClient;
+import org.elasticsearch.core.RestApiVersion;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.action.RestStatusToXContentListener;
@@ -23,7 +24,10 @@ public class RestPostStartBasicLicense extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(POST, "/_license/start_basic"));
+        return List.of(
+            Route.builder(POST, "/_license/start_basic")
+                .replaces(POST, "/_xpack/license/start_basic", RestApiVersion.V_7).build()
+        );
     }
 
     @Override

+ 5 - 1
x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java

@@ -9,6 +9,7 @@ package org.elasticsearch.license;
 
 import org.elasticsearch.client.node.NodeClient;
 import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.core.RestApiVersion;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.BytesRestResponse;
 import org.elasticsearch.rest.RestRequest;
@@ -27,7 +28,10 @@ public class RestPostStartTrialLicense extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(POST, "/_license/start_trial"));
+        return List.of(
+            Route.builder(POST, "/_license/start_trial")
+                .replaces(POST, "/_xpack/license/start_trial", RestApiVersion.V_7).build()
+        );
     }
 
     @Override

+ 6 - 2
x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java

@@ -8,6 +8,7 @@
 package org.elasticsearch.license;
 
 import org.elasticsearch.client.node.NodeClient;
+import org.elasticsearch.core.RestApiVersion;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.action.RestToXContentListener;
@@ -26,8 +27,11 @@ public class RestPutLicenseAction extends BaseRestHandler {
     public List<Route> routes() {
         // TODO: remove POST endpoint?
         return List.of(
-            new Route(POST, "/_license"),
-            new Route(PUT, "/_license"));
+            Route.builder(POST, "/_license")
+                .replaces(POST, "/_xpack/license", RestApiVersion.V_7).build(),
+            Route.builder(PUT, "/_license")
+                .replaces(PUT, "/_xpack/license", RestApiVersion.V_7).build()
+        );
     }
 
     @Override

+ 27 - 0
x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.delete.json

@@ -0,0 +1,27 @@
+{
+  "xpack-license.delete":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html",
+      "description":"Deletes licensing information for the cluster"
+    },
+    "stability":"stable",
+    "visibility":"public",
+    "headers":{
+      "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"]
+    },
+    "url":{
+      "paths":[
+        {
+          "path":"/_xpack/license",
+          "methods":[
+            "DELETE"
+          ],
+          "deprecated":{
+            "version":"7.0.0",
+            "description":"all _xpack prefix have been deprecated"
+          }
+        }
+      ]
+    }
+  }
+}

+ 38 - 0
x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.get.json

@@ -0,0 +1,38 @@
+{
+  "xpack-license.get":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html",
+      "description":"Retrieves licensing information for the cluster"
+    },
+    "stability":"stable",
+    "visibility":"public",
+    "headers":{
+      "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"]
+    },
+    "url":{
+      "paths":[
+        {
+          "path":"/_xpack/license",
+          "methods":[
+            "GET"
+          ],
+          "deprecated":{
+            "version":"7.0.0",
+            "description":"all _xpack prefix have been deprecated"
+          }
+        }
+      ]
+    },
+    "params":{
+      "local":{
+        "type":"boolean",
+        "description":"Return local information, do not retrieve the state from master node (default: false)"
+      },
+      "accept_enterprise":{
+        "type":"boolean",
+        "description":"Supported for backwards compatibility with 7.x. If this param is used it must be set to true",
+        "deprecated":true
+      }
+    }
+  }
+}

+ 28 - 0
x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.get_basic_status.json

@@ -0,0 +1,28 @@
+{
+  "xpack-license.get_basic_status":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html",
+      "description":"Retrieves information about the status of the basic license."
+    },
+    "stability":"stable",
+    "visibility":"public",
+    "headers":{
+      "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"]
+    },
+    "url":{
+      "paths":[
+        {
+          "path":"/_xpack/license/basic_status",
+          "methods":[
+            "GET"
+          ],
+          "deprecated":{
+            "version":"7.0.0",
+            "description":"all _xpack prefix have been deprecated"
+          }
+        }
+      ]
+    },
+    "params":{}
+  }
+}

+ 28 - 0
x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.get_trial_status.json

@@ -0,0 +1,28 @@
+{
+  "xpack-license.get_trial_status":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html",
+      "description":"Retrieves information about the status of the trial license."
+    },
+    "stability":"stable",
+    "visibility":"public",
+    "headers":{
+      "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"]
+    },
+    "url":{
+      "paths":[
+        {
+          "path":"/_xpack/license/trial_status",
+          "methods":[
+            "GET"
+          ],
+          "deprecated":{
+            "version":"7.0.0",
+            "description":"all _xpack prefix have been deprecated"
+          }
+        }
+      ]
+    },
+    "params":{}
+  }
+}

+ 38 - 0
x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.post.json

@@ -0,0 +1,38 @@
+{
+  "xpack-license.post":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html",
+      "description":"Updates the license for the cluster."
+    },
+    "stability":"stable",
+    "visibility":"public",
+    "headers":{
+      "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"],
+      "content_type": ["application/vnd.elasticsearch+json;compatible-with=7"]
+    },
+    "url":{
+      "paths":[
+        {
+          "path":"/_xpack/license",
+          "methods":[
+            "PUT",
+            "POST"
+          ],
+          "deprecated":{
+            "version":"7.0.0",
+            "description":"all _xpack prefix have been deprecated"
+          }
+        }
+      ]
+    },
+    "params":{
+      "acknowledge":{
+        "type":"boolean",
+        "description":"whether the user has acknowledged acknowledge messages (default: false)"
+      }
+    },
+    "body":{
+      "description":"licenses to be installed"
+    }
+  }
+}

+ 33 - 0
x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.post_start_basic.json

@@ -0,0 +1,33 @@
+{
+  "xpack-license.post_start_basic":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html",
+      "description":"Starts an indefinite basic license."
+    },
+    "stability":"stable",
+    "visibility":"public",
+    "headers":{
+      "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"]
+    },
+    "url":{
+      "paths":[
+        {
+          "path":"/_xpack/license/start_basic",
+          "methods":[
+            "POST"
+          ],
+          "deprecated":{
+            "version":"7.0.0",
+            "description":"all _xpack prefix have been deprecated"
+          }
+        }
+      ]
+    },
+    "params":{
+      "acknowledge":{
+        "type":"boolean",
+        "description":"whether the user has acknowledged acknowledge messages (default: false)"
+      }
+    }
+  }
+}

+ 37 - 0
x-pack/plugin/src/yamlRestCompatTest/resources/rest-api-spec/api/xpack-license.post_start_trial.json

@@ -0,0 +1,37 @@
+{
+  "xpack-license.post_start_trial":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html",
+      "description":"starts a limited time trial license."
+    },
+    "stability":"stable",
+    "visibility":"public",
+    "headers":{
+      "accept": [ "application/vnd.elasticsearch+json;compatible-with=7"]
+    },
+    "url":{
+      "paths":[
+        {
+          "path":"/_xpack/license/start_trial",
+          "methods":[
+            "POST"
+          ],
+          "deprecated":{
+            "version":"7.0.0",
+            "description":"all _xpack prefix have been deprecated"
+          }
+        }
+      ]
+    },
+    "params":{
+      "type":{
+        "type":"string",
+        "description":"The type of trial license to generate (default: \"trial\")"
+      },
+      "acknowledge":{
+        "type":"boolean",
+        "description":"whether the user has acknowledged acknowledge messages (default: false)"
+      }
+    }
+  }
+}