From bf6ebf74e73b8faa376722611cec9cf9513dcf94 Mon Sep 17 00:00:00 2001 From: laughedelic Date: Fri, 5 Jul 2024 04:52:19 +0200 Subject: [PATCH 1/2] feat!: add ListIDPGroupsOptions to support the filtering parameter --- github/teams.go | 14 +++++++++++++- github/teams_test.go | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/github/teams.go b/github/teams.go index 0f6cc9d16e4..6ae7a920189 100644 --- a/github/teams.go +++ b/github/teams.go @@ -796,6 +796,18 @@ func (s *TeamsService) RemoveTeamProjectBySlug(ctx context.Context, org, slug st return s.client.Do(ctx, req, nil) } +// ListIDPGroupsOptions specifies the optional parameters to the ListIDPGroupsInOrganization method. +type ListIDPGroupsOptions struct { + // The number of results to include per page. + PerPage int `url:"per_page,omitempty"` + + // Page token. + Page string `url:"page,omitempty"` + + // Filters the results to return only those that begin with the value specified by this parameter. + Query string `url:"q,omitempty"` +} + // IDPGroupList represents a list of external identity provider (IDP) groups. type IDPGroupList struct { Groups []*IDPGroup `json:"groups"` @@ -813,7 +825,7 @@ type IDPGroup struct { // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/teams/team-sync#list-idp-groups-for-an-organization // //meta:operation GET /orgs/{org}/team-sync/groups -func (s *TeamsService) ListIDPGroupsInOrganization(ctx context.Context, org string, opts *ListCursorOptions) (*IDPGroupList, *Response, error) { +func (s *TeamsService) ListIDPGroupsInOrganization(ctx context.Context, org string, opts *ListIDPGroupsOptions) (*IDPGroupList, *Response, error) { u := fmt.Sprintf("orgs/%v/team-sync/groups", org) u, err := addOptions(u, opts) if err != nil { diff --git a/github/teams_test.go b/github/teams_test.go index 516c88f43ae..e12ed8cba62 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1302,11 +1302,15 @@ func TestTeamsService_ListIDPGroupsInOrganization(t *testing.T) { testMethod(t, r, "GET") testFormValues(t, r, values{ "page": "url-encoded-next-page-token", + "q": "n", }) fmt.Fprint(w, `{"groups": [{"group_id": "1", "group_name": "n", "group_description": "d"}]}`) }) - opt := &ListCursorOptions{Page: "url-encoded-next-page-token"} + opt := &ListIDPGroupsOptions{ + Query: "n", + Page: "url-encoded-next-page-token", + } ctx := context.Background() groups, _, err := client.Teams.ListIDPGroupsInOrganization(ctx, "o", opt) if err != nil { From e492cddb07ded9c720a7b7b8c44325fc1bc0bc41 Mon Sep 17 00:00:00 2001 From: laughedelic Date: Fri, 5 Jul 2024 20:36:18 +0200 Subject: [PATCH 2/2] fixup: use nested ListCursorOptions --- github/teams.go | 8 ++------ github/teams_test.go | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/github/teams.go b/github/teams.go index 6ae7a920189..b44e9418c05 100644 --- a/github/teams.go +++ b/github/teams.go @@ -798,14 +798,10 @@ func (s *TeamsService) RemoveTeamProjectBySlug(ctx context.Context, org, slug st // ListIDPGroupsOptions specifies the optional parameters to the ListIDPGroupsInOrganization method. type ListIDPGroupsOptions struct { - // The number of results to include per page. - PerPage int `url:"per_page,omitempty"` - - // Page token. - Page string `url:"page,omitempty"` - // Filters the results to return only those that begin with the value specified by this parameter. Query string `url:"q,omitempty"` + + ListCursorOptions } // IDPGroupList represents a list of external identity provider (IDP) groups. diff --git a/github/teams_test.go b/github/teams_test.go index e12ed8cba62..bb4fa4eac38 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1308,8 +1308,8 @@ func TestTeamsService_ListIDPGroupsInOrganization(t *testing.T) { }) opt := &ListIDPGroupsOptions{ - Query: "n", - Page: "url-encoded-next-page-token", + Query: "n", + ListCursorOptions: ListCursorOptions{Page: "url-encoded-next-page-token"}, } ctx := context.Background() groups, _, err := client.Teams.ListIDPGroupsInOrganization(ctx, "o", opt)