Example #1
0
 def create_job(self, data):
     """
     Create/update a job
     """
     job = DkronJob.from_dict(data, self)
     self.save_job(job)
     return job
Example #2
0
 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)
Example #3
0
    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)
Example #4
0
 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]