cloudapi: Add DeleteCompose to delete a job by UUID
This adds the handler for DELETE /composes/{id} which will delete a job and
all of its dependencies, and any artifacts.
Related: RHEL-60120
This commit is contained in:
parent
a569ac0f7b
commit
56fc58cca3
4 changed files with 111 additions and 2 deletions
|
|
@ -329,6 +329,29 @@ func (h *apiHandlers) GetComposeList(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, stats)
|
||||
}
|
||||
|
||||
// DeleteCompose deletes a compose by UUID
|
||||
func (h *apiHandlers) DeleteCompose(ctx echo.Context, jobId uuid.UUID) error {
|
||||
return h.server.EnsureJobChannel(h.deleteComposeImpl)(ctx, jobId)
|
||||
}
|
||||
|
||||
func (h *apiHandlers) deleteComposeImpl(ctx echo.Context, jobId uuid.UUID) error {
|
||||
_, err := h.server.workers.JobType(jobId)
|
||||
if err != nil {
|
||||
return HTTPError(ErrorComposeNotFound)
|
||||
}
|
||||
|
||||
err = h.server.workers.DeleteJob(ctx.Request().Context(), jobId)
|
||||
if err != nil {
|
||||
return HTTPErrorWithInternal(ErrorDeletingJob, err)
|
||||
}
|
||||
|
||||
return ctx.JSON(http.StatusOK, ComposeDeleteStatus{
|
||||
Href: fmt.Sprintf("/api/image-builder-composer/v2/composes/delete/%v", jobId),
|
||||
Id: jobId.String(),
|
||||
Kind: "ComposeDeleteStatus",
|
||||
})
|
||||
}
|
||||
|
||||
func (h *apiHandlers) GetComposeStatus(ctx echo.Context, jobId uuid.UUID) error {
|
||||
return h.server.EnsureJobChannel(h.getComposeStatusImpl)(ctx, jobId)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue