github.com/google/go-github/v69@v69.2.0/github/issues_timeline.go (about) 1 // Copyright 2016 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "context" 10 "fmt" 11 "strings" 12 ) 13 14 // Timeline represents an event that occurred around an Issue or Pull Request. 15 // 16 // It is similar to an IssueEvent but may contain more information. 17 // GitHub API docs: https://docs.github.com/developers/webhooks-and-events/events/issue-event-types 18 type Timeline struct { 19 ID *int64 `json:"id,omitempty"` 20 URL *string `json:"url,omitempty"` 21 CommitURL *string `json:"commit_url,omitempty"` 22 23 // The User object that generated the event. 24 Actor *User `json:"actor,omitempty"` 25 26 // The person who commented on the issue. 27 User *User `json:"user,omitempty"` 28 29 // The person who authored the commit. 30 Author *CommitAuthor `json:"author,omitempty"` 31 // The person who committed the commit on behalf of the author. 32 Committer *CommitAuthor `json:"committer,omitempty"` 33 // The SHA of the commit in the pull request. 34 SHA *string `json:"sha,omitempty"` 35 // The commit message. 36 Message *string `json:"message,omitempty"` 37 // A list of parent commits. 38 Parents []*Commit `json:"parents,omitempty"` 39 40 // Event identifies the actual type of Event that occurred. Possible values 41 // are: 42 // 43 // assigned 44 // The issue was assigned to the assignee. 45 // 46 // closed 47 // The issue was closed by the actor. When the commit_id is present, it 48 // identifies the commit that closed the issue using "closes / fixes #NN" 49 // syntax. 50 // 51 // commented 52 // A comment was added to the issue. 53 // 54 // committed 55 // A commit was added to the pull request's 'HEAD' branch. Only provided 56 // for pull requests. 57 // 58 // cross-referenced 59 // The issue was referenced from another issue. The 'source' attribute 60 // contains the 'id', 'actor', and 'url' of the reference's source. 61 // 62 // demilestoned 63 // The issue was removed from a milestone. 64 // 65 // head_ref_deleted 66 // The pull request's branch was deleted. 67 // 68 // head_ref_restored 69 // The pull request's branch was restored. 70 // 71 // labeled 72 // A label was added to the issue. 73 // 74 // locked 75 // The issue was locked by the actor. 76 // 77 // mentioned 78 // The actor was @mentioned in an issue body. 79 // 80 // merged 81 // The issue was merged by the actor. The 'commit_id' attribute is the 82 // SHA1 of the HEAD commit that was merged. 83 // 84 // milestoned 85 // The issue was added to a milestone. 86 // 87 // referenced 88 // The issue was referenced from a commit message. The 'commit_id' 89 // attribute is the commit SHA1 of where that happened. 90 // 91 // renamed 92 // The issue title was changed. 93 // 94 // reopened 95 // The issue was reopened by the actor. 96 // 97 // reviewed 98 // The pull request was reviewed. 99 // 100 // review_requested 101 // The actor requested a review from a user or team. 102 // Reviewer and Requester/RequestedTeam will be populated. 103 // 104 // review_request_removed 105 // The actor removed a review request from a user or team. 106 // Reviewer and Requester/RequestedTeam will be populated. 107 // 108 // subscribed 109 // The actor subscribed to receive notifications for an issue. 110 // 111 // unassigned 112 // The assignee was unassigned from the issue. 113 // 114 // unlabeled 115 // A label was removed from the issue. 116 // 117 // unlocked 118 // The issue was unlocked by the actor. 119 // 120 // unsubscribed 121 // The actor unsubscribed to stop receiving notifications for an issue. 122 // 123 Event *string `json:"event,omitempty"` 124 125 // The string SHA of a commit that referenced this Issue or Pull Request. 126 CommitID *string `json:"commit_id,omitempty"` 127 // The timestamp indicating when the event occurred. 128 CreatedAt *Timestamp `json:"created_at,omitempty"` 129 // The Label object including `name` and `color` attributes. Only provided for 130 // 'labeled' and 'unlabeled' events. 131 Label *Label `json:"label,omitempty"` 132 // The User object which was assigned to (or unassigned from) this Issue or 133 // Pull Request. Only provided for 'assigned' and 'unassigned' events. 134 Assignee *User `json:"assignee,omitempty"` 135 Assigner *User `json:"assigner,omitempty"` 136 137 // The Milestone object including a 'title' attribute. 138 // Only provided for 'milestoned' and 'demilestoned' events. 139 Milestone *Milestone `json:"milestone,omitempty"` 140 // The 'id', 'actor', and 'url' for the source of a reference from another issue. 141 // Only provided for 'cross-referenced' events. 142 Source *Source `json:"source,omitempty"` 143 // An object containing rename details including 'from' and 'to' attributes. 144 // Only provided for 'renamed' events. 145 Rename *Rename `json:"rename,omitempty"` 146 // The state of a submitted review. Can be one of: 'commented', 147 // 'changes_requested' or 'approved'. 148 // Only provided for 'reviewed' events. 149 State *string `json:"state,omitempty"` 150 151 // The person requested to review the pull request. 152 Reviewer *User `json:"requested_reviewer,omitempty"` 153 // RequestedTeam contains the team requested to review the pull request. 154 RequestedTeam *Team `json:"requested_team,omitempty"` 155 // The person who requested a review. 156 Requester *User `json:"review_requester,omitempty"` 157 158 // The review summary text. 159 Body *string `json:"body,omitempty"` 160 SubmittedAt *Timestamp `json:"submitted_at,omitempty"` 161 162 PerformedViaGithubApp *App `json:"performed_via_github_app,omitempty"` 163 } 164 165 // Source represents a reference's source. 166 type Source struct { 167 ID *int64 `json:"id,omitempty"` 168 URL *string `json:"url,omitempty"` 169 Actor *User `json:"actor,omitempty"` 170 Type *string `json:"type,omitempty"` 171 Issue *Issue `json:"issue,omitempty"` 172 } 173 174 // ListIssueTimeline lists events for the specified issue. 175 // 176 // GitHub API docs: https://docs.github.com/rest/issues/timeline#list-timeline-events-for-an-issue 177 // 178 //meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/timeline 179 func (s *IssuesService) ListIssueTimeline(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Timeline, *Response, error) { 180 u := fmt.Sprintf("repos/%v/%v/issues/%v/timeline", owner, repo, number) 181 u, err := addOptions(u, opts) 182 if err != nil { 183 return nil, nil, err 184 } 185 186 req, err := s.client.NewRequest("GET", u, nil) 187 if err != nil { 188 return nil, nil, err 189 } 190 191 // TODO: remove custom Accept header when this API fully launches. 192 acceptHeaders := []string{mediaTypeTimelinePreview, mediaTypeProjectCardDetailsPreview} 193 req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) 194 195 var events []*Timeline 196 resp, err := s.client.Do(ctx, req, &events) 197 if err != nil { 198 return nil, resp, err 199 } 200 201 return events, resp, nil 202 }