Skip to content

Commit

Permalink
Add members arg to list_team_members to allow getting pending members
Browse files Browse the repository at this point in the history
  • Loading branch information
ateucher committed Jun 10, 2024
1 parent b4c0818 commit 21aaba2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
23 changes: 16 additions & 7 deletions R/list_teams.R
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
#' List members of a GitHub Team
#'
#' @inheritParams add_team_members
#' @param names_only Should only the team member names be returned (as a character vector; `TRUE`, the default),
#' or should all of the team member metadata be returned?
#' @param names_only Should only the team member names be returned (as a
#' character vector; `TRUE`, the default), or should all of the team member
#' metadata be returned?
#' @param members Should current members (`"members"`) be returned, or pending
#' invitations (`"invitations"`) invitations be returned? Default `"members"`.
#' @param ... passed on to [gh::gh()]
#'
#' @return a character vector of team member GitHub usernames if `names_only = TRUE`, otherwise
#' a `gh_response` object containing team member information
#' @return a character vector of team member GitHub usernames if `names_only =
#' TRUE`, otherwise a `gh_response` object containing team member information
#' @export
#'
#' @examples
#' \dontrun{
#' list_team_members(team = "2023-superdogs-test-cohort", org = "openscapes")
#' list_team_members(team = "2023-superdogs-test-cohort", org = "openscapes", names_only = FALSE)
#' list_team_members(team = "2023-superdogs-test-cohort", org = "openscapes",
#' names_only = FALSE)
#' list_team_members(team = "2023-superdogs-test-cohort", org = "openscapes",
#' members = "invitations")
#' }
list_team_members <- function(team, org = "openscapes", names_only = TRUE, ...) {
list_team_members <- function(team, org = "openscapes", names_only = TRUE,
members = c("members", "invitations"), ...) {
check_gh_pat()

team <- tolower(team)
org <- tolower(org)
org_teams <- tolower(list_teams(org))
members <- match.arg(members)

if (!team %in% org_teams) {
stop("'", team, "' is not part of the '", org, "' organization",
call. = FALSE)
}

team_members <- gh(
"GET /orgs/{org}/teams/{team_slug}/members",
"GET /orgs/{org}/teams/{team_slug}/{members}",
org = org,
team_slug = team,
members = members,
...,
.limit = Inf
)
Expand Down
19 changes: 14 additions & 5 deletions man/list_team_members.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 21aaba2

Please sign in to comment.