Search in sources :

Example 6 with SingularityTaskHistoryQuery

use of com.hubspot.singularity.SingularityTaskHistoryQuery in project Singularity by HubSpot.

the class HistoryResource method getTaskHistoryWithMetadata.

@GET
@Path("/tasks/withmetadata")
@ApiOperation("Retrieve the history sorted by startedAt for all inactive tasks.")
public SingularityPaginatedResponse<SingularityTaskIdHistory> getTaskHistoryWithMetadata(@Auth SingularityUser user, @ApiParam("Optional Request ID to match") @QueryParam("requestId") Optional<String> requestId, @ApiParam("Optional deploy ID to match") @QueryParam("deployId") Optional<String> deployId, @ApiParam("Optional runId to match") @QueryParam("runId") Optional<String> runId, @ApiParam("Optional host to match") @QueryParam("host") Optional<String> host, @ApiParam("Optional last task status to match") @QueryParam("lastTaskStatus") Optional<ExtendedTaskState> lastTaskStatus, @ApiParam("Optionally match only tasks started before") @QueryParam("startedBefore") Optional<Long> startedBefore, @ApiParam("Optionally match only tasks started after") @QueryParam("startedAfter") Optional<Long> startedAfter, @ApiParam("Optionally match tasks last updated before") @QueryParam("updatedBefore") Optional<Long> updatedBefore, @ApiParam("Optionally match tasks last updated after") @QueryParam("updatedAfter") Optional<Long> updatedAfter, @ApiParam("Sort direction") @QueryParam("orderDirection") Optional<OrderDirection> orderDirection, @ApiParam("Maximum number of items to return") @QueryParam("count") Integer count, @ApiParam("Which page of items to view") @QueryParam("page") Integer page) {
    if (requestId.isPresent()) {
        authorizationHelper.checkForAuthorizationByRequestId(requestId.get(), user, SingularityAuthorizationScope.READ);
    } else {
        authorizationHelper.checkAdminAuthorization(user);
    }
    final Optional<Integer> dataCount = taskHistoryHelper.getBlendedHistoryCount(new SingularityTaskHistoryQuery(requestId, deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter, orderDirection));
    final int limitCount = getLimitCount(count);
    final List<SingularityTaskIdHistory> data = this.getTaskHistory(user, requestId, deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter, orderDirection, count, page);
    final Optional<Integer> pageCount = getPageCount(dataCount, limitCount);
    return new SingularityPaginatedResponse<>(dataCount, pageCount, Optional.fromNullable(page), data);
}
Also used : SingularityTaskHistoryQuery(com.hubspot.singularity.SingularityTaskHistoryQuery) SingularityTaskIdHistory(com.hubspot.singularity.SingularityTaskIdHistory) SingularityPaginatedResponse(com.hubspot.singularity.SingularityPaginatedResponse) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation)

Aggregations

SingularityTaskHistoryQuery (com.hubspot.singularity.SingularityTaskHistoryQuery)6 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)5 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 SingularityTaskIdHistory (com.hubspot.singularity.SingularityTaskIdHistory)4 SingularityPaginatedResponse (com.hubspot.singularity.SingularityPaginatedResponse)2 ExtendedTaskState (com.hubspot.singularity.ExtendedTaskState)1 OrderDirection (com.hubspot.singularity.OrderDirection)1 SingularityTask (com.hubspot.singularity.SingularityTask)1 SingularityTaskHistoryUpdate (com.hubspot.singularity.SingularityTaskHistoryUpdate)1 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)1 HashSet (java.util.HashSet)1 List (java.util.List)1