Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions contentctl/actions/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
26 changes: 19 additions & 7 deletions contentctl/output/api_json_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from contentctl.output.json_writer import JsonWriter

JSON_API_VERSION = 2


class ApiJsonOutput:
output_path: pathlib.Path
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)
Loading