(privs_for_grantees, dry_run=False, verbose=False)
Removes existing grants between grantee roles and privilege roles, looked up by slug.
    :param privs_for_grantees: An iterable of tuples: `(grantee_slug, [priv_slugs])`
    :param dry_run: if True, will not make any changes to the DB
    :param verbose: if True, will log additional output
Removes existing grants between grantee roles and privilege roles, looked up by slug.
    :param privs_for_grantees: An iterable of tuples: `(grantee_slug, [priv_slugs])`
    :param dry_run: if True, will not make any changes to the DB
    :param verbose: if True, will log additional output
Removes existing grants between grantee roles and privilege roles looked up by slug . : param privs_for_grantees : An iterable of tuples : ( grantee_slug [ priv_slugs ] ) : param dry_run : if True will not make any changes to the DB : param verbose : if True will log additional output
def revoke_privs_for_grantees(privs_for_grantees, dry_run=False, verbose=False):
    """
    Removes existing grants between grantee roles and privilege roles, looked up by slug.
    :param privs_for_grantees: An iterable of tuples: `(grantee_slug, [priv_slugs])`
    :param dry_run: if True, will not make any changes to the DB
    :param verbose: if True, will log additional output
    """
    dry_run_tag = "[DRY RUN] " if dry_run else ""
    roles_by_slug = get_all_roles_by_slug()

    grants_to_delete = []
    for grantee_slug, priv_slugs in privs_for_grantees:
        if grantee_slug not in roles_by_slug:
            logger.info(f'grantee {grantee_slug} does not exist.')
            continue

        for priv_slug in priv_slugs:
            if priv_slug not in roles_by_slug:
                logger.info(f'privilege {priv_slug} does not exist.')
                continue

            existing_grants = get_grants(roles_by_slug[grantee_slug], roles_by_slug[priv_slug])
            if existing_grants:
                if verbose or dry_run:
                    logger.info(f'{dry_run_tag}Revoking privilege: {grantee_slug} => {priv_slug}')
                if not dry_run:
                    grants_to_delete.extend(existing_grants)
            else:
                if verbose or dry_run:
                    logger.info(f'{dry_run_tag}Privilege already revoked: {grantee_slug} => {priv_slug}')

    if grants_to_delete:
        delete_grants(grants_to_delete)
def revoke_privs_for_grantees ( privs_for_grantees , dry_run = False , verbose = False ) : dry_run_tag = "[DRY RUN] " if dry_run else "" roles_by_slug = get_all_roles_by_slug ( ) grants_to_delete = [ ] for grantee_slug , priv_slugs in privs_for_grantees : if grantee_slug not in roles_by_slug : logger . info ( f'grantee {grantee_slug} does not exist.' ) continue for priv_slug in priv_slugs : if priv_slug not in roles_by_slug : logger . info ( f'privilege {priv_slug} does not exist.' ) continue existing_grants = get_grants ( roles_by_slug [ grantee_slug ] , roles_by_slug [ priv_slug ] ) if existing_grants : if verbose or dry_run : logger . info ( f'{dry_run_tag}Revoking privilege: {grantee_slug} => {priv_slug}' ) if not dry_run : grants_to_delete . extend ( existing_grants ) else : if verbose or dry_run : logger . info ( f'{dry_run_tag}Privilege already revoked: {grantee_slug} => {priv_slug}' ) if grants_to_delete : delete_grants ( grants_to_delete )