1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from flask import request
12 from flask_restful import Resource
14 from api.utils import common as common_utils
15 from api.actions import test as test_action
16 from api.actions import result as result_action
17 from api.actions import env as env_action
19 logger = logging.getLogger(__name__)
22 class Release(Resource):
24 action = common_utils.translate_to_str(request.json.get('action', ''))
25 args = common_utils.translate_to_str(request.json.get('args', {}))
26 logger.debug('Input args is: action: %s, args: %s', action, args)
29 return getattr(test_action, action)(args)
30 except AttributeError:
31 return common_utils.error_handler('Wrong action')
34 class Results(Resource):
36 args = common_utils.translate_to_str(request.args)
37 action = args.get('action', '')
38 logger.debug('Input args is: action: %s, args: %s', action, args)
41 return getattr(result_action, action)(args)
42 except AttributeError:
43 return common_utils.error_handler('Wrong action')
48 action = common_utils.translate_to_str(request.json.get('action', ''))
49 args = common_utils.translate_to_str(request.json.get('args', {}))
50 logger.debug('Input args is: action: %s, args: %s', action, args)
53 return getattr(env_action, action)(args)
54 except AttributeError:
55 return common_utils.error_handler('Wrong action')