blob: a4ea96079e95184b216f751e8348f1a46f8564fc [file] [log] [blame]
HIGUCHI Yuta60a10142013-06-14 15:50:10 -07001package net.onrc.onos.ofcontroller.flowmanager.web;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08002
3import java.util.ArrayList;
4
HIGUCHI Yuta60a10142013-06-14 15:50:10 -07005import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07006import net.onrc.onos.ofcontroller.util.FlowPath;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -08007
8import org.restlet.resource.Get;
9import org.restlet.resource.ServerResource;
10import org.slf4j.Logger;
11import org.slf4j.LoggerFactory;
12
admin944ef4f2013-10-08 17:48:37 -070013/**
HIGUCHI Yutaeb567aa2013-10-08 19:27:35 -070014 * Flow Manager REST API implementation: Get all Flow state.
admin944ef4f2013-10-08 17:48:37 -070015 *
16 * GET /wm/flow/getall/json"
17 */
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080018public class GetAllFlowsResource extends ServerResource {
Yuta HIGUCHI6ac8d182013-10-22 15:24:56 -070019 protected final static Logger log = LoggerFactory.getLogger(GetAllFlowsResource.class);
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080020
admin944ef4f2013-10-08 17:48:37 -070021 /**
22 * Implement the API.
23 *
24 * @return the collection of Flow states if any found, otherwise null.
25 */
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080026 @Get("json")
27 public ArrayList<FlowPath> retrieve() {
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080028 ArrayList<FlowPath> result = null;
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080029
30 IFlowService flowService =
31 (IFlowService)getContext().getAttributes().
32 get(IFlowService.class.getCanonicalName());
33
34 if (flowService == null) {
35 log.debug("ONOS Flow Service not found");
36 return result;
37 }
38
39 // Extract the arguments
40 log.debug("Get All Flows Endpoints");
41
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080042 result = flowService.getAllFlows();
Pavlin Radoslavov5ab68512013-02-18 09:59:33 -080043
44 return result;
45 }
46}