Search in sources :

Example 1 with FlowHistoryEntry

use of org.openkilda.messaging.payload.history.FlowHistoryEntry in project open-kilda by telstra.

the class NorthboundServiceImpl method getFlowHistory.

@Override
public List<FlowHistoryEntry> getFlowHistory(String flowId, Long timeFrom, Long timeTo, Integer maxCount) {
    UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString("/api/v1/flows/{flow_id}/history");
    if (timeFrom != null) {
        uriBuilder.queryParam("timeFrom", timeFrom);
    }
    if (timeTo != null) {
        uriBuilder.queryParam("timeTo", timeTo);
    }
    if (maxCount != null) {
        uriBuilder.queryParam("max_count", maxCount);
    }
    FlowHistoryEntry[] flowHistory = restTemplate.exchange(uriBuilder.build().toString(), HttpMethod.GET, new HttpEntity(buildHeadersWithCorrelationId()), FlowHistoryEntry[].class, flowId).getBody();
    return Arrays.asList(flowHistory);
}
Also used : FlowHistoryEntry(org.openkilda.messaging.payload.history.FlowHistoryEntry) HttpEntity(org.springframework.http.HttpEntity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 2 with FlowHistoryEntry

use of org.openkilda.messaging.payload.history.FlowHistoryEntry in project open-kilda by telstra.

the class FlowServiceImpl method listFlowEvents.

@Override
public CompletableFuture<List<FlowHistoryEntry>> listFlowEvents(String flowId, long timestampFrom, long timestampTo, int maxCount) {
    if (maxCount < 1) {
        throw new MessageException(RequestCorrelationId.getId(), System.currentTimeMillis(), ErrorType.PARAMETERS_INVALID, format("Invalid `max_count` argument '%s'.", maxCount), "`max_count` argument must be positive.");
    }
    String correlationId = RequestCorrelationId.getId();
    GetFlowHistoryRequest request = GetFlowHistoryRequest.builder().flowId(flowId).timestampFrom(timestampFrom).timestampTo(timestampTo).maxCount(maxCount).build();
    CommandMessage command = new CommandMessage(request, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGetChunked(nbworkerTopic, command).thenApply(result -> result.stream().map(FlowHistoryEntry.class::cast).collect(Collectors.toList()));
}
Also used : FlowHistoryEntry(org.openkilda.messaging.payload.history.FlowHistoryEntry) MessageException(org.openkilda.messaging.error.MessageException) GetFlowHistoryRequest(org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

FlowHistoryEntry (org.openkilda.messaging.payload.history.FlowHistoryEntry)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 MessageException (org.openkilda.messaging.error.MessageException)1 GetFlowHistoryRequest (org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest)1 HttpEntity (org.springframework.http.HttpEntity)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1