main
py 90 lines 3.63 KB
Raw
1 from typing import List
2 from typing import Optional
3 from typing import Union
4
5 from pydantic import BaseModel
6 from pydantic import ConfigDict
7 from pydantic import Field
8
9
10 class WazuhGroup(BaseModel):
11 """Represents a single Wazuh group from the API."""
12
13 name: str = Field(..., description="Group name")
14 count: int = Field(..., description="Number of agents belonging to the group")
15 # Both checksum fields vary by Wazuh version: 4.9.0 returns only configSum, while
16 # other builds still return mergedSum. Keep them optional so the connector tolerates
17 # any Wazuh version (mirrors app/integrations/utils/schema.py). See issue #885.
18 mergedSum: Optional[str] = Field(None, description="Checksum of merged configuration files")
19 configSum: Optional[str] = Field(None, description="Checksum of configuration files")
20 model_config = ConfigDict(extra="ignore")
21
22
23 class WazuhGroupsResponse(BaseModel):
24 """Response model for Wazuh groups listing."""
25
26 success: bool = Field(..., description="Whether the request was successful")
27 message: str = Field(..., description="Response message")
28 results: List[WazuhGroup] = Field(default=[], description="List of groups")
29 total_items: Optional[int] = Field(None, description="Total number of groups")
30
31
32 class WazuhGroupFileResponse(BaseModel):
33 """Response model for Wazuh group file content."""
34
35 success: bool = Field(..., description="Whether the request was successful")
36 message: str = Field(..., description="Response message")
37 group_id: str = Field(..., description="The group ID")
38 filename: str = Field(..., description="The requested filename")
39 content: Union[dict, str] = Field(..., description="File content (structured or raw)")
40 is_raw: bool = Field(False, description="Whether the content is raw text")
41 total_items: Optional[int] = Field(None, description="Total affected items from API")
42
43
44 class WazuhGroupFile(BaseModel):
45 """Represents a single file in a Wazuh group."""
46
47 filename: str = Field(..., description="Name of the file")
48 hash: str = Field(..., description="Hash/checksum of the file")
49 model_config = ConfigDict(extra="ignore")
50
51
52 class WazuhGroupFilesResponse(BaseModel):
53 """Response model for Wazuh group files listing."""
54
55 success: bool = Field(..., description="Whether the request was successful")
56 message: str = Field(..., description="Response message")
57 group_id: str = Field(..., description="The group ID")
58 results: List[WazuhGroupFile] = Field(default=[], description="List of files in the group")
59 total_items: Optional[int] = Field(None, description="Total number of files")
60
61
62 class WazuhGroupConfigurationUpdateRequest(BaseModel):
63 """Request model for updating group configuration."""
64
65 configuration: str = Field(..., description="Full valid XML configuration content")
66 model_config = ConfigDict(
67 json_schema_extra={
68 "example": {
69 "configuration": """<agent_config>
70 <labels>
71 <label key="customer">example</label>
72 </labels>
73 <client_buffer>
74 <disabled>no</disabled>
75 <queue_size>100000</queue_size>
76 <events_per_second>1000</events_per_second>
77 </client_buffer>
78 </agent_config>""",
79 },
80 },
81 )
82
83
84 class WazuhGroupConfigurationUpdateResponse(BaseModel):
85 """Response model for group configuration update."""
86
87 success: bool = Field(..., description="Whether the request was successful")
88 message: str = Field(..., description="Response message")
89 group_id: str = Field(..., description="The group ID that was updated")
90 total_items: Optional[int] = Field(None, description="Total affected items from API")