MambuPy.rest.mamburoles

Mambu Roles objects.

MambuRole holds a user role.

MambuRoles holds a list of user roles.

Uses mambugeturl.getrolesurl as default urlfunc

Classes

MambuRole([urlfunc, entid])

A Role from Mambu.

MambuRoles([urlfunc, entid, itemclass])

A list of Roles from Mambu.

class MambuPy.rest.mamburoles.MambuRole(urlfunc=<function getrolesurl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A Role from Mambu.

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

Tasks done here:

Just initializes the MambuStruct.

__module__ = 'MambuPy.rest.mamburoles'
__repr__()[source]

Instead of the default id given by the parent class, shows the rolename

class MambuPy.rest.mamburoles.MambuRoles(urlfunc=<function getrolesurl>, entid='', itemclass=<class 'MambuPy.rest.mamburoles.MambuRole'>, *args, **kwargs)[source]

Bases: MambuStruct

A list of Roles from Mambu.

With the default urlfunc, entid argument must be empty at instantiation time to retrieve all the roles 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 MambuRole son class. Pass that to the itemclass argument here and voila, you get a list of YourMambuRole class using MambuRoles instead of plain old MambuRole 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 getrolesurl>, entid='', itemclass=<class 'MambuPy.rest.mamburoles.MambuRole'>, *args, **kwargs)[source]

entid argument is empty. That makes perfect sense: you always get serveral roles from Mambu REST API

__iter__()[source]
__module__ = 'MambuPy.rest.mamburoles'
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 Role (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.