Skip to content

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

Merged

Conversation

andyb-elastic
Copy link
Contributor

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

@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

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
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Contributor

@hub-cap hub-cap left a 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) {
Copy link
Contributor

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

@andyb-elastic
Copy link
Contributor Author

remove the HTTP verb from the name of the classes

Totally agree on this

@andyb-elastic
Copy link
Contributor Author

@hub-cap I moved the request converter to LicenseRequestConverters and changed the API name from "post start trial" to "start trial"

Copy link
Contributor

@hub-cap hub-cap left a 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.

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) -> {
Copy link
Contributor

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> ?

Copy link
Contributor Author

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

Copy link
Contributor Author

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 "],
  }
}

Copy link
Contributor

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.

Copy link
Contributor

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.

@hub-cap
Copy link
Contributor

hub-cap commented Sep 19, 2018

Pls also add a LicenseRequestConvertersTests to test your request converter.

@andyb-elastic
Copy link
Contributor Author

@hub-cap I pushed a couple commits that I believe address all your feedback

Copy link
Contributor

@hub-cap hub-cap left a 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. :shipit: 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();
Copy link
Contributor

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) -> {
Copy link
Contributor

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.

@andyb-elastic
Copy link
Contributor Author

Jenkins test this please

@andyb-elastic andyb-elastic merged commit 18aa1c1 into elastic:master Oct 17, 2018
andyb-elastic added a commit that referenced this pull request Oct 17, 2018
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
@andyb-elastic
Copy link
Contributor Author

master: 18aa1c1
6.x: 53b9ff1

@colings86 colings86 added >enhancement and removed :Security/License License functionality for commercial features labels Oct 25, 2018
kcm pushed a commit that referenced this pull request Oct 30, 2018
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants