Skip to content

Commit 8011fee

Browse files
committed
do not include objects with
null values when serializing for api output
1 parent 9dec906 commit 8011fee

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

contentctl/output/api_json_output.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
from contentctl.output.json_writer import JsonWriter
1818

19+
EXCLUDE_NONE: bool = True
20+
1921

2022
class ApiJsonOutput:
2123
output_path: pathlib.Path
@@ -51,7 +53,8 @@ def writeDetections(
5153
"source",
5254
"nes_fields",
5355
]
54-
)
56+
),
57+
exclude_none=EXCLUDE_NONE,
5558
)
5659
for detection in objects
5760
]
@@ -78,7 +81,10 @@ def writeMacros(
7881
objects: list[Macro],
7982
) -> None:
8083
macros = [
81-
macro.model_dump(include=set(["definition", "description", "name"]))
84+
macro.model_dump(
85+
include=set(["definition", "description", "name"]),
86+
exclude_none=EXCLUDE_NONE,
87+
)
8288
for macro in objects
8389
]
8490
for macro in macros:
@@ -111,7 +117,8 @@ def writeStories(
111117
"baseline_names",
112118
"detections",
113119
]
114-
)
120+
),
121+
exclude_none=EXCLUDE_NONE,
115122
)
116123
for story in objects
117124
]
@@ -157,7 +164,8 @@ def writeBaselines(
157164
"references",
158165
"tags",
159166
]
160-
)
167+
),
168+
exclude_none=EXCLUDE_NONE,
161169
)
162170
for baseline in objects
163171
]
@@ -190,7 +198,8 @@ def writeInvestigations(
190198
"tags",
191199
"lowercase_name",
192200
]
193-
)
201+
),
202+
exclude_none=EXCLUDE_NONE,
194203
)
195204
for investigation in objects
196205
]
@@ -218,7 +227,8 @@ def writeLookups(
218227
"min_matches",
219228
"case_sensitive_match",
220229
]
221-
)
230+
),
231+
exclude_none=EXCLUDE_NONE,
222232
)
223233
for lookup in objects
224234
]
@@ -248,7 +258,8 @@ def writeDeployments(
248258
"rba",
249259
"tags",
250260
]
251-
)
261+
),
262+
exclude_none=EXCLUDE_NONE,
252263
)
253264
for deployment in objects
254265
]

0 commit comments

Comments
 (0)