blob: 7a15c268a80075fed787677313576eaa15342ad8 [file] [log] [blame]
Pavlin Radoslavov13669052014-05-13 10:33:39 -07001package net.onrc.onos.core.intent.runtime.web;
2
Pavlin Radoslavov13669052014-05-13 10:33:39 -07003import net.onrc.onos.core.intent.Intent;
4import net.onrc.onos.core.intent.IntentMap;
5import net.onrc.onos.core.intent.runtime.IPathCalcRuntimeService;
Ray Milkey3aeda4f2014-05-21 14:38:58 -07006import org.restlet.representation.Representation;
Pavlin Radoslavov13669052014-05-13 10:33:39 -07007import org.restlet.resource.Get;
8import org.restlet.resource.ServerResource;
9import org.slf4j.Logger;
10import org.slf4j.LoggerFactory;
11
Ray Milkey3aeda4f2014-05-21 14:38:58 -070012import java.util.Collection;
13
Pavlin Radoslavov13669052014-05-13 10:33:39 -070014/**
15 * A class to access the low-level intents.
16 */
17public class IntentLowResource extends ServerResource {
18 private static final Logger log = LoggerFactory.getLogger(IntentLowResource.class);
19
20 /**
21 * Gets all low-level intents.
22 *
Ray Milkey3aeda4f2014-05-21 14:38:58 -070023 * @return a Representation of a collection of all of the low-level intents.
Pavlin Radoslavov13669052014-05-13 10:33:39 -070024 */
25 @Get("json")
Ray Milkey3aeda4f2014-05-21 14:38:58 -070026 public Representation retrieve() {
Pavlin Radoslavov13669052014-05-13 10:33:39 -070027 IPathCalcRuntimeService pathRuntime = (IPathCalcRuntimeService) getContext().
28 getAttributes().get(IPathCalcRuntimeService.class.getCanonicalName());
29
30 //
31 // Get all low-level intents
32 //
33 IntentMap intentMap = pathRuntime.getPathIntents();
34 Collection<Intent> intents = intentMap.getAllIntents();
35
Ray Milkey3aeda4f2014-05-21 14:38:58 -070036 return toRepresentation(intents, null);
Pavlin Radoslavov13669052014-05-13 10:33:39 -070037 }
38}