package org.opendaylight.controller.subnets.northbound;
import java.util.HashSet;
+
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * This class provides REST APIs to manage subnets.
+ *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * HTTPS Authentication is disabled by default.
+ *
+ */
+
@Path("/")
public class SubnetsNorthbound {
protected static final Logger logger = LoggerFactory.getLogger(SubnetsNorthbound.class);
* <pre>
* Example:
*
- * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/all
+ * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnets
*
* Response in XML:
* <subnetConfig>
* }
* </pre>
*/
- @Path("/{containerName}/subnet/all")
+ @Path("/{containerName}/subnets")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
* <pre>
* Example:
*
- * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+ * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
*
* Response in XML:
* <subnetConfig>
}
/**
- * Add a subnet to a container
+ * Add a subnet to a container. If a subnet by the given name already exists
+ * this method will return a non-successful response.
*
* @param containerName
* name of the container to which subnet needs to be added
* <pre>
* Example:
*
- * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+ * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
*
* Request XML:
* <subnetConfig>
*/
@Path("/{containerName}/subnet/{subnetName}")
- @POST
+ @PUT
@StatusCodes({ @ResponseCode(code = 201, condition = "Subnet created successfully"),
@ResponseCode(code = 400, condition = "Invalid data passed"),
@ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
@ResponseCode(code = 503, condition = "Service unavailable") })
public Response addSubnet(@PathParam("containerName") String containerName,
@PathParam("subnetName") String subnetName,
- @TypeHint(SubnetConfig.class) JAXBElement<SubnetConfig> subnetConfigData) {
+ @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) {
handleContainerDoesNotExist(containerName);
throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
- SubnetConfig cfgObject = subnetConfigData.getValue();
+ SubnetConfig cfgObject = subnetConfigData;
handleNameMismatch(cfgObject.getName(), subnetName);
ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this);
*
* <pre>
* Example:
- * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+ * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
*
* </pre>
*/
* <pre>
* Example:
*
- * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+ * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
*
* Request in XML:
* <subnetConfig>
* }
* </pre>
*/
- @Path("/{containerName}/subnet/{subnetName}/node-ports")
- @PUT
+ @Path("/{containerName}/subnet/{subnetName}/nodePorts")
+ @POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
@ResponseCode(code = 200, condition = "Ports replaced successfully"),
@ResponseCode(code = 503, condition = "Service unavailable") })
public Response modifySubnet(@PathParam("containerName") String containerName,
@PathParam("subnetName") String subnetName,
- @TypeHint(SubnetConfig.class) JAXBElement<SubnetConfig> subnetConfigData) {
+ @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) {
handleContainerDoesNotExist(containerName);
throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
- handleNameMismatch(subnetConfigData.getValue().getName(), subnetName);
+ handleNameMismatch(subnetConfigData.getName(), subnetName);
ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName,
this);
throw new ServiceUnavailableException("SwitchManager " + RestMessages.SERVICEUNAVAILABLE.toString());
}
- SubnetConfig subnetConf = subnetConfigData.getValue();
+ SubnetConfig subnetConf = subnetConfigData;
SubnetConfig existingConf = switchManager.getSubnetConfig(subnetName);
boolean successful = true;
}
/**
- * Add ports to a subnet in the container
+ * Add ports to a subnet in the container.
*
* @param containerName
* name of the container that has the subnet to which node ports
*
* <pre>
* Example:
- * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+ * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
*
* Request XML:
* <subnetConfig>
*
* </pre>
*/
- @Path("/{containerName}/subnet/{subnetName}/node-ports")
- @POST
+ @Path("/{containerName}/subnet/{subnetName}/nodePorts")
+ @PUT
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
@ResponseCode(code = 200, condition = "Added node ports to subnet successfully"),
@ResponseCode(code = 503, condition = "Service unavailable") })
public Response addNodePorts(@PathParam("containerName") String containerName,
@PathParam("subnetName") String subnetName,
- @TypeHint(SubnetConfig.class) JAXBElement<SubnetConfig> subnetConfigData) {
+ @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) {
handleContainerDoesNotExist(containerName);
throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
- handleNameMismatch(subnetConfigData.getValue().getName(), subnetName);
+ handleNameMismatch(subnetConfigData.getName(), subnetName);
- SubnetConfig subnetConf = subnetConfigData.getValue();
+ SubnetConfig subnetConf = subnetConfigData;
ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName,
this);
*
* <pre>
* Example:
- * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+ * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
*
* Request XML:
* <subnetConfig>
*
* </pre>
*/
- @Path("/{containerName}/subnet/{subnetName}/node-ports")
+ @Path("/{containerName}/subnet/{subnetName}/nodePorts")
@DELETE
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
@ResponseCode(code = 503, condition = "Service unavailable") })
public Response deleteNodePorts(@PathParam("containerName") String containerName,
@PathParam("subnetName") String subnetName,
- @TypeHint(SubnetConfig.class) JAXBElement<SubnetConfig> subnetConfigData) {
+ @TypeHint(SubnetConfig.class) SubnetConfig subnetConfigData) {
handleContainerDoesNotExist(containerName);
throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ containerName);
}
- handleNameMismatch(subnetConfigData.getValue().getName(), subnetName);
+ handleNameMismatch(subnetConfigData.getName(), subnetName);
- SubnetConfig subnetConf = subnetConfigData.getValue();
+ SubnetConfig subnetConf = subnetConfigData;
if (subnetConf.getNodePorts() == null || subnetConf.getNodePorts().isEmpty()) {
throw new BadRequestException(RestMessages.INVALIDDATA.toString() + " : invalid node ports");
}
}
if (successful) {
- return Response.status(Response.Status.NO_CONTENT).build();
+ return Response.noContent().build();
}
throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString());
}