Skip to content

Commit

Permalink
add endpoint to delete history
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus-Osuna-M committed Mar 27, 2024
1 parent 8aaafa8 commit 7f1e77b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5612,6 +5612,38 @@ return.''',
flush(response)
}

/**
* API: /api/job/{id}/history , version 1
*/
def apiJobHistoryDelete() {
if (!apiService.requireApi(request, response)) {
return
}
if (!apiService.requireParameters(params, response, ['id'])) {
return
}
jobHistoryService.deleteJobHistory(params.id)

response.contentType = 'application/json;charset=UTF-8'
response.status = 200
}

/**
* API: /api/job/{id}/history , version 1
*/
def apiJobHistoryDeleteById() {
if (!apiService.requireApi(request, response)) {
return
}
if (!apiService.requireParameters(params, response, ['historyId'])) {
return
}
jobHistoryService.deleteJobHistoryById(params.historyId)

response.contentType = 'application/json;charset=UTF-8'
response.status = 200
}

/**
* non-api interface to job executions results
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ class UrlMappings {
}

"/api/$api_version/job/$id/history"(controller: 'scheduledExecution') {
action = [GET: 'apiJobHistory']
action = [GET: 'apiJobHistory', DELETE: 'apiJobHistoryDelete']
}

"/api/$api_version/job/history/$historyId"(controller: 'scheduledExecution') {
action = [DELETE: 'apiJobHistoryDeleteById']
}

"/api/$api_version/job/$id/scm/$integration/status"(controller: 'scm', action: 'apiJobStatus')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class JobHistoryService implements JobDefinitionComponent, ApplicationContextAwa
JobHistory.executeUpdate("delete JobHistory jh where jh.jobUuid = :jobUuid", [jobUuid:jobUuid])
}

void deleteJobHistoryById(String historyId){
JobHistory.findById(historyId.toInteger()).delete(flush:true)
}

/**
* It retrieves all job histories and then parse the json stored in the DB to an actual ScheduledExecution
* It adds the history parameters to the scheduledExecution so it can be shown in the request
Expand Down

0 comments on commit 7f1e77b

Please sign in to comment.