Repository: google/go-github
File: github/enterprise_apps.go (Go)

Code before:
import (
	"context"
	"fmt"
)

// EnterpriseInstallationRepositoriesOptions specifies the parameters for
// EnterpriseService.AddRepositoriesToInstallation and
// EnterpriseService.RemoveRepositoriesFromInstallation.
type EnterpriseInstallationRepositoriesOptions struct {
	SelectedRepositoryIDs []int64 `json:"selected_repository_ids"`
}

// EnterpriseInstallationRepositoriesToggleOptions specifies the parameters for
// EnterpriseService.ToggleInstallationRepositories.
type EnterpriseInstallationRepositoriesToggleOptions struct {
	RepositorySelection   *string `json:"repository_selection,omitempty"` // Can be "all" or "selected"
	SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"`
}

// ListRepositoriesForOrgInstallation 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#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) ListRepositoriesForOrgInstallation(ctx context.Context, enterprise, org string, installationID int64, opts *ListOptions) (*ListRepositories, *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("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var r *ListRepositories
	resp, err := s.client.Do(ctx, req, &r)
	if err != nil {
		return nil, resp, err
	}

	return r, resp, nil
}

// ToggleInstallationRepositories 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#toggle-installation-repository-access-between-selected-and-all-repositories
//

Review comment (suggestion):
This endpoint return this response
```json
{
  "type": "array",
  "items": {
    "title": "Accessible Repository",
    "description": "A repository that may be made accessible to a GitHub App.",
    "type": "object",
    "properties": {
      "id": {
        "description": "Unique identifier of the repository",
        "type": "integer",
        "format": "int64",
        "examples": [
          1
        ]
      },
      "name": {
        "description": "The name of the repository.",
        "type": "string",
        "examples": [
          "Team Environment"
        ]
      },
      "full_name": {
        "type": "string",
        "examples": [
          "octocat/Hello-World"
        ]
      }
    },
    "required": [
      "full_name",
      "id",
      "name"
    ]
  }
}
```
But the function currently returns ListRepositories, which has this struct:

```go
type ListRepositories struct {
	TotalCount   *int          `json:"total_count,omitempty"`
	Repositories []*Repository `json:"repositories"`
}
```
I made a struct named `AccessibleRepository` in [PR #3830](https://github.com/google/go-github/pull/3830), you can re-use it and update this function to return []*AccessibleRepository once my PR is merged.

Code after:
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#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("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var r []*AccessibleRepository
	resp, err := s.client.Do(ctx, 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#toggle-installation-repository-access-between-selected-and-all-repositories
//