forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require acknowledgement to start_trial license
This is related to elastic#30134. It modifies the start_trial action to require an acknowledgement parameter in the rest request to actually start the trial license. There are backwards compatibility issues as prior ES versions did not support this parameter. To handle this, it is assumed that a request coming from a node prior to 6.3 is acknowledged. And attempts to write a non-acknowledged request to a prior to 6.3 node will throw an exception. Additionally this PR adds messages about the trial license the user is generating.
- Loading branch information
1 parent
0a5a9a2
commit a7629d9
Showing
21 changed files
with
1,396 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicensingClient.java.orig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.license; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.client.ElasticsearchClient; | ||
import org.elasticsearch.rest.action.RestBuilderListener; | ||
|
||
public class LicensingClient { | ||
|
||
private final ElasticsearchClient client; | ||
|
||
public LicensingClient(ElasticsearchClient client) { | ||
this.client = client; | ||
} | ||
|
||
public PutLicenseRequestBuilder preparePutLicense(License license) { | ||
return new PutLicenseRequestBuilder(client).setLicense(license); | ||
} | ||
|
||
public void putLicense(PutLicenseRequest request, ActionListener<PutLicenseResponse> listener) { | ||
client.execute(PutLicenseAction.INSTANCE, request, listener); | ||
} | ||
|
||
public GetLicenseRequestBuilder prepareGetLicense() { | ||
return new GetLicenseRequestBuilder(client); | ||
} | ||
|
||
public void getLicense(GetLicenseRequest request, ActionListener<GetLicenseResponse> listener) { | ||
client.execute(GetLicenseAction.INSTANCE, request, listener); | ||
} | ||
|
||
public DeleteLicenseRequestBuilder prepareDeleteLicense() { | ||
return new DeleteLicenseRequestBuilder(client); | ||
} | ||
|
||
public void deleteLicense(DeleteLicenseRequest request, ActionListener<DeleteLicenseResponse> listener) { | ||
client.execute(DeleteLicenseAction.INSTANCE, request, listener); | ||
} | ||
|
||
public PostStartTrialRequestBuilder preparePostUpgradeToTrial() { | ||
return new PostStartTrialRequestBuilder(client, PostStartTrialAction.INSTANCE); | ||
} | ||
|
||
public GetTrialStatusRequestBuilder prepareGetUpgradeToTrial() { | ||
return new GetTrialStatusRequestBuilder(client, GetTrialStatusAction.INSTANCE); | ||
} | ||
|
||
public void postStartTrial(PostStartTrialRequest request, ActionListener<PostStartTrialResponse> listener) { | ||
client.execute(PostStartTrialAction.INSTANCE, request, listener); | ||
} | ||
|
||
public void postStartBasic(PostStartBasicRequest request, ActionListener<PostStartBasicResponse> listener) { | ||
client.execute(PostStartBasicAction.INSTANCE, request, listener); | ||
} | ||
|
||
public PostStartBasicRequestBuilder preparePostStartBasic() { | ||
return new PostStartBasicRequestBuilder(client, PostStartBasicAction.INSTANCE); | ||
} | ||
|
||
public GetBasicStatusRequestBuilder prepareGetStartBasic() { | ||
return new GetBasicStatusRequestBuilder(client, GetBasicStatusAction.INSTANCE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartTrialRequest.java.orig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.license; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.support.master.MasterNodeRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class PostStartTrialRequest extends MasterNodeRequest<PostStartTrialRequest> { | ||
|
||
private String type; | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
public PostStartTrialRequest setType(String type) { | ||
this.type = type; | ||
return this; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
if (in.getVersion().onOrAfter(Version.V_6_3_0)) { | ||
type = in.readString(); | ||
} else { | ||
type = "trial"; | ||
} | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
Version version = Version.V_6_3_0; | ||
if (out.getVersion().onOrAfter(version)) { | ||
out.writeString(type); | ||
} else { | ||
throw new IllegalArgumentException("All nodes in cluster must be version [" + version | ||
+ "] or newer to use `type` parameter. Attempting to write to node with version [" + out.getVersion() + "]."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...lugin/core/src/main/java/org/elasticsearch/license/PostStartTrialRequestBuilder.java.orig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.license; | ||
|
||
import org.elasticsearch.action.ActionRequestBuilder; | ||
import org.elasticsearch.client.ElasticsearchClient; | ||
|
||
class PostStartTrialRequestBuilder extends ActionRequestBuilder<PostStartTrialRequest, | ||
PostStartTrialResponse, PostStartTrialRequestBuilder> { | ||
|
||
PostStartTrialRequestBuilder(ElasticsearchClient client, PostStartTrialAction action) { | ||
super(client, action, new PostStartTrialRequest()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.