@Path("/{containerName}/delete/pool/{poolName}") @DELETE @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @StatusCodes({ @ResponseCode(code = 200, condition = "Pool deleted successfully"), @ResponseCode(code = 404, condition = "The containerName not found"), @ResponseCode(code = 503, condition = "Load balancer service is unavailable"), @ResponseCode(code = 404, condition = "Pool not found"), @ResponseCode(code = 500, condition = "Failed to delete Pool") }) public Response deletePool( @PathParam(value = "containerName") String containerName, @PathParam(value = "poolName") String poolName) { if (poolName.isEmpty()) throw new UnsupportedMediaTypeException(RestMessages.INVALIDDATA.toString()); IConfigManager configManager = getConfigManagerService(containerName); if (configManager == null) { throw new ServiceUnavailableException( "Load Balancer" + RestMessages.SERVICEUNAVAILABLE.toString()); } if (!configManager.poolExists(poolName)) throw new ResourceNotFoundException(NBConst.RES_POOL_NOT_FOUND); for (Pool pool : configManager.getAllPools()) { if (pool.getName().equals(poolName)) { configManager.deletePool(poolName); return Response.ok().build(); } } throw new InternalServerErrorException(NBConst.RES_POOL_DELETION_FAILED); }
@Path("/{containerName}") @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @TypeHint(Pools.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 Pools getAllPools(@PathParam("containerName") String containerName) { IConfigManager configManager = getConfigManagerService(containerName); if (configManager == null) { throw new ServiceUnavailableException( "Load Balancer " + RestMessages.SERVICEUNAVAILABLE.toString()); } return new Pools(configManager.getAllPools()); }