github.com/go-playground/webhooks/v6@v6.3.0/bitbucket-server/payload.go (about) 1 package bitbucketserver 2 3 import ( 4 "fmt" 5 "strings" 6 "time" 7 ) 8 9 type DiagnosticsPingPayload struct{} 10 11 type RepositoryReferenceChangedPayload struct { 12 Date Date `json:"date"` 13 EventKey Event `json:"eventKey"` 14 Actor User `json:"actor"` 15 Repository Repository `json:"repository"` 16 Changes []RepositoryChange `json:"changes"` 17 } 18 19 type RepositoryModifiedPayload struct { 20 Date Date `json:"date"` 21 EventKey Event `json:"eventKey"` 22 Actor User `json:"actor"` 23 Old Repository `json:"old"` 24 New Repository `json:"new"` 25 } 26 27 type RepositoryForkedPayload struct { 28 Date Date `json:"date"` 29 EventKey Event `json:"eventKey"` 30 Actor User `json:"actor"` 31 Repository Repository `json:"repository"` 32 } 33 34 type RepositoryCommentAddedPayload struct { 35 Date Date `json:"date"` 36 EventKey Event `json:"eventKey"` 37 Actor User `json:"actor"` 38 Comment Comment `json:"comment"` 39 Repository Repository `json:"repository"` 40 Commit string `json:"commit"` 41 } 42 43 type RepositoryCommentEditedPayload struct { 44 Date Date `json:"date"` 45 EventKey Event `json:"eventKey"` 46 Actor User `json:"actor"` 47 Comment Comment `json:"comment"` 48 PreviousComment string `json:"previousComment"` 49 Repository Repository `json:"repository"` 50 Commit string `json:"commit"` 51 } 52 53 type RepositoryCommentDeletedPayload struct { 54 Date Date `json:"date"` 55 EventKey Event `json:"eventKey"` 56 Actor User `json:"actor"` 57 Comment Comment `json:"comment"` 58 Repository Repository `json:"repository"` 59 Commit string `json:"commit"` 60 } 61 62 type PullRequestOpenedPayload struct { 63 Date Date `json:"date"` 64 EventKey Event `json:"eventKey"` 65 Actor User `json:"actor"` 66 PullRequest PullRequest `json:"pullRequest"` 67 } 68 69 type PullRequestFromReferenceUpdatedPayload struct { 70 Date Date `json:"date"` 71 EventKey Event `json:"eventKey"` 72 Actor User `json:"actor"` 73 PullRequest PullRequest `json:"pullRequest"` 74 PreviousFromHash string `json:"previousFromHash"` 75 } 76 77 type PullRequestModifiedPayload struct { 78 Date Date `json:"date"` 79 EventKey Event `json:"eventKey"` 80 Actor User `json:"actor"` 81 PullRequest PullRequest `json:"pullRequest"` 82 PreviousTitle string `json:"previousTitle"` 83 PreviousDescription string `json:"previousDescription"` 84 PreviousTarget map[string]interface{} `json:"previousTarget"` 85 } 86 87 type PullRequestMergedPayload struct { 88 Date Date `json:"date"` 89 EventKey Event `json:"eventKey"` 90 Actor User `json:"actor"` 91 PullRequest PullRequest `json:"pullRequest"` 92 } 93 94 type PullRequestDeclinedPayload struct { 95 Date Date `json:"date"` 96 EventKey Event `json:"eventKey"` 97 Actor User `json:"actor"` 98 PullRequest PullRequest `json:"pullRequest"` 99 } 100 101 type PullRequestDeletedPayload struct { 102 Date Date `json:"date"` 103 EventKey Event `json:"eventKey"` 104 Actor User `json:"actor"` 105 PullRequest PullRequest `json:"pullRequest"` 106 } 107 108 type PullRequestReviewerUpdatedPayload struct { 109 Date Date `json:"date"` 110 EventKey Event `json:"eventKey"` 111 Actor User `json:"actor"` 112 PullRequest PullRequest `json:"pullRequest"` 113 RemovedReviewers []User `json:"removedReviewers"` 114 AddedReviewers []User `json:"addedReviewers"` 115 } 116 117 type PullRequestReviewerApprovedPayload struct { 118 Date Date `json:"date"` 119 EventKey Event `json:"eventKey"` 120 Actor User `json:"actor"` 121 PullRequest PullRequest `json:"pullRequest"` 122 Participant PullRequestParticipant `json:"participant"` 123 PreviousStatus string `json:"previousStatus"` 124 } 125 126 type PullRequestReviewerUnapprovedPayload struct { 127 Date Date `json:"date"` 128 EventKey Event `json:"eventKey"` 129 Actor User `json:"actor"` 130 PullRequest PullRequest `json:"pullRequest"` 131 Participant PullRequestParticipant `json:"participant"` 132 PreviousStatus string `json:"previousStatus"` 133 } 134 135 type PullRequestReviewerNeedsWorkPayload struct { 136 Date Date `json:"date"` 137 EventKey Event `json:"eventKey"` 138 Actor User `json:"actor"` 139 PullRequest PullRequest `json:"pullRequest"` 140 Participant PullRequestParticipant `json:"participant"` 141 PreviousStatus string `json:"previousStatus"` 142 } 143 144 type PullRequestCommentAddedPayload struct { 145 Date Date `json:"date"` 146 EventKey Event `json:"eventKey"` 147 Actor User `json:"actor"` 148 PullRequest PullRequest `json:"pullRequest"` 149 Comment Comment `json:"comment"` 150 CommentParentID uint64 `json:"commentParentId,omitempty"` 151 } 152 153 type PullRequestCommentEditedPayload struct { 154 Date Date `json:"date"` 155 EventKey Event `json:"eventKey"` 156 Actor User `json:"actor"` 157 PullRequest PullRequest `json:"pullRequest"` 158 Comment Comment `json:"comment"` 159 CommentParentID string `json:"commentParentId,omitempty"` 160 PreviousComment string `json:"previousComment"` 161 } 162 163 type PullRequestCommentDeletedPayload struct { 164 Date Date `json:"date"` 165 EventKey Event `json:"eventKey"` 166 Actor User `json:"actor"` 167 PullRequest PullRequest `json:"pullRequest"` 168 Comment Comment `json:"comment"` 169 CommentParentID uint64 `json:"commentParentId,omitempty"` 170 } 171 172 // ----------------------- 173 174 type User struct { 175 ID uint64 `json:"id"` 176 Name string `json:"name"` 177 EmailAddress string `json:"emailAddress"` 178 DisplayName string `json:"displayName"` 179 Active bool `json:"active"` 180 Slug string `json:"slug"` 181 Type string `json:"type"` 182 Links map[string]interface{} `json:"links"` 183 } 184 185 type Repository struct { 186 ID uint64 `json:"id"` 187 Slug string `json:"slug"` 188 Name string `json:"name"` 189 ScmID string `json:"scmId"` 190 State string `json:"state"` 191 StatusMessage string `json:"statusMessage"` 192 Forkable bool `json:"forkable"` 193 Origin *Repository `json:"origin,omitempty"` 194 Project Project `json:"project"` 195 Public bool `json:"public"` 196 Links map[string]interface{} `json:"links"` 197 } 198 199 type Project struct { 200 ID uint64 `json:"id"` 201 Key string `json:"key"` 202 Name string `json:"name"` 203 Type string `json:"type"` 204 Public *bool `json:"public,omitempty"` 205 Owner User `json:"owner"` 206 Links map[string]interface{} `json:"links"` 207 } 208 209 type PullRequest struct { 210 ID uint64 `json:"id"` 211 Version uint64 `json:"version"` 212 Title string `json:"title"` 213 Description string `json:"description,omitempty"` 214 State string `json:"state"` 215 Open bool `json:"open"` 216 Closed bool `json:"closed"` 217 CreatedDate uint64 `json:"createdDate"` 218 UpdatedDate uint64 `json:"updatedDate,omitempty"` 219 ClosedDate uint64 `json:"closedDate,omitempty"` 220 FromRef RepositoryReference `json:"fromRef"` 221 ToRef RepositoryReference `json:"toRef"` 222 Locked bool `json:"locked"` 223 Author PullRequestParticipant `json:"author"` 224 Reviewers []PullRequestParticipant `json:"reviewers"` 225 Participants []PullRequestParticipant `json:"participants"` 226 Properties map[string]interface{} `json:"properties,omitempty"` 227 Links map[string]interface{} `json:"links"` 228 } 229 230 type RepositoryChange struct { 231 Reference RepositoryReference `json:"ref"` 232 ReferenceID string `json:"refId"` 233 FromHash string `json:"fromHash"` 234 ToHash string `json:"toHash"` 235 Type string `json:"type"` 236 } 237 238 type RepositoryReference struct { 239 ID string `json:"id"` 240 DisplayID string `json:"displayId"` 241 Type string `json:"type,omitempty"` 242 LatestCommit string `json:"latestCommit,omitempty"` 243 Repository Repository `json:"repository,omitempty"` 244 } 245 246 type Comment struct { 247 ID uint64 `json:"id"` 248 Properties map[string]interface{} `json:"properties,omitempty"` 249 Version uint64 `json:"version"` 250 Text string `json:"text"` 251 Author User `json:"author"` 252 CreatedDate uint64 `json:"createdDate"` 253 UpdatedDate uint64 `json:"updatedDate"` 254 Comments []map[string]interface{} `json:"comments"` 255 Tasks []map[string]interface{} `json:"tasks"` 256 PermittedOperations map[string]interface{} `json:"permittedOperations,omitempty"` 257 } 258 259 type PullRequestParticipant struct { 260 User User `json:"user"` 261 LastReviewedCommit string `json:"lastReviewedCommit,omitempty"` 262 Role string `json:"role"` 263 Approved bool `json:"approved"` 264 Status string `json:"status"` 265 } 266 267 type Date time.Time 268 269 func (b *Date) UnmarshalJSON(p []byte) error { 270 t, err := time.Parse("2006-01-02T15:04:05Z0700", strings.Replace(string(p), "\"", "", -1)) 271 if err != nil { 272 return err 273 } 274 *b = Date(t) 275 return nil 276 } 277 278 func (b Date) MarshalJSON() ([]byte, error) { 279 stamp := fmt.Sprintf("\"%s\"", time.Time(b).Format("2006-01-02T15:04:05Z0700")) 280 return []byte(stamp), nil 281 }