diff --git a/github/enterprise_app_installation.go b/github/enterprise_app_installation.go index 495b6d83966..ae736ecbcd3 100644 --- a/github/enterprise_app_installation.go +++ b/github/enterprise_app_installation.go @@ -157,3 +157,112 @@ func (s *EnterpriseService) UninstallApp(ctx context.Context, enterprise, org st return resp, nil } + +// AppInstallationRepositoriesRequest specifies the parameters for +// EnterpriseService.AddRepositoriesToAppInstallation and +// EnterpriseService.RemoveRepositoriesFromAppInstallation. +type AppInstallationRepositoriesRequest struct { + // Repository names to add to or remove from the installation. + Repositories []string `json:"repositories"` +} + +// UpdateAppInstallationRepositoriesRequest specifies the parameters for +// EnterpriseService.UpdateAppInstallationRepositories. +type UpdateAppInstallationRepositoriesRequest struct { + // Can be "all" or "selected". + RepositorySelection *string `json:"repository_selection,omitempty"` + // Repository names to grant the installation access to. Only required + // when RepositorySelection is "selected". + Repositories []string `json:"repositories,omitempty"` +} + +// ListRepositoriesForOrgAppInstallation lists the repositories that an enterprise app installation +// has access to on an organization. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#get-the-repositories-accessible-to-a-given-github-app-installation +// +//meta:operation GET /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories +func (s *EnterpriseService) ListRepositoriesForOrgAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts *ListOptions) ([]*AccessibleRepository, *Response, error) { + u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories", enterprise, org, installationID) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest(ctx, "GET", u, nil) + if err != nil { + return nil, nil, err + } + + var r []*AccessibleRepository + resp, err := s.client.Do(req, &r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + +// UpdateAppInstallationRepositories changes a GitHub App installation's repository access +// between all repositories and a selected set. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#toggle-installation-repository-access-between-selected-and-all-repositories +// +//meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories +func (s *EnterpriseService) UpdateAppInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts UpdateAppInstallationRepositoriesRequest) (*Installation, *Response, error) { + u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories", enterprise, org, installationID) + req, err := s.client.NewRequest(ctx, "PATCH", u, opts) + if err != nil { + return nil, nil, err + } + + var r *Installation + resp, err := s.client.Do(req, &r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + +// AddRepositoriesToAppInstallation grants repository access for a GitHub App installation. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#grant-repository-access-to-an-organization-installation +// +//meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/add +func (s *EnterpriseService) AddRepositoriesToAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts AppInstallationRepositoriesRequest) ([]*AccessibleRepository, *Response, error) { + u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories/add", enterprise, org, installationID) + req, err := s.client.NewRequest(ctx, "PATCH", u, opts) + if err != nil { + return nil, nil, err + } + + var r []*AccessibleRepository + resp, err := s.client.Do(req, &r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + +// RemoveRepositoriesFromAppInstallation revokes repository access from a GitHub App installation. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#remove-repository-access-from-an-organization-installation +// +//meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/remove +func (s *EnterpriseService) RemoveRepositoriesFromAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts AppInstallationRepositoriesRequest) ([]*AccessibleRepository, *Response, error) { + u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories/remove", enterprise, org, installationID) + req, err := s.client.NewRequest(ctx, "PATCH", u, opts) + if err != nil { + return nil, nil, err + } + + var r []*AccessibleRepository + resp, err := s.client.Do(req, &r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} diff --git a/github/enterprise_app_installation_test.go b/github/enterprise_app_installation_test.go index d57a8a18041..b42318f70a7 100644 --- a/github/enterprise_app_installation_test.go +++ b/github/enterprise_app_installation_test.go @@ -195,3 +195,144 @@ func TestEnterpriseService_UninstallApp(t *testing.T) { return client.Enterprise.UninstallApp(ctx, "e", "org1", 123) }) } + +func TestEnterpriseService_ListRepositoriesForOrgAppInstallation(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"page": "1"}) + fmt.Fprint(w, `[{"id":1}]`) + }) + + ctx := t.Context() + repos, _, err := client.Enterprise.ListRepositoriesForOrgAppInstallation(ctx, "e", "o", 1, &ListOptions{Page: 1}) + if err != nil { + t.Errorf("Enterprise.ListRepositoriesForOrgAppInstallation returned error: %v", err) + } + + want := []*AccessibleRepository{{ID: 1}} + if diff := cmp.Diff(repos, want); diff != "" { + t.Errorf("Enterprise.ListRepositoriesForOrgAppInstallation returned diff (-want +got):\n%v", diff) + } + + const methodName = "ListRepositoriesForOrgAppInstallation" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Enterprise.ListRepositoriesForOrgAppInstallation(ctx, "\n", "\n", -1, &ListOptions{}) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + _, resp, err := client.Enterprise.ListRepositoriesForOrgAppInstallation(ctx, "e", "o", 1, &ListOptions{}) + return resp, err + }) +} + +func TestEnterpriseService_UpdateAppInstallationRepositories(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := UpdateAppInstallationRepositoriesRequest{ + RepositorySelection: Ptr("selected"), + Repositories: []string{"hello-world", "hello-world-2"}, + } + + mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PATCH") + testJSONBody(t, r, input) + fmt.Fprint(w, `{"id":1, "repository_selection":"selected"}`) + }) + + ctx := t.Context() + inst, _, err := client.Enterprise.UpdateAppInstallationRepositories(ctx, "e", "o", 1, input) + if err != nil { + t.Errorf("Enterprise.UpdateAppInstallationRepositories returned error: %v", err) + } + + want := &Installation{ID: Ptr(int64(1)), RepositorySelection: Ptr("selected")} + if diff := cmp.Diff(inst, want); diff != "" { + t.Errorf("Enterprise.UpdateAppInstallationRepositories returned diff (-want +got):\n%v", diff) + } + + const methodName = "UpdateAppInstallationRepositories" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Enterprise.UpdateAppInstallationRepositories(ctx, "\n", "\n", -1, input) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + _, resp, err := client.Enterprise.UpdateAppInstallationRepositories(ctx, "e", "o", 1, input) + return resp, err + }) +} + +func TestEnterpriseService_AddRepositoriesToAppInstallation(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := AppInstallationRepositoriesRequest{Repositories: []string{"hello-world", "hello-world-2"}} + + mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories/add", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PATCH") + testJSONBody(t, r, input) + fmt.Fprint(w, `[{"id":1},{"id":2}]`) + }) + + ctx := t.Context() + repos, _, err := client.Enterprise.AddRepositoriesToAppInstallation(ctx, "e", "o", 1, input) + if err != nil { + t.Errorf("Enterprise.AddRepositoriesToAppInstallation returned error: %v", err) + } + + want := []*AccessibleRepository{{ID: 1}, {ID: 2}} + if diff := cmp.Diff(repos, want); diff != "" { + t.Errorf("Enterprise.AddRepositoriesToAppInstallation returned diff (-want +got):\n%v", diff) + } + + const methodName = "AddRepositoriesToAppInstallation" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Enterprise.AddRepositoriesToAppInstallation(ctx, "\n", "\n", -1, input) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + _, resp, err := client.Enterprise.AddRepositoriesToAppInstallation(ctx, "e", "o", 1, input) + return resp, err + }) +} + +func TestEnterpriseService_RemoveRepositoriesFromAppInstallation(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := AppInstallationRepositoriesRequest{Repositories: []string{"hello-world", "hello-world-2"}} + + mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories/remove", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PATCH") + testJSONBody(t, r, input) + fmt.Fprint(w, `[{"id":1},{"id":2}]`) + }) + + ctx := t.Context() + repos, _, err := client.Enterprise.RemoveRepositoriesFromAppInstallation(ctx, "e", "o", 1, input) + if err != nil { + t.Errorf("Enterprise.RemoveRepositoriesFromAppInstallation returned error: %v", err) + } + + want := []*AccessibleRepository{{ID: 1}, {ID: 2}} + if diff := cmp.Diff(repos, want); diff != "" { + t.Errorf("Enterprise.RemoveRepositoriesFromAppInstallation returned diff (-want +got):\n%v", diff) + } + + const methodName = "RemoveRepositoriesFromAppInstallation" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Enterprise.RemoveRepositoriesFromAppInstallation(ctx, "\n", "\n", -1, input) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + _, resp, err := client.Enterprise.RemoveRepositoriesFromAppInstallation(ctx, "e", "o", 1, input) + return resp, err + }) +} diff --git a/github/enterprise_apps.go b/github/enterprise_apps.go deleted file mode 100644 index bd1e6573469..00000000000 --- a/github/enterprise_apps.go +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2025 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" -) - -// AppInstallationRepositoriesOptions specifies the parameters for -// EnterpriseService.AddRepositoriesToAppInstallation and -// EnterpriseService.RemoveRepositoriesFromAppInstallation. -type AppInstallationRepositoriesOptions struct { - SelectedRepositoryIDs []int64 `json:"selected_repository_ids"` -} - -// UpdateAppInstallationRepositoriesOptions specifies the parameters for -// EnterpriseService.UpdateAppInstallationRepositories. -type UpdateAppInstallationRepositoriesOptions struct { - RepositorySelection *string `json:"repository_selection,omitempty"` // Can be "all" or "selected" - SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"` -} - -// ListRepositoriesForOrgAppInstallation lists the repositories that an enterprise app installation -// has access to on an organization. -// -// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#get-the-repositories-accessible-to-a-given-github-app-installation -// -//meta:operation GET /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories -func (s *EnterpriseService) ListRepositoriesForOrgAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts *ListOptions) ([]*AccessibleRepository, *Response, error) { - u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories", enterprise, org, installationID) - u, err := addOptions(u, opts) - if err != nil { - return nil, nil, err - } - - req, err := s.client.NewRequest(ctx, "GET", u, nil) - if err != nil { - return nil, nil, err - } - - var r []*AccessibleRepository - resp, err := s.client.Do(req, &r) - if err != nil { - return nil, resp, err - } - - return r, resp, nil -} - -// UpdateAppInstallationRepositories changes a GitHub App installation's repository access -// between all repositories and a selected set. -// -// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#toggle-installation-repository-access-between-selected-and-all-repositories -// -//meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories -func (s *EnterpriseService) UpdateAppInstallationRepositories(ctx context.Context, enterprise, org string, installationID int64, opts UpdateAppInstallationRepositoriesOptions) (*Installation, *Response, error) { - u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories", enterprise, org, installationID) - req, err := s.client.NewRequest(ctx, "PATCH", u, opts) - if err != nil { - return nil, nil, err - } - - var r *Installation - resp, err := s.client.Do(req, &r) - if err != nil { - return nil, resp, err - } - - return r, resp, nil -} - -// AddRepositoriesToAppInstallation grants repository access for a GitHub App installation. -// -// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#grant-repository-access-to-an-organization-installation -// -//meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/add -func (s *EnterpriseService) AddRepositoriesToAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts AppInstallationRepositoriesOptions) ([]*AccessibleRepository, *Response, error) { - u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories/add", enterprise, org, installationID) - req, err := s.client.NewRequest(ctx, "PATCH", u, opts) - if err != nil { - return nil, nil, err - } - - var r []*AccessibleRepository - resp, err := s.client.Do(req, &r) - if err != nil { - return nil, resp, err - } - - return r, resp, nil -} - -// RemoveRepositoriesFromAppInstallation revokes repository access from a GitHub App installation. -// -// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28#remove-repository-access-from-an-organization-installation -// -//meta:operation PATCH /enterprises/{enterprise}/apps/organizations/{org}/installations/{installation_id}/repositories/remove -func (s *EnterpriseService) RemoveRepositoriesFromAppInstallation(ctx context.Context, enterprise, org string, installationID int64, opts AppInstallationRepositoriesOptions) ([]*AccessibleRepository, *Response, error) { - u := fmt.Sprintf("enterprises/%v/apps/organizations/%v/installations/%v/repositories/remove", enterprise, org, installationID) - req, err := s.client.NewRequest(ctx, "PATCH", u, opts) - if err != nil { - return nil, nil, err - } - - var r []*AccessibleRepository - resp, err := s.client.Do(req, &r) - if err != nil { - return nil, resp, err - } - - return r, resp, nil -} diff --git a/github/enterprise_apps_test.go b/github/enterprise_apps_test.go deleted file mode 100644 index 05ca3465dcf..00000000000 --- a/github/enterprise_apps_test.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2025 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "fmt" - "net/http" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestEnterpriseService_ListRepositoriesForOrgAppInstallation(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - testFormValues(t, r, values{"page": "1"}) - fmt.Fprint(w, `[{"id":1}]`) - }) - - ctx := t.Context() - repos, _, err := client.Enterprise.ListRepositoriesForOrgAppInstallation(ctx, "e", "o", 1, &ListOptions{Page: 1}) - if err != nil { - t.Errorf("Enterprise.ListRepositoriesForOrgAppInstallation returned error: %v", err) - } - - want := []*AccessibleRepository{{ID: 1}} - if diff := cmp.Diff(repos, want); diff != "" { - t.Errorf("Enterprise.ListRepositoriesForOrgAppInstallation returned diff (-want +got):\n%v", diff) - } - - const methodName = "ListRepositoriesForOrgAppInstallation" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Enterprise.ListRepositoriesForOrgAppInstallation(ctx, "\n", "\n", -1, &ListOptions{}) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - _, resp, err := client.Enterprise.ListRepositoriesForOrgAppInstallation(ctx, "e", "o", 1, &ListOptions{}) - return resp, err - }) -} - -func TestEnterpriseService_UpdateAppInstallationRepositories(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := UpdateAppInstallationRepositoriesOptions{ - RepositorySelection: Ptr("selected"), - SelectedRepositoryIDs: []int64{1, 2}, - } - - mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testJSONBody(t, r, input) - fmt.Fprint(w, `{"id":1, "repository_selection":"selected"}`) - }) - - ctx := t.Context() - inst, _, err := client.Enterprise.UpdateAppInstallationRepositories(ctx, "e", "o", 1, input) - if err != nil { - t.Errorf("Enterprise.UpdateAppInstallationRepositories returned error: %v", err) - } - - want := &Installation{ID: Ptr(int64(1)), RepositorySelection: Ptr("selected")} - if diff := cmp.Diff(inst, want); diff != "" { - t.Errorf("Enterprise.UpdateAppInstallationRepositories returned diff (-want +got):\n%v", diff) - } - - const methodName = "UpdateAppInstallationRepositories" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Enterprise.UpdateAppInstallationRepositories(ctx, "\n", "\n", -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - _, resp, err := client.Enterprise.UpdateAppInstallationRepositories(ctx, "e", "o", 1, input) - return resp, err - }) -} - -func TestEnterpriseService_AddRepositoriesToAppInstallation(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := AppInstallationRepositoriesOptions{SelectedRepositoryIDs: []int64{1, 2}} - - mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories/add", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testJSONBody(t, r, input) - fmt.Fprint(w, `[{"id":1},{"id":2}]`) - }) - - ctx := t.Context() - repos, _, err := client.Enterprise.AddRepositoriesToAppInstallation(ctx, "e", "o", 1, input) - if err != nil { - t.Errorf("Enterprise.AddRepositoriesToAppInstallation returned error: %v", err) - } - - want := []*AccessibleRepository{{ID: 1}, {ID: 2}} - if diff := cmp.Diff(repos, want); diff != "" { - t.Errorf("Enterprise.AddRepositoriesToAppInstallation returned diff (-want +got):\n%v", diff) - } - - const methodName = "AddRepositoriesToAppInstallation" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Enterprise.AddRepositoriesToAppInstallation(ctx, "\n", "\n", -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - _, resp, err := client.Enterprise.AddRepositoriesToAppInstallation(ctx, "e", "o", 1, input) - return resp, err - }) -} - -func TestEnterpriseService_RemoveRepositoriesFromAppInstallation(t *testing.T) { - t.Parallel() - client, mux, _ := setup(t) - - input := AppInstallationRepositoriesOptions{SelectedRepositoryIDs: []int64{1, 2}} - - mux.HandleFunc("/enterprises/e/apps/organizations/o/installations/1/repositories/remove", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") - testJSONBody(t, r, input) - fmt.Fprint(w, `[{"id":1},{"id":2}]`) - }) - - ctx := t.Context() - repos, _, err := client.Enterprise.RemoveRepositoriesFromAppInstallation(ctx, "e", "o", 1, input) - if err != nil { - t.Errorf("Enterprise.RemoveRepositoriesFromAppInstallation returned error: %v", err) - } - - want := []*AccessibleRepository{{ID: 1}, {ID: 2}} - if diff := cmp.Diff(repos, want); diff != "" { - t.Errorf("Enterprise.RemoveRepositoriesFromAppInstallation returned diff (-want +got):\n%v", diff) - } - - const methodName = "RemoveRepositoriesFromAppInstallation" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Enterprise.RemoveRepositoriesFromAppInstallation(ctx, "\n", "\n", -1, input) - return err - }) - - testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - _, resp, err := client.Enterprise.RemoveRepositoriesFromAppInstallation(ctx, "e", "o", 1, input) - return resp, err - }) -} diff --git a/github/github-accessors.go b/github/github-accessors.go index bc3194bc1b6..53702daaf21 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1670,12 +1670,12 @@ func (a *AppConfig) GetWebhookSecret() string { return *a.WebhookSecret } -// GetSelectedRepositoryIDs returns the SelectedRepositoryIDs slice if it's non-nil, nil otherwise. -func (a *AppInstallationRepositoriesOptions) GetSelectedRepositoryIDs() []int64 { - if a == nil || a.SelectedRepositoryIDs == nil { +// GetRepositories returns the Repositories slice if it's non-nil, nil otherwise. +func (a *AppInstallationRepositoriesRequest) GetRepositories() []string { + if a == nil || a.Repositories == nil { return nil } - return a.SelectedRepositoryIDs + return a.Repositories } // GetFrom returns the From field if it's non-nil, zero value otherwise. @@ -40982,22 +40982,22 @@ func (u *UnauthenticatedRateLimitedTransport) GetClientSecret() string { return u.ClientSecret } +// GetRepositories returns the Repositories slice if it's non-nil, nil otherwise. +func (u *UpdateAppInstallationRepositoriesRequest) GetRepositories() []string { + if u == nil || u.Repositories == nil { + return nil + } + return u.Repositories +} + // GetRepositorySelection returns the RepositorySelection field if it's non-nil, zero value otherwise. -func (u *UpdateAppInstallationRepositoriesOptions) GetRepositorySelection() string { +func (u *UpdateAppInstallationRepositoriesRequest) GetRepositorySelection() string { if u == nil || u.RepositorySelection == nil { return "" } return *u.RepositorySelection } -// GetSelectedRepositoryIDs returns the SelectedRepositoryIDs slice if it's non-nil, nil otherwise. -func (u *UpdateAppInstallationRepositoriesOptions) GetSelectedRepositoryIDs() []int64 { - if u == nil || u.SelectedRepositoryIDs == nil { - return nil - } - return u.SelectedRepositoryIDs -} - // GetOp returns the Op field. func (u *UpdateAttributeForSCIMUserOperations) GetOp() string { if u == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index c9ced173fe0..305c10bb398 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -2076,15 +2076,15 @@ func TestAppConfig_GetWebhookSecret(tt *testing.T) { a.GetWebhookSecret() } -func TestAppInstallationRepositoriesOptions_GetSelectedRepositoryIDs(tt *testing.T) { +func TestAppInstallationRepositoriesRequest_GetRepositories(tt *testing.T) { tt.Parallel() - zeroValue := []int64{} - a := &AppInstallationRepositoriesOptions{SelectedRepositoryIDs: zeroValue} - a.GetSelectedRepositoryIDs() - a = &AppInstallationRepositoriesOptions{} - a.GetSelectedRepositoryIDs() + zeroValue := []string{} + a := &AppInstallationRepositoriesRequest{Repositories: zeroValue} + a.GetRepositories() + a = &AppInstallationRepositoriesRequest{} + a.GetRepositories() a = nil - a.GetSelectedRepositoryIDs() + a.GetRepositories() } func TestArchivedAt_GetFrom(tt *testing.T) { @@ -51531,26 +51531,26 @@ func TestUnauthenticatedRateLimitedTransport_GetClientSecret(tt *testing.T) { u.GetClientSecret() } -func TestUpdateAppInstallationRepositoriesOptions_GetRepositorySelection(tt *testing.T) { +func TestUpdateAppInstallationRepositoriesRequest_GetRepositories(tt *testing.T) { tt.Parallel() - var zeroValue string - u := &UpdateAppInstallationRepositoriesOptions{RepositorySelection: &zeroValue} - u.GetRepositorySelection() - u = &UpdateAppInstallationRepositoriesOptions{} - u.GetRepositorySelection() + zeroValue := []string{} + u := &UpdateAppInstallationRepositoriesRequest{Repositories: zeroValue} + u.GetRepositories() + u = &UpdateAppInstallationRepositoriesRequest{} + u.GetRepositories() u = nil - u.GetRepositorySelection() + u.GetRepositories() } -func TestUpdateAppInstallationRepositoriesOptions_GetSelectedRepositoryIDs(tt *testing.T) { +func TestUpdateAppInstallationRepositoriesRequest_GetRepositorySelection(tt *testing.T) { tt.Parallel() - zeroValue := []int64{} - u := &UpdateAppInstallationRepositoriesOptions{SelectedRepositoryIDs: zeroValue} - u.GetSelectedRepositoryIDs() - u = &UpdateAppInstallationRepositoriesOptions{} - u.GetSelectedRepositoryIDs() + var zeroValue string + u := &UpdateAppInstallationRepositoriesRequest{RepositorySelection: &zeroValue} + u.GetRepositorySelection() + u = &UpdateAppInstallationRepositoriesRequest{} + u.GetRepositorySelection() u = nil - u.GetSelectedRepositoryIDs() + u.GetRepositorySelection() } func TestUpdateAttributeForSCIMUserOperations_GetOp(tt *testing.T) {