main
ts 115 lines 3.17 KB
Raw
1 import type { FlaskBaseResponse } from "@/types/flask.d"
2 import type {
3 WazuhGroup,
4 WazuhGroupConfigurationUpdate,
5 WazuhGroupFile,
6 WazuhGroupFileDetails
7 } from "@/types/wazuh/groups.d"
8 import { HttpClient } from "../../httpClient"
9
10 // Interface for groups query parameters
11 export interface GroupsQueryParams {
12 /** Show results in human-readable format */
13 pretty?: boolean
14 /** Disable timeout response */
15 wait_for_complete?: boolean
16 /** List of group IDs (separated by comma) */
17 groups_list?: string[]
18 /** First element to return in the collection */
19 offset?: number
20 /** Maximum number of elements to return */
21 limit?: number
22 /** Sort the collection by a field or fields */
23 sort?: string | null
24 /** Look for elements containing the specified string */
25 search?: string | null
26 /** Select algorithm to generate the returned checksums */
27 hash?: string | null
28 /** Query to filter results by */
29 q?: string | null
30 /** Select which fields to return */
31 select?: string[] | null
32 /** Look for distinct values */
33 distinct?: boolean
34 }
35
36 // Interface for group files query parameters
37 export interface GroupFilesQueryParams {
38 /** Show results in human-readable format */
39 pretty?: boolean
40 /** Disable timeout response */
41 wait_for_complete?: boolean
42 /** First element to return in the collection */
43 offset?: number
44 /** Maximum number of elements to return */
45 limit?: number
46 /** Sort the collection by a field or fields */
47 sort?: string | null
48 /** Look for elements containing the specified string */
49 search?: string | null
50 /** Select algorithm to generate the returned checksums */
51 hash?: string | null
52 /** Query to filter results by */
53 q?: string | null
54 /** Select which fields to return */
55 select?: string[] | null
56 /** Look for distinct values */
57 distinct?: boolean
58 }
59
60 // Interface for group file query parameters
61 export interface GroupFileQueryParams {
62 /** Show results in human-readable format */
63 pretty?: boolean
64 /** Disable timeout response */
65 wait_for_complete?: boolean
66 /** Type of file */
67 type?: string[] | null
68 /** Format response in plain text */
69 raw?: boolean
70 }
71
72 export default {
73 getGroups(query: GroupsQueryParams, signal?: AbortSignal) {
74 return HttpClient.get<FlaskBaseResponse & { results: WazuhGroup[]; total_items: number }>(
75 `/wazuh_manager/groups`,
76 {
77 params: query,
78 signal
79 }
80 )
81 },
82 getGroupFiles(groupId: string, query: GroupFilesQueryParams, signal?: AbortSignal) {
83 return HttpClient.get<FlaskBaseResponse & { results: WazuhGroupFile[]; total_items: number }>(
84 `/wazuh_manager/groups/${groupId}/files`,
85 {
86 params: query,
87 signal
88 }
89 )
90 },
91 getGroupFile(groupId: string, filename: string, query?: GroupFileQueryParams) {
92 return HttpClient.get<FlaskBaseResponse & WazuhGroupFileDetails>(
93 `/wazuh_manager/groups/${groupId}/files/${filename}`,
94 {
95 params: {
96 raw: true,
97 pretty: false,
98 wait_for_complete: false,
99 ...query
100 }
101 }
102 )
103 },
104 updateGroupConfiguration(groupId: string, configContent: string) {
105 return HttpClient.put<FlaskBaseResponse & WazuhGroupConfigurationUpdate>(
106 `/wazuh_manager/groups/${groupId}/configuration`,
107 configContent,
108 {
109 headers: {
110 "Content-Type": "application/xml"
111 }
112 }
113 )
114 }
115 }