From e00ee2baee56d2457dd2f1b2f1ee17d2e73f3679 Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Sat, 1 Aug 2026 03:56:11 +0900 Subject: [PATCH] refactor!: Pass `UpdateConnectedExternalGroup` request body by value via new `UpdateConnectedExternalGroupRequest` UpdateConnectedExternalGroup reused the ExternalGroup response type as its request body, but group_id is the only parameter the endpoint accepts, and it is required. The new UpdateConnectedExternalGroupRequest models that schema exactly, with a non-pointer GroupID, and is passed by value. ExternalGroup stays unchanged as the response type, and the old entry is removed from the .golangci.yml allowlist. BREAKING CHANGE: TeamsService.UpdateConnectedExternalGroup now takes a new UpdateConnectedExternalGroupRequest (with non-pointer GroupID) by value instead of *ExternalGroup. --- .golangci.yml | 1 - github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 8 ++++++++ github/teams.go | 8 +++++++- github/teams_test.go | 8 ++++---- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 22832ae0bea..d0355298196 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -222,7 +222,6 @@ linters: - DependencyGraphSnapshot - EncryptedSecret - EnterpriseSecurityAnalysisSettings - - ExternalGroup - Hook - ImpersonateUserOptions - Import diff --git a/github/github-accessors.go b/github/github-accessors.go index 0fa6e1567f8..c8ce45d38a0 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -43062,6 +43062,14 @@ func (u *UpdateCodespaceOptions) GetRecentFolders() []string { return u.RecentFolders } +// GetGroupID returns the GroupID field. +func (u *UpdateConnectedExternalGroupRequest) GetGroupID() int64 { + if u == nil { + return 0 + } + return u.GroupID +} + // GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. func (u *UpdateCustomOrgRoleRequest) GetBaseRole() string { if u == nil || u.BaseRole == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 5c757237a1a..c5eb447e439 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -53905,6 +53905,14 @@ func TestUpdateCodespaceOptions_GetRecentFolders(tt *testing.T) { u.GetRecentFolders() } +func TestUpdateConnectedExternalGroupRequest_GetGroupID(tt *testing.T) { + tt.Parallel() + u := &UpdateConnectedExternalGroupRequest{} + u.GetGroupID() + u = nil + u.GetGroupID() +} + func TestUpdateCustomOrgRoleRequest_GetBaseRole(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/teams.go b/github/teams.go index f0bc98ad84d..185d3bfbf4f 100644 --- a/github/teams.go +++ b/github/teams.go @@ -974,6 +974,12 @@ type ExternalGroupList struct { Groups []*ExternalGroup `json:"groups"` } +// UpdateConnectedExternalGroupRequest represents a request to update the connection +// between an external group and a team. +type UpdateConnectedExternalGroupRequest struct { + GroupID int64 `json:"group_id"` +} + // GetExternalGroup fetches an external group. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/teams/external-groups?apiVersion=2022-11-28#get-an-external-group @@ -1056,7 +1062,7 @@ func (s *TeamsService) ListExternalGroupsForTeamBySlug(ctx context.Context, org, // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/teams/external-groups?apiVersion=2022-11-28#update-the-connection-between-an-external-group-and-a-team // //meta:operation PATCH /orgs/{org}/teams/{team_slug}/external-groups -func (s *TeamsService) UpdateConnectedExternalGroup(ctx context.Context, org, slug string, body *ExternalGroup) (*ExternalGroup, *Response, error) { +func (s *TeamsService) UpdateConnectedExternalGroup(ctx context.Context, org, slug string, body UpdateConnectedExternalGroupRequest) (*ExternalGroup, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/external-groups", org, slug) req, err := s.client.NewRequest(ctx, "PATCH", u, body) diff --git a/github/teams_test.go b/github/teams_test.go index 752072c7a26..915b02e04d9 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1802,8 +1802,8 @@ func TestTeamsService_UpdateConnectedExternalGroup(t *testing.T) { }) ctx := t.Context() - body := &ExternalGroup{ - GroupID: Ptr(int64(123)), + body := UpdateConnectedExternalGroupRequest{ + GroupID: 123, } externalGroup, _, err := client.Teams.UpdateConnectedExternalGroup(ctx, "o", "t", body) if err != nil { @@ -1868,8 +1868,8 @@ func TestTeamsService_UpdateConnectedExternalGroup_notFound(t *testing.T) { }) ctx := t.Context() - body := &ExternalGroup{ - GroupID: Ptr(int64(123)), + body := UpdateConnectedExternalGroupRequest{ + GroupID: 123, } eg, resp, err := client.Teams.UpdateConnectedExternalGroup(ctx, "o", "t", body) if err == nil {