-
Notifications
You must be signed in to change notification settings - Fork 25.6k
HLRC: Add delete user action #35294
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
Merged
HLRC: Add delete user action #35294
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
396e65c
HLRC: Add delete user action
iverase 876f4a0
Fix precommit
iverase ae9059f
Fix precommit
iverase 2d4aa98
Merge remote-tracking branch 'origin/master' into deleteUser
iverase 321935a
address some of the review comments
iverase e4a0904
fist bug serializing response
iverase 058f6c4
Implement DeleteUserResponse by extending AcknowledgedResponse
iverase 86786e2
Merge remote-tracking branch 'origin/master' into deleteUser
iverase ff6f055
Acknowledge response is in core now
iverase 041aeb6
javadocs
iverase ee6d4c6
simplify docs
iverase a2f2d52
sync with head and implement response as Optional
iverase 7465462
fix checkStyle
iverase b83312d
remove otioonal and use AcknowledgeResponse
iverase e89ea8b
Merge remote-tracking branch 'origin/master' into deleteUser
iverase 7e90b83
Implement delete response
iverase f3e76a5
remove unused imports
iverase 0351a26
add license
iverase 5f10520
formatting
iverase 1f7fb31
add license
iverase c697fc0
fix checkStyle
iverase a55981a
Merge remote-tracking branch 'origin/master' into deleteUser
iverase 4368f2e
Merge remote-tracking branch 'origin/master' into deleteUser
iverase d4d66af
Merge remote-tracking branch 'origin/master' into deleteUser
iverase 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
71 changes: 71 additions & 0 deletions
71
...nt/rest-high-level/src/main/java/org/elasticsearch/client/security/DeleteUserRequest.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,71 @@ | ||
| /* | ||
| * 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.security; | ||
|
|
||
| import org.elasticsearch.client.Validatable; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * A request to delete a user from the native realm. | ||
| */ | ||
| public final class DeleteUserRequest implements Validatable { | ||
|
|
||
| private final String name; | ||
| private final RefreshPolicy refreshPolicy; | ||
|
|
||
| public DeleteUserRequest(String name) { | ||
| this(name, RefreshPolicy.IMMEDIATE); | ||
| } | ||
|
|
||
| public DeleteUserRequest(String name, RefreshPolicy refreshPolicy) { | ||
| this.name = Objects.requireNonNull(name, "user name is required"); | ||
| this.refreshPolicy = Objects.requireNonNull(refreshPolicy, "refresh policy is required"); | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public RefreshPolicy getRefreshPolicy() { | ||
| return refreshPolicy; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(name, refreshPolicy); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
| if (obj == null) { | ||
| return false; | ||
| } | ||
| if (getClass() != obj.getClass()) { | ||
| return false; | ||
| } | ||
| final DeleteUserRequest other = (DeleteUserRequest) obj; | ||
|
|
||
| return (refreshPolicy == other.refreshPolicy) && Objects.equals(name, other.name); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
...t/rest-high-level/src/main/java/org/elasticsearch/client/security/DeleteUserResponse.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,50 @@ | ||
| /* | ||
| * 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.security; | ||
|
|
||
| import org.elasticsearch.client.core.AcknowledgedResponse; | ||
| import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
| import org.elasticsearch.common.xcontent.XContentParser; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Response for a user being deleted from the native realm | ||
| */ | ||
| public final class DeleteUserResponse extends AcknowledgedResponse { | ||
|
|
||
| private static final String PARSE_FIELD_NAME = "found"; | ||
|
|
||
| private static final ConstructingObjectParser<DeleteUserResponse, Void> PARSER = AcknowledgedResponse | ||
| .generateParser("delete_user_response", DeleteUserResponse::new, PARSE_FIELD_NAME); | ||
|
|
||
| public DeleteUserResponse(boolean acknowledged) { | ||
| super(acknowledged); | ||
| } | ||
|
|
||
| public static DeleteUserResponse fromXContent(final XContentParser parser) throws IOException { | ||
| return PARSER.parse(parser, null); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getFieldName() { | ||
| return PARSE_FIELD_NAME; | ||
| } | ||
| } | ||
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
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.
I think we can gut this altogether since optional has a "isPresent()" field. See #35470 and leave your thoughts there or here.
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.
Im still on the fence for whether we even need a found true/false in the code since we return an optional. WDYT?