Merge pull request #922 from alphagov/cancelled-jobs

Let users cancel a job
This commit is contained in:
Chris Hill-Scott
2016-09-06 17:12:19 +01:00
committed by GitHub
7 changed files with 109 additions and 4 deletions

View File

@@ -78,3 +78,18 @@ class JobApiClient(BaseAPIClient):
job['data']['notifications_requested'] = stats['requested']
return job
def cancel_job(self, service_id, job_id):
job = self.post(
url='/service/{}/job/{}/cancel'.format(service_id, job_id),
data={}
)
stats = self.__convert_statistics(job['data'])
job['data']['notifications_sent'] = stats['delivered'] + stats['failed']
job['data']['notifications_delivered'] = stats['delivered']
job['data']['notifications_failed'] = stats['failed']
job['data']['notifications_requested'] = stats['requested']
return job