use of org.onosproject.inbandtelemetry.api.IntService in project onos by opennetworkinglab.
the class IntWebResource method getIntents.
/**
* Gets all IntIntents. Returns array of all IntIntents in the system.
* @return 200 OK with a collection of IntIntents
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getIntents() {
ArrayNode intsNode = root.putArray(INTS);
IntService service = get(IntService.class);
Map<IntIntentId, IntIntent> intIntents = service.getIntIntents();
if (!intIntents.isEmpty()) {
intIntents.entrySet().forEach(intIntentEntry -> {
intsNode.add(codec(IntIntent.class).encode(intIntentEntry.getValue(), this).put(ID, intIntentEntry.getKey().id()));
});
}
return ok(root).build();
}
use of org.onosproject.inbandtelemetry.api.IntService in project onos by opennetworkinglab.
the class IntWebResource method deleteIntent.
/**
* Removes the specified IntIntent.
*
* @param id InIntentId
* @return 204 NO CONTENT
*/
@DELETE
@Path("{id}")
public Response deleteIntent(@PathParam("id") String id) {
IntService service = get(IntService.class);
service.removeIntIntent(IntIntentId.valueOf(Long.parseLong(id)));
return Response.noContent().build();
}
use of org.onosproject.inbandtelemetry.api.IntService in project onos by opennetworkinglab.
the class IntWebResource method getIntent.
/**
* Get an IntIntent. Returns an IntIntent in the system.
* @param id IntIntentId
* @return 200 OK with a IntIntent
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
public Response getIntent(@PathParam("id") String id) {
ArrayNode intsNode = root.putArray(INT);
IntService service = get(IntService.class);
final IntIntent intIntent = nullIsNotFound(service.getIntIntent(IntIntentId.valueOf(Long.parseLong(id))), INT_NOT_FOUND + id);
intsNode.add(codec(IntIntent.class).encode(intIntent, this));
return ok(root).build();
}
use of org.onosproject.inbandtelemetry.api.IntService in project onos by opennetworkinglab.
the class IntWebResource method createIntent.
/**
* Creates new IntIntent. Creates and installs a new IntIntent.
*
* @param stream IntIntent JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel Int
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createIntent(InputStream stream) {
IntService service = get(IntService.class);
try {
ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
IntIntent intIntent = codec(IntIntent.class).decode(jsonTree, this);
IntIntentId intIntentId = service.installIntIntent(intIntent);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder().path(INT).path(Long.toString(intIntentId.id()));
return Response.created(locationBuilder.build()).build();
} catch (IOException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
Aggregations