main
py 84 lines 2.54 KB
Raw
1 from typing import Any
2 from typing import Dict
3 from typing import List
4 from typing import Optional
5
6 from pydantic import BaseModel
7 from pydantic import ConfigDict
8 from pydantic import Field
9 from pydantic import model_validator
10
11
12 class ProvisionMimecastRequest(BaseModel):
13 customer_code: str = Field(
14 ...,
15 description="The customer code.",
16 examples=["00002"],
17 )
18 integration_name: str = Field(
19 "Mimecast",
20 description="The integration name.",
21 examples=["Mimecast"],
22 )
23
24 # ensure the `integration_name` is always set to "Mimecast"
25 @model_validator(mode="before")
26 @classmethod
27 def set_integration_name(cls, values: Dict[str, Any]) -> Dict[str, Any]:
28 values["integration_name"] = "Mimecast"
29 return values
30
31
32 class ProvisionMimecastResponse(BaseModel):
33 success: bool
34 message: str
35
36
37 # ! STREAMS ! #
38 class StreamRule(BaseModel):
39 field: str
40 type: int
41 inverted: bool
42 value: str
43
44
45 class MimecastEventStream(BaseModel):
46 title: str = Field(..., description="Title of the stream")
47 description: str = Field(..., description="Description of the stream")
48 index_set_id: str = Field(..., description="ID of the associated index set")
49 rules: List[StreamRule] = Field(..., description="List of rules for the stream")
50 matching_type: str = Field(..., description="Matching type for the rules")
51 remove_matches_from_default_stream: bool = Field(
52 ...,
53 description="Whether to remove matches from the default stream",
54 )
55 content_pack: Optional[str] = Field(
56 None,
57 description="Associated content pack, if any",
58 )
59 model_config = ConfigDict(
60 json_schema_extra={
61 "example": {
62 "title": "Mimecast EVENTS - Example Company",
63 "description": "Mimecast EVENTS - Example Company",
64 "index_set_id": "12345",
65 "rules": [
66 {
67 "field": "agent_labels_customer",
68 "type": 1,
69 "inverted": False,
70 "value": "ExampleCode",
71 },
72 {
73 "field": "agent_labels_integration",
74 "type": 1,
75 "inverted": False,
76 "value": "Office365",
77 },
78 ],
79 "matching_type": "AND",
80 "remove_matches_from_default_stream": True,
81 "content_pack": None,
82 },
83 },
84 )