def on_put(self, req, resp, owner, operation_name): try: #Check owner validity #Check operation validity oper = Operation(owner, operation_name) operation_id, status, operation_name, owner = oper.create() except IOError: raise falcon.HTTPNotFound() resp.status = falcon.HTTP_201 resp.body = '{"operation_id":' + operation_id + ', "status":' + status.name + \ ', "operation":' + operation_name + ', "owner":' + owner +'}'
def on_get(self, req, resp): try: #Check operation id validity oper = Operation('owner', 'consolidate') opid = req.get_param('id', True) print(opid) operation_id, status, operation_name, owner = oper.get(opid) except Exception as ex: print(ex) description = ('Aliens have attacked our base! We will ' 'be back as soon as we fight them off. ' 'We appreciate your patience.') raise falcon.HTTPServiceUnavailable( 'Service Outage', description, 30) resp.status = falcon.HTTP_200 resp.body = '{"operation_id":' + operation_id + ', "status":' + status.name + \ ', "operation":' + operation_name + ', "owner":' + owner +'}'