44
55from enum import Enum
66from typing import Dict , Any , List , Optional
7- from dataclasses import dataclass , field
87from datetime import datetime
98
109
@@ -154,7 +153,6 @@ def to_dict(self) -> Dict[str, Any]:
154153 }
155154
156155
157- @dataclass
158156class ApplicabilityRule :
159157 """
160158 Represents a rule to determine if a check is applicable based on context properties
@@ -165,8 +163,9 @@ class ApplicabilityRule:
165163 :type value: Any
166164 """
167165
168- property : str
169- value : Any
166+ def __init__ (self , property : str , value : Any ):
167+ self .property = property
168+ self .value = value
170169
171170 def is_applicable (self , context_value : Any ) -> bool :
172171 """
@@ -202,7 +201,6 @@ def is_applicable(self, context_value: Any) -> bool:
202201 return context_value == self .value
203202
204203
205- @dataclass
206204class Check :
207205 """
208206 Represents a configuration check
@@ -217,8 +215,8 @@ class Check:
217215 :type category: str
218216 :param workload: Workload type (e.g., SAP, Non-SAP)
219217 :type workload: str
220- :param TestSeverity: TestSeverity level of the check
221- :type TestSeverity : TestSeverity
218+ :param severity: Severity level of the check
219+ :type severity : TestSeverity
222220 :param collector_type: Type of collector to use (e.g., command, azure)
223221 :type collector_type: str
224222 :param collector_args: Arguments for the collector
@@ -237,20 +235,37 @@ class Check:
237235 :type report: Optional[str]
238236 """
239237
240- id : str
241- name : str
242- description : str
243- category : str
244- workload : str
245- severity : TestSeverity = TestSeverity .WARNING
246- collector_type : str = "command"
247- collector_args : Dict [str , Any ] = field (default_factory = dict )
248- validator_type : str = "string"
249- validator_args : Dict [str , Any ] = field (default_factory = dict )
250- tags : List [str ] = field (default_factory = list )
251- applicability : List [ApplicabilityRule ] = field (default_factory = list )
252- references : Dict [str , str ] = field (default_factory = dict )
253- report : Optional [str ] = "check"
238+ def __init__ (
239+ self ,
240+ id : str ,
241+ name : str ,
242+ description : str ,
243+ category : str ,
244+ workload : str ,
245+ severity : TestSeverity = TestSeverity .WARNING ,
246+ collector_type : str = "command" ,
247+ collector_args : Optional [Dict [str , Any ]] = None ,
248+ validator_type : str = "string" ,
249+ validator_args : Optional [Dict [str , Any ]] = None ,
250+ tags : Optional [List [str ]] = None ,
251+ applicability : Optional [List [ApplicabilityRule ]] = None ,
252+ references : Optional [Dict [str , str ]] = None ,
253+ report : Optional [str ] = "check" ,
254+ ):
255+ self .id = id
256+ self .name = name
257+ self .description = description
258+ self .category = category
259+ self .workload = workload
260+ self .severity = severity
261+ self .collector_type = collector_type
262+ self .collector_args = collector_args if collector_args is not None else {}
263+ self .validator_type = validator_type
264+ self .validator_args = validator_args if validator_args is not None else {}
265+ self .tags = tags if tags is not None else []
266+ self .applicability = applicability if applicability is not None else []
267+ self .references = references if references is not None else {}
268+ self .report = report
254269
255270 def is_applicable (self , context : Dict [str , Any ]) -> bool :
256271 """
@@ -270,7 +285,6 @@ def is_applicable(self, context: Dict[str, Any]) -> bool:
270285 return True
271286
272287
273- @dataclass
274288class CheckResult :
275289 """
276290 Represents the result of a check execution
@@ -293,11 +307,22 @@ class CheckResult:
293307 :type details: Optional[str]
294308 """
295309
296- check : Check
297- status : TestStatus
298- hostname : str
299- expected_value : Any
300- actual_value : Any
301- execution_time : float
302- timestamp : datetime = field (default_factory = datetime .now )
303- details : Optional [str ] = None
310+ def __init__ (
311+ self ,
312+ check : Check ,
313+ status : TestStatus ,
314+ hostname : str ,
315+ expected_value : Any ,
316+ actual_value : Any ,
317+ execution_time : float ,
318+ timestamp : Optional [datetime ] = None ,
319+ details : Optional [str ] = None ,
320+ ):
321+ self .check = check
322+ self .status = status
323+ self .hostname = hostname
324+ self .expected_value = expected_value
325+ self .actual_value = actual_value
326+ self .execution_time = execution_time
327+ self .timestamp = timestamp if timestamp is not None else datetime .now ()
328+ self .details = details
0 commit comments