use of org.onosproject.kubevirtnetworking.api.KubevirtNetworkAdminService in project onos by opennetworkinglab.
the class KubevirtNetworkWebResource method createNetwork.
/**
* Creates a network from the JSON input stream.
*
* @param input network JSON input stream
* @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
* is invalid or duplicated network already exists
* @onos.rsModel KubevirtNetwork
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createNetwork(InputStream input) {
log.trace(String.format(MESSAGE, "CREATE"));
KubevirtNetworkAdminService service = get(KubevirtNetworkAdminService.class);
URI location;
try {
ObjectNode jsonTree = readTreeFromStream(mapper(), input);
final KubevirtNetwork network = codec(KubevirtNetwork.class).decode(jsonTree, this);
service.createNetwork(network);
location = new URI(network.networkId());
} catch (IOException | URISyntaxException e) {
throw new IllegalArgumentException(e);
}
return Response.created(location).build();
}
Aggregations