Skip to content
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

[Entity Analytics] Improve response body for asset criticality delete route #189872

Merged

Conversation

hop-dev
Copy link
Contributor

@hop-dev hop-dev commented Aug 5, 2024

While doing the API docs I noticed the asset criticality delete route did not return a response body, and returned a very ugly 404 if you attempted to delete something which didnt exist...

{"message":"{\"_index\":\".asset-criticality.asset-criticality-default\",\"_id\":\"host.name:my_host\",\"_version\":1,\"result\":\"not_found\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"_seq_no\":0,\"_primary_term\":1}","full_error":"{\"name\":\"ResponseError\",\"message\":\"{\\\"_index\\\":\\\".asset-criticality.asset-criticality-default\\\",\\\"_id\\\":\\\"host.name:my_host\\\",\\\"_version\\\":1,\\\"result\\\":\\\"not_found\\\",\\\"_shards\\\":{\\\"total\\\":2,\\\"successful\\\":1,\\\"failed\\\":0},\\\"_seq_no\\\":0,\\\"_primary_term\\\":1}\"}","status_code":404}%

I have now made it so that we return a boolean for if the record was deleted or not (false if the record didnt exist) and we also return the record that was deleted if it was, e.g...

{
    "deleted": true,
    "record": {
        "id_field": "host.name",
        "id_value": "my_host",
        "criticality_level": "medium_impact",
        "@timestamp": "2024-08-05T09:42:11.240Z"
    }
}

And if the record didnt exist...

{
    "deleted": false,
}

@hop-dev hop-dev added release_note:enhancement Team:Entity Analytics Security Entity Analytics Team labels Aug 5, 2024
@hop-dev hop-dev self-assigned this Aug 5, 2024
@hop-dev hop-dev requested a review from a team as a code owner August 5, 2024 11:26
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-entity-analytics (Team:Entity Analytics)

Copy link
Contributor

@tiansivive tiansivive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner August 5, 2024 12:13
@hop-dev hop-dev enabled auto-merge (squash) August 5, 2024 12:26
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #8 / machine learning - anomaly detection forecasts with single metric job displays job results

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @hop-dev

@hop-dev hop-dev merged commit 70a4ad4 into elastic:main Aug 5, 2024
41 checks passed
@hop-dev hop-dev deleted the asset-criticality-delete-api-improvements branch August 5, 2024 13:41
@kibanamachine kibanamachine added v8.16.0 backport:skip This commit does not require backporting labels Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:enhancement Team:Entity Analytics Security Entity Analytics Team v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants