#NEWLINE# @ require_json #NEWLINE# @ require_POST #NEWLINE# @ require_api_key #NEWLINE# def update_build_status( request , repository_name , build_number ) : #NEWLINE# #INDENT# '\n    Update a build status. Useful when another\n    separate micro-service runs the builds.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# status = request . json [ 'status' ] #NEWLINE# #UNINDENT# except ( TypeError , KeyError ) : #NEWLINE# #INDENT# return JsonResponse ( { #NEWLINE# #INDENT# 'error' : 'Missing status field.' , #NEWLINE# #UNINDENT# } , status = 400 ) #NEWLINE# #UNINDENT# build = get_object_or_404 ( Build , repository__name = repository_name , number = build_number ) #NEWLINE# try : #NEWLINE# #INDENT# build . update_status ( status ) #NEWLINE# #UNINDENT# except InvalidStatus as error : #NEWLINE# #INDENT# return JsonResponse ( { #NEWLINE# #INDENT# 'error' : str ( error ) , #NEWLINE# #UNINDENT# } , status = 400 ) #NEWLINE# #UNINDENT# except MissingToken : #NEWLINE# #INDENT# return JsonResponse ( { #NEWLINE# #INDENT# 'error' : 'No token.' , #NEWLINE# #UNINDENT# } , status = 400 ) #NEWLINE# #UNINDENT# return JsonResponse ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } )