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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding RestActions support for Detector Stats API (#237)
* Adding RestActions support for detector stats * Update SearchAnomalyDetectorAction.java * Adding Unit Tests
- Loading branch information
1 parent
71923ff
commit 4c52b23
Showing
8 changed files
with
351 additions
and
133 deletions.
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
...n/java/com/amazon/opendistroforelasticsearch/ad/transport/StatsAnomalyDetectorAction.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; | ||
|
||
public class StatsAnomalyDetectorAction extends ActionType<StatsAnomalyDetectorResponse> { | ||
public static final StatsAnomalyDetectorAction INSTANCE = new StatsAnomalyDetectorAction(); | ||
public static final String NAME = "cluster:admin/opendistro/ad/detector/stats"; | ||
|
||
private StatsAnomalyDetectorAction() { | ||
super(NAME, StatsAnomalyDetectorResponse::new); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
...java/com/amazon/opendistroforelasticsearch/ad/transport/StatsAnomalyDetectorResponse.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,50 @@ | ||
/* | ||
* 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 java.io.IOException; | ||
|
||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import com.amazon.opendistroforelasticsearch.ad.stats.ADStatsResponse; | ||
|
||
public class StatsAnomalyDetectorResponse extends ActionResponse implements ToXContentObject { | ||
private ADStatsResponse adStatsResponse; | ||
|
||
public StatsAnomalyDetectorResponse(StreamInput in) throws IOException { | ||
super(in); | ||
adStatsResponse = new ADStatsResponse(in); | ||
} | ||
|
||
public StatsAnomalyDetectorResponse(ADStatsResponse adStatsResponse) { | ||
this.adStatsResponse = adStatsResponse; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
adStatsResponse.writeTo(out); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
adStatsResponse.toXContent(builder, params); | ||
return builder; | ||
} | ||
} |
Oops, something went wrong.