7
7
8
8
import type { HttpStart } from '@kbn/core/public' ;
9
9
import type { Cases , CasesStatus , CasesMetrics } from '../../common/ui' ;
10
- import { CASE_FIND_URL , CASE_METRICS_URL , CASE_STATUS_URL } from '../../common/constants' ;
10
+ import {
11
+ CASE_FIND_URL ,
12
+ CASE_METRICS_URL ,
13
+ CASE_STATUS_URL ,
14
+ INTERNAL_BULK_GET_CASES_URL ,
15
+ } from '../../common/constants' ;
11
16
import type {
17
+ CaseResponse ,
18
+ CasesBulkGetRequestCertainFields ,
19
+ CasesBulkGetResponseCertainFields ,
12
20
CasesFindRequest ,
13
21
CasesFindResponse ,
14
22
CasesMetricsRequest ,
@@ -18,6 +26,7 @@ import type {
18
26
} from '../../common/api' ;
19
27
import { convertAllCasesToCamel , convertToCamelCase } from './utils' ;
20
28
import {
29
+ decodeCasesBulkGetResponse ,
21
30
decodeCasesFindResponse ,
22
31
decodeCasesMetricsResponse ,
23
32
decodeCasesStatusResponse ,
@@ -58,3 +67,21 @@ export const getCasesMetrics = async ({
58
67
const res = await http . get < CasesMetricsResponse > ( CASE_METRICS_URL , { signal, query } ) ;
59
68
return convertToCamelCase ( decodeCasesMetricsResponse ( res ) ) ;
60
69
} ;
70
+
71
+ export const bulkGetCases = async < Field extends keyof CaseResponse = keyof CaseResponse > ( {
72
+ http,
73
+ signal,
74
+ params,
75
+ } : HTTPService & { params : CasesBulkGetRequestCertainFields < Field > } ) : Promise <
76
+ CasesBulkGetResponseCertainFields < Field >
77
+ > => {
78
+ const res = await http . post < CasesBulkGetResponseCertainFields < Field > > (
79
+ INTERNAL_BULK_GET_CASES_URL ,
80
+ {
81
+ body : JSON . stringify ( { ...params } ) ,
82
+ signal,
83
+ }
84
+ ) ;
85
+
86
+ return decodeCasesBulkGetResponse ( res , params . fields ) ;
87
+ } ;
0 commit comments