diff --git a/streams/events.go b/streams/events.go new file mode 100644 index 0000000..1bb9916 --- /dev/null +++ b/streams/events.go @@ -0,0 +1,44 @@ +package streams + +// Event represents events sent via the `gerrit stream-events` command, or sent as a webhook. +// It differs slightly from the REST API types, which is why this lives in a separate package. +// Docs: https://gerrit-review.googlesource.com/Documentation/cmd-stream-events.html#events +type Event struct { + Type string `json:"type"` + + Change Change `json:"change"` + PatchSet PatchSet `json:"patchSet"` + + Abandoner Account `json:"abandoner"` + Author Account `json:"author"` + Adder Account `json:"adder"` + Changer Account `json:"changer"` + Deleter Account `json:"deleter"` + Editor Account `json:"editor"` + Restorer Account `json:"restorer"` + Remover Account `json:"remover"` + Reviewer Account `json:"reviewer"` + Submitter Account `json:"submitter"` + Uploader Account `json:"uploader"` + + Reason string `json:"reason,omitempty"` + EventCreatedOn int `json:"eventCreatedOn,omitempty"` + NewRev string `json:"newRev,omitempty"` + Approvals []Approval `json:"approvals,omitempty"` + Comment string `json:"comment,omitempty"` + + Added []string `json:"added,omitempty"` + Removed []string `json:"removed,omitempty"` + Hashtags []string `json:"hashtags,omitempty"` + + ProjectName string `json:"projectName,omitempty"` + ProjectHead string `json:"projectHead,omitempty"` + + RefUpdate RefUpdate `json:"refUpdate"` + RefUpdates []RefUpdate `json:"refUpdates,omitempty"` + + OldTopic string `json:"oldTopic,omitempty"` + + OldHead string `json:"oldHead,omitempty"` + NewHead string `json:"newHead,omitempty"` +} diff --git a/streams/types.go b/streams/types.go new file mode 100644 index 0000000..5048341 --- /dev/null +++ b/streams/types.go @@ -0,0 +1,118 @@ +package streams + +type Change struct { + Project string `json:"project,omitempty"` + Branch string `json:"branch,omitempty"` + Topic string `json:"topic,omitempty"` + ID string `json:"id,omitempty"` + Number string `json:"number,omitempty"` + Subject string `json:"subject,omitempty"` + Owner Account `json:"owner"` + URL string `json:"url,omitempty"` + CommitMessage string `json:"commitMessage,omitempty"` + Hashtags []string `json:"hashtags,omitempty"` + CreatedOn int `json:"createdOn,omitempty"` + LastUpdated int `json:"lastUpdated,omitempty"` + Open bool `json:"open,omitempty"` + Status string `json:"status,omitempty"` + Private bool `json:"private,omitempty"` + Wip bool `json:"wip,omitempty"` + Comments []Message `json:"comments,omitempty"` + TrackingIDs []TrackingID `json:"trackingIds,omitempty"` + CurrentPatchSet PatchSet `json:"currentPatchSet"` + PatchSets []PatchSet `json:"patchSets,omitempty"` + DependsOn []Dependency `json:"dependsOn,omitempty"` + NeededBy []Dependency `json:"neededBy,omitempty"` + SubmitRecords SubmitRecord `json:"submitRecords"` + AllReviewers []Account `json:"allReviewers,omitempty"` +} + +type TrackingID struct { + System string `json:"system,omitempty"` + ID string `json:"id,omitempty"` +} + +type Account struct { + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` + Username string `json:"username,omitempty"` +} + +type PatchSet struct { + Number string `json:"number,omitempty"` + Revision string `json:"revision,omitempty"` + Parents []string `json:"parents,omitempty"` + Ref string `json:"ref,omitempty"` + Uploader Account `json:"uploader"` + Author Account `json:"author"` + CreatedOn int `json:"createdOn,omitempty"` + Kind string `json:"kind,omitempty"` + Approvals Approval `json:"approvals"` + Comments []PatchsetComment `json:"comments,omitempty"` + Files []File `json:"files,omitempty"` + SizeInsertions int `json:"sizeInsertions,omitempty"` + SizeDeletions int `json:"sizeDeletions,omitempty"` +} + +type Approval struct { + Type string `json:"type,omitempty"` + Description string `json:"description,omitempty"` + Value string `json:"value,omitempty"` + OldValue string `json:"oldValue,omitempty"` + GrantedOn int `json:"grantedOn,omitempty"` + By Account `json:"by"` +} + +type RefUpdate struct { + OldRev string `json:"oldRev,omitempty"` + NewRev string `json:"newRev,omitempty"` + RefName string `json:"refName,omitempty"` + Project string `json:"project,omitempty"` +} + +type SubmitRecord struct { + Status string `json:"status,omitempty"` + Labels []Label `json:"labels,omitempty"` + Requirements []Requirement `json:"requirements,omitempty"` +} + +type Requirement struct { + FallbackText string `json:"fallbackText,omitempty"` + Type string `json:"type,omitempty"` + Data interface{} `json:"data,omitempty"` +} + +type Label struct { + Label string `json:"label,omitempty"` + Status string `json:"status,omitempty"` + By Account `json:"by"` +} + +type Dependency struct { + ID string `json:"id,omitempty"` + Number string `json:"number,omitempty"` + Revision string `json:"revision,omitempty"` + Ref string `json:"ref,omitempty"` + IsCurrentPatchSet bool `json:"isCurrentPatchSet,omitempty"` +} + +type Message struct { + Timestamp int `json:"timestamp,omitempty"` + Reviewer Account `json:"reviewer"` + Message string `json:"message,omitempty"` +} + +type PatchsetComment struct { + File string `json:"file,omitempty"` + Line string `json:"line,omitempty"` + Reviewer Account `json:"reviewer"` + Message string `json:"message,omitempty"` +} + +type File struct { + File string `json:"file,omitempty"` + FileOld string `json:"fileOld,omitempty"` + Type string `json:"type,omitempty"` + Insertions int `json:"insertions,omitempty"` + Deletions int `json:"deletions,omitempty"` +}