-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: AWSHurneyt <[email protected]>
- Loading branch information
1 parent
2b9e04a
commit 5429ac9
Showing
9 changed files
with
255 additions
and
149 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
50 changes: 50 additions & 0 deletions
50
src/main/java/org/opensearch/securityanalytics/action/FetchIocsActionResponse.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 OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.core.action.ActionResponse; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import org.opensearch.securityanalytics.model.IOC; | ||
import org.opensearch.securityanalytics.model.IocDto; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class FetchIocsActionResponse extends ActionResponse implements ToXContentObject { | ||
public static String IOCS_FIELD = "iocs"; | ||
public static String TOTAL_FIELD = "total"; | ||
private List<IocDto> iocs = Collections.emptyList(); | ||
|
||
public FetchIocsActionResponse(List<IOC> iocs) { | ||
super(); | ||
iocs.forEach( ioc -> this.iocs.add(new IocDto(ioc))); | ||
} | ||
|
||
public FetchIocsActionResponse(StreamInput sin) throws IOException { | ||
this(sin.readList(IOC::new)); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeList(iocs); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
return builder.startObject() | ||
.field(IOCS_FIELD, this.iocs) | ||
.field(TOTAL_FIELD, this.iocs.size()) | ||
.endObject(); | ||
} | ||
|
||
public List<IocDto> getIocs() { | ||
return iocs; | ||
} | ||
} |
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
Oops, something went wrong.