MambuPy.rest.mambuuser

Mambu Users objects.

MambuUser holds a user.

MambuUsers holds a list of users.

Uses mambugeturl.getuserurl as default urlfunc

Classes

MambuUser([urlfunc, entid])

A User from Mambu.

MambuUsers([urlfunc, entid, itemclass])

A list of Users from Mambu.

class MambuPy.rest.mambuuser.MambuUser(urlfunc=<function getuserurl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A User from Mambu.

With the default urlfunc, entid argument must be the ID of the user you wish to retrieve.

__init__(urlfunc=<function getuserurl>, entid='', *args, **kwargs)[source]

Tasks done here:

Just initializes the MambuStruct.

__module__ = 'MambuPy.rest.mambuuser'
create(data, *args, **kwargs)[source]

Creates an user in Mambu

Parameters -data dictionary with data to send

preprocess()[source]

Preprocessing.

Removes repeated chars from firstName and lastName fields.

Adds a ‘name’ field joining all names in to one string.

setBranch(*args, **kwargs)[source]

Adds the branch to which this user belongs

setGroups(*args, **kwargs)[source]

Adds the groups assigned to this user to a ‘groups’ field.

Returns the number of requests done to Mambu.

setRoles(*args, **kwargs)[source]

Adds the role assigned to this user to a ‘role’ field.

Depends on the ‘role’ field that comes with a fullDetails=True build of the MambuUser.

Returns the number of requests done to Mambu.

update(data, *args, **kwargs)[source]

Updates a user in Mambu

Updates customFields of a MambuUser

https://support.mambu.com/docs/users-api#post-users https://support.mambu.com/docs/users-api#parameters-for-patch-custom-fields-method-for-user

Parameters -data dictionary with data to update

update_patch(data, *args, **kwargs)[source]

Updates a Mambu user using method PATCH

Parameters:

data (dictionary) – dictionary with data to update

https://support.mambu.com/docs/users-api#patch-user-custom-field-values

class MambuPy.rest.mambuuser.MambuUsers(urlfunc=<function getuserurl>, entid='', itemclass=<class 'MambuPy.rest.mambuuser.MambuUser'>, *args, **kwargs)[source]

Bases: MambuStruct

A list of Users from Mambu.

With the default urlfunc, entid argument must be empty at instantiation time to retrieve all the users according to any other filter you send to the urlfunc.

itemclass argument allows you to pass some other class as the elements for the list. Why is this useful? You may wish to override several behaviours by creating your own MambuUser son class. Pass that to the itemclass argument here and voila, you get a list of YourMambuUser class using MambuUsers instead of plain old MambuUser elements.

If you wish to specialize other Mambu objects on MambuPy you may do that. Mind that if you desire that the iterable version of it to have elements of your specialized class, you need to change the logic of the constructor and the convert_dict_to_attrs method in the iterable class to use some sort of itemclass there too. Don’t forget to submit the change on a pull request when done ;-)

__init__(urlfunc=<function getuserurl>, entid='', itemclass=<class 'MambuPy.rest.mambuuser.MambuUser'>, *args, **kwargs)[source]

By default, entid argument is empty. That makes perfect sense: you want several branches, not just one

__iter__()[source]
__module__ = 'MambuPy.rest.mambuuser'
convert_dict_to_attrs(*args, **kwargs)[source]

The trick for iterable Mambu Objects comes here:

You iterate over each element of the responded List from Mambu, and create a Mambu User (or your own itemclass) object for each one, initializing them one at a time, and changing the attrs attribute (which just holds a list of plain dictionaries) with a MambuUser (or your own itemclass) just created.

Todo

pass a valid (perhaps default) urlfunc, and its corresponding id to entid to each itemclass, telling MambuStruct not to connect() by default. It’s desirable to connect at any other further moment to refresh some element in the list.