| 1 | from typing import List |
| 2 | from typing import Optional |
| 3 | |
| 4 | from pydantic import BaseModel |
| 5 | |
| 6 | |
| 7 | class Stage(BaseModel): |
| 8 | match: str |
| 9 | rules: List[str] |
| 10 | stage: int |
| 11 | |
| 12 | |
| 13 | class StageWithRuleID(Stage): |
| 14 | rule_ids: List[Optional[str]] # Add a new field to store rule IDs |
| 15 | |
| 16 | |
| 17 | class Pipeline(BaseModel): |
| 18 | created_at: str |
| 19 | description: Optional[str] = None # Make description optional |
| 20 | errors: Optional[None] = None |
| 21 | id: str |
| 22 | modified_at: Optional[str] = None # Make modified_at optional |
| 23 | source: str |
| 24 | stages: List[Stage] |
| 25 | title: str |
| 26 | |
| 27 | |
| 28 | class GraylogPipelinesResponse(BaseModel): |
| 29 | message: str |
| 30 | pipelines: List[Pipeline] |
| 31 | success: bool |
| 32 | |
| 33 | |
| 34 | class PipelineRule(BaseModel): |
| 35 | created_at: str |
| 36 | description: Optional[str] = None # Make description optional |
| 37 | errors: Optional[None] = None |
| 38 | id: str |
| 39 | modified_at: Optional[str] = None # Make modified_at optional |
| 40 | source: str |
| 41 | title: str |
| 42 | |
| 43 | |
| 44 | # Define the main response model |
| 45 | class PipelineRulesResponse(BaseModel): |
| 46 | message: str |
| 47 | pipeline_rules: List[PipelineRule] |
| 48 | success: bool |
| 49 | |
| 50 | |
| 51 | class PipelineWithRuleID(Pipeline): |
| 52 | stages: List[StageWithRuleID] # Override the `stages` field with the new class |
| 53 | |
| 54 | |
| 55 | class GraylogPipelinesResponseWithRuleID(BaseModel): |
| 56 | message: str |
| 57 | pipelines: List[PipelineWithRuleID] |
| 58 | success: bool |
| 59 | |
| 60 | |
| 61 | # Creation of Pipelines |
| 62 | class CreatePipelineRule(BaseModel): |
| 63 | title: str |
| 64 | description: str |
| 65 | source: str |
| 66 | |
| 67 | |
| 68 | class CreatePipeline(BaseModel): |
| 69 | title: str |
| 70 | description: str |
| 71 | source: str |
| 72 | |
| 73 | |
| 74 | class ModifyPipeline(BaseModel): |
| 75 | pipeline_id: str |
| 76 | source: str |