diff --git a/contentctl/actions/build.py b/contentctl/actions/build.py index 6d5e96bd..64bcad4e 100644 --- a/contentctl/actions/build.py +++ b/contentctl/actions/build.py @@ -6,7 +6,7 @@ from contentctl.input.director import DirectorOutputDto from contentctl.objects.config import build -from contentctl.output.api_json_output import ApiJsonOutput +from contentctl.output.api_json_output import JSON_API_VERSION, ApiJsonOutput from contentctl.output.conf_output import ConfOutput from contentctl.output.conf_writer import ConfWriter @@ -76,7 +76,9 @@ def execute(self, input_dto: BuildInputDto) -> DirectorOutputDto: api_json_output.writeDeployments(input_dto.director_output_dto.deployments) # create version file for sse api - version_file = input_dto.config.getAPIPath() / "version.json" + version_file = ( + input_dto.config.getAPIPath() / f"version_v{JSON_API_VERSION}.json" + ) utc_time = ( datetime.datetime.now(datetime.timezone.utc) .replace(microsecond=0, tzinfo=None) diff --git a/contentctl/output/api_json_output.py b/contentctl/output/api_json_output.py index 846d44bb..dabf18fd 100644 --- a/contentctl/output/api_json_output.py +++ b/contentctl/output/api_json_output.py @@ -16,6 +16,8 @@ from contentctl.output.json_writer import JsonWriter +JSON_API_VERSION = 2 + class ApiJsonOutput: output_path: pathlib.Path @@ -70,7 +72,9 @@ def writeDetections( # del() JsonWriter.writeJsonObject( - os.path.join(self.output_path, "detections.json"), "detections", detections + os.path.join(self.output_path, f"detections_v{JSON_API_VERSION}.json"), + "detections", + detections, ) def writeMacros( @@ -86,7 +90,9 @@ def writeMacros( if k in macro: del macro[k] JsonWriter.writeJsonObject( - os.path.join(self.output_path, "macros.json"), "macros", macros + os.path.join(self.output_path, f"macros_v{JSON_API_VERSION}.json"), + "macros", + macros, ) def writeStories( @@ -132,7 +138,9 @@ def writeStories( ] JsonWriter.writeJsonObject( - os.path.join(self.output_path, "stories.json"), "stories", stories + os.path.join(self.output_path, f"stories_v{JSON_API_VERSION}.json"), + "stories", + stories, ) def writeBaselines( @@ -163,7 +171,9 @@ def writeBaselines( ] JsonWriter.writeJsonObject( - os.path.join(self.output_path, "baselines.json"), "baselines", baselines + os.path.join(self.output_path, f"baselines_v{JSON_API_VERSION}.json"), + "baselines", + baselines, ) def writeInvestigations( @@ -195,7 +205,7 @@ def writeInvestigations( for investigation in objects ] JsonWriter.writeJsonObject( - os.path.join(self.output_path, "response_tasks.json"), + os.path.join(self.output_path, f"response_tasks_v{JSON_API_VERSION}.json"), "response_tasks", investigations, ) @@ -227,7 +237,9 @@ def writeLookups( if k in lookup: del lookup[k] JsonWriter.writeJsonObject( - os.path.join(self.output_path, "lookups.json"), "lookups", lookups + os.path.join(self.output_path, f"lookups_v{JSON_API_VERSION}.json"), + "lookups", + lookups, ) def writeDeployments( @@ -255,7 +267,7 @@ def writeDeployments( # references are not to be included, but have been deleted in the # model_serialization logic JsonWriter.writeJsonObject( - os.path.join(self.output_path, "deployments.json"), + os.path.join(self.output_path, f"deployments_v{JSON_API_VERSION}.json"), "deployments", deployments, )