'Update a backup.'

@wsgi.Controller.api_version(BACKUP_UPDATE_MICRO_VERSION)
def update(self, req, id, body):

    context = req.environ['cinder.context']
    self.assert_valid_body(body, 'backup')
    req_version = req.api_version_request
    backup_update = body['backup']
    self.validate_name_and_description(backup_update)
    update_dict = {}
    if ('name' in backup_update):
        update_dict['display_name'] = backup_update.pop('name')
    if ('description' in backup_update):
        update_dict['display_description'] = backup_update.pop('description')
    if (req_version.matches('3.43') and ('metadata' in backup_update)):
        update_dict['metadata'] = backup_update.pop('metadata')
    if backup_update:
        msg = (_('Unsupported    fields    %s.') % ',    '.join(backup_update))
        raise exc.HTTPBadRequest(explanation=msg)
    new_backup = self.backup_api.update(context, id, update_dict)
    return self._view_builder.summary(req, new_backup)
