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

Code before:
//meta:operation GET /orgs/{org}/personal-access-tokens
func (s *OrganizationsService) ListFineGrainedPersonalAccessTokens(ctx context.Context, org string, opts *ListFineGrainedPATOptions) ([]*PersonalAccessToken, *Response, error) {
	u := fmt.Sprintf("orgs/%v/personal-access-tokens", org)
	// The `owner` parameter is a special case that uses the `owner[]=...` format and needs a custom function to format it correctly.
	u, err := addListFineGrainedPATOptions(u, opts)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, opts)
	if err != nil {
		return nil, nil, err
	}

	var pats []*PersonalAccessToken

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

	return pats, resp, nil
}

// FineGrainedPersonalAccessTokenRequests represents the details of a request to access organization resources via a fine-grained personal access token.
type FineGrainedPersonalAccessTokenRequests struct {
	// Unique identifier of the request for access via fine-grained personal access token.
	ID *int64 `json:"id,omitempty"`

	// Reason is the reason for the request.
	Reason *string `json:"reason,omitempty"`

	// Owner is the GitHub user associated with the token.
	Owner *User `json:"owner,omitempty"`

	// RepositorySelection is the type of repository selection requested.
	// Possible values are: "none", "all", "subset".
	RepositorySelection *string `json:"repository_selection,omitempty"`

	// URL to the list of repositories the fine-grained personal access token can access.
	// Only follow when `repository_selection` is `subset`.
	RepositoriesURL *string `json:"repositories_url,omitempty"`

	// Permissions are the permissions requested, categorized by type.
	Permissions *PersonalAccessTokenPermissions `json:"permissions,omitempty"`

	// Date and time when the request was created.
	CreatedAt *Timestamp `json:"created_at,omitempty"`

	// Whether the associated fine-grained personal access token has expired.
	TokenExpired *bool `json:"token_expired,omitempty"`

Review comment (suggestion):
```suggestion
type FineGrainedPersonalAccessTokenRequest struct {
```

The API may be called _"personal-access-token-requests"_ but it returns an array(and GitHub's naming isn't exactly well thought through).

CC @alexandear 


Code after:
//
// GitHub API docs: https://docs.github.com/rest/orgs/personal-access-tokens#list-fine-grained-personal-access-tokens-with-access-to-organization-resources
//
//meta:operation GET /orgs/{org}/personal-access-tokens
func (s *OrganizationsService) ListFineGrainedPersonalAccessTokens(ctx context.Context, org string, opts *ListFineGrainedPATOptions) ([]*PersonalAccessToken, *Response, error) {
	u := fmt.Sprintf("orgs/%v/personal-access-tokens", org)
	// The `owner` parameter is a special case that uses the `owner[]=...` format and needs a custom function to format it correctly.
	u, err := addListFineGrainedPATOptions(u, opts)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, opts)
	if err != nil {
		return nil, nil, err
	}

	var pats []*PersonalAccessToken

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

	return pats, resp, nil
}

// FineGrainedPersonalAccessTokenRequest represents the details of a request to access organization resources via a fine-grained personal access token.
type FineGrainedPersonalAccessTokenRequest struct {
	// Unique identifier of the request for access via fine-grained personal access token.
	ID int64 `json:"id"`

	// Reason is the reason for the request.
	Reason string `json:"reason"`

	// Owner is the GitHub user associated with the token.
	Owner User `json:"owner"`

	// RepositorySelection is the type of repository selection requested.
	// Possible values are: "none", "all", "subset".
	RepositorySelection string `json:"repository_selection"`

	// URL to the list of repositories the fine-grained personal access token can access.
	// Only follow when `repository_selection` is `subset`.
	RepositoriesURL string `json:"repositories_url"`

	// Permissions are the permissions requested, categorized by type.
	Permissions PersonalAccessTokenPermissions `json:"permissions"`

	// Date and time when the request was created.
	CreatedAt *Timestamp `json:"created_at"`