| 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 ProvisionSonicwallRequest(BaseModel): |
| 11 | customer_code: str = Field( |
| 12 | ..., |
| 13 | description="The customer code.", |
| 14 | examples=["00002"], |
| 15 | ) |
| 16 | integration_name: str = Field( |
| 17 | "Sonicwall", |
| 18 | description="The integration name.", |
| 19 | examples=["Sonicwall"], |
| 20 | ) |
| 21 | tls_enabled: Optional[bool] = Field( |
| 22 | False, |
| 23 | description="TLS enabled for secure log forwarding.", |
| 24 | examples=[True], |
| 25 | ) |
| 26 | hot_data_retention: int = Field( |
| 27 | ..., |
| 28 | examples=[30], |
| 29 | description="Number of days to retain hot data", |
| 30 | ) |
| 31 | index_replicas: int = Field( |
| 32 | ..., |
| 33 | examples=[1], |
| 34 | description="Number of replicas for the customer's Graylog instance", |
| 35 | ) |
| 36 | |
| 37 | # ensure the `integration_name` is always set to "Sonicwall" |
| 38 | @model_validator(mode="before") |
| 39 | @classmethod |
| 40 | def set_integration_name(cls, values: Dict[str, Any]) -> Dict[str, Any]: |
| 41 | values["integration_name"] = "Sonicwall" |
| 42 | return values |
| 43 | |
| 44 | |
| 45 | class ProvisionSonicwallResponse(BaseModel): |
| 46 | success: bool |
| 47 | message: str |
| 48 | |
| 49 | |
| 50 | class ProvisionSonicwallKeys(BaseModel): |
| 51 | SYSLOG_PORT: str = Field( |
| 52 | ..., |
| 53 | description="The syslog port.", |
| 54 | examples=["514"], |
| 55 | ) |
| 56 | TLS_CERT_FILE: str = Field( |
| 57 | ..., |
| 58 | description="The TLS certificate file path.", |
| 59 | examples=["/etc/graylog/server/certs/Sonicwall_cert.pem"], |
| 60 | ) |
| 61 | TLS_KEY_FILE: str = Field( |
| 62 | ..., |
| 63 | description="The TLS key file path.", |
| 64 | examples=["/etc/graylog/server/certs/Sonicwall_key.key"], |
| 65 | ) |
| 66 | |
| 67 | |
| 68 | class SonicwallCustomerDetails(BaseModel): |
| 69 | customer_name: str = Field( |
| 70 | ..., |
| 71 | description="The customer name.", |
| 72 | examples=["Customer 1"], |
| 73 | ) |
| 74 | customer_code: str = Field( |
| 75 | ..., |
| 76 | description="The customer code.", |
| 77 | examples=["00002"], |
| 78 | ) |
| 79 | syslog_port: int = Field( |
| 80 | ..., |
| 81 | description="The syslog port.", |
| 82 | examples=[514], |
| 83 | ) |
| 84 | tls_cert_file: str = Field( |
| 85 | ..., |
| 86 | description="The TLS certificate file path.", |
| 87 | examples=["/etc/graylog/server/certs/Sonicwall_cert.pem"], |
| 88 | ) |
| 89 | tls_key_file: str = Field( |
| 90 | ..., |
| 91 | description="The TLS key file path.", |
| 92 | examples=["/etc/graylog/server/certs/Sonicwall_key.key"], |
| 93 | ) |
| 94 | hot_data_retention: int = Field( |
| 95 | ..., |
| 96 | examples=[30], |
| 97 | description="Number of days to retain hot data", |
| 98 | ) |
| 99 | index_replicas: int = Field( |
| 100 | ..., |
| 101 | examples=[1], |
| 102 | description="Number of replicas for the customer's Graylog instance", |
| 103 | ) |