main
py 65 lines 1.81 KB
Raw
1 from fastapi import HTTPException
2 from pydantic import BaseModel
3 from pydantic import Field
4 from pydantic import field_validator
5
6
7 class InvokeHuntressRequest(BaseModel):
8 customer_code: str = Field(
9 ...,
10 description="The customer code.",
11 examples=["00002"],
12 )
13 integration_name: str = Field(
14 "Huntress",
15 description="The integration name.",
16 examples=["Huntress"],
17 )
18
19
20 class HuntressAuthKeys(BaseModel):
21 API_KEY: str = Field(
22 ...,
23 description="The API key.",
24 examples=["123456"],
25 )
26 API_SECRET: str = Field(
27 ...,
28 description="The secret key.",
29 examples=["123456"],
30 )
31
32
33 class InvokeHuntressResponse(BaseModel):
34 success: bool = Field(
35 ...,
36 description="The success status.",
37 examples=[True],
38 )
39 message: str = Field(
40 ...,
41 description="The message.",
42 examples=["Huntress Events collected successfully."],
43 )
44
45
46 class CollectHuntress(BaseModel):
47 integration: str = Field(..., examples=["huntress"])
48 customer_code: str = Field(..., examples=["socfortress"])
49 graylog_host: str = Field(..., examples=["127.0.0.1"])
50 graylog_port: str = Field(..., examples=[12201])
51 wazuh_indexer_host: str = Field(..., examples=["127.0.0.1"])
52 wazuh_indexer_username: str = Field(..., examples=["admin"])
53 wazuh_indexer_password: str = Field(..., examples=["admin"])
54 api_key: str = Field(..., examples=["1234567890"])
55 api_secret: str = Field(..., examples=["1234567890"])
56
57 @field_validator("integration")
58 @classmethod
59 def check_integration(cls, v):
60 if v != "huntress":
61 raise HTTPException(
62 status_code=400,
63 detail="Invalid integration. Only 'huntress' is supported.",
64 )
65 return v