Exemplo n.º 1
0
def cmd_plans_set(config, user, action, product, plans):
    """assign products and plans to given user

    """
    from .service_plans import SERVICE_PLANS
    _matches = create_matcher(product.split())

    products = filter(_matches, SERVICE_PLANS['skus_by_string_id'].values())

    assert len(products) != 0, "no products found matching '%s'" % product
    assert len(
        products) == 1, "more than one product found matching '%s'" % product

    #for v in SERVICE_PLANS['skus_by_string_id'].values():

    #if _matches(v):

    if action == 'set':
        pass
    # get current licenses

    api = get_api(config)
    user_info = api.get('users/%s' % user, **{'$select': 'assignedLicenses'})

    #for lic in user_info['assignedLicenses']:

    command = {'addLicenses': {}, 'removeLicenses': {}}
Exemplo n.º 2
0
def cmd_users_show(config, all_fields, select, user):
    params = get_input_docs(user)[0]
    if select:
        params['select'] = select
    if all_fields:
        params['select'] = ",".join(get_fields('user'))

    api = get_api(config)

    for u in user:
        data = api.get("users/" + u, params).json()
    pyaml.p(data)
Exemplo n.º 3
0
def cmd_users_ls(config, all_fields, select, filter, param):
    params = get_input_docs(param)[0]
    if all:
        params['$select'] = ",".join(get_fields('user'))

    if filter:
        params['$filter'] = filter

    # see https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list
    exclude = """aboutMe, birthday, hireDate, interests, mySite,
        pastProjects, preferredName, responsibilities, schools, skills,
        mailboxSettings""".replace(",", '').split()
    select = []
    for field in params['$select'].split(","):
        if field not in exclude:
            select.append(field)
    params['$select'] = ",".join(select)

    api = get_api(config)

    data = api.get("users", params).json()
    pyaml.p(data)
Exemplo n.º 4
0
def cmd_create_command(config, mailNickname, displayName, internal):
    data = dict(
        displayName=displayName,
        mailEnabled=True,
        mailNickname=mailNickname,
        securityEnabled=False,
        groupTypes=["Unified"],
    )

    api = get_api(config)
    response = api.post('groups', data)

    try:
        data = response.json()
        pyaml.p(data)
    except:
        return handle_response(response)

    response = api.patch('groups/%(id)s' % data,
                         dict(allowExternalSenders=not internal, ))
    handle_response(response)
    response = api.patch('groups/%(id)s' % data,
                         dict(autoSubscribeNewMembers=True, ))
    return handle_response(response)
Exemplo n.º 5
0
def cmd_group_ls(config):
    api = get_api(config)
    data = api.get("groups").json()
    pyaml.p(data)