def put(volume_id):
"""Edits a volume dict based on the given representation.
Expects to receive a json payload with a complete new version of the volume to be edited
Args:
volume_id (str): The id parsed from the URL
Returns:
tuple: payload, http status code, headers
"""
manager = app.volume_manager
volume = manager.by_id(volume_id)
if volume is None:
return {'message': 'Not Found'}, 404
if volume.value['state'] != 'ready':
return {'message': 'Resource not in ready state, can\'t update.'}, 409
new_volume, errors = VolumeAttributeSchema().load(request.get_json(force=True))
if errors:
return {'message': errors}, 400
if volume.value['requested'] == new_volume:
return '', 304
volume.value['requested'] = new_volume
volume.value['state'] = 'pending'
volume = manager.update(volume)
if not volume:
return {'message': 'Resource changed during transition.'}, 409
result, _ = VolumeSchema().dump(volume)
return result, 202, {'Location': app.api.url_for(Volume, volume_id=result['id'])}
评论列表
文章目录