use of org.onosproject.routeservice.RouteAdminService in project onos by opennetworkinglab.
the class RouteServiceWebResource method createRoutes.
/**
* Creates new unicast routes.
* Creates a new route in the unicast RIB. Source field is kept optional.
* Without Source field routes are created as STATIC routes. Otherwise as per the mentioned Source
*
* @param routesStream unicast routes JSON array
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid, NO_CONTENT otherwise
* @onos.rsModel RoutesTypePost
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/bulk")
public Response createRoutes(InputStream routesStream) {
RouteAdminService service = get(RouteAdminService.class);
try {
ObjectNode jsonTree = readTreeFromStream(mapper(), routesStream);
ArrayNode routesArray = nullIsIllegal((ArrayNode) jsonTree.get(ROUTES), ROUTES_KEY_ERROR);
List<Route> routes = codec(Route.class).decode(routesArray, this);
service.update(routes);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response.noContent().build();
}
Aggregations