Skip to content

[Cases] Add bulk attachments internal route#129092

Merged
cnasikas merged 13 commits intoelastic:mainfrom
cnasikas:bulk_add_attachments
Apr 14, 2022
Merged

[Cases] Add bulk attachments internal route#129092
cnasikas merged 13 commits intoelastic:mainfrom
cnasikas:bulk_add_attachments

Conversation

@cnasikas
Copy link
Copy Markdown
Member

@cnasikas cnasikas commented Mar 31, 2022

Summary

This PR adds the ability to bulk attach attachments to a case. It creates the following internal route:

POST /internal/cases/{case_id}/attachments/_bulk_create

Testing

To test the new endpoint do the following request and check if you see the attachments in the case.

POST /internal/cases/<case_id>/attachments/_bulk_create

[
    {
        "alertId": [
            "40ed218f68f268172de6e86a0eba05f366e25913bee7faeda0ccbc677206a0c8"
        ],
        "index": [
            ".internal.alerts-security.alerts-default-000001"
        ],
        "rule": {
            "id": null,
            "name": null
        },
        "type": "alert",
        "owner": "securitySolution"
    },
    {
        "type": "user",
        "comment": "a comment",
        "owner": "securitySolution"
    }
]

Closes: #124814

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@cnasikas cnasikas self-assigned this Mar 31, 2022
@cnasikas cnasikas added Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// Feature:Cases Cases feature v8.3.0 release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Mar 31, 2022
@cnasikas cnasikas force-pushed the bulk_add_attachments branch from 7439a55 to bc9bf1d Compare March 31, 2022 16:10
@cnasikas cnasikas force-pushed the bulk_add_attachments branch from bc9bf1d to c0ddc3a Compare April 1, 2022 17:05
@cnasikas
Copy link
Copy Markdown
Member Author

cnasikas commented Apr 4, 2022

@elasticmachine merge upstream

@cnasikas cnasikas marked this pull request as ready for review April 11, 2022 13:15
@cnasikas cnasikas requested a review from a team as a code owner April 11, 2022 13:15
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@cnasikas cnasikas requested a review from academo April 11, 2022 13:15
Copy link
Copy Markdown
Contributor

@academo academo left a comment

Choose a reason for hiding this comment

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

Something that is not clear in the code for me: What happens if we hit the API with 0 attachments? would it fail on the validation? Can you also add a test for it?

@cnasikas cnasikas requested a review from academo April 13, 2022 10:09
@kibana-ci
Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Default CI Group #9 / maps app auto fit map to bounds initial location should automatically fit to bounds on initial map load

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 90.6KB 90.7KB +11.0B

History

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

cc @cnasikas

savedObjectsWithoutErrors.some((so) => so.id === attachment.id)
);

await Promise.all([
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cnasikas this is one of those cases I mentioned where things can fail but still succeed. e.g. the attachments are created but the user actions are not.

no need to take action, just a good example of it.

Copy link
Copy Markdown
Contributor

@academo academo left a comment

Choose a reason for hiding this comment

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

Thanks for the test changes!

@cnasikas cnasikas merged commit b5817af into elastic:main Apr 14, 2022
@cnasikas cnasikas deleted the bulk_add_attachments branch April 14, 2022 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Cases Cases feature release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cases] Support bulk cases POST comment

5 participants