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

Code before:
// restore the package for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#restore-a-package-for-a-user
//
// 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)
}

// ListPackageVersionOptions specifies the optional parameters to the UsersService.ListPackageVersions.
type ListPackageVersionOptions 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 *ListPackageVersionOptions) ([]*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)

Review comment (suggestion):
Sorry, one more remark:
```suggestion
type ListPackageVersionsOptions struct {
```

I propose to add also `s` for consistency with other similar structs. So if anyone greps the method `ListPackageVersion` also will find the `Options` struct.

Code after:
// restore the package for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#restore-a-package-for-a-user
//
// 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)