def update_job(self, user_id, job_id, patch_doc): valid_patch = JobDoc.create_patch(patch_doc) # check that document exists assert (self.job_manager.get(user_id, job_id)) version = self.job_manager.update(job_id, valid_patch) logging.info(_i18n._LI('Job %(id)s updated to version %(version)s') % {'id': job_id, 'version': version}) return version
def replace_job(self, user_id, job_id, doc): # check that no document exists with # same job_id and different user_id try: self.job_manager.get(user_id, job_id) except freezer_api_exc.DocumentNotFound: pass valid_doc = JobDoc.update(doc, user_id, job_id) (created, version) = self.job_manager.insert(valid_doc, job_id) if created: logging.info(_i18n._LI('Job %s created') % job_id) else: logging.info(_i18n._LI('Job %(id)s replaced with version %(version)s' % {'id': job_id, 'version': version})) return version
def add_job(self, user_id, doc): jobdoc = JobDoc.create(doc, user_id) job_id = jobdoc['job_id'] self.job_manager.insert(jobdoc, job_id) logging.info(_i18n._LI('Job registered, job id: %s') % job_id) return job_id