def get_current_user(self): """ Get user and group assignments of this session :return: instance of TM1py.User """ request = "/api/v1/ActiveUser?$expand=Groups" response = self._rest.GET(request) return User.from_dict(response.json())
def get_current_user(self, **kwargs) -> User: """ Get user and group assignments of this session :return: instance of TM1py.User """ url = "/api/v1/ActiveUser?$select=Name,FriendlyName,Password,Type,Enabled&$expand=Groups" response = self._rest.GET(url, **kwargs) return User.from_dict(response.json())
def get_active_users(self, **kwargs) -> List[User]: """ Get the activate users in TM1 :return: List of TM1py.User instances """ url = '/api/v1/Users?$filter=IsActive eq true&$expand=Groups' response = self._rest.GET(url, **kwargs) users = [User.from_dict(user) for user in response.json()['value']] return users
def get(self, user_name): """ Get user from TM1 Server :param user_name: :return: instance of TM1py.User """ request = '/api/v1/Users(\'{}\')?$expand=Groups'.format(user_name) response = self._rest.GET(request) return User.from_json(response)
def get_active_users(self): """ Get the activate users in TM1 Server :return: List of TM1py.User instances """ request = '/api/v1/Users?$filter=IsActive eq true&$expand=Groups' response = self._rest.GET(request) users = [User.from_dict(user) for user in response.json()['value']] return users
def get_all_users(self): """ Get all users from TM1 Server :return: List of TM1py.User instances """ request = '/api/v1/Users?$expand=Groups' response = self._rest.GET(request) users = [User.from_dict(user) for user in response.json()['value']] return users
def get_all_users(self, **kwargs): """ Get all users from TM1 Server :return: List of TM1py.User instances """ url = '/api/v1/Users?$select=Name,FriendlyName,Password,Type,Enabled&$expand=Groups' response = self._rest.GET(url, **kwargs) users = [User.from_dict(user) for user in response.json()['value']] return users
def get_user(self, user_name): """ Get user from TM1 Server :param user_name: :return: instance of TM1py.User """ user_name = self.determine_actual_user_name(user_name) request = "/api/v1/Users('{}')?$expand=Groups".format(user_name) response = self._rest.GET(request) return User.from_dict(response.json())
def get_users_from_group(self, group_name): """ Get all users from group :param group_name: :return: List of TM1py.User instances """ request = '/api/v1/Groups(\'{}\')?$expand=Users($expand=Groups)'.format(group_name) response = self._rest.GET(request) users = [User.from_dict(user) for user in response.json()['Users']] return users
def update_user(self, user: User, **kwargs) -> Response: """ Update user on TM1 Server :param user: instance of TM1py.User :return: response """ user.name = self.determine_actual_user_name(user.name, **kwargs) for current_group in self.get_groups(user.name, **kwargs): if current_group not in user.groups: self.remove_user_from_group(current_group, user.name, **kwargs) url = format_url("/api/v1/Users('{}')", user.name) return self._rest.PATCH(url, user.body, **kwargs)
def get_user(self, user_name: str, **kwargs) -> User: """ Get user from TM1 Server :param user_name: :return: instance of TM1py.User """ user_name = self.determine_actual_user_name(user_name, **kwargs) url = format_url( "/api/v1/Users('{}')?$select=Name,FriendlyName,Password,Type,Enabled&$expand=Groups", user_name) response = self._rest.GET(url, **kwargs) return User.from_dict(response.json())
def get_users_from_group(self, group_name: str, **kwargs): """ Get all users from group :param group_name: :return: List of TM1py.User instances """ url = format_url( "/api/v1/Groups('{}')?$expand=Users($select=Name,FriendlyName,Password,Type,Enabled;$expand=Groups)", group_name) response = self._rest.GET(url, **kwargs) users = [User.from_dict(user) for user in response.json()['Users']] return users