private static async Task SecureItemFromGroupAsync(IPermissionManager mgr, int workspaceId, string groupName, int artifactId) { var itemSecurity = await mgr.GetItemLevelSecurityAsync(workspaceId, artifactId); if (!itemSecurity.Enabled) { itemSecurity.Enabled = true; await mgr.SetItemLevelSecurityAsync(workspaceId, itemSecurity); } var selection = await mgr.GetItemGroupSelectorAsync(workspaceId, artifactId); foreach (var enabledGroup in selection.EnabledGroups) { if (enabledGroup.Name == groupName) { selection.DisabledGroups.Add(enabledGroup); selection.EnabledGroups.Add(enabledGroup); await mgr.AddRemoveItemGroupsAsync(workspaceId, artifactId, selection); break; } } }