|
@@ -6,7 +6,9 @@
|
|
|
|
|
|
package org.elasticsearch.license;
|
|
|
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
import org.elasticsearch.client.node.NodeClient;
|
|
|
+import org.elasticsearch.common.logging.DeprecationLogger;
|
|
|
import org.elasticsearch.common.xcontent.ToXContent;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
|
|
@@ -27,6 +29,8 @@ import static org.elasticsearch.rest.RestStatus.OK;
|
|
|
|
|
|
public class RestGetLicenseAction extends BaseRestHandler {
|
|
|
|
|
|
+ private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGetLicenseAction.class));
|
|
|
+
|
|
|
RestGetLicenseAction(RestController controller) {
|
|
|
controller.registerHandler(GET, "/_license", this);
|
|
|
}
|
|
@@ -47,6 +51,18 @@ public class RestGetLicenseAction extends BaseRestHandler {
|
|
|
final Map<String, String> overrideParams = new HashMap<>(2);
|
|
|
overrideParams.put(License.REST_VIEW_MODE, "true");
|
|
|
overrideParams.put(License.LICENSE_VERSION_MODE, String.valueOf(License.VERSION_CURRENT));
|
|
|
+
|
|
|
+ // In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0 the flag is deprecated and can only be true
|
|
|
+ // TODO Remove this from 9.0
|
|
|
+ if (request.hasParam("accept_enterprise")) {
|
|
|
+ deprecationLogger.deprecatedAndMaybeLog("get_license_accept_enterprise",
|
|
|
+ "Including [accept_enterprise] in get license requests is deprecated." +
|
|
|
+ " The parameter will be removed in the next major version");
|
|
|
+ if (request.paramAsBoolean("accept_enterprise", true) == false) {
|
|
|
+ throw new IllegalArgumentException("The [accept_enterprise] parameters may not be false");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
final ToXContent.Params params = new ToXContent.DelegatingMapParams(overrideParams, request);
|
|
|
GetLicenseRequest getLicenseRequest = new GetLicenseRequest();
|
|
|
getLicenseRequest.local(request.paramAsBoolean("local", getLicenseRequest.local()));
|