use of org.onosproject.yang.model.YangModel in project onos by opennetworkinglab.
the class YangWebResource method getModules.
/**
* Returns all modules registered with YANG runtime under given model
* identifier.If the operation is successful, the JSON presentation of the
* resource plus HTTP status code "200 OK" is returned. Otherwise,
* HTTP error status code "400 Bad Request" is returned.
*
* @onos.rsModel YangModulesGet
* @param id for model
* @return HTTP response
*/
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public Response getModules(@PathParam("id") String id) {
modelRegistry = getService(YangModelRegistry.class);
ObjectNode result = mapper().createObjectNode();
YangModel model = modelRegistry.getModel(id);
if (model == null) {
return Response.status(NOT_FOUND).build();
}
Set<YangModule> modules = model.getYangModules();
ArrayNode ids = result.putArray(id);
for (YangModule m : modules) {
ids.add(m.getYangModuleId().moduleName() + "@" + m.getYangModuleId().revision());
}
return Response.ok(result).build();
}
use of org.onosproject.yang.model.YangModel in project onos by opennetworkinglab.
the class YangModelsListCommand method json.
// Produces JSON structure.
private JsonNode json(YangModelRegistry service) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode result = mapper.createObjectNode();
for (YangModel model : service.getModels()) {
ArrayNode modelNode = mapper.createArrayNode();
result.set(model.getYangModelId(), modelNode);
for (YangModule module : model.getYangModules()) {
ObjectNode moduleNode = mapper.createObjectNode();
modelNode.add(moduleNode);
moduleNode.put(MODULE_NAME, module.getYangModuleId().moduleName());
moduleNode.put(MODULE_REVISION, module.getYangModuleId().revision());
}
}
return result;
}
use of org.onosproject.yang.model.YangModel in project onos by opennetworkinglab.
the class YangWebResource method getModels.
/**
* Returns all models registered with YANG runtime. If the operation is
* successful, the JSON presentation of the resource plus HTTP status
* code "200 OK" is returned.Otherwise,
* HTTP error status code "400 Bad Request" is returned.
*
* @onos.rsModel YangModelsGet
* @return HTTP response
*/
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getModels() {
modelRegistry = getService(YangModelRegistry.class);
ObjectNode result = mapper().createObjectNode();
Set<YangModel> models = modelRegistry.getModels();
ArrayNode ids = result.putArray("model_ids");
for (YangModel m : models) {
ids.add(m.getYangModelId());
}
return Response.ok(result.toString()).build();
}
Aggregations