Search in sources :

Example 1 with DeleteSwitchResult

use of org.openkilda.northbound.dto.v1.switches.DeleteSwitchResult in project open-kilda by telstra.

the class SwitchServiceImpl method deleteSwitch.

/**
 * {@inheritDoc}
 */
@Override
public CompletableFuture<DeleteSwitchResult> deleteSwitch(SwitchId switchId, boolean force) {
    String correlationId = RequestCorrelationId.getId();
    CommandMessage deleteCommand = new CommandMessage(new DeleteSwitchRequest(switchId, force), System.currentTimeMillis(), correlationId, Destination.WFM);
    return messagingChannel.sendAndGet(nbworkerTopic, deleteCommand).thenApply(DeleteSwitchResponse.class::cast).thenApply(response -> new DeleteSwitchResult(response.isDeleted()));
}
Also used : DeleteSwitchResult(org.openkilda.northbound.dto.v1.switches.DeleteSwitchResult) CommandMessage(org.openkilda.messaging.command.CommandMessage) DeleteSwitchRequest(org.openkilda.messaging.nbtopology.request.DeleteSwitchRequest)

Example 2 with DeleteSwitchResult

use of org.openkilda.northbound.dto.v1.switches.DeleteSwitchResult in project open-kilda by telstra.

the class NorthboundServiceImpl method deleteSwitch.

@Override
public DeleteSwitchResult deleteSwitch(SwitchId switchId, boolean force) {
    HttpHeaders httpHeaders = buildHeadersWithCorrelationId();
    httpHeaders.set(Utils.EXTRA_AUTH, String.valueOf(System.currentTimeMillis()));
    String url = "/api/v1/switches/{switch_id}?force={force}";
    return restTemplate.exchange(url, HttpMethod.DELETE, new HttpEntity(httpHeaders), DeleteSwitchResult.class, switchId, force).getBody();
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) DeleteSwitchResult(org.openkilda.northbound.dto.v1.switches.DeleteSwitchResult)

Aggregations

DeleteSwitchResult (org.openkilda.northbound.dto.v1.switches.DeleteSwitchResult)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 DeleteSwitchRequest (org.openkilda.messaging.nbtopology.request.DeleteSwitchRequest)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1