Skip to content
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 Delete Privileges API to HLRC #35454

Merged
merged 5 commits into from
Nov 14, 2018

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Nov 12, 2018

This commit adds the Delete Privileges API to the high level REST client.

Related to #29827

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra


/**
* Asynchronously removes an application privilege
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/delete-role/delete-privilege

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw it and pushed 85bfdc8

public DeletePrivilegesRequest(String application, String[] privileges, RefreshPolicy refreshPolicy) {
this.application = Objects.requireNonNull(application, "application is required");
this.privileges = Objects.requireNonNull(privileges, "privileges are required");
this.refreshPolicy = Objects.requireNonNull(refreshPolicy, "refresh policy is required");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other APIs, we have allowed null and used RefreshPolicy.getDefault(). I don't have strong feelings for implicit vs explicit in this case but I think consistency helps. Would it make sense to make a decision and use this for all APIs? @hub-cap WDYT ?

Copy link
Member Author

@tlrx tlrx Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it consistent and changed the code to use the RefreshPolicy.getDefault().

We can still change this later if someone thinks it should be immediate too.

public void testDeletePrivilege() throws Exception {
RestHighLevelClient client = highLevelClient();
{
final Request createPrivilegeRequest = new Request("POST", "/_xpack/security/privilege");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mental note to possibly replcae this when Put Privilege is in place

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's why I asked you to review this :)

Copy link
Contributor

@bizybot bizybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few nits and some changes, else LGTM.

@tlrx
Copy link
Member Author

tlrx commented Nov 13, 2018

Thanks @jkakavas and @bizybot ! Code is updated.

Copy link
Contributor

@bizybot bizybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once the comments are addressed and the build is successful. Thank you.

if (token == null) {
token = parser.nextToken();
}
ensureExpectedToken(token, XContentParser.Token.START_OBJECT, parser::getTokenLocation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this earlier, I think this should be ensureExpectedToken(XContentParser.Token.START_OBJECT,token, parser::getTokenLocation)
(expected, actual, getTokenLocation or else might result in wrong error message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlrx tlrx force-pushed the add-delete-privileges-to-hlrc branch from 217acac to e33ac10 Compare November 14, 2018 09:23
@tlrx tlrx merged commit 5b7446b into elastic:master Nov 14, 2018
@tlrx tlrx deleted the add-delete-privileges-to-hlrc branch November 14, 2018 13:04
@tlrx
Copy link
Member Author

tlrx commented Nov 14, 2018

Thanks @jkakavas and @bizybot

tlrx added a commit that referenced this pull request Nov 14, 2018
This commit adds the Delete Privileges API to the high level REST
client.

Related to #29827
@tlrx tlrx added the v6.6.0 label Nov 14, 2018
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.

5 participants