/
media_types.go
340 lines (294 loc) · 8.55 KB
/
media_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
const (
cmsAsyncUnprocessed = "unprocessed"
cmsAsyncSubmitted = "submitted"
cmsAsyncFailed = "failed"
cmsAsyncEvaluated = "evaluated"
)
var EntryMedia = MediaType("application/vnd.com.jossemargt.sao.entry+json", func() {
Description("Any source code or input to be compiled, executed and evaluated")
Reference(AbstractEntry)
Attributes(func() {
Attribute("id", Integer, "Unique entry ID", func() {
Example(1236)
})
Attribute("href", String, "API href for making requests on the entry", func() {
Example("/entries/1236")
})
Attribute("contestSlug")
Attribute("contestID", Integer, "Contest ID where this Entry has been submitted", func() {
Default(0)
})
Attribute("taskSlug")
Attribute("taskID", Integer, "Task ID where this Entry has been submitted", func() {
Default(0)
})
Attribute("userID", Integer, "User ID of the Entry's owner", func() {
Default(0)
})
Attribute("token")
Attribute("language")
Attribute("result", ResultMedia, "The entry processing result")
Required("id", "href")
})
Links(func() {
Link("result", "link")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("contestSlug")
Attribute("taskSlug")
Attribute("token")
})
View("full", func() {
Attribute("id")
Attribute("href")
Attribute("contestID")
Attribute("contestSlug")
Attribute("taskID")
Attribute("taskSlug")
Attribute("userID")
Attribute("token")
Attribute("language")
Attribute("links")
})
})
var DraftMedia = MediaType("application/vnd.com.jossemargt.sao.draft+json", func() {
Description("Any source code or input to be compiled and executed against the user test case")
Reference(AbstractEntry)
Attributes(func() {
Attribute("id", Integer, "Unique entry ID", func() {
Example(1236)
})
Attribute("href", String, "API href for making requests on the entry", func() {
Example("/drafts/1236")
})
Attribute("contestSlug")
Attribute("contestID", Integer, "Contest ID where this Entry has been submitted", func() {
Default(0)
})
Attribute("taskSlug")
Attribute("taskID", Integer, "Task ID where this Entry has been submitted", func() {
Default(0)
})
Attribute("userID", Integer, "User ID of the Entry's owner", func() {
Default(0)
})
Attribute("language")
Attribute("result", DraftResultMedia, "The entry processing result")
Required("id", "href")
})
Links(func() {
Link("result", "link")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("contestSlug")
Attribute("taskSlug")
})
View("full", func() {
Attribute("id")
Attribute("href")
Attribute("contestID")
Attribute("contestSlug")
Attribute("taskID")
Attribute("taskSlug")
Attribute("userID")
Attribute("language")
Attribute("links")
})
})
var ResultMedia = MediaType("application/vnd.com.jossemargt.sao.result+json", func() {
Description("The representation of the result of an entry compile, evaluation and grading process")
Attributes(func() {
Attribute("id", String, "Compound Result ID", func() {
Example("1236-5689")
})
Attribute("href", String, "API href for making requests on the result", func() {
Example("/results/1236-5689")
})
Attribute("compilation", CompilationResult, "Entry compilation result")
Attribute("evaluation", EvaluationResult, "Entry evaluation result")
Attribute("score", ScoreResult, "Entry graded score")
Required("id", "href", "evaluation")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("evaluation")
Attribute("score")
})
View("full", func() {
Attribute("id")
Attribute("href")
Attribute("compilation")
Attribute("evaluation")
Attribute("score")
})
})
var DraftResultMedia = MediaType("application/vnd.com.jossemargt.sao.draft-result+json", func() {
Description("The representation of the result of an entry draft compile, execution and evaluation process")
Attributes(func() {
Attribute("id", String, "Compound Result ID", func() {
Example("1236-5689")
})
Attribute("href", String, "API href for making requests on the result", func() {
Example("/draft-results/1236-5689")
})
Attribute("compilation", CompilationResult, "Entry compilation result")
Attribute("execution", ExecutionResult, "Entry execution result")
Attribute("evaluation", EvaluationResult, "Entry evaluation result")
Required("id", "href", "execution")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("execution")
})
View("full", func() {
Attribute("id")
Attribute("href")
Attribute("compilation")
Attribute("execution")
Attribute("evaluation")
})
})
var AbstractEntrySubmitTrx = Type("AbstractEntrySubmitTrx", func() {
Description("Abstracts the common attributes from SubmitEntry and SubmitDraft transactional resources")
Attribute("createdAt", DateTime, "Transaction creation timestamp")
Attribute("updatedAt", DateTime, "Transaction last update timestamp")
Attribute("status", String, "", func() {
Enum(cmsAsyncUnprocessed, cmsAsyncSubmitted, cmsAsyncFailed, cmsAsyncEvaluated)
Default(cmsAsyncUnprocessed)
})
})
var EntrySubmitTrx = MediaType("application/vnd.com.jossemargt.sao.entry-submit-transaction+json", func() {
Description("Represents the process of queueing, compilation, evaluation and grading of an Entry")
Reference(AbstractEntrySubmitTrx)
Attributes(func() {
Attribute("id", String, "Unique SubmitEntryTransaction ID", func() {
Example("5cf4a17916fdac79059141a0")
})
Attribute("href", String, "API href for making requests on the entry", func() {
Example("/entry-submit-transaction/1236")
})
Attribute("createdAt")
Attribute("updatedAt")
Attribute("status")
Attribute("entry", EntryMedia, "The entry being processed on this transaction")
Required("id", "href", "status")
})
Links(func() {
Link("entry", "link")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("status")
})
View("full", func() {
Attribute("id")
Attribute("href")
Attribute("status")
Attribute("createdAt")
Attribute("updatedAt")
Attribute("links")
})
})
var DraftSubmitTrx = MediaType("application/vnd.com.jossemargt.sao.draft-submit-transaction+json", func() {
Description("Represents the process of queueing, compilation and execution of an Entry Draft")
Reference(AbstractEntrySubmitTrx)
Attributes(func() {
Attribute("id", String, "Unique SubmitDraftTransaction ID", func() {
Example("5cf4a17916fdac79059141a0")
})
Attribute("href", String, "API href for making requests on the entry", func() {
Example("/draft-submit-transaction/1236")
})
Attribute("createdAt")
Attribute("updatedAt")
Attribute("status")
Attribute("draft", DraftMedia, "The entry draft being processed on this transaction")
Required("id", "href", "status")
})
Links(func() {
Link("draft", "link")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("status")
})
View("full", func() {
Attribute("id")
Attribute("href")
Attribute("status")
Attribute("createdAt")
Attribute("updatedAt")
Attribute("links")
})
})
var ScoreSumMedia = MediaType("application/vnd.com.jossemargt.sao.score-sum+json", func() {
Description("The representation of a summarized entry's score")
Attributes(func() {
Attribute("contestID", Integer, "Contest Identifier associated with this score", func() {
Example(1)
Minimum(1)
})
Attribute("userID", Integer, "Contest Identifier associated with this score", func() {
Example(1)
Minimum(1)
})
Attribute("username", String, "Contest Identifier associated with this score", func() {
Example("foobar")
})
Attribute("taskID", Integer, "Contest Identifier associated with this score", func() {
Example(1)
Minimum(1)
})
Attribute("taskValue", Number, "The graded value relative to the Task total score", func() {
Example(100.00)
})
Attribute("contestValue", Number, "The graded value relative to the contest", func() {
Example(25.00)
})
Required("contestValue", "taskValue")
})
View("default", func() {
Attribute("contestID")
Attribute("userID")
Attribute("taskID")
Attribute("taskValue")
Attribute("contestValue")
})
})