(g)ULP!
Loading...
Searching...
No Matches
GulpMapping Class Reference
Inheritance diagram for GulpMapping:
Collaboration diagram for GulpMapping:

Public Member Functions

dict to_dict (self)
 
 to_py_dict (cls, str|dict data)
 

Static Public Member Functions

"GulpMapping" from_dict (dict d)
 

Static Public Attributes

dict fields
 
dict model_config
 
Optional options
 

Detailed Description

defines a source->elasticsearch document mapping for a Gulp plugin.

Definition at line 168 of file models.py.

Member Function Documentation

◆ from_dict()

"GulpMapping" from_dict ( dict d)
static

Definition at line 224 of file models.py.

224 def from_dict(d: dict) -> "GulpMapping":
225 m = d.get("fields", {})
226 if len(m) > 0:
227 fields = {k: FieldMappingEntry.from_dict(v) for k, v in m.items()}
228 else:
229 fields = {}
230 opts = d.get("options", None)
231 if opts is not None:
232 options = GulpMappingOptions.from_dict(opts)
233 else:
234 # default values
235 options = GulpMappingOptions()
236
237 return GulpMapping(
238 fields=fields,
239 options=options,
240 )
241

◆ to_dict()

dict to_dict ( self)
NOTE: options is guaranteed to be not None (default values are applied if None)

Definition at line 209 of file models.py.

209 def to_dict(self) -> dict:
210 """
211 NOTE: options is guaranteed to be not None (default values are applied if None)
212 """
213 d = {
214 "fields": {k: v.to_dict() for k, v in self.fields.items()},
215 "options": (
216 GulpMappingOptions.to_dict(self.options)
217 if self.options is not None
218 else GulpMappingOptions().to_dict()
219 ),
220 }
221 return d
222
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_py_dict()

to_py_dict ( cls,
str | dict data )

Definition at line 244 of file models.py.

244 def to_py_dict(cls, data: str | dict):
245 if data is None or len(data) == 0:
246 return {}
247
248 if isinstance(data, dict):
249 return data
250
251 return json.loads(data)

Member Data Documentation

◆ fields

dict fields
static
Initial value:
= Field(
{},
description='a dictionary where each key is a source field to be mapped to "map_to" defined in "FieldMappingEntry".',
)

Definition at line 173 of file models.py.

◆ model_config

dict model_config
static
Initial value:
= {
"json_schema_extra": {
"example": {
"fields": {
"source_field1_single": {"map_to": "my_field"},
"source_field2_multiple": {"map_to": ["my_field1", "myfield2"]},
"source_field3_variable": {
"map_to": [
["category", "process_creation", "process.pe.company"],
["category", "image_load", "file.pe.company"],
]
},
},
"options": {
"agent_type": "my_agent_type",
"event_code": "my_event_code",
"mapping_id": "my_mapping_id",
"ignore_unmapped": False,
"timestamp_yearfirst": True,
"timestamp_dayfirst": False,
"timestamp_tz": "UTC",
"extra": {"my_custom_option": "my_custom_value"},
},
}
}
}

Definition at line 182 of file models.py.

◆ options

Optional options
static
Initial value:
= Field(
None,
description="specific options for this GulpMapping. if None, defaults are applied.",
)

Definition at line 177 of file models.py.


The documentation for this class was generated from the following file: