MCPcopy Index your code
hub / github.com/cli/cli / OrganizationTeams

Function OrganizationTeams

api/queries_org.go:77–111  ·  view source on GitHub ↗

OrganizationTeams fetches all the teams in an organization

(client *Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

75
76// OrganizationTeams fetches all the teams in an organization
77func OrganizationTeams(client *Client, repo ghrepo.Interface) ([]OrgTeam, error) {
78 type responseData struct {
79 Organization struct {
80 Teams struct {
81 Nodes []OrgTeam
82 PageInfo struct {
83 HasNextPage bool
84 EndCursor string
85 }
86 } `graphql:"teams(first: 100, orderBy: {field: NAME, direction: ASC}, after: $endCursor)"`
87 } `graphql:"organization(login: $owner)"`
88 }
89
90 variables := map[string]interface{}{
91 "owner": githubv4.String(repo.RepoOwner()),
92 "endCursor": (*githubv4.String)(nil),
93 }
94
95 var teams []OrgTeam
96 for {
97 var query responseData
98 err := client.Query(repo.RepoHost(), "OrganizationTeamList", &query, variables)
99 if err != nil {
100 return nil, err
101 }
102
103 teams = append(teams, query.Organization.Teams.Nodes...)
104 if !query.Organization.Teams.PageInfo.HasNextPage {
105 break
106 }
107 variables["endCursor"] = githubv4.String(query.Organization.Teams.PageInfo.EndCursor)
108 }
109
110 return teams, nil
111}

Callers 1

RepoMetadataFunction · 0.85

Calls 4

RepoOwnerMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected