blob: f54463ea868298e849c56c0643200e77fce35e9f [file] [log] [blame]
Pavlin Radoslavov13669052014-05-13 10:33:39 -07001package net.onrc.onos.core.intent.runtime.web;
2
Pavlin Radoslavovc097fdf2014-05-23 17:40:57 -07003import java.util.Collection;
4
Pavlin Radoslavov13669052014-05-13 10:33:39 -07005import net.onrc.onos.core.intent.Intent;
6import net.onrc.onos.core.intent.IntentMap;
7import net.onrc.onos.core.intent.runtime.IPathCalcRuntimeService;
Pavlin Radoslavovc097fdf2014-05-23 17:40:57 -07008
Ray Milkey3aeda4f2014-05-21 14:38:58 -07009import org.restlet.representation.Representation;
Pavlin Radoslavov13669052014-05-13 10:33:39 -070010import org.restlet.resource.Get;
11import org.restlet.resource.ServerResource;
Ray Milkey3aeda4f2014-05-21 14:38:58 -070012
Pavlin Radoslavov13669052014-05-13 10:33:39 -070013/**
14 * A class to access the low-level intents.
15 */
16public class IntentLowResource extends ServerResource {
Pavlin Radoslavov13669052014-05-13 10:33:39 -070017 /**
18 * Gets all low-level intents.
19 *
Pavlin Radoslavove2238bc2014-06-09 18:05:23 -070020 * @return a Representation of a collection of all low-level intents.
Pavlin Radoslavov13669052014-05-13 10:33:39 -070021 */
22 @Get("json")
Ray Milkey3aeda4f2014-05-21 14:38:58 -070023 public Representation retrieve() {
Pavlin Radoslavovc097fdf2014-05-23 17:40:57 -070024 IPathCalcRuntimeService pathRuntime =
25 (IPathCalcRuntimeService) getContext().getAttributes()
26 .get(IPathCalcRuntimeService.class.getCanonicalName());
Pavlin Radoslavov13669052014-05-13 10:33:39 -070027
28 //
29 // Get all low-level intents
30 //
31 IntentMap intentMap = pathRuntime.getPathIntents();
32 Collection<Intent> intents = intentMap.getAllIntents();
33
Ray Milkey3aeda4f2014-05-21 14:38:58 -070034 return toRepresentation(intents, null);
Pavlin Radoslavov13669052014-05-13 10:33:39 -070035 }
36}