@@ -22,6 +22,12 @@ class LogSourceSignature(ABC):
2222def is_suitable (self ,** kwargs )-> bool :
2323raise NotImplementedError ("Abstract method" )
2424
25+ def is_probably_suitable (self ,** kwargs )-> bool :
26+ """
27+ Performs check with more options, but the result is less accurate than the "is_suitable" method
28+ """
29+ raise NotImplementedError ("Abstract method" )
30+
2531@staticmethod
2632def _check_conditions (conditions :list [Union [bool ,None ]])-> bool :
2733conditions = [condition for condition in conditions if condition is not None ]
@@ -88,11 +94,13 @@ def __init__(
8894log_source_signature :_LogSourceSignatureType = None ,
8995fields_mapping :Optional [FieldsMapping ]= None ,
9096raw_log_fields :Optional [dict ]= None ,
97+ conditions :Optional [dict ]= None ,
9198 ):
9299self .source_id = source_id
93100self .log_source_signature = log_source_signature
94101self .fields_mapping = fields_mapping or FieldsMapping ([])
95102self .raw_log_fields = raw_log_fields
103+ self .conditions = conditions
96104
97105
98106class BasePlatformMappings :
@@ -123,6 +131,7 @@ def prepare_mapping(self) -> dict[str, SourceMapping]:
123131
124132field_mappings_dict = mapping_dict .get ("field_mapping" , {})
125133raw_log_fields = mapping_dict .get ("raw_log_fields" , {})
134+ conditions = mapping_dict .get ("conditions" , {})
126135field_mappings_dict .update ({field :field for field in raw_log_fields })
127136fields_mapping = self .prepare_fields_mapping (field_mapping = field_mappings_dict )
128137self .update_default_source_mapping (default_mapping = default_mapping ,fields_mapping = fields_mapping )
@@ -131,6 +140,7 @@ def prepare_mapping(self) -> dict[str, SourceMapping]:
131140log_source_signature = log_source_signature ,
132141fields_mapping = fields_mapping ,
133142raw_log_fields = raw_log_fields ,
143+ conditions = conditions ,
134144 )
135145
136146if self .skip_load_default_mappings :
@@ -170,31 +180,47 @@ def get_source_mappings_by_fields_and_log_sources(
170180
171181return by_log_sources_and_fields or by_fields or [self ._source_mappings [DEFAULT_MAPPING_NAME ]]
172182
173- def get_source_mappings_by_ids (self ,source_mapping_ids :list [str ])-> list [SourceMapping ]:
183+ def get_source_mapping (self ,source_id :str )-> Optional [SourceMapping ]:
184+ return self ._source_mappings .get (source_id )
185+
186+ def get_source_mappings_by_ids (
187+ self ,source_mapping_ids :list [str ],return_default :bool = True
188+ )-> list [SourceMapping ]:
174189source_mappings = []
175190for source_mapping_id in source_mapping_ids :
191+ if source_mapping_id == DEFAULT_MAPPING_NAME :
192+ continue
176193if source_mapping := self .get_source_mapping (source_mapping_id ):
177194source_mappings .append (source_mapping )
178195
179- if not source_mappings :
196+ if not source_mappings and return_default :
180197source_mappings = [self .get_source_mapping (DEFAULT_MAPPING_NAME )]
181198
182199return source_mappings
183200
184- def get_source_mapping (self ,source_id : str )-> Optional [SourceMapping ]:
185- return self . _source_mappings . get ( source_id )
201+ def get_source_mappings_by_log_sources (self ,log_sources : dict )-> Optional [list [ str ] ]:
202+ raise NotImplementedError ( "Abstract method" )
186203
187204@property
188205def default_mapping (self )-> SourceMapping :
189206return self ._source_mappings [DEFAULT_MAPPING_NAME ]
190207
191- def check_fields_mapping_existence (self ,field_tokens :list [Field ],source_mapping :SourceMapping )-> list [str ]:
208+ def check_fields_mapping_existence (
209+ self ,
210+ query_field_tokens :list [Field ],
211+ function_field_tokens_map :dict [str ,list [Field ]],
212+ supported_func_render_names :set [str ],
213+ source_mapping :SourceMapping ,
214+ )-> list [str ]:
192215unmapped = []
193- for field in field_tokens :
194- generic_field_name = field .get_generic_field_name (source_mapping .source_id )
195- mapped_field = source_mapping .fields_mapping .get_platform_field_name (generic_field_name = generic_field_name )
196- if not mapped_field and field .source_name not in unmapped :
197- unmapped .append (field .source_name )
216+
217+ for field in query_field_tokens :
218+ self ._check_field_mapping_existence (field ,source_mapping ,unmapped )
219+
220+ for func_name ,function_field_tokens in function_field_tokens_map .items ():
221+ if func_name in supported_func_render_names :
222+ for field in function_field_tokens :
223+ self ._check_field_mapping_existence (field ,source_mapping ,unmapped )
198224
199225if self .is_strict_mapping and unmapped :
200226raise StrictPlatformException (
@@ -203,6 +229,13 @@ def check_fields_mapping_existence(self, field_tokens: list[Field], source_mappi
203229
204230return unmapped
205231
232+ @staticmethod
233+ def _check_field_mapping_existence (field :Field ,source_mapping :SourceMapping ,unmapped :list [str ])-> None :
234+ generic_field_name = field .get_generic_field_name (source_mapping .source_id )
235+ mapped_field = source_mapping .fields_mapping .get_platform_field_name (generic_field_name = generic_field_name )
236+ if not mapped_field and field .source_name not in unmapped :
237+ unmapped .append (field .source_name )
238+
206239@staticmethod
207240def map_field (field :Field ,source_mapping :SourceMapping )-> list [str ]:
208241generic_field_name = field .get_generic_field_name (source_mapping .source_id )