Search in sources :

Example 1 with SwitchConnectionsResponse

use of org.openkilda.messaging.nbtopology.response.SwitchConnectionsResponse in project open-kilda by telstra.

the class SwitchOperationsService method getSwitchConnections.

/**
 * Find and return the set of connections to the speakers for specific switch.
 */
public SwitchConnectionsResponse getSwitchConnections(SwitchId switchId) throws SwitchNotFoundException {
    Switch sw = switchRepository.findById(switchId).orElseThrow(() -> new SwitchNotFoundException(switchId));
    SwitchAvailabilityData.SwitchAvailabilityDataBuilder payload = SwitchAvailabilityData.builder();
    for (SwitchConnect entry : switchConnectRepository.findBySwitchId(switchId)) {
        payload.connection(SwitchMapper.INSTANCE.map(entry));
    }
    return new SwitchConnectionsResponse(sw.getSwitchId(), sw.getStatus(), payload.build());
}
Also used : Switch(org.openkilda.model.Switch) SwitchAvailabilityData(org.openkilda.messaging.model.SwitchAvailabilityData) SwitchConnect(org.openkilda.model.SwitchConnect) SwitchConnectionsResponse(org.openkilda.messaging.nbtopology.response.SwitchConnectionsResponse) SwitchNotFoundException(org.openkilda.wfm.error.SwitchNotFoundException)

Aggregations

SwitchAvailabilityData (org.openkilda.messaging.model.SwitchAvailabilityData)1 SwitchConnectionsResponse (org.openkilda.messaging.nbtopology.response.SwitchConnectionsResponse)1 Switch (org.openkilda.model.Switch)1 SwitchConnect (org.openkilda.model.SwitchConnect)1 SwitchNotFoundException (org.openkilda.wfm.error.SwitchNotFoundException)1