Skip to content

Commit

Permalink
[Cases] Support bulk creating cases though the cases client (#170326)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas authored Nov 7, 2023
1 parent 42b3526 commit 30e6677
Show file tree
Hide file tree
Showing 32 changed files with 2,954 additions and 241 deletions.
23 changes: 23 additions & 0 deletions x-pack/plugins/cases/common/types/api/case/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ export const CasePostRequestRt = rt.intersection([
),
]);

/**
* Bulk create cases
*/

const CaseCreateRequestWithOptionalId = rt.intersection([
CasePostRequestRt,
rt.exact(rt.partial({ id: rt.string })),
]);

export const BulkCreateCasesRequestRt = rt.strict({
cases: rt.array(CaseCreateRequestWithOptionalId),
});

export const BulkCreateCasesResponseRt = rt.strict({
cases: rt.array(CaseRt),
});

/**
* Find cases
*/

export const CasesFindRequestSearchFieldsRt = rt.keyof({
description: null,
title: null,
Expand Down Expand Up @@ -480,3 +501,5 @@ export type CasesBulkGetRequest = rt.TypeOf<typeof CasesBulkGetRequestRt>;
export type CasesBulkGetResponse = rt.TypeOf<typeof CasesBulkGetResponseRt>;
export type GetRelatedCasesByAlertResponse = rt.TypeOf<typeof GetRelatedCasesByAlertResponseRt>;
export type CaseRequestCustomFields = rt.TypeOf<typeof CustomFieldsRt>;
export type BulkCreateCasesRequest = rt.TypeOf<typeof BulkCreateCasesRequestRt>;
export type BulkCreateCasesResponse = rt.TypeOf<typeof BulkCreateCasesResponseRt>;
16 changes: 9 additions & 7 deletions x-pack/plugins/cases/server/client/attachments/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,15 @@ export async function deleteComment(
const attachmentRequestAttributes = decodeOrThrow(AttachmentRequestRt)(attachment.attributes);

await userActionService.creator.createUserAction({
type: UserActionTypes.comment,
action: UserActionActions.delete,
caseId: id,
attachmentId: attachmentID,
payload: { attachment: attachmentRequestAttributes },
user,
owner: attachment.attributes.owner,
userAction: {
type: UserActionTypes.comment,
action: UserActionActions.delete,
caseId: id,
attachmentId: attachmentID,
payload: { attachment: attachmentRequestAttributes },
user,
owner: attachment.attributes.owner,
},
});

await handleAlerts({ alertsService, attachments: [attachment.attributes], caseId: id });
Expand Down
Loading

0 comments on commit 30e6677

Please sign in to comment.