Skip to content

Commit

Permalink
Bug 1437938 - Remove unused /jobs/update_state/ API (#3221)
Browse files Browse the repository at this point in the history
The remaining REST API job submitters are using `JobsViewSet.create`
to transition jobs from one state to the next instead.
  • Loading branch information
edmorley committed Feb 13, 2018
1 parent b521523 commit 2eac7bc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
3 changes: 0 additions & 3 deletions treeherder/model/models.py
Expand Up @@ -423,9 +423,6 @@ class Job(models.Model):
"""
This class represents a build or test job in Treeherder
"""
INCOMPLETE_STATES = ["running", "pending"]
STATES = INCOMPLETE_STATES + ["completed"]

objects = JobManager()

id = models.BigAutoField(primary_key=True)
Expand Down
30 changes: 0 additions & 30 deletions treeherder/webapp/api/jobs.py
Expand Up @@ -326,36 +326,6 @@ def list(self, request, project):

return Response(response_body)

@detail_route(methods=['post'])
def update_state(self, request, project, pk=None):
"""
Change the state of a job.
"""
state = request.data.get('state', None)

# check that this state is valid
if state not in Job.STATES:
return Response(
{"message": ("'{0}' is not a valid state. Must be "
"one of: {1}".format(
state,
", ".join(Job.STATES)
))},
status=HTTP_400_BAD_REQUEST,
)

if not pk: # pragma nocover
return Response({"message": "job id required"}, status=HTTP_400_BAD_REQUEST)

try:
job = Job.objects.get(repository__name=project,
id=pk)
job.state = state
job.save()
except ObjectDoesNotExist:
return Response("No job with id: {0}".format(pk), status=HTTP_404_NOT_FOUND)
return Response({"message": "state updated to '{0}'".format(state)})

@list_route(methods=['post'], permission_classes=[IsAuthenticated])
def cancel(self, request, project):
try:
Expand Down

0 comments on commit 2eac7bc

Please sign in to comment.