Skip to content

Commit f395503

Browse files
authored
Merge pull request #408 from splunk/bunch_api_to_v2
Bump api to v2
2 parents 646f489 + 90c9399 commit f395503

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

contentctl/actions/build.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from contentctl.input.director import DirectorOutputDto
88
from contentctl.objects.config import build
9-
from contentctl.output.api_json_output import ApiJsonOutput
9+
from contentctl.output.api_json_output import JSON_API_VERSION, ApiJsonOutput
1010
from contentctl.output.conf_output import ConfOutput
1111
from contentctl.output.conf_writer import ConfWriter
1212

@@ -76,7 +76,9 @@ def execute(self, input_dto: BuildInputDto) -> DirectorOutputDto:
7676
api_json_output.writeDeployments(input_dto.director_output_dto.deployments)
7777

7878
# create version file for sse api
79-
version_file = input_dto.config.getAPIPath() / "version.json"
79+
version_file = (
80+
input_dto.config.getAPIPath() / f"version_v{JSON_API_VERSION}.json"
81+
)
8082
utc_time = (
8183
datetime.datetime.now(datetime.timezone.utc)
8284
.replace(microsecond=0, tzinfo=None)

contentctl/output/api_json_output.py

Lines changed: 19 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+
JSON_API_VERSION = 2
20+
1921

2022
class ApiJsonOutput:
2123
output_path: pathlib.Path
@@ -70,7 +72,9 @@ def writeDetections(
7072
# del()
7173

7274
JsonWriter.writeJsonObject(
73-
os.path.join(self.output_path, "detections.json"), "detections", detections
75+
os.path.join(self.output_path, f"detections_v{JSON_API_VERSION}.json"),
76+
"detections",
77+
detections,
7478
)
7579

7680
def writeMacros(
@@ -86,7 +90,9 @@ def writeMacros(
8690
if k in macro:
8791
del macro[k]
8892
JsonWriter.writeJsonObject(
89-
os.path.join(self.output_path, "macros.json"), "macros", macros
93+
os.path.join(self.output_path, f"macros_v{JSON_API_VERSION}.json"),
94+
"macros",
95+
macros,
9096
)
9197

9298
def writeStories(
@@ -132,7 +138,9 @@ def writeStories(
132138
]
133139

134140
JsonWriter.writeJsonObject(
135-
os.path.join(self.output_path, "stories.json"), "stories", stories
141+
os.path.join(self.output_path, f"stories_v{JSON_API_VERSION}.json"),
142+
"stories",
143+
stories,
136144
)
137145

138146
def writeBaselines(
@@ -163,7 +171,9 @@ def writeBaselines(
163171
]
164172

165173
JsonWriter.writeJsonObject(
166-
os.path.join(self.output_path, "baselines.json"), "baselines", baselines
174+
os.path.join(self.output_path, f"baselines_v{JSON_API_VERSION}.json"),
175+
"baselines",
176+
baselines,
167177
)
168178

169179
def writeInvestigations(
@@ -195,7 +205,7 @@ def writeInvestigations(
195205
for investigation in objects
196206
]
197207
JsonWriter.writeJsonObject(
198-
os.path.join(self.output_path, "response_tasks.json"),
208+
os.path.join(self.output_path, f"response_tasks_v{JSON_API_VERSION}.json"),
199209
"response_tasks",
200210
investigations,
201211
)
@@ -227,7 +237,9 @@ def writeLookups(
227237
if k in lookup:
228238
del lookup[k]
229239
JsonWriter.writeJsonObject(
230-
os.path.join(self.output_path, "lookups.json"), "lookups", lookups
240+
os.path.join(self.output_path, f"lookups_v{JSON_API_VERSION}.json"),
241+
"lookups",
242+
lookups,
231243
)
232244

233245
def writeDeployments(
@@ -255,7 +267,7 @@ def writeDeployments(
255267
# references are not to be included, but have been deleted in the
256268
# model_serialization logic
257269
JsonWriter.writeJsonObject(
258-
os.path.join(self.output_path, "deployments.json"),
270+
os.path.join(self.output_path, f"deployments_v{JSON_API_VERSION}.json"),
259271
"deployments",
260272
deployments,
261273
)

0 commit comments

Comments
 (0)