use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.
the class ComponentConfigWebResource method getComponentConfig.
/**
* Gets specified value of a specified component and variable.
*
* @param component component name
* @param attribute attribute name
* @return 200 OK with a collection of component configurations
*/
@GET
@Path("{component}/{attribute}")
@Produces(MediaType.APPLICATION_JSON)
public Response getComponentConfig(@PathParam("component") String component, @PathParam("attribute") String attribute) {
ComponentConfigService service = get(ComponentConfigService.class);
ObjectNode root = mapper().createObjectNode();
encodeConfigs(component, attribute, nullIsNotFound(service.getProperty(component, attribute), (service.getProperties(component) == null) ? "No such component" : (service.getProperty(component, attribute) == null) ? ("No such attribute in " + component) : "No such attribute and component"), root);
return ok(root).build();
}
use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.
the class ComponentConfigWebResource method unsetConfigs.
/**
* Selectively clears configuration properties.
* Clears only the properties present in the JSON request.
*
* @param component component name
* @param request JSON configuration
* @return 204 NO CONTENT
* @throws IOException to signify bad request
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("{component}")
public Response unsetConfigs(@PathParam("component") String component, InputStream request) throws IOException {
ComponentConfigService service = get(ComponentConfigService.class);
ObjectNode props = readTreeFromStream(mapper(), request);
props.fieldNames().forEachRemaining(k -> service.unsetProperty(component, k));
return Response.noContent().build();
}
Aggregations