diff --git a/src/sempy_labs/_helper_functions.py b/src/sempy_labs/_helper_functions.py index 2ff51e5..b476770 100644 --- a/src/sempy_labs/_helper_functions.py +++ b/src/sempy_labs/_helper_functions.py @@ -781,9 +781,8 @@ def get_capacity_id(workspace: Optional[str] = None) -> UUID: """ if workspace is None: - capacity_id = _get_x_id(name="trident.capacity.id") + capacity_id = _get_fabric_context_setting(name="trident.capacity.id") else: - workspace = fabric.resolve_workspace_name(workspace) filter_condition = urllib.parse.quote(workspace) dfW = fabric.list_workspaces(filter=f"name eq '{filter_condition}'") diff --git a/src/sempy_labs/tom/_model.py b/src/sempy_labs/tom/_model.py index 97582a5..cb81853 100644 --- a/src/sempy_labs/tom/_model.py +++ b/src/sempy_labs/tom/_model.py @@ -4529,7 +4529,7 @@ def set_value_filter_behavior(self, value_filter_behavior: str = "Automatic"): def add_role_member(self, role_name: str, member: str | List[str]): """ - Adds a external model role member (AzureAD) to a role. + Adds an external model role member (AzureAD) to a role. Parameters ---------- @@ -4561,6 +4561,35 @@ def add_role_member(self, role_name: str, member: str | List[str]): f"{icons.yellow_dot} '{m}' is already a member in the '{role_name}' role." ) + def remove_role_member(self, role_name: str, member: str | List[str]): + """ + Removes an external model role member (AzureAD) from a role. + + Parameters + ---------- + role_name : str + The role name. + member : str | List[str] + The email address(es) of the member(s) to remove. + """ + + if isinstance(member, str): + member = [member] + + role = self.model.Roles[role_name] + current_members = {m.MemberName: m.Name for m in role.Members} + for m in member: + name = current_members.get(m) + if name is not None: + role.Members.Remove(role.Members[name]) + print( + f"{icons.green_dot} The '{m}' member has been removed from the '{role_name}' role." + ) + else: + print( + f"{icons.yellow_dot} '{m}' is not a member of the '{role_name}' role." + ) + def close(self): if not self._readonly and self.model is not None: