summaryrefslogtreecommitdiffstats
path: root/result_collection_api/resources/pod_handlers.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-05-26 20:32:02 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-05-26 20:40:13 +0800
commit07b1553b8f00933d7d0f057ac1558a4f7d80245e (patch)
treeb2d160394f074c7cf0caf96c0388d5343cd90f6b /result_collection_api/resources/pod_handlers.py
parent533e640ee68b1d5839f3b5385caf9b773083a6a0 (diff)
swagger-ize project-apis of testAPI
rename pod_handler.py to pod_handlers.py JIRA: FUNCTEST-264 Change-Id: I8699999776bdb238f680a128b83cea0a098534c5 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'result_collection_api/resources/pod_handlers.py')
-rw-r--r--result_collection_api/resources/pod_handlers.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/result_collection_api/resources/pod_handlers.py b/result_collection_api/resources/pod_handlers.py
new file mode 100644
index 0000000..590ae5b
--- /dev/null
+++ b/result_collection_api/resources/pod_handlers.py
@@ -0,0 +1,75 @@
+from tornado import gen
+from tornado.web import asynchronous
+
+from tornado_swagger_ui.tornado_swagger import swagger
+from handlers import GenericApiHandler
+from pod_models import Pod
+
+
+class GenericPodHandler(GenericApiHandler):
+ def __init__(self, application, request, **kwargs):
+ super(GenericPodHandler, self).__init__(application, request, **kwargs)
+ self.table = 'pods'
+ self.table_cls = Pod
+
+
+class PodCLHandler(GenericPodHandler):
+ @swagger.operation(nickname='list-all')
+ def get(self):
+ """
+ @description: list all pods
+ @return 200: list all pods, empty list is no pod exist
+ @rtype: L{Pods}
+ """
+ self._list()
+
+ @gen.coroutine
+ @swagger.operation(nickname='create')
+ def post(self):
+ """
+ @description: create a pod
+ @param body: pod to be created
+ @type body: L{PodCreateRequest}
+ @in body: body
+ @rtype: L{Pod}
+ @return 200: pod is created.
+ @raise 403: pod already exists
+ @raise 400: post without body
+ """
+ self._create('{} already exists as a {}')
+
+
+class PodGURHandler(GenericPodHandler):
+ @swagger.operation(nickname='get-one')
+ def get(self, pod_name):
+ """
+ @description: get a single pod by pod_name
+ @rtype: L{Pod}
+ @return 200: pod exist
+ @raise 404: pod not exist
+ """
+ query = dict()
+ query['name'] = pod_name
+ self._get_one(query)
+
+ @asynchronous
+ @gen.coroutine
+ def delete(self, pod_name):
+ """ Remove a POD
+
+ # check for an existing pod to be deleted
+ mongo_dict = yield self.db.pods.find_one(
+ {'name': pod_name})
+ pod = TestProject.pod(mongo_dict)
+ if pod is None:
+ raise HTTPError(HTTP_NOT_FOUND,
+ "{} could not be found as a pod to be deleted"
+ .format(pod_name))
+
+ # just delete it, or maybe save it elsewhere in a future
+ res = yield self.db.projects.remove(
+ {'name': pod_name})
+
+ self.finish_request(answer)
+ """
+ pass