main
py 117 lines 3.1 KB
Raw
1 from typing import Optional
2
3 from fastapi import HTTPException
4 from pydantic import BaseModel
5 from pydantic import Field
6 from pydantic import field_validator
7
8
9 class InvokeMimecastRequest(BaseModel):
10 customer_code: str = Field(
11 ...,
12 description="The customer code.",
13 examples=["00002"],
14 )
15 integration_name: str = Field(
16 "Mimecast",
17 description="The integration name.",
18 examples=["Mimecast"],
19 )
20
21
22 class MimecastAuthKeys(BaseModel):
23 APP_ID: str = Field(
24 ...,
25 description="YOUR DEVELOPER APPLICATION ID",
26 examples=["00002"],
27 )
28 APP_KEY: str = Field(
29 ...,
30 description="YOUR DEVELOPER APPLICATION KEY",
31 examples=["00002"],
32 )
33 EMAIL_ADDRESS: Optional[str] = Field(
34 None,
35 description="EMAIL ADDRESS OF YOUR ADMINISTRATOR",
36 examples=["00002"],
37 )
38 ACCESS_KEY: str = Field(
39 ...,
40 description="ACCESS KEY FOR YOUR ADMINISTRATOR",
41 examples=["00002"],
42 )
43 SECRET_KEY: str = Field(
44 ...,
45 description="SECRET KEY FOR YOUR ADMINISTRATOR",
46 examples=["00002"],
47 )
48 URI: str = Field(
49 "/api/audit/get-siem-logs",
50 description="URI FOR YOUR API Endpoint",
51 examples=["/api/audit/get-siem-logs"],
52 )
53
54
55 class InvokeMimecastResponse(BaseModel):
56 success: bool = Field(
57 ...,
58 description="The success status.",
59 examples=[True],
60 )
61 message: str = Field(
62 ...,
63 description="The message.",
64 examples=["Mimecast Events collected successfully."],
65 )
66
67
68 class CollectMimecast(BaseModel):
69 integration: str = Field(..., examples=["mimecast"])
70 customer_code: str = Field(..., examples=["socfortress"])
71 graylog_host: str = Field(..., examples=["127.0.0.1"])
72 graylog_port: str = Field(..., examples=[12201])
73 app_id: str = Field(
74 ...,
75 description="YOUR DEVELOPER APPLICATION ID",
76 examples=["00002"],
77 )
78 app_key: str = Field(
79 ...,
80 description="YOUR DEVELOPER APPLICATION KEY",
81 examples=["00002"],
82 )
83 email_address: Optional[str] = Field(
84 None,
85 description="EMAIL ADDRESS OF YOUR ADMINISTRATOR",
86 examples=["00002"],
87 )
88 access_key: str = Field(
89 ...,
90 description="ACCESS KEY FOR YOUR ADMINISTRATOR",
91 examples=["00002"],
92 )
93 secret_key: str = Field(
94 ...,
95 description="SECRET KEY FOR YOUR ADMINISTRATOR",
96 examples=["00002"],
97 )
98 uri: str = Field(
99 "/api/audit/get-siem-logs",
100 description="URI FOR YOUR API Endpoint",
101 examples=["/api/audit/get-siem-logs"],
102 )
103 time_range: Optional[str] = Field(
104 "15m",
105 pattern="^[1-9][0-9]*[mhdw]$",
106 description="Time range for the query (1m, 1h, 1d, 1w)",
107 )
108
109 @field_validator("integration")
110 @classmethod
111 def check_integration(cls, v):
112 if v != "mimecast":
113 raise HTTPException(
114 status_code=400,
115 detail="Invalid integration. Only 'mimecast' is supported.",
116 )
117 return v