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

Code before:
// GitHub API docs: https://docs.github.com/rest/packages/packages#restore-a-package-for-the-authenticated-user
//
//meta:operation POST /user/packages/{package_type}/{package_name}/restore
//meta:operation POST /users/{username}/packages/{package_type}/{package_name}/restore
func (s *UsersService) RestorePackage(ctx context.Context, user, packageType, packageName string) (*Response, error) {
	var u string
	if user != "" {
		u = fmt.Sprintf("users/%v/packages/%v/%v/restore", user, packageType, packageName)
	} else {
		u = fmt.Sprintf("user/packages/%v/%v/restore", packageType, packageName)
	}

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

	return s.client.Do(ctx, req, nil)
}

// ListPackageVersions gets all versions of a package for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-the-authenticated-user
//
//meta:operation GET /user/packages/{package_type}/{package_name}/versions
func (s *UsersService) ListPackageVersions(ctx context.Context, packageType, packageName string, opts *PackageListOptions) ([]*PackageVersion, *Response, error) {
	u := fmt.Sprintf("user/packages/%v/%v/versions", packageType, packageName)
	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 versions []*PackageVersion
	resp, err := s.client.Do(ctx, req, &versions)
	if err != nil {
		return nil, resp, err
	}

	return versions, resp, nil
}

// ListPackageVersionsForUser gets all versions of a package for a user.
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-a-user
//
//meta:operation GET /users/{username}/packages/{package_type}/{package_name}/versions

Review comment (suggestion):
This endpoint method accept following query parameters according to docs
<img width="599" height="470" alt="Image" src="https://github.com/user-attachments/assets/9967d629-c421-4cf5-a833-0e83a37e1e6c" />

but currently it's `opts` field have some extra parameters
https://github.com/google/go-github/blob/e3c4fb576edf192e734c2307fb81cb55d11612cb/github/packages.go#L185-L197

should I make a new `opts` struct for it? like :
```go
type PackageVersionListOptions struct {
	// State of package either "active" or "deleted".
	State *string `url:"state,omitempty"`

	ListOptions
}
```

Code after:
// GitHub API docs: https://docs.github.com/rest/packages/packages#restore-a-package-for-the-authenticated-user
//
//meta:operation POST /user/packages/{package_type}/{package_name}/restore
//meta:operation POST /users/{username}/packages/{package_type}/{package_name}/restore
func (s *UsersService) RestorePackage(ctx context.Context, user, packageType, packageName string) (*Response, error) {
	var u string
	if user != "" {
		u = fmt.Sprintf("users/%v/packages/%v/%v/restore", user, packageType, packageName)
	} else {
		u = fmt.Sprintf("user/packages/%v/%v/restore", packageType, packageName)
	}

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

	return s.client.Do(ctx, req, nil)
}

// ListPackageVersionsOptions specifies the optional parameters to the UsersService.ListPackageVersions.
type ListPackageVersionsOptions struct {
	// State of package either "active" or "deleted".
	State string `url:"state,omitempty"`

	ListOptions
}

// ListPackageVersions gets all versions of a package for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-the-authenticated-user
//
//meta:operation GET /user/packages/{package_type}/{package_name}/versions
func (s *UsersService) ListPackageVersions(ctx context.Context, packageType, packageName string, opts *ListPackageVersionsOptions) ([]*PackageVersion, *Response, error) {
	u := fmt.Sprintf("user/packages/%v/%v/versions", packageType, packageName)
	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 versions []*PackageVersion
	resp, err := s.client.Do(ctx, req, &versions)
	if err != nil {
		return nil, resp, err
	}