-
Notifications
You must be signed in to change notification settings - Fork 25.2k
HLRC: add support for get license basic/trial status API #33176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
javanna
merged 5 commits into
elastic:master
from
javanna:enhancement/hlrc_get_license_status
Nov 13, 2018
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e047f63
HLRC: add support for get license basic/trial status API
javanna 3ae1de0
remove unused constant
javanna 337a7ea
unused imports
javanna 14f6797
unused imports
javanna e127c9c
Merge branch 'master' into enhancement/hlrc_get_license_status
javanna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
79 changes: 79 additions & 0 deletions
79
...est-high-level/src/main/java/org/elasticsearch/client/license/GetBasicStatusResponse.java
This file contains hidden or 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,79 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.license; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.ObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.util.Objects; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
|
||
/** | ||
* Response class for license get basic status API | ||
*/ | ||
public class GetBasicStatusResponse { | ||
|
||
private static final ParseField ELIGIBLE_TO_START_BASIC = new ParseField("eligible_to_start_basic"); | ||
|
||
private static final ConstructingObjectParser<GetBasicStatusResponse, Void> PARSER = new ConstructingObjectParser<>( | ||
"get_basic_status_response", true, a -> new GetBasicStatusResponse((boolean) a[0])); | ||
|
||
static { | ||
PARSER.declareField(constructorArg(), (parser, context) -> parser.booleanValue(), ELIGIBLE_TO_START_BASIC, | ||
ObjectParser.ValueType.BOOLEAN); | ||
} | ||
|
||
private final boolean eligibleToStartBasic; | ||
|
||
GetBasicStatusResponse(boolean eligibleToStartBasic) { | ||
this.eligibleToStartBasic = eligibleToStartBasic; | ||
} | ||
|
||
/** | ||
* Returns whether the license is eligible to start basic or not | ||
*/ | ||
public boolean isEligibleToStartBasic() { | ||
return eligibleToStartBasic; | ||
} | ||
|
||
public static GetBasicStatusResponse fromXContent(XContentParser parser) { | ||
return PARSER.apply(parser, null); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
GetBasicStatusResponse that = (GetBasicStatusResponse) o; | ||
return eligibleToStartBasic == that.eligibleToStartBasic; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(eligibleToStartBasic); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...est-high-level/src/main/java/org/elasticsearch/client/license/GetTrialStatusResponse.java
This file contains hidden or 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,80 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.license; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.ObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.util.Objects; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
|
||
/** | ||
* Response class for license get trial status API | ||
*/ | ||
public class GetTrialStatusResponse { | ||
|
||
private static final ParseField ELIGIBLE_TO_START_TRIAL = new ParseField("eligible_to_start_trial"); | ||
|
||
private static final ConstructingObjectParser<GetTrialStatusResponse, Void> PARSER = new ConstructingObjectParser<>( | ||
"get_trial_status_response", true, a -> new GetTrialStatusResponse((boolean) a[0])); | ||
|
||
static { | ||
PARSER.declareField(constructorArg(), (parser, context) -> parser.booleanValue(), ELIGIBLE_TO_START_TRIAL, | ||
ObjectParser.ValueType.BOOLEAN); | ||
} | ||
|
||
private final boolean eligibleToStartTrial; | ||
|
||
GetTrialStatusResponse(boolean eligibleToStartTrial) { | ||
this.eligibleToStartTrial = eligibleToStartTrial; | ||
} | ||
|
||
/** | ||
* Returns whether the license is eligible to start trial or not | ||
*/ | ||
public boolean isEligibleToStartTrial() { | ||
return eligibleToStartTrial; | ||
} | ||
|
||
public static GetTrialStatusResponse fromXContent(XContentParser parser) { | ||
return PARSER.apply(parser, null); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
GetTrialStatusResponse that = (GetTrialStatusResponse) o; | ||
return eligibleToStartTrial == that.eligibleToStartTrial; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(eligibleToStartTrial); | ||
} | ||
|
||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
23 changes: 23 additions & 0 deletions
23
docs/java-rest/high-level/licensing/get-basic-status.asciidoc
This file contains hidden or 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,23 @@ | ||
[[java-rest-high-get-basic-status]] | ||
=== Get Basic Status | ||
|
||
[[java-rest-high-get-basic-status-execution]] | ||
==== Execution | ||
|
||
The basic status of the license can be retrieved as follows: | ||
|
||
["source","java",subs="attributes,callouts,macros"] | ||
-------------------------------------------------- | ||
include-tagged::{doc-tests}/LicensingDocumentationIT.java[get-basic-status-execute] | ||
-------------------------------------------------- | ||
|
||
[[java-rest-high-get-basic-status-response]] | ||
==== Response | ||
|
||
The returned `GetTrialStatusResponse` holds only a `boolean` flag: | ||
|
||
["source","java",subs="attributes,callouts,macros"] | ||
-------------------------------------------------- | ||
include-tagged::{doc-tests}/LicensingDocumentationIT.java[get-basic-status-response] | ||
-------------------------------------------------- | ||
<1> Whether the license is eligible to start basic or not |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I went for exposing only sync versions of these two methods, I don't see how they would be used in an async fashion. Also, I went for not adding an empty request and mimic what we already did with ping and info, which are somehow an exception when you look at the method argument.