mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
Endpoint and dao method for updating job status.
This commit is contained in:
@@ -8,6 +8,7 @@ from flask import (
|
||||
current_app
|
||||
)
|
||||
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy.exc import DataError
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
@@ -19,7 +20,8 @@ from app.dao.jobs_dao import (
|
||||
|
||||
from app.schemas import (
|
||||
job_schema,
|
||||
jobs_schema
|
||||
jobs_schema,
|
||||
job_schema_load_json
|
||||
)
|
||||
|
||||
job = Blueprint('job', __name__, url_prefix='/service/<service_id>/job')
|
||||
@@ -56,6 +58,19 @@ def create_job(service_id):
|
||||
return jsonify(data=job_schema.dump(job).data), 201
|
||||
|
||||
|
||||
@job.route('/<job_id>', methods=['PUT'])
|
||||
def update_job(service_id, job_id):
|
||||
job = get_job(service_id, job_id)
|
||||
update_dict, errors = job_schema_load_json.load(request.get_json())
|
||||
if errors:
|
||||
return jsonify(result="error", message=errors), 400
|
||||
try:
|
||||
save_job(job, update_dict=update_dict)
|
||||
except Exception as e:
|
||||
return jsonify(result="error", message=str(e)), 400
|
||||
return jsonify(data=job_schema.dump(job).data), 200
|
||||
|
||||
|
||||
def _enqueue_job(job):
|
||||
aws_region = current_app.config['AWS_REGION']
|
||||
queue_name = current_app.config['NOTIFY_JOB_QUEUE']
|
||||
|
||||
Reference in New Issue
Block a user