/// <summary> /// Returns all members with the specified role in the given team of the given role. /// </summary> /// <remarks> /// https://developer.github.com/v3/orgs/teams/#list-team-members /// </remarks> /// <param name="id">The team identifier</param> /// <param name="request">The request filter</param> /// <param name="options">Options to change API behaviour.</param> public IObservable <User> GetAllMembers(int id, TeamMembersRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return(_connection.GetAndFlattenAllPages <User>(ApiUrls.TeamMembers(id), request.ToParametersDictionary(), AcceptHeaders.NestedTeamsPreview, options)); }
private async Task LoadTeamsAsync(CachedOrg cachedOrg) { await GitHubClient.PrintProgressAsync(Log, "Loading team list"); var teams = await GitHubClient.Organization.Team.GetAll(cachedOrg.Name); var i = 0; foreach (var team in teams) { await GitHubClient.PrintProgressAsync(Log, "Loading team", team.Name, i ++, teams.Count); var cachedTeam = new CachedTeam { Id = team.Id.ToString(), ParentId = team.Parent?.Id.ToString(), Name = team.Name }; cachedOrg.Teams.Add(cachedTeam); var maintainerRequest = new TeamMembersRequest(TeamRoleFilter.Maintainer); var maintainers = await GitHubClient.Organization.Team.GetAllMembers(team.Id, maintainerRequest); foreach (var maintainer in maintainers) { cachedTeam.MaintainerLogins.Add(maintainer.Login); } await GitHubClient.WaitForEnoughQuotaAsync(Log); var memberRequest = new TeamMembersRequest(TeamRoleFilter.All); var members = await GitHubClient.Organization.Team.GetAllMembers(team.Id, memberRequest); foreach (var member in members) { cachedTeam.MemberLogins.Add(member.Login); } await GitHubClient.WaitForEnoughQuotaAsync(Log); foreach (var repo in await GitHubClient.Organization.Team.GetAllRepositories(team.Id)) { var permissionLevel = repo.Permissions.Admin ? CachedPermission.Admin : repo.Permissions.Push ? CachedPermission.Push : CachedPermission.Pull; var cachedRepoAccess = new CachedTeamAccess { RepoName = repo.Name, Permission = permissionLevel }; cachedTeam.Repos.Add(cachedRepoAccess); } } }
private static async Task LoadTeamsAsync(GitHubClient client, CachedOrg cachedOrg) { var teams = await client.Organization.Team.GetAll(cachedOrg.Name); var i = 0; foreach (var team in teams) { PrintRateLimit(client); PrintPercentage(i++, teams.Count, team.Name); var cachedTeam = new CachedTeam { Id = team.Id.ToString(), ParentId = team.Parent?.Id.ToString(), Name = team.Name }; cachedOrg.Teams.Add(cachedTeam); var request = new TeamMembersRequest(TeamRoleFilter.All); var members = await client.Organization.Team.GetAllMembers(team.Id, request); foreach (var member in members) { cachedTeam.Members.Add(member.Login); } foreach (var repo in await client.Organization.Team.GetAllRepositories(team.Id)) { var permissionLevel = repo.Permissions.Admin ? CachedPermission.Admin : repo.Permissions.Push ? CachedPermission.Push : CachedPermission.Pull; var cachedRepoAccess = new CachedTeamAccess { RepoName = repo.Name, Permission = permissionLevel }; cachedTeam.Repos.Add(cachedRepoAccess); } } }
/// <summary> /// Returns all members with the specified role in the given team of the given role. /// </summary> /// <remarks> /// https://developer.github.com/v3/orgs/teams/#list-team-members /// </remarks> /// <param name="id">The team identifier</param> /// <param name="request">The request filter</param> public IObservable <User> GetAllMembers(int id, TeamMembersRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); return(GetAllMembers(id, request, ApiOptions.None)); }