Esempio n. 1
0
def make(args):
    io.start('Making user %s a member of role %s' %
             (highlight(args.user), highlight(args.role.upper())))

    group_name = _find_group(args.role)

    url = config().get('api', 'member') % group_name
    post(url, {'username': args.user, 'roleName': args.role.upper()})
def make(args):
    io.start('Making user %s a member of role %s' %
             (highlight(args.user), highlight(args.role.upper())))

    group_name = _find_group(args.role)

    url = config.api('member').format(group_name)
    post(url, {'username': args.user, 'roleName': args.role.upper()})
def add_package(args):
    io.start('Adding package %s' % highlight(args.id))

    data = {'id': args.id, 'label': args.id}

    if args.parent:
        data['parent'] = args.parent

    post(config().get('api', 'rest1') + 'sys_md_Package', data)
Esempio n. 4
0
def enable_rls(args):
    io.start('Enabling row level security on entity type %s' %
             highlight(args.entity))

    ensure_resource_exists(args.entity, ResourceType.ENTITY_TYPE)
    post(config().get('api', 'rls'),
         data={
             'id': args.entity,
             'rlsEnabled': True
         })
def enable_rls(args):
    if not io.confirm(
            'Are you sure you want to disable row level security on %s?' %
            args.entity):
        return

    io.start('Disabling row level security on entity type %s' %
             highlight(args.entity))

    ensure_resource_exists(args.entity, ResourceType.ENTITY_TYPE)
    post(config.api('rls'), data={'id': args.entity, 'rlsEnabled': False})
def add_token(args):
    io.start('Adding token %s for user %s' %
             (highlight(args.token), highlight(args.user)))

    user = get(config().get('api', 'rest2') +
               'sys_sec_User?attrs=id&q=username==%s' % args.user)
    if user.json()['total'] == 0:
        raise McmdError('Unknown user %s' % args.user)

    user_id = user.json()['items'][0]['id']

    data = {'User': user_id, 'token': args.token}

    post(config().get('api', 'rest1') + 'sys_sec_Token', data)
def add_user(args):
    io.start('Adding user %s' % highlight(args.username))

    password = args.set_password if args.set_password else args.username
    email = args.with_email if args.with_email else args.username + '@molgenis.org'
    active = not args.is_inactive
    superuser = args.is_superuser
    ch_pwd = args.change_password

    post(
        config().get('api', 'rest1') + 'sys_sec_User', {
            'username': args.username,
            'password_': password,
            'changePassword': ch_pwd,
            'Email': email,
            'active': active,
            'superuser': superuser
        })
Esempio n. 8
0
def enable_theme(args):
    """
    enable_theme enables a bootstrap theme
    :param args: commandline arguments containing the id of the theme (without .css)
    :exception McmdError: when applying the theme fails
    :return None
    """
    theme = args.theme.replace('.css', '').replace('.min', '')
    io.start('Applying theme {}'.format(highlight(theme)))
    # Resource can be bootstrap-name.min.css (if molgenis theme), or name.min.css (if uploaded .min.css), or
    # name.css (if uploaded as .css).
    if one_resource_exists([theme + '.min.css', theme + '.css', 'bootstrap-' + theme + '.min.css'], ResourceType.THEME):
        # Molgenis themes start with bootstrap- but this is stripped from the name in the theme manager
        try:
            post(config.api('set_theme'), theme)
        except:
            post(config.api('set_theme'), theme.split('bootstrap-')[1])
    else:
        raise McmdError(
            'Applying theme failed. No themes found containing {} in the name'.format(args.theme, 'sys_set_StyleSheet'))
def add_group(args):
    io.start('Adding group %s' % highlight(args.name))
    post(config().get('api', 'group'), {
        'name': args.name.lower(),
        'label': args.name
    })