Skip to content

Commit 1b598dd

Browse files
[Cases] Route: Get all alerts attach to a case (#101878)
Co-authored-by: Jonathan Buttner <jonathan.buttner@elastic.co>
1 parent 711da58 commit 1b598dd

46 files changed

Lines changed: 674 additions & 111 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import * as rt from 'io-ts';
9+
10+
const AlertRt = rt.type({
11+
id: rt.string,
12+
index: rt.string,
13+
attached_at: rt.string,
14+
});
15+
16+
export const AlertResponseRt = rt.array(AlertRt);
17+
18+
export type AlertResponse = rt.TypeOf<typeof AlertResponseRt>;

x-pack/plugins/cases/common/api/cases/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export * from './status';
1212
export * from './user_actions';
1313
export * from './sub_case';
1414
export * from './constants';
15+
export * from './alerts';

x-pack/plugins/cases/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const CASE_TAGS_URL = `${CASES_URL}/tags`;
5151
export const CASE_USER_ACTIONS_URL = `${CASE_DETAILS_URL}/user_actions`;
5252

5353
export const CASE_ALERTS_URL = `${CASES_URL}/alerts/{alert_id}`;
54+
export const CASE_DETAILS_ALERTS_URL = `${CASE_DETAILS_URL}/alerts`;
5455

5556
/**
5657
* Action routes

x-pack/plugins/cases/docs/cases_client/classes/client.casesclient.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,63 +45,63 @@ Client wrapper that contains accessor methods for individual entities within the
4545

4646
**Returns:** [*CasesClient*](client.casesclient.md)
4747

48-
Defined in: [client.ts:28](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L28)
48+
Defined in: [client.ts:28](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L28)
4949

5050
## Properties
5151

5252
### \_attachments
5353

5454
`Private` `Readonly` **\_attachments**: [*AttachmentsSubClient*](../interfaces/attachments_client.attachmentssubclient.md)
5555

56-
Defined in: [client.ts:24](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L24)
56+
Defined in: [client.ts:24](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L24)
5757

5858
___
5959

6060
### \_cases
6161

6262
`Private` `Readonly` **\_cases**: [*CasesSubClient*](../interfaces/cases_client.casessubclient.md)
6363

64-
Defined in: [client.ts:23](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L23)
64+
Defined in: [client.ts:23](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L23)
6565

6666
___
6767

6868
### \_casesClientInternal
6969

7070
`Private` `Readonly` **\_casesClientInternal**: *CasesClientInternal*
7171

72-
Defined in: [client.ts:22](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L22)
72+
Defined in: [client.ts:22](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L22)
7373

7474
___
7575

7676
### \_configure
7777

7878
`Private` `Readonly` **\_configure**: [*ConfigureSubClient*](../interfaces/configure_client.configuresubclient.md)
7979

80-
Defined in: [client.ts:27](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L27)
80+
Defined in: [client.ts:27](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L27)
8181

8282
___
8383

8484
### \_stats
8585

8686
`Private` `Readonly` **\_stats**: [*StatsSubClient*](../interfaces/stats_client.statssubclient.md)
8787

88-
Defined in: [client.ts:28](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L28)
88+
Defined in: [client.ts:28](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L28)
8989

9090
___
9191

9292
### \_subCases
9393

9494
`Private` `Readonly` **\_subCases**: [*SubCasesClient*](../interfaces/sub_cases_client.subcasesclient.md)
9595

96-
Defined in: [client.ts:26](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L26)
96+
Defined in: [client.ts:26](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L26)
9797

9898
___
9999

100100
### \_userActions
101101

102102
`Private` `Readonly` **\_userActions**: [*UserActionsSubClient*](../interfaces/user_actions_client.useractionssubclient.md)
103103

104-
Defined in: [client.ts:25](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L25)
104+
Defined in: [client.ts:25](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L25)
105105

106106
## Accessors
107107

@@ -113,7 +113,7 @@ Retrieves an interface for interacting with attachments (comments) entities.
113113

114114
**Returns:** [*AttachmentsSubClient*](../interfaces/attachments_client.attachmentssubclient.md)
115115

116-
Defined in: [client.ts:50](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L50)
116+
Defined in: [client.ts:50](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L50)
117117

118118
___
119119

@@ -125,7 +125,7 @@ Retrieves an interface for interacting with cases entities.
125125

126126
**Returns:** [*CasesSubClient*](../interfaces/cases_client.casessubclient.md)
127127

128-
Defined in: [client.ts:43](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L43)
128+
Defined in: [client.ts:43](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L43)
129129

130130
___
131131

@@ -137,7 +137,7 @@ Retrieves an interface for interacting with the configuration of external connec
137137

138138
**Returns:** [*ConfigureSubClient*](../interfaces/configure_client.configuresubclient.md)
139139

140-
Defined in: [client.ts:76](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L76)
140+
Defined in: [client.ts:76](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L76)
141141

142142
___
143143

@@ -149,7 +149,7 @@ Retrieves an interface for retrieving statistics related to the cases entities.
149149

150150
**Returns:** [*StatsSubClient*](../interfaces/stats_client.statssubclient.md)
151151

152-
Defined in: [client.ts:83](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L83)
152+
Defined in: [client.ts:83](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L83)
153153

154154
___
155155

@@ -163,7 +163,7 @@ Currently this functionality is disabled and will throw an error if this functio
163163

164164
**Returns:** [*SubCasesClient*](../interfaces/sub_cases_client.subcasesclient.md)
165165

166-
Defined in: [client.ts:66](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L66)
166+
Defined in: [client.ts:66](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L66)
167167

168168
___
169169

@@ -175,4 +175,4 @@ Retrieves an interface for interacting with the user actions associated with the
175175

176176
**Returns:** [*UserActionsSubClient*](../interfaces/user_actions_client.useractionssubclient.md)
177177

178-
Defined in: [client.ts:57](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/client.ts#L57)
178+
Defined in: [client.ts:57](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/client.ts#L57)

x-pack/plugins/cases/docs/cases_client/interfaces/attachments_add.addargs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The arguments needed for creating a new attachment to a case.
2121

2222
The case ID that this attachment will be associated with
2323

24-
Defined in: [attachments/add.ts:308](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/add.ts#L308)
24+
Defined in: [attachments/add.ts:305](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/add.ts#L305)
2525

2626
___
2727

@@ -31,4 +31,4 @@ ___
3131

3232
The attachment values.
3333

34-
Defined in: [attachments/add.ts:312](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/add.ts#L312)
34+
Defined in: [attachments/add.ts:309](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/add.ts#L309)

x-pack/plugins/cases/docs/cases_client/interfaces/attachments_client.attachmentssubclient.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ API for interacting with the attachments to a case.
1616
- [find](attachments_client.attachmentssubclient.md#find)
1717
- [get](attachments_client.attachmentssubclient.md#get)
1818
- [getAll](attachments_client.attachmentssubclient.md#getall)
19+
- [getAllAlertsAttachToCase](attachments_client.attachmentssubclient.md#getallalertsattachtocase)
1920
- [update](attachments_client.attachmentssubclient.md#update)
2021

2122
## Methods
@@ -34,7 +35,7 @@ Adds an attachment to a case.
3435

3536
**Returns:** *Promise*<[*ICaseResponse*](typedoc_interfaces.icaseresponse.md)\>
3637

37-
Defined in: [attachments/client.ts:25](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/client.ts#L25)
38+
Defined in: [attachments/client.ts:35](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L35)
3839

3940
___
4041

@@ -52,7 +53,7 @@ Deletes a single attachment for a specific case.
5253

5354
**Returns:** *Promise*<void\>
5455

55-
Defined in: [attachments/client.ts:33](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/client.ts#L33)
56+
Defined in: [attachments/client.ts:43](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L43)
5657

5758
___
5859

@@ -70,7 +71,7 @@ Deletes all attachments associated with a single case.
7071

7172
**Returns:** *Promise*<void\>
7273

73-
Defined in: [attachments/client.ts:29](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/client.ts#L29)
74+
Defined in: [attachments/client.ts:39](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L39)
7475

7576
___
7677

@@ -88,7 +89,7 @@ Retrieves all comments matching the search criteria.
8889

8990
**Returns:** *Promise*<[*ICommentsResponse*](typedoc_interfaces.icommentsresponse.md)\>
9091

91-
Defined in: [attachments/client.ts:37](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/client.ts#L37)
92+
Defined in: [attachments/client.ts:47](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L47)
9293

9394
___
9495

@@ -106,7 +107,7 @@ Retrieves a single attachment for a case.
106107

107108
**Returns:** *Promise*<{ `comment`: *string* ; `owner`: *string* ; `type`: user } & { `associationType`: AssociationType ; `created_at`: *string* ; `created_by`: { email: string \| null \| undefined; full\_name: string \| null \| undefined; username: string \| null \| undefined; } ; `owner`: *string* ; `pushed_at`: ``null`` \| *string* ; `pushed_by`: ``null`` \| { email: string \| null \| undefined; full\_name: string \| null \| undefined; username: string \| null \| undefined; } ; `updated_at`: ``null`` \| *string* ; `updated_by`: ``null`` \| { email: string \| null \| undefined; full\_name: string \| null \| undefined; username: string \| null \| undefined; } } & { `id`: *string* ; `version`: *string* } & { `alertId`: *string* \| *string*[] ; `index`: *string* \| *string*[] ; `owner`: *string* ; `rule`: { id: string \| null; name: string \| null; } ; `type`: alert \| generatedAlert } & { `associationType`: AssociationType ; `created_at`: *string* ; `created_by`: { email: string \| null \| undefined; full\_name: string \| null \| undefined; username: string \| null \| undefined; } ; `owner`: *string* ; `pushed_at`: ``null`` \| *string* ; `pushed_by`: ``null`` \| { email: string \| null \| undefined; full\_name: string \| null \| undefined; username: string \| null \| undefined; } ; `updated_at`: ``null`` \| *string* ; `updated_by`: ``null`` \| { email: string \| null \| undefined; full\_name: string \| null \| undefined; username: string \| null \| undefined; } } & { `id`: *string* ; `version`: *string* }\>
108109

109-
Defined in: [attachments/client.ts:45](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/client.ts#L45)
110+
Defined in: [attachments/client.ts:59](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L59)
110111

111112
___
112113

@@ -124,7 +125,25 @@ Gets all attachments for a single case.
124125

125126
**Returns:** *Promise*<[*IAllCommentsResponse*](typedoc_interfaces.iallcommentsresponse.md)\>
126127

127-
Defined in: [attachments/client.ts:41](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/client.ts#L41)
128+
Defined in: [attachments/client.ts:55](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L55)
129+
130+
___
131+
132+
### getAllAlertsAttachToCase
133+
134+
**getAllAlertsAttachToCase**(`params`: [*GetAllAlertsAttachToCase*](attachments_get.getallalertsattachtocase.md)): *Promise*<{ `attached_at`: *string* ; `id`: *string* ; `index`: *string* }[]\>
135+
136+
Retrieves all alerts attach to a case given a single case ID
137+
138+
#### Parameters
139+
140+
| Name | Type |
141+
| :------ | :------ |
142+
| `params` | [*GetAllAlertsAttachToCase*](attachments_get.getallalertsattachtocase.md) |
143+
144+
**Returns:** *Promise*<{ `attached_at`: *string* ; `id`: *string* ; `index`: *string* }[]\>
145+
146+
Defined in: [attachments/client.ts:51](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L51)
128147

129148
___
130149

@@ -144,4 +163,4 @@ The request must include all fields for the attachment. Even the fields that are
144163

145164
**Returns:** *Promise*<[*ICaseResponse*](typedoc_interfaces.icaseresponse.md)\>
146165

147-
Defined in: [attachments/client.ts:51](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/client.ts#L51)
166+
Defined in: [attachments/client.ts:65](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/client.ts#L65)

x-pack/plugins/cases/docs/cases_client/interfaces/attachments_delete.deleteallargs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Parameters for deleting all comments of a case or sub case.
2121

2222
The case ID to delete all attachments for
2323

24-
Defined in: [attachments/delete.ts:26](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/delete.ts#L26)
24+
Defined in: [attachments/delete.ts:31](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/delete.ts#L31)
2525

2626
___
2727

@@ -31,4 +31,4 @@ ___
3131

3232
If specified the caseID will be ignored and this value will be used to find a sub case for deleting all the attachments
3333

34-
Defined in: [attachments/delete.ts:30](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/delete.ts#L30)
34+
Defined in: [attachments/delete.ts:35](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/delete.ts#L35)

x-pack/plugins/cases/docs/cases_client/interfaces/attachments_delete.deleteargs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Parameters for deleting a single attachment of a case or sub case.
2222

2323
The attachment ID to delete
2424

25-
Defined in: [attachments/delete.ts:44](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/delete.ts#L44)
25+
Defined in: [attachments/delete.ts:49](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/delete.ts#L49)
2626

2727
___
2828

@@ -32,7 +32,7 @@ ___
3232

3333
The case ID to delete an attachment from
3434

35-
Defined in: [attachments/delete.ts:40](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/delete.ts#L40)
35+
Defined in: [attachments/delete.ts:45](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/delete.ts#L45)
3636

3737
___
3838

@@ -42,4 +42,4 @@ ___
4242

4343
If specified the caseID will be ignored and this value will be used to find a sub case for deleting the attachment
4444

45-
Defined in: [attachments/delete.ts:48](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/delete.ts#L48)
45+
Defined in: [attachments/delete.ts:53](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/delete.ts#L53)

x-pack/plugins/cases/docs/cases_client/interfaces/attachments_get.findargs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Parameters for finding attachments of a case
2121

2222
The case ID for finding associated attachments
2323

24-
Defined in: [attachments/get.ts:48](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/get.ts#L48)
24+
Defined in: [attachments/get.ts:47](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/get.ts#L47)
2525

2626
___
2727

@@ -48,4 +48,4 @@ Optional parameters for filtering the returned attachments
4848
| `sortOrder` | *undefined* \| ``"desc"`` \| ``"asc"`` |
4949
| `subCaseId` | *undefined* \| *string* |
5050

51-
Defined in: [attachments/get.ts:52](https://github.com/jonathan-buttner/kibana/blob/2085a3b4480/x-pack/plugins/cases/server/client/attachments/get.ts#L52)
51+
Defined in: [attachments/get.ts:51](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/get.ts#L51)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[Cases Client API Interface](../cases_client_api.md) / [attachments/get](../modules/attachments_get.md) / GetAllAlertsAttachToCase
2+
3+
# Interface: GetAllAlertsAttachToCase
4+
5+
[attachments/get](../modules/attachments_get.md).GetAllAlertsAttachToCase
6+
7+
## Table of contents
8+
9+
### Properties
10+
11+
- [caseId](attachments_get.getallalertsattachtocase.md#caseid)
12+
13+
## Properties
14+
15+
### caseId
16+
17+
**caseId**: *string*
18+
19+
The ID of the case to retrieve the alerts from
20+
21+
Defined in: [attachments/get.ts:87](https://github.com/jonathan-buttner/kibana/blob/0e98e105663/x-pack/plugins/cases/server/client/attachments/get.ts#L87)

0 commit comments

Comments
 (0)