-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/threat_intel_feeds' into job
Signed-off-by: Joanne Wang <[email protected]>
- Loading branch information
Showing
4 changed files
with
86 additions
and
2 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
65 changes: 65 additions & 0 deletions
65
src/main/java/org/opensearch/securityanalytics/threatIntel/action/RestPutTIFJobHandler.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,65 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.threatIntel.action; | ||
|
||
import org.opensearch.client.node.NodeClient; | ||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.unit.TimeValue; | ||
import org.opensearch.core.xcontent.XContentParser; | ||
import org.opensearch.rest.BaseRestHandler; | ||
import org.opensearch.rest.RestRequest; | ||
import org.opensearch.rest.action.RestToXContentListener; | ||
import org.opensearch.securityanalytics.settings.SecurityAnalyticsSettings; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.opensearch.rest.RestRequest.Method.GET; | ||
import static org.opensearch.rest.RestRequest.Method.PUT; | ||
|
||
/** | ||
* Rest handler for threat intel TIFjob creation | ||
* | ||
* This handler handles a request of | ||
* PUT /_plugins/security_analytics/threatintel/tifjob/{id} | ||
* { | ||
* "id": {id}, | ||
* "name": {name}, | ||
* "update_interval_in_days": 1 | ||
* } | ||
* | ||
* When request is received, it will create a TIFjob | ||
* After the creation of TIFjob is completed, it will schedule the next update task after update_interval_in_days. | ||
* | ||
*/ | ||
public class RestPutTIFJobHandler extends BaseRestHandler { | ||
private static final String ACTION_NAME = "threatintel_tifjob_put"; | ||
private final ClusterSettings clusterSettings; | ||
|
||
public RestPutTIFJobHandler(final ClusterSettings clusterSettings) { | ||
this.clusterSettings = clusterSettings; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return ACTION_NAME; | ||
} | ||
|
||
@Override | ||
protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { | ||
final PutTIFJobRequest putTIFJobRequest = new PutTIFJobRequest("jobname", | ||
new TimeValue(1, TimeUnit.MINUTES)); | ||
|
||
return channel -> client.executeLocally(PutTIFJobAction.INSTANCE, putTIFJobRequest, new RestToXContentListener<>(channel)); | ||
} | ||
|
||
@Override | ||
public List<Route> routes() { | ||
String path = "/_p/_s"; | ||
return List.of(new Route(GET, path)); | ||
} | ||
} |
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