Search in sources :

Example 1 with PortHistoryResponse

use of org.openkilda.northbound.dto.v2.switches.PortHistoryResponse in project open-kilda by telstra.

the class NorthboundServiceV2Impl method getPortHistory.

@Override
public List<PortHistoryResponse> getPortHistory(SwitchId switchId, Integer port, Long timeFrom, Long timeTo) {
    UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString("/api/v2/switches/{switch_id}/ports/{port}/history");
    if (timeFrom != null) {
        uriBuilder.queryParam("timeFrom", dateFormat.format(new Date(timeFrom)));
    }
    if (timeTo != null) {
        uriBuilder.queryParam("timeTo", dateFormat.format(new Date(timeTo)));
    }
    PortHistoryResponse[] portHistory = restTemplate.exchange(uriBuilder.build().toString(), HttpMethod.GET, new HttpEntity(buildHeadersWithCorrelationId()), PortHistoryResponse[].class, switchId, port).getBody();
    return Arrays.asList(portHistory);
}
Also used : HttpEntity(org.springframework.http.HttpEntity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) PortHistoryResponse(org.openkilda.northbound.dto.v2.switches.PortHistoryResponse) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 PortHistoryResponse (org.openkilda.northbound.dto.v2.switches.PortHistoryResponse)1 HttpEntity (org.springframework.http.HttpEntity)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1