use of org.onosproject.net.config.SubjectFactory in project onos by opennetworkinglab.
the class NetworkConfigWebResource method download.
/**
* Gets all network configuration for a subjectKey.
*
* @param subjectClassKey subjectKey class key
* @param subjectKey subjectKey key
* @return 200 OK with network configuration JSON
*/
@GET
@Path("{subjectClassKey}/{subjectKey}")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response download(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey) {
NetworkConfigService service = get(NetworkConfigService.class);
ObjectNode root = mapper().createObjectNode();
SubjectFactory subjectFactory = nullIsNotFound(service.getSubjectFactory(subjectClassKey), subjectClassNotFoundErrorString(subjectClassKey));
produceSubjectJson(service, root, subjectFactory.createSubject(subjectKey), true, subjectNotFoundErrorString(subjectClassKey, subjectKey));
return ok(root).build();
}
use of org.onosproject.net.config.SubjectFactory in project onos by opennetworkinglab.
the class NetworkConfigWebResource method upload.
/**
* Upload specific network configuration for a subjectKey.
*
* @param subjectClassKey subjectKey class key
* @param subjectKey subjectKey key
* @param configKey configuration class key
* @param request network configuration JSON rooted at the top node
* @return 200 OK
* @throws IOException if unable to parse the request
*/
@POST
@Path("{subjectClassKey}/{subjectKey}/{configKey}")
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey, @PathParam("configKey") String configKey, InputStream request) throws IOException {
NetworkConfigService service = get(NetworkConfigService.class);
JsonNode root = readTreeFromStream(mapper(), request);
SubjectFactory subjectFactory = nullIsNotFound(service.getSubjectFactory(subjectClassKey), subjectClassNotValidErrorString(subjectClassKey));
service.applyConfig(subjectClassKey, subjectFactory.createSubject(subjectKey), configKey, root);
return Response.ok().build();
}
use of org.onosproject.net.config.SubjectFactory in project onos by opennetworkinglab.
the class NetworkConfigWebResource method delete.
/**
* Clear specific network configuration for a subjectKey.
*
* @param subjectClassKey subjectKey class key
* @param subjectKey subjectKey key
* @param configKey configuration class key
* @return 204 NO CONTENT
*/
@DELETE
@Path("{subjectClassKey}/{subjectKey}/{configKey}")
@SuppressWarnings("unchecked")
public Response delete(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey, @PathParam("configKey") String configKey) {
NetworkConfigService service = get(NetworkConfigService.class);
SubjectFactory subjectFactory = nullIsNotFound(service.getSubjectFactory(subjectClassKey), subjectClassNotValidErrorString(subjectClassKey));
service.removeConfig(subjectClassKey, subjectFactory.createSubject(subjectKey), configKey);
return Response.noContent().build();
}
Aggregations