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

Code before:
type SubIssue Issue

func (i SubIssue) String() string {
	return Stringify(i)
}

// SubIssueListByIssueOptions specifies the optional parameters to the
// SubIssueService.ListByIssue method.
type SubIssueListByIssueOptions struct {
	IssueListByRepoOptions
}

// SubIssueRequest represents a request to add, remove, or reprioritize sub-issues.
type SubIssueRequest struct {
	SubIssueID    int64  `json:"sub_issue_id"`             // Required: The ID of the sub-issue
	AfterID       *int64 `json:"after_id,omitempty"`       // Optional: Position after this sub-issue ID
	BeforeID      *int64 `json:"before_id,omitempty"`      // Optional: Position before this sub-issue ID
	ReplaceParent *bool  `json:"replace_parent,omitempty"` // Optional: Whether to replace the existing parent
}

// Remove a sub-issue from the specified repository.
//
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#remove-sub-issue
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/sub_issue
func (s *SubIssueService) Remove(ctx context.Context, owner, repo string, subIssueNumber int64, subIssue *SubIssueRequest) (*SubIssue, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, subIssueNumber)

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

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeV3)

	si := new(SubIssue)
	resp, err := s.client.Do(ctx, req, si)
	if err != nil {
		return nil, resp, err
	}

	return si, resp, nil
}

// ListByIssue lists all sub-issues for the specified issue.
//
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#list-sub-issues
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
func (s *SubIssueService) ListByIssue(ctx context.Context, owner, repo string, issueNumber int64, opts *IssueListOptions) ([]*SubIssue, *Response, error) {

Review comment (suggestion):
Since `SubIssueID` is a required field, the `subIssue` parameter should be passed by value instead of by reference (so that it cannot be `nil`):

```suggestion
func (s *SubIssueService) Remove(ctx context.Context, owner, repo string, subIssueNumber int64, subIssue SubIssueRequest) (*SubIssue, *Response, error) {
```

Code after:
type SubIssue Issue

func (i SubIssue) String() string {
	return Stringify(i)
}

// SubIssueListByIssueOptions specifies the optional parameters to the
// SubIssueService.ListByIssue method.
type SubIssueListByIssueOptions struct {
	IssueListByRepoOptions
}

// SubIssueRequest represents a request to add, remove, or reprioritize sub-issues.
type SubIssueRequest struct {
	SubIssueID    int64  `json:"sub_issue_id"`             // Required: The ID of the sub-issue
	AfterID       *int64 `json:"after_id,omitempty"`       // Optional: Position after this sub-issue ID
	BeforeID      *int64 `json:"before_id,omitempty"`      // Optional: Position before this sub-issue ID
	ReplaceParent *bool  `json:"replace_parent,omitempty"` // Optional: Whether to replace the existing parent
}

// Remove a sub-issue from the specified repository.
//
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#remove-sub-issue
//
//meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/sub_issue
func (s *SubIssueService) Remove(ctx context.Context, owner, repo string, subIssueNumber int64, subIssue SubIssueRequest) (*SubIssue, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, subIssueNumber)

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

	si := new(SubIssue)
	resp, err := s.client.Do(ctx, req, si)
	if err != nil {
		return nil, resp, err
	}

	return si, resp, nil
}

// ListByIssue lists all sub-issues for the specified issue.
//
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#list-sub-issues
//
//meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
func (s *SubIssueService) ListByIssue(ctx context.Context, owner, repo string, issueNumber int64, opts *IssueListOptions) ([]*SubIssue, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, issueNumber)
	u, err := addOptions(u, opts)
	if err != nil {