This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Adding RestActions support for AD Search Rest API's #234
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d07fe7
Adding RestActions support for AD Search Rest API's
saratvemulapalli 4ca0da3
Adding Unit Tests and updating Action name's
saratvemulapalli 35d28e7
Fixing typo for one of the Unit Test
saratvemulapalli 3e534c2
Removing .* imports
saratvemulapalli a853b1a
Adding spotless changes
saratvemulapalli 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 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 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 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 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
28 changes: 28 additions & 0 deletions
28
.../java/com/amazon/opendistroforelasticsearch/ad/transport/SearchAnomalyDetectorAction.java
This file contains 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,28 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.ad.transport; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.search.SearchResponse; | ||
|
||
public class SearchAnomalyDetectorAction extends ActionType<SearchResponse> { | ||
public static final SearchAnomalyDetectorAction INSTANCE = new SearchAnomalyDetectorAction(); | ||
public static final String NAME = "cluster:admin/ad/search/detector"; | ||
|
||
private SearchAnomalyDetectorAction() { | ||
super(NAME, SearchResponse::new); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../amazon/opendistroforelasticsearch/ad/transport/SearchAnomalyDetectorTransportAction.java
This file contains 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,57 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.ad.transport; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.search.SearchRequest; | ||
import org.elasticsearch.action.search.SearchResponse; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.HandledTransportAction; | ||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
|
||
public class SearchAnomalyDetectorTransportAction extends HandledTransportAction<SearchRequest, SearchResponse> { | ||
|
||
private final Client client; | ||
|
||
@Inject | ||
public SearchAnomalyDetectorTransportAction( | ||
TransportService transportService, | ||
ActionFilters actionFilters, | ||
Client client | ||
) { | ||
super(SearchAnomalyDetectorAction.NAME, transportService, actionFilters, SearchRequest::new); | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
protected void doExecute(Task task, SearchRequest request, ActionListener<SearchResponse> listener) { | ||
client.search(request, new ActionListener<SearchResponse>() { | ||
@Override | ||
public void onResponse(SearchResponse searchResponse) { | ||
listener.onResponse(searchResponse); | ||
} | ||
|
||
@Override | ||
public void onFailure(Exception e) { | ||
listener.onFailure(e); | ||
} | ||
}); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...in/java/com/amazon/opendistroforelasticsearch/ad/transport/SearchAnomalyResultAction.java
This file contains 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,28 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.ad.transport; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.search.SearchResponse; | ||
|
||
public class SearchAnomalyResultAction extends ActionType<SearchResponse> { | ||
public static final SearchAnomalyResultAction INSTANCE = new SearchAnomalyResultAction(); | ||
public static final String NAME = "cluster:admin/ad/search/result"; | ||
|
||
private SearchAnomalyResultAction() { | ||
super(NAME, SearchResponse::new); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...om/amazon/opendistroforelasticsearch/ad/transport/SearchAnomalyResultTransportAction.java
This file contains 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,57 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.ad.transport; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.search.SearchRequest; | ||
import org.elasticsearch.action.search.SearchResponse; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.HandledTransportAction; | ||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
|
||
public class SearchAnomalyResultTransportAction extends HandledTransportAction<SearchRequest, SearchResponse> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NP: your rest handler is called : There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thats a good point. Existing Transport Actions were named that way, so I just followed them to be consistent. |
||
|
||
private final Client client; | ||
|
||
@Inject | ||
public SearchAnomalyResultTransportAction( | ||
TransportService transportService, | ||
ActionFilters actionFilters, | ||
Client client | ||
) { | ||
super(SearchAnomalyResultAction.NAME, transportService, actionFilters, SearchRequest::new); | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
protected void doExecute(Task task, SearchRequest request, ActionListener<SearchResponse> listener) { | ||
client.search(request, new ActionListener<SearchResponse>() { | ||
@Override | ||
public void onResponse(SearchResponse searchResponse) { | ||
listener.onResponse(searchResponse); | ||
} | ||
|
||
@Override | ||
public void onFailure(Exception e) { | ||
listener.onFailure(e); | ||
} | ||
}); | ||
} | ||
} |
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.
Lets use
opendistro
in the action name. For example:cluster:admin/opendistro/alerting/destinations/write
Also you might want to end with verb like:
cluster:admin/opendistro/ad/detectors/search
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.
Sure that makes sense.
Will make changes.