def create_job(self, data): """ Create/update a job """ job = DkronJob.from_dict(data, self) self.save_job(job) return job
def get_job(self, name): """ Return a job by name """ resp = self._call(_GET, "/jobs/%s" % name) if resp.status_code == 404: raise DkronJobNotFound("Job %s was not found" % name) return DkronJob.from_dict(resp.json(), self)
def toggle(self, name): ''' Enable/disable a job Arguments: name {string} -- the name of job Raises: DkronJobNotFound -- raise if the job not exists Returns: DkronJob -- a job of Dkron ''' resp = self._call(_POST, "/jobs/%s/toggle" % name) if resp.status_code == 404: raise DkronJobNotFound("Job %s was not found" % name) return DkronJob.from_dict(resp.json(), self)
def jobs(self): """ Returns a list of jobs """ data = self._call(_GET, "/jobs").json() return [DkronJob.from_dict(job_data, self) for job_data in data]