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/>
27 # Event ID from Github.
28 var id
: nullable String is writable
30 # Action performed by the event.
31 var action
: nullable String is writable
33 # Repo where this event occured.
34 var repo
: Repo is writable
37 # Triggered when a commit comment is created.
38 class CommitCommentEvent
42 # The `Comment` itself.
43 var comment
: CommitComment is writable
46 # Triggered when a repository, branch, or tag is created.
51 # Oject type that was created.
53 # Can be one of `repository`, `branch`, or `tag`.
54 var ref_type
: String is writable
56 # Git ref (or null if only a repository was created).
57 var ref
: String is writable
59 # Name of the repo's default branch (usually master).
60 var master_branch
: String is writable
62 # Repo's current description.
63 var description
: nullable String is writable
66 # Triggered when a branch or a tag is deleted.
71 # Object type that was deleted.
73 # Can be one of `repository`, `branch`, or `tag`.
74 var ref_type
: String is writable
76 # Git ref (or null if only a repository was deleted).
77 var ref
: String is writable
80 # Triggered when a new snapshot is deployed.
82 # Deployement are mainly used with integration testing servers.
87 # Commit SHA for which this deployment was created.
88 var sha
: String is writable
90 # Name of repository for this deployment, formatted as :owner/:repo.
91 var name
: String is writable
93 # Optional extra information for this deployment.
94 var payload
: nullable String is writable
96 # Optional environment to deploy to.
97 # Default: "production"
98 var environment
: nullable String is writable
100 # Optional human-readable description added to the deployment.
101 var description
: nullable String is writable
104 # Triggered when a deployement's status changes.
105 class DeploymentStatusEvent
109 # New deployment state.
111 # Can be `pending`, `success`, `failure`, or `error`.
112 var state
: String is writable
114 # Optional link added to the status.
115 var target_url
: nullable String is writable
117 # Deployment hash that this status is associated with.
118 var deployment
: String is writable
120 # Optional human-readable description added to the status.
121 var description
: nullable String is writable
124 # Triggered when a user forks a repository.
129 # Created repository.
130 var forkee
: Repo is writable
133 # Triggered when an issue comment is created.
134 class IssueCommentEvent
138 # `Issue` the comment belongs to.
139 var issue
: Issue is writable
141 # The `Comment` itself.
142 var comment
: IssueComment is writable
145 # Triggered when an event occurs on an issue.
147 # Triggered when an issue is assigned, unassigned, labeled, unlabeled,
148 # opened, closed or reopened.
153 # The `Issue` itself.
154 var issue
: Issue is writable
156 # Optional `Label` that was added or removed from the issue.
157 var lbl
: nullable Label is writable, serialize_as
("label")
159 # Optional `User` that was assigned or unassigned from the issue.
160 var assignee
: nullable User is writable
163 # Triggered when a user is added as a collaborator to a repository.
168 # `User` that was added.
169 var member
: User is writable
172 # Triggered when an event occurs on a pull request.
174 # Triggered when a pull request is assigned, unassigned,
175 # labeled, unlabeled, opened, closed, reopened, or synchronized.
176 class PullRequestEvent
180 # The pull request number.
181 var number
: Int is writable
183 # The `PullRequest` itself.
184 var pull
: PullRequest is writable
187 # Triggered when a comment is created on a pull request diff.
188 class PullRequestReviewCommentEvent
192 # The `Comment` itself.
193 var comment
: ReviewComment is writable
195 # `PullRequest` the `comment` belongs to.
196 var pull
: PullRequest is writable
199 # Triggered when a repository branch is pushed to.
204 # SHA of the HEAD commit on the repository.
205 var head_commit
: Commit is writable
207 # Full Git ref that was pushed.
209 # Example: “refs/heads/master”
210 var ref
: String is writable
212 # Number of commits in the push.
213 var size
: nullable Int is writable
215 # Array of pushed commits.
216 var commits
= new Array[Commit] is writable, optional
219 # Triggered when the status of a Git commit changes.
224 # The `Commit` itself.
225 var sha
: String is writable
229 # Can be `pending`, `success`, `failure`, or `error`.
230 var state
: String is writable
232 # Optional human-readable description added to the status.
233 var description
: nullable String is writable
235 # Optional link added to the status.
236 var target_url
: nullable String is writable
238 # Array of branches containing the status' SHA.
240 # Each branch contains the given SHA,
241 # but the SHA may or may not be the head of the branch.
243 # The array includes a maximum of 10 branches.
244 var branches
= new Array[Branch] is writable, optional
247 redef class GithubDeserializer
249 redef fun class_name_heuristic
(json_object
) do
250 if json_object
.has_key
("action") and json_object
.has_key
("commit") and json_object
.has_key
("comment") then
251 return "CommitCommentEvent"
252 else if json_object
.has_key
("ref") and json_object
.has_key
("master_branch") then
254 else if json_object
.has_key
("ref") and json_object
.has_key
("ref_type") then
256 else if json_object
.has_key
("action") and json_object
.has_key
("sha") then
257 return "DeploymentEvent"
258 else if json_object
.has_key
("action") and json_object
.has_key
("state") then
259 return "DeploymentStatusEvent"
260 else if json_object
.has_key
("action") and json_object
.has_key
("forkee") then
262 else if json_object
.has_key
("action") and json_object
.has_key
("issue") and json_object
.has_key
("comment") then
263 return "IssueCommentEvent"
264 else if json_object
.has_key
("action") and json_object
.has_key
("issue") then
266 else if json_object
.has_key
("action") and json_object
.has_key
("member") then
268 else if json_object
.has_key
("action") and json_object
.has_key
("number") then
269 return "PullRequestEvent"
270 else if json_object
.has_key
("action") and json_object
.has_key
("pull") and json_object
.has_key
("comment") then
271 return "PullRequestReviewCommentEvent"
272 else if json_object
.has_key
("head_commit") and json_object
.has_key
("commits") then
274 else if json_object
.has_key
("action") and json_object
.has_key
("branches") then
276 else if json_object
.has_key
("action") and json_object
.has_key
("issue") then