-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
449 lines (409 loc) · 17.7 KB
/
models.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
package backlog
import (
"time"
)
// Activity represents a activity.
type Activity struct {
ID int `json:"id,omitempty"`
Project *Project `json:"project,omitempty"`
Type int `json:"type,omitempty"`
Content *ActivityContent `json:"content,omitempty"`
Notifications []*Notification `json:"notifications,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
}
// ActivityContent represents content of Activity.
type ActivityContent struct {
ID int `json:"id,omitempty"`
KeyID int `json:"key_id,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Comment *Comment `json:"comment,omitempty"`
}
// Attachment represents a attachment.
type Attachment struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Size int `json:"size,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
}
// Category represents a category.
type Category []struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
DisplayOrder int `json:"displayOrder,omitempty"`
}
// ChangeLog reprements the changelog.
type ChangeLog struct {
Field string `json:"field,omitempty"`
NewValue string `json:"newValue,omitempty"`
OriginalValue string `json:"originalValue,omitempty"`
}
// Comment reprements any one comment.
type Comment struct {
ID int `json:"id,omitempty"`
Content string `json:"content,omitempty"`
ChangeLogs []*ChangeLog `json:"changeLog,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
Updated time.Time `json:"updated,omitempty"`
Stars *Star `json:"stars,omitempty"`
Notifications []*Notification `json:"notifications,omitempty"`
}
// CustomField represents a custom field.
type CustomField struct {
ID int `json:"id,omitempty"`
TypeID int `json:"typeId,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
ApplicableIssueTypeIDs []int `json:"applicableIssueTypes,omitempty"`
AllowAddItem bool `json:"allowAddItem,omitempty"`
Items []*CustomFieldItem `json:"items,omitempty"`
}
// CustomFieldItem represents one of Items in CustomField.
type CustomFieldItem struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
DisplayOrder int `json:"displayOrder,omitempty"`
}
// DiskUsageBase represents base of disk usage.
type DiskUsageBase struct {
Issue int `json:"issue,omitempty"`
Wiki int `json:"wiki,omitempty"`
File int `json:"file,omitempty"`
Subversion int `json:"subversion,omitempty"`
Git int `json:"git,omitempty"`
GitLFS int `json:"gitLFS,omitempty"`
}
// DiskUsageSpace represents space's disk usage.
type DiskUsageSpace struct {
DiskUsageBase
Capacity int `json:"capacity,omitempty"`
Details []*DiskUsageProject `json:"details,omitempty"`
}
// DiskUsageProject represents project's disk usage.
type DiskUsageProject struct {
DiskUsageBase
ProjectID int `json:"projectId,omitempty"`
}
// Licence represents licence.
type Licence struct {
Active bool `json:"active,omitempty"`
AttachmentLimit int `json:"attachmentLimit,omitempty"`
AttachmentLimitPerFile int `json:"attachmentLimitPerFile,omitempty"`
AttachmentNumLimit int `json:"attachmentNumLimit,omitempty"`
Attribute bool `json:"attribute,omitempty"`
AttributeLimit int `json:"attributeLimit,omitempty"`
Burndown bool `json:"burndown,omitempty"`
CommentLimit int `json:"commentLimit,omitempty"`
ComponentLimit int `json:"componentLimit,omitempty"`
FileSharing bool `json:"fileSharing,omitempty"`
Gantt bool `json:"gantt,omitempty"`
Git bool `json:"git,omitempty"`
IssueLimit int `json:"issueLimit,omitempty"`
LicenceTypeID int `json:"licenceTypeId,omitempty"`
LimitDate time.Time `json:"limitDate,omitempty"`
NulabAccount bool `json:"nulabAccount,omitempty"`
ParentChildIssue bool `json:"parentChildIssue,omitempty"`
PostIssueByMail bool `json:"postIssueByMail,omitempty"`
ProjectGroup bool `json:"projectGroup,omitempty"`
ProjectLimit int `json:"projectLimit,omitempty"`
PullRequestAttachmentLimitPerFile int `json:"pullRequestAttachmentLimitPerFile,omitempty"`
PullRequestAttachmentNumLimit int `json:"pullRequestAttachmentNumLimit,omitempty"`
RemoteAddress bool `json:"remoteAddress,omitempty"`
RemoteAddressLimit int `json:"remoteAddressLimit,omitempty"`
StartedOn time.Time `json:"startedOn,omitempty"`
StorageLimit int64 `json:"storageLimit,omitempty"`
Subversion bool `json:"subversion,omitempty"`
SubversionExternal bool `json:"subversionExternal,omitempty"`
UserLimit int `json:"userLimit,omitempty"`
VersionLimit int `json:"versionLimit,omitempty"`
WikiAttachment bool `json:"wikiAttachment,omitempty"`
WikiAttachmentLimitPerFile int `json:"wikiAttachmentLimitPerFile,omitempty"`
WikiAttachmentNumLimit int `json:"wikiAttachmentNumLimit,omitempty"`
}
// Notification represents some notification.
type Notification struct {
ID int `json:"id,omitempty"`
AlreadyRead bool `json:"alreadyRead,omitempty"`
Reason int `json:"reason,omitempty"`
ResourceAlreadyRead bool `json:"resourceAlreadyRead,omitempty"`
Project *Project `json:"project,omitempty"`
Issue *Issue `json:"issue,omitempty"`
Comment *Comment `json:"comment,omitempty"`
PullRequest *PullRequest `json:"pullRequest,omitempty"`
PullRequestComment *Comment `json:"pullRequestComment,omitempty"`
Sender *User `json:"sender,omitempty"`
Created time.Time `json:"created,omitempty"`
}
// Issue represents a issue of Backlog.
type Issue struct {
ID int `json:"id,omitempty"`
ProjectID int `json:"projectId,omitempty"`
IssueKey string `json:"issueKey,omitempty"`
KeyID int `json:"keyId,omitempty"`
IssueType *IssueType `json:"issueType,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Resolutions []*Resolution `json:"resolutions,omitempty"`
Priority *Priority `json:"priority,omitempty"`
Status *Status `json:"status,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Category *Category `json:"category,omitempty"`
Versions *Version `json:"versions,omitempty"`
Milestone *Version `json:"milestone,omitempty"`
StartDate time.Time `json:"startDate,omitempty"`
DueDate time.Time `json:"dueDate,omitempty"`
EstimatedHours int `json:"estimatedHours,omitempty"`
ActualHours int `json:"actualHours,omitempty"`
ParentIssueID int `json:"parentIssueId,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
UpdatedUser *User `json:"updatedUser,omitempty"`
Updated time.Time `json:"updated,omitempty"`
CustomFields []*CustomField `json:"customFields,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
SharedFiles []*SharedFile `json:"sharedFiles,omitempty"`
Stars []*Star `json:"stars,omitempty"`
}
// IssueType represents type of Issue.
type IssueType struct {
ID int `json:"id,omitempty"`
ProjectID int `json:"projectId,omitempty"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
DisplayOrder int `json:"displayOrder,omitempty"`
}
// Priority represents a priority.
type Priority struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}
// Project represents a project of Backlog.
type Project struct {
ID int `json:"id,omitempty"`
ProjectKey string `json:"projectKey,omitempty"`
Name string `json:"name,omitempty"`
ChartEnabled bool `json:"chartEnabled,omitempty"`
SubtaskingEnabled bool `json:"subtaskingEnabled,omitempty"`
ProjectLeaderCanEditProjectLeader bool `json:"projectLeaderCanEditProjectLeader,omitempty"`
TextFormattingRule Format `json:"textFormattingRule,omitempty"`
Archived bool `json:"archived,omitempty"`
}
// PullRequest represents pull request of Backlog git.
type PullRequest struct {
ID int `json:"id,omitempty"`
ProjectID int `json:"projectId,omitempty"`
RepositoryID int `json:"repositoryId,omitempty"`
Number int `json:"number,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Base string `json:"base,omitempty"`
Branch string `json:"branch,omitempty"`
Status *Status `json:"status,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Issue *Issue `json:"issue,omitempty"`
BaseCommit interface{} `json:"baseCommit,omitempty"`
BranchCommit interface{} `json:"branchCommit,omitempty"`
CloseAt time.Time `json:"closeAt,omitempty"`
MergeAt time.Time `json:"mergeAt,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
UpdatedUser *User `json:"updatedUser,omitempty"`
Updated time.Time `json:"updated,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
Stars []*Star `json:"stars,omitempty"`
}
// Repository represents repository of Backlog git.
type Repository struct {
ID int `json:"id,omitempty"`
ProjectID int `json:"projectId,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
HookURL string `json:"hookUrl,omitempty"`
HTTPURL string `json:"httpUrl,omitempty"`
SSHURL string `json:"sshUrl,omitempty"`
DisplayOrder int `json:"displayOrder,omitempty"`
PushedAt time.Time `json:"pushedAt,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
UpdatedUser *User `json:"updatedUser,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// Resolution represents a resolushon.
type Resolution struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}
// SharedFile represents a shared file.
type SharedFile struct {
ID int `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Dir string `json:"dir,omitempty"`
Name string `json:"name,omitempty"`
Size int `json:"size,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
UpdatedUser *User `json:"updatedUser,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// Space represents space of Backlog.
type Space struct {
SpaceKey string `json:"spaceKey,omitempty"`
Name string `json:"name,omitempty"`
OwnerID int `json:"ownerId,omitempty"`
Lang string `json:"lang,omitempty"`
Timezone string `json:"timezone,omitempty"`
ReportSendTime string `json:"reportSendTime,omitempty"`
TextFormattingRule Format `json:"textFormattingRule,omitempty"`
Created time.Time `json:"created,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// SpaceNotification represents a notification of Space.
type SpaceNotification struct {
Content string `json:"content,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// Star represents any Star.
type Star struct {
ID int `json:"id,omitempty"`
Comment string `json:"comment,omitempty"`
URL string `json:"url,omitempty"`
Title string `json:"title,omitempty"`
Presenter *User `json:"presenter,omitempty"`
Created time.Time `json:"created,omitempty"`
}
// Status represents any status.
type Status struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}
// Tag represents one of tags in Wiki.
type Tag struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}
// Team represents team.
type Team struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Members []*User `json:"members,omitempty"`
DisplayOrder int `json:"displayOrder,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
UpdatedUser *User `json:"updatedUser,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// User represents user.
type User struct {
ID int `json:"id,omitempty"`
UserID string `json:"userId,omitempty"`
Name string `json:"name,omitempty"`
RoleType Role `json:"roleType,omitempty"`
Lang string `json:"lang,omitempty"`
MailAddress string `json:"mailAddress,omitempty"`
}
// Version represents any version.
type Version struct {
ID int `json:"id,omitempty"`
ProjectID int `json:"projectId,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
StartDate time.Time `json:"startDate,omitempty"`
ReleaseDueDate time.Time `json:"releaseDueDate,omitempty"`
Archived bool `json:"archived,omitempty"`
DisplayOrder int `json:"displayOrder,omitempty"`
}
// WatchingItem represents an item of watching list.
type WatchingItem struct {
ID int `json:"id,omitempty"`
ResourceAlreadyRead bool `json:"resourceAlreadyRead,omitempty"`
Note string `json:"note,omitempty"`
Type string `json:"type,omitempty"`
Issue *Issue `json:"issue,omitempty"`
LastContentUpdated time.Time `json:"lastContentUpdated,omitempty"`
Created time.Time `json:"created,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// Webhook represents webhook of Backlog.
type Webhook struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
HookURL string `json:"hookUrl,omitempty"`
AllEvent bool `json:"allEvent,omitempty"`
ActivityTypeIds []int `json:"activityTypeIds,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
UpdatedUser *User `json:"updatedUser,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// Wiki represents Backlog Wiki.
type Wiki struct {
ID int `json:"id,omitempty"`
ProjectID int `json:"projectId,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
Tags []*Tag `json:"tags,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
SharedFiles []*SharedFile `json:"sharedFiles,omitempty"`
Stars []*Star `json:"stars,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
UpdatedUser *User `json:"updatedUser,omitempty"`
Updated time.Time `json:"updated,omitempty"`
}
// WikiHistory reprements history of Wiki.
type WikiHistory struct {
PageID int `json:"pageId,omitempty"`
Version int `json:"version,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
CreatedUser *User `json:"createdUser,omitempty"`
Created time.Time `json:"created,omitempty"`
}
// Format of Backlog wiki.
type Format string
func (f Format) String() string {
switch f {
case FormatMarkdown:
return "Markdown"
case FormatBacklog:
return "Backlog"
default:
return "unknown"
}
}
// Order type.
type Order string
func (o Order) String() string {
switch o {
case OrderAsc:
return "Asc"
case OrderDesc:
return "Desc"
default:
return "unknown"
}
}
// Role type.
type Role int
func (r Role) String() string {
switch r {
case RoleAdministrator:
return "Administrator"
case RoleNormalUser:
return "NormalUser"
case RoleReporter:
return "Reporter"
case RoleViewer:
return "Viewer"
case RoleGuestReporter:
return "GuestReporter"
case RoleGuestViewer:
return "GuestViewer"
default:
return "unknown"
}
}