Exemple #1
0
def resource_acl_patch(context, data_dict):
    '''Patch the resource acl

    :param id: the id of the resource acl
    :param auth_type: user, org
    :param auth_id: the id of user or organization
    :param permission: none, read
    '''
    reference = get_or_bust(data_dict, 'id')
    acl = ResourceAcl.get(reference)

    if not acl:
        raise NotFound('acl <{id}> was not found.'.format(id=reference))

    data_dict['resource_id'] = acl.resource_id

    check_access('resource_acl_patch', context, data_dict)

    data, errors = validate(data_dict, resource_acl_patch_schema(), context)

    if errors:
        raise ValidationError(errors)

    acl.auth_type = data.get('auth_type', acl.auth_type)
    acl.auth_id = data.get('auth_id', acl.auth_id)
    acl.permission = data.get('permission', acl.permission)
    acl.last_modified = datetime.datetime.utcnow()
    acl.modifier_user_id = context.get('user')

    acl.commit()

    return acl.as_dict()
Exemple #2
0
def resource_acl_show(context, data_dict):
    '''Return the information of the resource acl

    :param id: the id of the resource acl
    '''
    reference = get_or_bust(data_dict, 'id')
    acl = ResourceAcl.get(reference)

    if not acl:
        raise NotFound('acl <{id}> was not found.'.format(id=reference))

    data_dict['resource_id'] = acl.resource_id
    check_access('resource_acl_show', context, data_dict)

    return acl.as_dict()
Exemple #3
0
def resource_acl_delete(context, data_dict):
    '''Delete the resource acl from the list of resource acls

    :param id: the id of the resource acl
    '''
    reference = get_or_bust(data_dict, 'id')
    acl = ResourceAcl.get(reference)

    if not acl:
        raise NotFound('acl <{id}> was not found.'.format(id=reference))

    data_dict['resource_id'] = acl.resource_id

    check_access('resource_acl_delete', context, data_dict)

    acl.delete()
    acl.commit()