def create(name, label, attrs=None): if attrs is None: attrs = {} attrs['label'] = label res = get_backend_users_proxy().organization_create(name, **attrs) get_organization_info(name).invalidate_info() get_organization_list.invalidate() return res
def get_organization_list(): """ get the list of organizations :return: list of organizations :rtype: list(dict) """ return get_backend_users_proxy().organization_list()
def get_user_list(organization=None, with_flag=None): """ get the list of users. :param str organization: organization filter :param str with_flag: flag filter :return: user list :rtype: list(dict) """ return get_backend_users_proxy().user_list(organization=organization, with_flag=with_flag)
def _modify(self, attrs): orga = None if ('organization' in attrs) and (self.get_organization_name() != attrs['organization']): orga = self.get_organization_name() res = get_backend_users_proxy().user_modify(self.name, attrs) if orga is not None: get_organization_info(orga).invalidate_info() get_organization_info(attrs['organization']).invalidate_info() return res
def organization_has_role(self, organization, role): """ check whether the organization has the given role. :param str organization: target organization name :param str role: maximum role as in auth.permissions.Role :return: the role :rtype: bool """ user_list = [] for user, user_role in self.info()['permissions'].iteritems(): if topology_role.Role.leq(role,user_role): user_list.append(user) organizations_with_role = get_backend_users_proxy().organization_list(user_list) return (organization in organizations_with_role)
def create(username, organization, email, password, attrs): res = get_backend_users_proxy().user_create(username, organization, email, password, attrs) get_user_info(username).invalidate_info() get_user_list.invalidate() return res
def _remove(self): get_backend_users_proxy().organization_remove(self.name) get_organization_info(self.name).invalidate_info()
def _check_exists(self): if self._info is not None: return True return get_backend_users_proxy().organization_exists(self.name)
def _fetch_info(self, fetch=False): return get_backend_users_proxy().user_info(self.name)
def _remove(self): orga = self.get_organization_name() get_backend_users_proxy().user_remove(self.name) get_organization_info(orga).invalidate_info()
def _remove(self): get_backend_users_proxy().organization_remove(self.name)
def _fetch_info(self, fetch=False): return get_backend_users_proxy().organization_info(self.name)
def _modify(self, attrs): return get_backend_users_proxy().organization_modify(self.name, attrs)