summaryrefslogtreecommitdiffstats
path: root/qtip/api/controllers/plan.py
blob: 93836a32acca54e4c9a597eba9d32f00c94c7839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
##############################################################################
# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

import httplib

import connexion

from qtip.base import error
from qtip.loader import plan


def list_plans():
    plan_list = list(plan.Plan.list_all())
    return plan_list, httplib.OK


def get_plan(name):
    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"):
    return connexion.problem(httplib.NOT_IMPLEMENTED,
                             'Run a plan',
                             'Plan runner not implemented')