use of alien4cloud.rest.deployment.model.GetMultipleJsonResult in project alien4cloud by alien4cloud.
the class DeploymentEventsController method get.
/**
* Batch processing oriented API to retrieve deployment status events. This API is not intended for frequent requests but can retrieve lot of data.
*
* @return
*/
@ApiOperation(value = "Get deployment status events from a given date.", notes = "Batch processing oriented API to retrieve deployment status events. This API is not intended for frequent requests but can retrieve lot of data.", authorizations = { @Authorization("ADMIN"), @Authorization("APPLICATION_MANAGER") })
@RequestMapping(value = "/status", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public GetMultipleJsonResult get(@RequestBody @Valid TimedRequest timedRequest) {
RangeFilterBuilder dateFilter = FilterBuilders.rangeFilter("date").gte(timedRequest.getIntervalStart());
if (timedRequest.getIntervalEnd() != null) {
dateFilter.lt(timedRequest.getIntervalEnd());
}
SearchResponse response = monitorDao.getClient().prepareSearch(monitorDao.getIndexForType(PaaSDeploymentStatusMonitorEvent.class)).setTypes(MappingBuilder.indexTypeFromClass(PaaSDeploymentStatusMonitorEvent.class)).setQuery(QueryBuilders.constantScoreQuery(dateFilter)).setFrom(timedRequest.getFrom()).setSize(timedRequest.getSize()).get();
GetMultipleJsonResult result = new GetMultipleJsonResult();
result.setData(ResponseUtil.rawMultipleData(response));
result.setTotalResults(response.getHits().getTotalHits());
result.setQueryDuration(response.getTookInMillis());
return result;
}
Aggregations