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

Code before:
	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
func (s *UsersService) ListPackageVersionsForUser(ctx context.Context, user, packageType, packageName string) ([]*PackageVersion, *Response, error) {
	u := fmt.Sprintf("users/%v/packages/%v/%v/versions", user, packageType, packageName)

	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
}

// PackageGetVersion gets a specific version of a package for a user. Passing the empty string for "user" will
// get the version for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#get-a-package-version-for-a-user
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#get-a-package-version-for-the-authenticated-user
//
//meta:operation GET /user/packages/{package_type}/{package_name}/versions/{package_version_id}
//meta:operation GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}

Review comment (suggestion):
This would be better:
```suggestion
func (s *UsersService) ListUserOwnedPackageVersions(ctx context.Context, user, packageType, packageName string) ([]*PackageVersion, *Response, error) {
```

Or maybe `ListUserPackageVersions`. What do you think?

According to the endpoint's docs:
> Lists package versions for a public package owned by a specified user.

Code after:
	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
}

// ListUserPackageVersions returns package versions for a public package owned by a specified 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
func (s *UsersService) ListUserPackageVersions(ctx context.Context, user, packageType, packageName string) ([]*PackageVersion, *Response, error) {
	u := fmt.Sprintf("users/%v/packages/%v/%v/versions", user, packageType, packageName)

	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
}

// PackageGetVersion gets a specific version of a package for a user. Passing the empty string for "user" will
// get the version for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#get-a-package-version-for-a-user
//
// GitHub API docs: https://docs.github.com/rest/packages/packages#get-a-package-version-for-the-authenticated-user
//
//meta:operation GET /user/packages/{package_type}/{package_name}/versions/{package_version_id}
//meta:operation GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}