/** * Returns all switches * * @param none * @return List of all switches * <pre> * * Example: * * Request URL: * http://localhost:8080/controller/nb/v2/opendove/odmc/switches * * Response body in JSON: * { * "switches": [ { * "id": "uuid", * "name": "switch name", * "tunnelip": "10.10.10.1", * "mgmtip": "20.20.20.2", * "timestamp": "now" * } ] * } * </pre> */ @GET @Produces({MediaType.APPLICATION_JSON}) @TypeHint(OpenDoveSwitchRequest.class) @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 204, condition = "No content"), @ResponseCode(code = 401, condition = "Unauthorized"), @ResponseCode(code = 500, condition = "Internal Error") }) public Response showServiceAppliances() { IfOpenDoveSwitchCRUD sbInterface = OpenDoveCRUDInterfaces.getIfOpenDoveSwitchCRU(this); if (sbInterface == null) { throw new ServiceUnavailableException( "OpenDove SB Interface " + RestMessages.SERVICEUNAVAILABLE.toString()); } return Response.status(200) .entity(new OpenDoveSwitchRequest(sbInterface.getSwitches())) .build(); }
/** * Returns a particular switch * * @param switchUUID Identifier of the switch * @return Data on that switch * <pre> * * Example: * * Request URL: * http://localhost:8080/controller/nb/v2/opendove/odmc/switches/uuid * * Response body in JSON: * { * "switch": { * "id": "uuid", * "name": "switch name", * "tunnelip": "10.10.10.1", * "mgmtip": "20.20.20.2", * "timestamp": "now" * } * } * </pre> */ @Path("{switchUUID}") @GET @Produces({MediaType.APPLICATION_JSON}) @TypeHint(OpenDoveSwitchRequest.class) @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 204, condition = "No content"), @ResponseCode(code = 401, condition = "Unauthorized"), @ResponseCode(code = 404, condition = "Not Found"), @ResponseCode(code = 500, condition = "Internal Error") }) public Response showSwtich(@PathParam("switchUUID") String switchUUID) { IfOpenDoveSwitchCRUD sbInterface = OpenDoveCRUDInterfaces.getIfOpenDoveSwitchCRU(this); if (sbInterface == null) { throw new ServiceUnavailableException( "OpenDove SB Interface " + RestMessages.SERVICEUNAVAILABLE.toString()); } if (!sbInterface.switchExists(switchUUID)) { throw new ResourceNotFoundException("Switch doesn't exist"); } return Response.status(200) .entity(new OpenDoveSwitchRequest(sbInterface.getSwitch(switchUUID))) .build(); }