Skip to content

Commit

Permalink
Merge pull request #246 from Sanketika-Obsrv/status-api-changes
Browse files Browse the repository at this point in the history
#OBS-I203: Remove the archived and purged status transition from the API
  • Loading branch information
HarishGangula authored Sep 16, 2024
2 parents 8a87aea + 0a527d4 commit b90f378
Showing 1 changed file with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ const allowedTransitions: Record<string, any> = {
Delete: [DatasetStatus.Draft, DatasetStatus.ReadyToPublish],
ReadyToPublish: [DatasetStatus.Draft],
Live: [DatasetStatus.ReadyToPublish],
Retire: [DatasetStatus.Live],
Archive: [DatasetStatus.Retired],
Purge: [DatasetStatus.Archived]
Retire: [DatasetStatus.Live]
}
const liveDatasetActions = ["Retire", "Archive", "Purge"]
const liveDatasetActions = ["Retire"]

const validateRequest = (req: Request, datasetId: any) => {
const isRequestValid: Record<string, any> = schemaValidation(req.body, StatusTransitionSchema)
Expand Down Expand Up @@ -70,12 +68,8 @@ const datasetStatusTransition = async (req: Request, res: Response) => {
case "Retire":
await retireDataset(dataset);
break;
case "Archive":
await archiveDataset(dataset);
break;
case "Purge":
await purgeDataset(dataset);
break;
default:
throw obsrvError(dataset.id, "UNKNOWN_STATUS_TRANSITION", "Unknown status transition requested", "BAD_REQUEST", 400)
}

ResponseHandler.successResponse(req, res, { status: httpStatus.OK, data: { message: `Dataset status transition to ${status} successful`, dataset_id } });
Expand Down Expand Up @@ -239,14 +233,4 @@ export const restartPipeline = async (dataset: Record<string, any>) => {
return executeCommand(dataset.id, "RESTART_PIPELINE")
}

const archiveDataset = async (dataset: Record<string, any>) => {

throw obsrvError(dataset.id, "ARCHIVE_NOT_IMPLEMENTED", "Archive functionality is not implemented", "NOT_IMPLEMENTED", 501)
}

const purgeDataset = async (dataset: Record<string, any>) => {

throw obsrvError(dataset.id, "PURGE_NOT_IMPLEMENTED", "Purge functionality is not implemented", "NOT_IMPLEMENTED", 501)
}

export default datasetStatusTransition;

0 comments on commit b90f378

Please sign in to comment.