'Verifies required attributes are in request body.
Also checking that an attribute is only specified if it is allowed
for the given operation (create/update).
Attribute with default values are considered to be optional.
body argument must be the deserialized body.'

@staticmethod
def prepare_request_body(context, body, is_create, resource, attr_info, allow_bulk=False):

    collection = (resource + 's')
    if (not body):
        raise webob.exc.HTTPBadRequest(_('Resource    body    required'))
    LOG.debug('Request    body:    %(body)s', {'body': body})
    try:
        if (collection in body):
            if (not allow_bulk):
                raise webob.exc.HTTPBadRequest(_('Bulk    operation    not    supported'))
            if (not body[collection]):
                raise webob.exc.HTTPBadRequest(_('Resources    required'))
            bulk_body = [Controller.prepare_request_body(context, (item if (resource in item) else {resource: item}), is_create, resource, attr_info, allow_bulk) for item in body[collection]]
            return {collection: bulk_body}
        res_dict = body.get(resource)
    except (AttributeError, TypeError):
        msg = _('Body    contains    invalid    data')
        raise webob.exc.HTTPBadRequest(msg)
    if (res_dict is None):
        msg = (_("Unable    to    find    '%s'    in    request    body") % resource)
        raise webob.exc.HTTPBadRequest(msg)
    attr_ops = attributes.AttributeInfo(attr_info)
    attr_ops.populate_project_id(context, res_dict, is_create)
    attributes.populate_project_info(attr_info)
    attr_ops.verify_attributes(res_dict)
    if is_create:
        attr_ops.fill_post_defaults(res_dict, exc_cls=webob.exc.HTTPBadRequest)
    else:
        for (attr, attr_vals) in attr_info.items():
            if ((attr in res_dict) and (not attr_vals['allow_put'])):
                msg = (_('Cannot    update    read-only    attribute    %s') % attr)
                raise webob.exc.HTTPBadRequest(msg)
    attr_ops.convert_values(res_dict, exc_cls=webob.exc.HTTPBadRequest)
    return body
