| 1 | from typing import Any |
| 2 | from typing import Dict |
| 3 | from typing import Optional |
| 4 | |
| 5 | from pydantic import BaseModel |
| 6 | from pydantic import Field |
| 7 | from pydantic import model_validator |
| 8 | |
| 9 | |
| 10 | class ProvisionFortinetRequest(BaseModel): |
| 11 | customer_code: str = Field( |
| 12 | ..., |
| 13 | description="The customer code.", |
| 14 | examples=["00002"], |
| 15 | ) |
| 16 | integration_name: str = Field( |
| 17 | "Fortinet", |
| 18 | description="The integration name.", |
| 19 | examples=["Fortinet"], |
| 20 | ) |
| 21 | tcp_enabled: Optional[bool] = Field( |
| 22 | False, |
| 23 | description="The tcp enabled.", |
| 24 | examples=[True], |
| 25 | ) |
| 26 | udp_enabled: Optional[bool] = Field( |
| 27 | False, |
| 28 | description="The udp enabled.", |
| 29 | examples=[True], |
| 30 | ) |
| 31 | hot_data_retention: int = Field( |
| 32 | ..., |
| 33 | examples=[30], |
| 34 | description="Number of days to retain hot data", |
| 35 | ) |
| 36 | index_replicas: int = Field( |
| 37 | ..., |
| 38 | examples=[1], |
| 39 | description="Number of replicas for the customer's Graylog instance", |
| 40 | ) |
| 41 | |
| 42 | # ensure the `integration_name` is always set to "Fortinet" |
| 43 | @model_validator(mode="before") |
| 44 | @classmethod |
| 45 | def set_integration_name(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| 46 | values["integration_name"] = "Fortinet" |
| 47 | return values |
| 48 | |
| 49 | |
| 50 | class ProvisionFortinetResponse(BaseModel): |
| 51 | success: bool |
| 52 | message: str |
| 53 | |
| 54 | |
| 55 | class ProvisionFortinetKeys(BaseModel): |
| 56 | SYSLOG_PORT: str = Field( |
| 57 | ..., |
| 58 | description="The syslog port.", |
| 59 | examples=["514"], |
| 60 | ) |
| 61 | |
| 62 | |
| 63 | class FortinetCustomerDetails(BaseModel): |
| 64 | customer_name: str = Field( |
| 65 | ..., |
| 66 | description="The customer name.", |
| 67 | examples=["Customer 1"], |
| 68 | ) |
| 69 | customer_code: str = Field( |
| 70 | ..., |
| 71 | description="The customer code.", |
| 72 | examples=["00002"], |
| 73 | ) |
| 74 | protocal_type: str = Field( |
| 75 | ..., |
| 76 | description="The protocal type.", |
| 77 | examples=["TCP"], |
| 78 | ) |
| 79 | syslog_port: int = Field( |
| 80 | ..., |
| 81 | description="The syslog port.", |
| 82 | examples=[514], |
| 83 | ) |
| 84 | hot_data_retention: int = Field( |
| 85 | ..., |
| 86 | examples=[30], |
| 87 | description="Number of days to retain hot data", |
| 88 | ) |
| 89 | index_replicas: int = Field( |
| 90 | ..., |
| 91 | examples=[1], |
| 92 | description="Number of replicas for the customer's Graylog instance", |
| 93 | ) |