-
Notifications
You must be signed in to change notification settings - Fork 25.2k
add start trial API to HLRC #33406
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
add start trial API to HLRC #33406
Conversation
Introduces client-specific request and response classes that do not depend on the server The `type` parameter is named `licenseType` in the response class to be more descriptive. The parts that make up the acknowledged-required response are given slightly different names than their server-response types to be consistent with the naming in the put license API
Pinging @elastic/es-core-infra |
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.
Hey great work, One thing id like to see is that we remove the HTTP verb from the name of the classes. Since this is High Level, I would like to see us move away from adding the HTTP verb, even though some of the older methods have them still. Its worth cleaning up before 7.0 imho, but lets def not add more :)
@@ -1278,6 +1279,26 @@ static Request deleteLicense(DeleteLicenseRequest deleteLicenseRequest) { | |||
return request; | |||
} | |||
|
|||
static Request postStartTrial(PostStartTrialRequest postStartTrialRequest) { |
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.
This should be in LicenseRequestConverters now
Totally agree on this |
@hub-cap I moved the request converter to LicenseRequestConverters and changed the API name from "post start trial" to "start trial" |
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.
Something I noticed is that somehow we do not have a LicensingIT
test class that does more against a live cluster, maybe can you add that and add some random tests with all the values in the request.
client/rest-high-level/src/main/java/org/elasticsearch/client/LicenseRequestConverters.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/license/StartTrialRequest.java
Outdated
Show resolved
Hide resolved
PARSER.declareString(optionalConstructorArg(), LICENSE_TYPE_FIELD); | ||
PARSER.declareString(optionalConstructorArg(), ERROR_MESSAGE_FIELD); | ||
// todo consolidate this parsing with the parsing in PutLicenseResponse | ||
PARSER.declareObject(optionalConstructorArg(), (parser, aVoid) -> { |
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.
I dont know a ton about this data structure here, but is it possible to use the parser's built in .map
functions to return a Map<String, Object>
?
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.
I think so, I'm not super knowledgeable about the parser facility. I'll give it a shot
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.
It looks like XContentFactory#map
works - somehow that version seems even uglier than the old school parsing code though, let me know if that's not what you meant.
It's a little tricky because the object looks like this, where the header ("message") is parsed as part of the map but is its own particular field that we pull out
{
"acknowledge": {
"message": "you need to acknowledge blah blah",
"security": [ "security won't be enabled blah blah" ],
"watcher": [ "another acknowledge message "],
}
}
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.
HAH, ill have a look.
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.
I think that its a bit nicer, given that you cant actually parse something incorrectly. Sure its manipulating a bunch of k/v stuff in that map, but the actual parsing logic is way trappier and more subject to fail if slightly messed up. mucking with a map of list of lists is pretty low from a trappy perspective.
client/rest-high-level/src/main/java/org/elasticsearch/client/license/StartTrialResponse.java
Outdated
Show resolved
Hide resolved
Pls also add a LicenseRequestConvertersTests to test your request converter. |
@hub-cap I pushed a couple commits that I believe address all your feedback |
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.
Sorry for the late reply. after test failures :) Left a comment about the use of the parsers builtin
map()
function which was the last bit of unresolved business i think.
.addPathPartAsIs("_xpack") | ||
.addPathPartAsIs("license") | ||
.build(); | ||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_xpack", "license").build(); |
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.
looks great now, ty for cleaning these up as well.
PARSER.declareString(optionalConstructorArg(), LICENSE_TYPE_FIELD); | ||
PARSER.declareString(optionalConstructorArg(), ERROR_MESSAGE_FIELD); | ||
// todo consolidate this parsing with the parsing in PutLicenseResponse | ||
PARSER.declareObject(optionalConstructorArg(), (parser, aVoid) -> { |
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.
I think that its a bit nicer, given that you cant actually parse something incorrectly. Sure its manipulating a bunch of k/v stuff in that map, but the actual parsing logic is way trappier and more subject to fail if slightly messed up. mucking with a map of list of lists is pretty low from a trappy perspective.
Jenkins test this please |
Introduces client-specific request and response classes that do not depend on the server The `type` parameter is named `licenseType` in the response class to be more descriptive. The parts that make up the acknowledged-required response are given slightly different names than their server-response types to be consistent with the naming in the put license API Tests do not cover all cases because the integ test cluster starts up with a trial license - this will be addressed in a future commit
Introduces client-specific request and response classes that do not depend on the server The `type` parameter is named `licenseType` in the response class to be more descriptive. The parts that make up the acknowledged-required response are given slightly different names than their server-response types to be consistent with the naming in the put license API Tests do not cover all cases because the integ test cluster starts up with a trial license - this will be addressed in a future commit
Introduces client-specific request and response classes that do not
depend on the server
The
type
parameter is namedlicenseType
in the response class to bemore descriptive. The parts that make up the acknowledged-required
response are given slightly different names than their server-response
types to be consistent with the naming in the put license API
@hub-cap I believe this is the blessed way to do this as of now, let me know if anything's not in the right place
This takes over from #32799 which I'll close