def post(self, batch_id): """ Executes batch with identifier *batch_id* ** Request ** .. sourcecode:: http POST /batch/:batch_id ** Response ** .. sourcecode:: http HTTP/1.1 202 ACCEPTED :param batch_id: batch's unique id :type batch_id: string :status 202: Successfully executed :status 400: Batch could not be executed :status 404: No such batch :status 409: Trying to reexecute an already executed batch """ log.debug('Routing to batch {} (POST)'.format(batch_id)) try: batch = SimpleBatch(batch_id) except: log.debug('Batch {} not found'.format(batch_id)) return {'message': 'Batch Not Found: {}'.format(batch_id)}, 404 if batch.get_state() == 'NONE': try: batch.run() return { 'id': batch_id, 'url': url_for('api.batch', batch_id=batch_id) }, 202 except: log.debug('Batch {} could not be executed'.format(batch_id), exc_info=True) return {'message': 'Batch could not be executed'}, 400 else: log.debug('Batch {} already executed'.format(batch_id)) return {'message': 'Batch already executed'}, 409
def post(self, batch_id): """ Executes batch with identifier *batch_id* ** Request ** .. sourcecode:: http POST /batch/:batch_id ** Response ** .. sourcecode:: http HTTP/1.1 202 ACCEPTED :param batch_id: batch's unique id :type batch_id: string :status 202: Successfully executed :status 400: Batch could not be executed :status 404: No such batch :status 409: Trying to reexecute an already executed batch """ log.debug('Routing to batch {} (POST)'.format(batch_id)) try: batch = SimpleBatch(batch_id) except: log.debug('Batch {} not found'.format(batch_id)) return {'message': 'Batch Not Found: {}'.format(batch_id)}, 404 if batch.get_state() == 'NONE': try: batch.run() return {'id': batch_id, 'url': url_for('api.batch', batch_id=batch_id)}, 202 except: log.debug('Batch {} could not be executed'.format(batch_id), exc_info=True) return {'message': 'Batch could not be executed'}, 400 else: log.debug('Batch {} already executed'.format(batch_id)) return {'message': 'Batch already executed'}, 409