| 1 | import type { CommonResponse } from "@/types/common" |
| 2 | import type { |
| 3 | EnabledDashboard, |
| 4 | EventSearchResult, |
| 5 | EventSourceItem, |
| 6 | FieldMapping, |
| 7 | PanelDataResponse |
| 8 | } from "@/types/siem" |
| 9 | import { HttpClient } from "../httpClient" |
| 10 | import { withCustomerCodes } from "../params" |
| 11 | |
| 12 | export default { |
| 13 | getEventSources(customerCode: string) { |
| 14 | return HttpClient.get<CommonResponse<{ event_sources: EventSourceItem[] }>>( |
| 15 | `/siem/event_sources/${customerCode}` |
| 16 | ) |
| 17 | }, |
| 18 | |
| 19 | queryEvents( |
| 20 | customerCode: string, |
| 21 | sourceName: string, |
| 22 | params: { |
| 23 | timerange?: string |
| 24 | page_size?: number |
| 25 | scroll_id?: string |
| 26 | query?: string |
| 27 | time_from?: string |
| 28 | time_to?: string |
| 29 | } |
| 30 | ) { |
| 31 | return HttpClient.get< |
| 32 | CommonResponse<{ events: EventSearchResult[]; total: number; scroll_id: string | null; page_size: number }> |
| 33 | >(`/siem/events/${customerCode}/${sourceName}`, { params }) |
| 34 | }, |
| 35 | |
| 36 | getFieldMappings(customerCode: string, sourceName: string) { |
| 37 | return HttpClient.get<CommonResponse<{ fields: FieldMapping[]; total: number; index_pattern: string }>>( |
| 38 | `/siem/events/${customerCode}/${sourceName}/fields` |
| 39 | ) |
| 40 | }, |
| 41 | |
| 42 | getEnabledDashboards(customerCode: string) { |
| 43 | return HttpClient.get<CommonResponse<{ enabled_dashboards: EnabledDashboard[] }>>( |
| 44 | `/siem/dashboards/enabled/${customerCode}` |
| 45 | ) |
| 46 | }, |
| 47 | |
| 48 | getEnabledDashboardsForCustomers(customerCodes?: string[]) { |
| 49 | return HttpClient.get<CommonResponse<{ enabled_dashboards: EnabledDashboard[] }>>( |
| 50 | "/siem/dashboards/enabled", |
| 51 | withCustomerCodes(customerCodes) |
| 52 | ) |
| 53 | }, |
| 54 | |
| 55 | disableDashboard(dashboardId: number) { |
| 56 | return HttpClient.delete<CommonResponse>(`/siem/dashboards/disable/${dashboardId}`) |
| 57 | }, |
| 58 | |
| 59 | getPanelData(dashboardId: number, timerange: string, signal?: AbortSignal) { |
| 60 | return HttpClient.post<CommonResponse<PanelDataResponse>>( |
| 61 | `/siem/dashboards/panel-data`, |
| 62 | { dashboard_id: dashboardId, timerange }, |
| 63 | signal ? { signal } : {} |
| 64 | ) |
| 65 | } |
| 66 | } |