-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete threat intel source config API #1066
Delete threat intel source config API #1066
Conversation
Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: Joanne Wang <[email protected]>
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; |
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.
Should there be a check here to assert that the id
is not null or empty?
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.
Added a check to ensure id exists
@@ -158,7 +159,8 @@ public void deleteTIFSourceConfig( | |||
SATIFSourceConfig SaTifSourceConfig = convertToSATIFConfig(SaTifSourceConfigDto); | |||
SaTifSourceConfigService.deleteTIFSourceConfig(SaTifSourceConfig, ActionListener.wrap( | |||
deleteResponse -> { | |||
log.debug("Successfully deleted threat intel source config"); | |||
log.debug("Successfully deleted threat intel source config [{}]", SaTifSourceConfig.getId()); |
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.
Not blocking, but should we consider making this an info-level log?
@@ -248,7 +246,7 @@ public void deleteTIFSourceConfig( | |||
client.delete(request, ActionListener.wrap( | |||
deleteResponse -> { | |||
if (deleteResponse.status().equals(RestStatus.OK)) { | |||
log.info("Deleted threat intel source config [{}] successfully", SaTifSourceConfig.getId()); | |||
log.debug("Deleted threat intel source config [{}] successfully", SaTifSourceConfig.getId()); |
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.
Same question as above.
Signed-off-by: Joanne Wang <[email protected]>
|
||
public class SADeleteTIFSourceConfigResponse extends ActionResponse implements ToXContentObject { | ||
private final String id; | ||
private final RestStatus status; |
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.
what status implies deleted?
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.
if the delete response is OK
then the document is deleted successfully.
@@ -10,4 +10,6 @@ | |||
public class Constants { | |||
public static final String USER_AGENT_KEY = "User-Agent"; | |||
public static final String USER_AGENT_VALUE = String.format(Locale.ROOT, "OpenSearch/%s vanilla", Version.CURRENT.toString()); | |||
public static final String SOURCE_CONFIG_ID = "source_config_id"; |
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.
MEGA-NIT: threat_intel_source_config_id?
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.
changed to threat_intel_source_config_id
|
||
@Override | ||
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { | ||
String SaTifSourceConfigId = request.param(SOURCE_CONFIG_ID, SATIFSourceConfigDto.NO_ID); |
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.
lower case letter to begin variable name
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.
fixed
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { | ||
String SaTifSourceConfigId = request.param(SOURCE_CONFIG_ID, SATIFSourceConfigDto.NO_ID); | ||
|
||
if (SaTifSourceConfigId == null || SaTifSourceConfigId.isEmpty()) { |
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.
nit: Stringutils.isBlank() instead
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.
changed
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.
if there is only one config and it it's being deleted we need to ensure there are no jobs
Fail the delete request of the config saying plz delete all threat intel monitors before deleting the last config
Signed-off-by: Joanne Wang <[email protected]>
Added a method |
Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: Joanne Wang <[email protected]>
686d317
into
opensearch-project:feature/threat_intel
* delete api Signed-off-by: Joanne Wang <[email protected]> * clean up Signed-off-by: Joanne Wang <[email protected]> * delete api integ test Signed-off-by: Joanne Wang <[email protected]> * added validation logic Signed-off-by: Joanne Wang <[email protected]> * respond to comments Signed-off-by: Joanne Wang <[email protected]> * fix merge conflicts Signed-off-by: Joanne Wang <[email protected]> * fix merge conflicts Signed-off-by: Joanne Wang <[email protected]> --------- Signed-off-by: Joanne Wang <[email protected]>
Description
Architecture for delete threat intel source config API
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.