1 from tornado import gen
2 from tornado.web import asynchronous
4 from tornado_swagger_ui.tornado_swagger import swagger
5 from handlers import GenericApiHandler
6 from pod_models import Pod
9 class GenericPodHandler(GenericApiHandler):
10 def __init__(self, application, request, **kwargs):
11 super(GenericPodHandler, self).__init__(application, request, **kwargs)
16 class PodCLHandler(GenericPodHandler):
17 @swagger.operation(nickname='list-all')
20 @description: list all pods
21 @return 200: list all pods, empty list is no pod exist
27 @swagger.operation(nickname='create')
30 @description: create a pod
31 @param body: pod to be created
32 @type body: L{PodCreateRequest}
35 @return 200: pod is created.
36 @raise 403: pod already exists
37 @raise 400: post without body
39 self._create('{} already exists as a {}')
42 class PodGURHandler(GenericPodHandler):
43 @swagger.operation(nickname='get-one')
44 def get(self, pod_name):
46 @description: get a single pod by pod_name
48 @return 200: pod exist
49 @raise 404: pod not exist
52 query['name'] = pod_name
57 def delete(self, pod_name):
60 # check for an existing pod to be deleted
61 mongo_dict = yield self.db.pods.find_one(
63 pod = TestProject.pod(mongo_dict)
65 raise HTTPError(HTTP_NOT_FOUND,
66 "{} could not be found as a pod to be deleted"
69 # just delete it, or maybe save it elsewhere in a future
70 res = yield self.db.projects.remove(
73 self.finish_request(answer)