@Path("/{containerName}/delete/vip/{vipName}") @DELETE @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @StatusCodes({ @ResponseCode(code = 200, condition = "VIP deleted successfully"), @ResponseCode(code = 404, condition = "The containerName not found"), @ResponseCode(code = 503, condition = "Load balancer service is unavailable"), @ResponseCode(code = 404, condition = "VIP not found"), @ResponseCode(code = 500, condition = "Failed to delete VIP") }) public Response deleteVIP( @PathParam(value = "containerName") String containerName, @PathParam(value = "vipName") String vipName) { if (vipName.isEmpty()) throw new UnsupportedMediaTypeException(RestMessages.INVALIDDATA.toString()); IConfigManager configManager = getConfigManagerService(containerName); if (configManager == null) { throw new ServiceUnavailableException( "Load Balancer" + RestMessages.SERVICEUNAVAILABLE.toString()); } if (!configManager.vipExists(vipName)) throw new ResourceNotFoundException(NBConst.RES_VIP_NOT_FOUND); for (VIP vip : configManager.getAllVIPs()) { if (vip.getName().equals(vipName)) { configManager.deleteVIP(vipName); return Response.ok().build(); } } throw new InternalServerErrorException(NBConst.RES_VIP_DELETION_FAILED); }
@Path("/{containerName}/vips") @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @TypeHint(VIPs.class) @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 404, condition = "The containerName is not found"), @ResponseCode(code = 503, condition = "Load balancer service is unavailable") }) public VIPs getAllVIPs(@PathParam("containerName") String containerName) { IConfigManager configManager = getConfigManagerService(containerName); if (configManager == null) { throw new ServiceUnavailableException( "Load Balancer " + RestMessages.SERVICEUNAVAILABLE.toString()); } return new VIPs(configManager.getAllVIPs()); }