-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class DeleteCustomLogTypeAction extends ActionType<DeleteCustomLogTypeResponse> { | ||
|
||
public static final DeleteCustomLogTypeAction INSTANCE = new DeleteCustomLogTypeAction(); | ||
Check warning on line 15 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeAction.java
|
||
public static final String NAME = "cluster:admin/opensearch/securityanalytics/logtype/delete"; | ||
|
||
public DeleteCustomLogTypeAction() { | ||
super(NAME, DeleteCustomLogTypeResponse::new); | ||
} | ||
Check warning on line 20 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeAction.java
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.action.support.WriteRequest; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class DeleteCustomLogTypeRequest extends ActionRequest { | ||
|
||
private String logTypeId; | ||
|
||
private WriteRequest.RefreshPolicy refreshPolicy; | ||
|
||
public DeleteCustomLogTypeRequest(String logTypeId, WriteRequest.RefreshPolicy refreshPolicy) { | ||
super(); | ||
this.logTypeId = logTypeId; | ||
this.refreshPolicy = refreshPolicy; | ||
} | ||
Check warning on line 29 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeRequest.java
|
||
|
||
public DeleteCustomLogTypeRequest(StreamInput sin) throws IOException { | ||
this(sin.readString(), | ||
WriteRequest.RefreshPolicy.readFrom(sin)); | ||
} | ||
Check warning on line 34 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeRequest.java
|
||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
Check warning on line 38 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeRequest.java
|
||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(logTypeId); | ||
refreshPolicy.writeTo(out); | ||
} | ||
Check warning on line 45 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeRequest.java
|
||
|
||
public String getLogTypeId() { | ||
return logTypeId; | ||
Check warning on line 48 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeRequest.java
|
||
} | ||
|
||
public WriteRequest.RefreshPolicy getRefreshPolicy() { | ||
return refreshPolicy; | ||
Check warning on line 52 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeRequest.java
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionResponse; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import org.opensearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.opensearch.securityanalytics.util.RestHandlerUtils._ID; | ||
import static org.opensearch.securityanalytics.util.RestHandlerUtils._VERSION; | ||
|
||
public class DeleteCustomLogTypeResponse extends ActionResponse implements ToXContentObject { | ||
|
||
private String id; | ||
|
||
private Long version; | ||
|
||
private RestStatus status; | ||
|
||
public DeleteCustomLogTypeResponse(String id, Long version, RestStatus status) { | ||
super(); | ||
this.id = id; | ||
this.version = version; | ||
this.status = status; | ||
} | ||
Check warning on line 36 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeResponse.java
|
||
|
||
public DeleteCustomLogTypeResponse(StreamInput sin) throws IOException { | ||
this( | ||
sin.readString(), | ||
sin.readLong(), | ||
sin.readEnum(RestStatus.class) | ||
Check warning on line 42 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeResponse.java
|
||
); | ||
} | ||
Check warning on line 44 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeResponse.java
|
||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject() | ||
.field(_ID, id) | ||
.field(_VERSION, version); | ||
return builder.endObject(); | ||
Check warning on line 51 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeResponse.java
|
||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(id); | ||
out.writeLong(version); | ||
} | ||
Check warning on line 58 in src/main/java/org/opensearch/securityanalytics/action/DeleteCustomLogTypeResponse.java
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class IndexCustomLogTypeAction extends ActionType<IndexCustomLogTypeResponse> { | ||
|
||
public static final IndexCustomLogTypeAction INSTANCE = new IndexCustomLogTypeAction(); | ||
public static final String NAME = "cluster:admin/opensearch/securityanalytics/logtype/write"; | ||
|
||
public IndexCustomLogTypeAction() { | ||
super(NAME, IndexCustomLogTypeResponse::new); | ||
} | ||
Check warning on line 20 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeAction.java
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.action.support.WriteRequest; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.rest.RestRequest; | ||
import org.opensearch.securityanalytics.model.CustomLogType; | ||
|
||
import java.io.IOException; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class IndexCustomLogTypeRequest extends ActionRequest { | ||
|
||
private String logTypeId; | ||
|
||
private WriteRequest.RefreshPolicy refreshPolicy; | ||
|
||
private RestRequest.Method method; | ||
|
||
private CustomLogType customLogType; | ||
|
||
private static final Pattern IS_VALID_CUSTOM_LOG_NAME = Pattern.compile("[a-zA-Z0-9 _,-.]{5,50}"); | ||
Check warning on line 33 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
|
||
public IndexCustomLogTypeRequest( | ||
String logTypeId, | ||
WriteRequest.RefreshPolicy refreshPolicy, | ||
RestRequest.Method method, | ||
CustomLogType customLogType | ||
) { | ||
super(); | ||
this.logTypeId = logTypeId; | ||
this.refreshPolicy = refreshPolicy; | ||
this.method = method; | ||
this.customLogType = customLogType; | ||
} | ||
Check warning on line 46 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
|
||
public IndexCustomLogTypeRequest(StreamInput sin) throws IOException { | ||
this( | ||
sin.readString(), | ||
WriteRequest.RefreshPolicy.readFrom(sin), | ||
sin.readEnum(RestRequest.Method.class), | ||
CustomLogType.readFrom(sin) | ||
Check warning on line 53 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
); | ||
} | ||
Check warning on line 55 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
Matcher matcher = IS_VALID_CUSTOM_LOG_NAME.matcher(customLogType.getName()); | ||
boolean find = matcher.matches(); | ||
Check warning on line 60 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
if (!find) { | ||
throw new ActionRequestValidationException(); | ||
Check warning on line 62 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
} | ||
return null; | ||
Check warning on line 64 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(logTypeId); | ||
refreshPolicy.writeTo(out); | ||
out.writeEnum(method); | ||
customLogType.writeTo(out); | ||
} | ||
Check warning on line 73 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
|
||
public String getLogTypeId() { | ||
return logTypeId; | ||
Check warning on line 76 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
} | ||
|
||
public WriteRequest.RefreshPolicy getRefreshPolicy() { | ||
return refreshPolicy; | ||
Check warning on line 80 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
} | ||
|
||
public RestRequest.Method getMethod() { | ||
return method; | ||
Check warning on line 84 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
} | ||
|
||
public CustomLogType getCustomLogType() { | ||
return customLogType; | ||
Check warning on line 88 in src/main/java/org/opensearch/securityanalytics/action/IndexCustomLogTypeRequest.java
|
||
} | ||
} |