1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Events are emitted by Github Hooks.
17 # See <https://developer.github.com/v3/activity/events/types/>
28 # Event ID from Github.
29 var id
: nullable String is writable
31 # Action performed by the event.
32 var action
: nullable String is writable
34 # Repo where this event occured.
35 var repo
: Repo is writable
38 # Triggered when a commit comment is created.
39 class CommitCommentEvent
43 # The `Comment` itself.
44 var comment
: CommitComment is writable
47 # Triggered when a repository, branch, or tag is created.
52 # Oject type that was created.
54 # Can be one of `repository`, `branch`, or `tag`.
55 var ref_type
: String is writable
57 # Git ref (or null if only a repository was created).
58 var ref
: String is writable
60 # Name of the repo's default branch (usually master).
61 var master_branch
: String is writable
63 # Repo's current description.
64 var description
: nullable String is writable
67 # Triggered when a branch or a tag is deleted.
72 # Object type that was deleted.
74 # Can be one of `repository`, `branch`, or `tag`.
75 var ref_type
: String is writable
77 # Git ref (or null if only a repository was deleted).
78 var ref
: String is writable
81 # Triggered when a new snapshot is deployed.
83 # Deployement are mainly used with integration testing servers.
88 # Commit SHA for which this deployment was created.
89 var sha
: String is writable
91 # Name of repository for this deployment, formatted as :owner/:repo.
92 var name
: String is writable
94 # Optional extra information for this deployment.
95 var payload
: nullable String is writable
97 # Optional environment to deploy to.
98 # Default: "production"
99 var environment
: nullable String is writable
101 # Optional human-readable description added to the deployment.
102 var description
: nullable String is writable
105 # Triggered when a deployement's status changes.
106 class DeploymentStatusEvent
110 # New deployment state.
112 # Can be `pending`, `success`, `failure`, or `error`.
113 var state
: String is writable
115 # Optional link added to the status.
116 var target_url
: nullable String is writable
118 # Deployment hash that this status is associated with.
119 var deployment
: String is writable
121 # Optional human-readable description added to the status.
122 var description
: nullable String is writable
125 # Triggered when a user forks a repository.
130 # Created repository.
131 var forkee
: Repo is writable
134 # Triggered when an issue comment is created.
135 class IssueCommentEvent
139 # `Issue` the comment belongs to.
140 var issue
: Issue is writable
142 # The `Comment` itself.
143 var comment
: IssueComment is writable
146 # Triggered when an event occurs on an issue.
148 # Triggered when an issue is assigned, unassigned, labeled, unlabeled,
149 # opened, closed or reopened.
154 # The `Issue` itself.
155 var issue
: Issue is writable
157 # Optional `Label` that was added or removed from the issue.
158 var lbl
: nullable Label is writable, serialize_as
("label")
160 # Optional `User` that was assigned or unassigned from the issue.
161 var assignee
: nullable User is writable
164 # Triggered when a user is added as a collaborator to a repository.
169 # `User` that was added.
170 var member
: User is writable
173 # Triggered when an event occurs on a pull request.
175 # Triggered when a pull request is assigned, unassigned,
176 # labeled, unlabeled, opened, closed, reopened, or synchronized.
177 class PullRequestEvent
181 # The pull request number.
182 var number
: Int is writable
184 # The `PullRequest` itself.
185 var pull
: PullRequest is writable
188 # Triggered when a comment is created on a pull request diff.
189 class PullRequestReviewCommentEvent
193 # The `Comment` itself.
194 var comment
: ReviewComment is writable
196 # `PullRequest` the `comment` belongs to.
197 var pull
: PullRequest is writable
200 # Triggered when a repository branch is pushed to.
205 # SHA of the HEAD commit on the repository.
206 var head_commit
: Commit is writable
208 # Full Git ref that was pushed.
210 # Example: “refs/heads/master”
211 var ref
: String is writable
213 # Number of commits in the push.
214 var size
: nullable Int is writable
216 # Array of pushed commits.
217 var commits
= new Array[Commit] is writable, optional
220 # Triggered when the status of a Git commit changes.
225 # The `Commit` itself.
226 var sha
: String is writable
230 # Can be `pending`, `success`, `failure`, or `error`.
231 var state
: String is writable
233 # Optional human-readable description added to the status.
234 var description
: nullable String is writable
236 # Optional link added to the status.
237 var target_url
: nullable String is writable
239 # Array of branches containing the status' SHA.
241 # Each branch contains the given SHA,
242 # but the SHA may or may not be the head of the branch.
244 # The array includes a maximum of 10 branches.
245 var branches
= new Array[Branch] is writable, optional
248 redef class GithubDeserializer
250 redef fun class_name_heuristic
(json_object
) do
251 if json_object
.has_key
("action") and json_object
.has_key
("commit") and json_object
.has_key
("comment") then
252 return "CommitCommentEvent"
253 else if json_object
.has_key
("ref") and json_object
.has_key
("master_branch") then
255 else if json_object
.has_key
("ref") and json_object
.has_key
("ref_type") then
257 else if json_object
.has_key
("action") and json_object
.has_key
("sha") then
258 return "DeploymentEvent"
259 else if json_object
.has_key
("action") and json_object
.has_key
("state") then
260 return "DeploymentStatusEvent"
261 else if json_object
.has_key
("action") and json_object
.has_key
("forkee") then
263 else if json_object
.has_key
("action") and json_object
.has_key
("issue") and json_object
.has_key
("comment") then
264 return "IssueCommentEvent"
265 else if json_object
.has_key
("action") and json_object
.has_key
("issue") then
267 else if json_object
.has_key
("action") and json_object
.has_key
("member") then
269 else if json_object
.has_key
("action") and json_object
.has_key
("number") then
270 return "PullRequestEvent"
271 else if json_object
.has_key
("action") and json_object
.has_key
("pull") and json_object
.has_key
("comment") then
272 return "PullRequestReviewCommentEvent"
273 else if json_object
.has_key
("head_commit") and json_object
.has_key
("commits") then
275 else if json_object
.has_key
("action") and json_object
.has_key
("branches") then
277 else if json_object
.has_key
("action") and json_object
.has_key
("issue") then