| 1 | import type { FlaskBaseResponse } from "@/types/flask.d" |
| 2 | import type { |
| 3 | AvailableIntegration, |
| 4 | CustomerIntegration, |
| 5 | CustomerIntegrationMetaCommon, |
| 6 | CustomerIntegrationMetaResponse |
| 7 | } from "@/types/integrations.d" |
| 8 | import { HttpClient } from "../httpClient" |
| 9 | |
| 10 | export interface IntegrationAuthKeyPairs { |
| 11 | auth_key_name: string |
| 12 | auth_value: string |
| 13 | } |
| 14 | |
| 15 | export interface NewIntegration { |
| 16 | customer_code: string |
| 17 | customer_name: string |
| 18 | integration_name: string |
| 19 | integration_auth_keys: IntegrationAuthKeyPairs[] |
| 20 | } |
| 21 | |
| 22 | export interface NewIntegrationPayload extends NewIntegration { |
| 23 | integration_config: { |
| 24 | auth_type: string |
| 25 | config_key: string |
| 26 | config_value: string |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | export interface UpdateMetaAutoRequest extends Omit<CustomerIntegrationMetaCommon, "id"> { |
| 31 | integration_name: string |
| 32 | } |
| 33 | |
| 34 | export type UpdateIntegrationPayload = Omit<NewIntegration, "customer_name"> |
| 35 | |
| 36 | export default { |
| 37 | // #region Integrations |
| 38 | getAvailableIntegrations() { |
| 39 | return HttpClient.get<FlaskBaseResponse & { available_integrations: AvailableIntegration[] }>( |
| 40 | `/integrations/available_integrations` |
| 41 | ) |
| 42 | }, |
| 43 | getMetaAuto(customerCode: string, integrationName: string) { |
| 44 | return HttpClient.get<FlaskBaseResponse & CustomerIntegrationMetaResponse>( |
| 45 | `/integrations/meta_auto/${customerCode}/${integrationName}` |
| 46 | ) |
| 47 | }, |
| 48 | getCustomerIntegrations(customerCode: string) { |
| 49 | return HttpClient.get<FlaskBaseResponse & { available_integrations: CustomerIntegration[] }>( |
| 50 | `/integrations/customer_integrations/${customerCode}` |
| 51 | ) |
| 52 | }, |
| 53 | createIntegration(props: NewIntegration) { |
| 54 | const payload: NewIntegrationPayload = { |
| 55 | ...props, |
| 56 | integration_config: { |
| 57 | auth_type: "Wazuh", |
| 58 | config_key: "endpoint", |
| 59 | config_value: "not applicable" |
| 60 | } |
| 61 | } |
| 62 | return HttpClient.post<FlaskBaseResponse>(`/integrations/create_integration`, payload) |
| 63 | }, |
| 64 | updateIntegration(payload: UpdateIntegrationPayload) { |
| 65 | return HttpClient.put<FlaskBaseResponse & { additional_info: string | null }>( |
| 66 | `/integrations/update_integration/${payload.customer_code}`, |
| 67 | payload |
| 68 | ) |
| 69 | }, |
| 70 | updateMetaAuto(payload: UpdateMetaAutoRequest) { |
| 71 | return HttpClient.put<FlaskBaseResponse>(`/integrations/update_meta_auto`, payload) |
| 72 | }, |
| 73 | deleteIntegration(customerCode: string, integrationName: string) { |
| 74 | return HttpClient.delete<FlaskBaseResponse>(`/integrations/delete_integration`, { |
| 75 | data: { customer_code: customerCode, integration_name: integrationName } |
| 76 | }) |
| 77 | }, |
| 78 | // #endregion |
| 79 | |
| 80 | // #region Provision |
| 81 | office365Provision(customerCode: string, integrationName: string) { |
| 82 | return HttpClient.post<FlaskBaseResponse>(`/office365/provision`, { |
| 83 | customer_code: customerCode, |
| 84 | integration_name: integrationName || "Office365" |
| 85 | }) |
| 86 | }, |
| 87 | mimecastProvision(customerCode: string, integrationName: string) { |
| 88 | return HttpClient.post<FlaskBaseResponse>(`/mimecast/provision`, { |
| 89 | customer_code: customerCode, |
| 90 | integration_name: integrationName || "Mimecast" |
| 91 | }) |
| 92 | }, |
| 93 | crowdstrikeProvision(customerCode: string, integrationName: string) { |
| 94 | return HttpClient.post<FlaskBaseResponse>(`/crowdstrike/provision`, { |
| 95 | customer_code: customerCode, |
| 96 | integration_name: integrationName || "Crowdstrike", |
| 97 | hot_data_retention: 30, |
| 98 | index_replicas: 0 |
| 99 | }) |
| 100 | }, |
| 101 | duoProvision(customerCode: string, integrationName: string) { |
| 102 | return HttpClient.post<FlaskBaseResponse>(`/duo/provision`, { |
| 103 | customer_code: customerCode, |
| 104 | integration_name: integrationName || "Duo", |
| 105 | time_interval: 15 |
| 106 | }) |
| 107 | }, |
| 108 | darktraceProvision(customerCode: string, integrationName: string) { |
| 109 | return HttpClient.post<FlaskBaseResponse>(`/darktrace/provision`, { |
| 110 | customer_code: customerCode, |
| 111 | integration_name: integrationName || "Darktrace", |
| 112 | time_interval: 15 |
| 113 | }) |
| 114 | }, |
| 115 | bitdefenderProvision(customerCode: string, integrationName: string) { |
| 116 | return HttpClient.post<FlaskBaseResponse>(`/bitdefender/provision`, { |
| 117 | customer_code: customerCode, |
| 118 | integration_name: integrationName || "BitDefender", |
| 119 | hot_data_retention: 30, |
| 120 | index_replicas: 0 |
| 121 | }) |
| 122 | }, |
| 123 | catoProvision(customerCode: string, integrationName: string) { |
| 124 | return HttpClient.post<FlaskBaseResponse>(`/cato/provision`, { |
| 125 | customer_code: customerCode, |
| 126 | integration_name: integrationName || "Cato", |
| 127 | time_interval: 15 |
| 128 | }) |
| 129 | }, |
| 130 | defenderForEndpointProvision(customerCode: string, integrationName: string) { |
| 131 | return HttpClient.post<FlaskBaseResponse>(`/defender_for_endpoint/provision`, { |
| 132 | customer_code: customerCode, |
| 133 | integration_name: integrationName || "DefenderForEndpoint" |
| 134 | }) |
| 135 | }, |
| 136 | socfortressMdrProvision(customerCode: string, integrationName: string) { |
| 137 | return HttpClient.post<FlaskBaseResponse>(`/socfortress_mdr/provision`, { |
| 138 | customer_code: customerCode, |
| 139 | integration_name: integrationName || "SOCFortress MDR" |
| 140 | }) |
| 141 | } |
| 142 | // #endregion |
| 143 | } |