use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class NextObjectiveCodecTest method testNextObjectiveDecode.
/**
* Test decoding of a NextObjective object.
*/
@Test
public void testNextObjectiveDecode() throws IOException {
ApplicationId appId = new DefaultApplicationId(0, SAMPLE_APP_ID);
expect(mockCoreService.registerApplication(SAMPLE_APP_ID)).andReturn(appId).anyTimes();
replay(mockCoreService);
NextObjective nextObjective = getNextObjective("NextObjective.json");
assertThat(nextObjective.type(), is(NextObjective.Type.FAILOVER));
assertThat(nextObjective.op(), is(NextObjective.Operation.ADD));
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class FlowsWebResource method getFlowByAppId.
/**
* Gets flow rules generated by an application.
* Returns the flow rule specified by the application id.
*
* @param appId application identifier
* @return 200 OK with a collection of flows of given application id
* @onos.rsModel FlowRules
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("application/{appId}")
public Response getFlowByAppId(@PathParam("appId") String appId) {
ObjectNode root = mapper().createObjectNode();
ArrayNode flowsNode = root.putArray(FLOWS);
ApplicationService appService = get(ApplicationService.class);
ApplicationId idInstant = nullIsNotFound(appService.getId(appId), APP_ID_NOT_FOUND);
Iterable<FlowEntry> flowEntries = get(FlowRuleService.class).getFlowEntriesById(idInstant);
flowEntries.forEach(flow -> flowsNode.add(codec(FlowEntry.class).encode(flow, this)));
return ok(root).build();
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class FlowsWebResource method removeFlowByAppId.
/**
* Removes flow rules by application ID.
* Removes a collection of flow rules generated by the given application.
*
* @param appId application identifier
* @return 204 NO CONTENT
*/
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("application/{appId}")
public Response removeFlowByAppId(@PathParam("appId") String appId) {
FlowRuleService service = get(FlowRuleService.class);
ApplicationService appService = get(ApplicationService.class);
ApplicationId idInstant = nullIsNotFound(appService.getId(appId), APP_ID_NOT_FOUND);
service.removeFlowRulesById(idInstant);
return Response.noContent().build();
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class IntentsWebResource method getIntentsByAppId.
/**
* Gets intents by application.
* Returns the intents specified by the application id.
* @param detail flag to return full details of intents in list.
*
* @param appId application identifier
* @return 200 OK with a collection of intents of given application id
* @onos.rsModel Intents
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("application/{appId}")
public Response getIntentsByAppId(@PathParam("appId") String appId, @QueryParam("detail") boolean detail) {
final ApplicationId app = get(CoreService.class).getAppId(appId);
nullIsNotFound(app, APP_ID_NOT_FOUND);
final Iterable<Intent> intents = get(IntentService.class).getIntentsByAppId(app);
ObjectNode root = null;
if (detail) {
root = mapper().createObjectNode();
ArrayNode intentsNode = root.putArray(INTENTS);
intents.forEach(intent -> intentsNode.add(codec(intent).encode(intent, this)));
} else {
root = encodeArray(Intent.class, INTENTS, intents);
}
return ok(root).build();
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class IntentsWebResource method getIntentById.
/**
* Gets intent by application and key.
* Returns details of the specified intent.
*
* @param appId application identifier
* @param key intent key
* @return 200 OK with intent data
* @onos.rsModel Intents
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{appId}/{key}")
public Response getIntentById(@PathParam("appId") String appId, @PathParam("key") String key) {
final ApplicationId app = get(CoreService.class).getAppId(appId);
nullIsNotFound(app, APP_ID_NOT_FOUND);
Intent intent = get(IntentService.class).getIntent(Key.of(key, app));
if (intent == null) {
long numericalKey = Long.decode(key);
intent = get(IntentService.class).getIntent(Key.of(numericalKey, app));
}
nullIsNotFound(intent, INTENT_NOT_FOUND);
final ObjectNode root = codec(intent).encode(intent, this);
return ok(root).build();
}
Aggregations