aboutsummaryrefslogtreecommitdiffstats
path: root/qtip/api/controllers/plan.py
diff options
context:
space:
mode:
authorakhilbatra898 <akhil.batra@research.iiit.ac.in>2017-03-10 15:35:04 +0530
committerakhilbatra898 <akhil.batra@research.iiit.ac.in>2017-03-10 15:49:18 +0530
commit15fceada86ad0d5dabe26365451aae9c95b36be1 (patch)
treee76f22cfb9dc4b0be373fd5cabb9e73e7fdc9ac1 /qtip/api/controllers/plan.py
parentc5f64d5114be98cbe6a74c2078b22b741ae984a4 (diff)
Implement Retrieval of plans, QPIs, and metrics
- All specs can be listed - All specs can be individually retrieved - API can be installed alongside qtip - API can be hosted using command `qtip-api` JIRA: QTIP-221 JIRA: QTIP-222 Change-Id: I1e80e6609cae1252cb2fcdc38c71b4bf6d02e8c9 Signed-off-by: akhilbatra898 <akhil.batra@research.iiit.ac.in>
Diffstat (limited to 'qtip/api/controllers/plan.py')
-rw-r--r--qtip/api/controllers/plan.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/qtip/api/controllers/plan.py b/qtip/api/controllers/plan.py
index e202b413..93836a32 100644
--- a/qtip/api/controllers/plan.py
+++ b/qtip/api/controllers/plan.py
@@ -7,20 +7,29 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import connexion
import httplib
+import connexion
+
+from qtip.base import error
+from qtip.loader import plan
+
def list_plans():
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'List plans',
- 'Plans listing not implemented')
+ plan_list = list(plan.Plan.list_all())
+ return plan_list, httplib.OK
def get_plan(name):
- return connexion.problem(httplib.NOT_IMPLEMENTED,
- 'Get a plan',
- 'Plan retrieval not implemented')
+ try:
+ plan_spec = plan.Plan(name)
+ return {'name': plan_spec.name,
+ 'abspath': plan_spec.abspath,
+ 'content': plan_spec.content}, httplib.OK
+ except error.NotFoundError:
+ return connexion.problem(httplib.NOT_FOUND,
+ 'Plan Not Found',
+ 'requested plan `' + name + '` not found.')
def run_plan(name, action="run"):