-
Notifications
You must be signed in to change notification settings - Fork 5
/
issues.models.go
257 lines (241 loc) · 12.4 KB
/
issues.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
package taigo
import (
"log"
"time"
)
func genericToIssue(anyIssueObject interface{}) *Issue {
payloadIssue := Issue{}
convertStructViaJSON(&anyIssueObject, &payloadIssue)
return &payloadIssue
}
func genericToIssues(anyIssueObjectSlice interface{}) []Issue {
payloadIssuesSlice := []Issue{}
err := convertStructViaJSON(&anyIssueObjectSlice, &payloadIssuesSlice)
if err != nil {
log.Println(err)
}
return payloadIssuesSlice
}
// Issue represents the mandatory fields of an Issue only
type Issue struct {
TaigaBaseObject
ID int `json:"id,omitempty"`
Ref int `json:"ref,omitempty"`
Version int `json:"version,omitempty"`
AssignedTo int `json:"assigned_to,omitempty"`
BlockedNote string `json:"blocked_note,omitempty"`
Description string `json:"description,omitempty"`
IsBlocked bool `json:"is_blocked,omitempty"`
IsClosed bool `json:"is_closed,omitempty"`
Milestone int `json:"milestone,omitempty"`
Owner int `json:"owner,omitempty"`
Priority int `json:"priority,omitempty"`
Project int `json:"project"`
Severity int `json:"severity,omitempty"`
Status int `json:"status,omitempty"`
Subject string `json:"subject"`
Tags Tags `json:"tags,omitempty"`
Type int `json:"type,omitempty"`
Watchers []int `json:"watchers,omitempty"`
CreatedDate time.Time `json:"created_date,omitempty"`
ModifiedDate time.Time `json:"modified_date,omitempty"`
FinishedDate time.Time `json:"finished_date,omitempty"`
DueDate string `json:"due_date,omitempty"`
DueDateReason string `json:"due_date_reason,omitempty"`
DueDateStatus string `json:"due_date_status,omitempty"`
IssueDetail *IssueDetail
IssueDetailGET *IssueDetailGET
IssueDetailLIST *IssueDetailLIST
}
// GetID returns the ID
func (i *Issue) GetID() int {
return i.ID
}
// GetRef returns the Ref
func (i *Issue) GetRef() int {
return i.Ref
}
// GetVersion return the version
func (i *Issue) GetVersion() int {
return i.Version
}
// GetSubject returns the subject
func (i *Issue) GetSubject() string {
return i.Subject
}
// GetProject returns the project ID
func (i *Issue) GetProject() int {
return i.Project
}
// IssueDetailLIST -> Issue detail (LIST)
//
// https://taigaio.github.io/taiga-doc/dist/api.html#object-issue-detail-list
type IssueDetailLIST []struct {
AssignedTo int `json:"assigned_to"`
AssignedToExtraInfo AssignedToExtraInfo `json:"assigned_to_extra_info"`
Attachments []GenericObjectAttachment `json:"attachments"`
BlockedNote string `json:"blocked_note"`
CreatedDate time.Time `json:"created_date"`
ModifiedDate time.Time `json:"modified_date"`
FinishedDate time.Time `json:"finished_date"`
DueDate string `json:"due_date"`
DueDateReason string `json:"due_date_reason"`
DueDateStatus string `json:"due_date_status"`
ExternalReference []int `json:"external_reference"`
ID int `json:"id"`
IsBlocked bool `json:"is_blocked"`
IsClosed bool `json:"is_closed"`
IsVoter bool `json:"is_voter"`
IsWatcher bool `json:"is_watcher"`
Milestone int `json:"milestone"`
Owner int `json:"owner"`
OwnerExtraInfo OwnerExtraInfo `json:"owner_extra_info"`
Priority int `json:"priority"`
Project int `json:"project"`
ProjectExtraInfo ProjectExtraInfo `json:"project_extra_info"`
Ref int `json:"ref"`
Severity int `json:"severity"`
Status int `json:"status"`
StatusExtraInfo StatusExtraInfo `json:"status_extra_info"`
Subject string `json:"subject"`
Tags Tags `json:"tags"`
TotalVoters int `json:"total_voters"`
TotalWatchers int `json:"total_watchers"`
Type int `json:"type"`
Version int `json:"version"`
Watchers []int `json:"watchers"`
}
// AsIssues packs the returned IssueDetailLIST into a generic Issue struct
func (issueL *IssueDetailLIST) AsIssues() ([]Issue, error) {
issues := genericToIssues(&issueL)
for i := 0; i < len(issues); i++ {
issues[i].IssueDetailLIST = issueL
}
return issues, nil
}
// IssueDetailGET -> Issue detail (GET)
// https://taigaio.github.io/taiga-doc/dist/api.html#object-issue-detail-get
type IssueDetailGET struct {
AssignedTo int `json:"assigned_to"`
AssignedToExtraInfo AssignedToExtraInfo `json:"assigned_to_extra_info"`
Attachments []GenericObjectAttachment `json:"attachments"`
BlockedNote string `json:"blocked_note"`
BlockedNoteHTML string `json:"blocked_note_html"`
Comment string `json:"comment"`
CreatedDate time.Time `json:"created_date"`
Description string `json:"description"`
DescriptionHTML string `json:"description_html"`
DueDate string `json:"due_date"`
DueDateReason string `json:"due_date_reason"`
DueDateStatus string `json:"due_date_status"`
ExternalReference []int `json:"external_reference"`
FinishedDate time.Time `json:"finished_date"`
GeneratedUserStories []int `json:"generated_user_stories"`
ID int `json:"id"`
IsBlocked bool `json:"is_blocked"`
IsClosed bool `json:"is_closed"`
IsVoter bool `json:"is_voter"`
IsWatcher bool `json:"is_watcher"`
Milestone int `json:"milestone"`
ModifiedDate time.Time `json:"modified_date"`
Neighbors Neighbors `json:"neighbors"`
Owner int `json:"owner"`
OwnerExtraInfo OwnerExtraInfo `json:"owner_extra_info"`
Priority int `json:"priority"`
Project int `json:"project"`
ProjectExtraInfo ProjectExtraInfo `json:"project_extra_info"`
Ref int `json:"ref"`
Severity int `json:"severity"`
Status int `json:"status"`
StatusExtraInfo StatusExtraInfo `json:"status_extra_info"`
Subject string `json:"subject"`
Tags Tags `json:"tags"`
TotalVoters int `json:"total_voters"`
TotalWatchers int `json:"total_watchers"`
Type int `json:"type"`
Version int `json:"version"`
Watchers []int `json:"watchers"`
}
// AsIssue packs the returned IssueDetailGET into a generic Issue struct
func (issueD *IssueDetailGET) AsIssue() (*Issue, error) {
issue := genericToIssue(&issueD)
issue.IssueDetailGET = issueD
return issue, nil
}
// IssueDetail -> Issue detail
// https://taigaio.github.io/taiga-doc/dist/api.html#object-issue-detail
type IssueDetail struct {
AssignedTo int `json:"assigned_to"`
AssignedToExtraInfo AssignedToExtraInfo `json:"assigned_to_extra_info"`
Attachments []GenericObjectAttachment `json:"attachments"`
BlockedNote string `json:"blocked_note"`
BlockedNoteHTML string `json:"blocked_note_html"`
Comment string `json:"comment"`
CreatedDate time.Time `json:"created_date"`
Description string `json:"description"`
DescriptionHTML string `json:"description_html"`
DueDate string `json:"due_date"`
DueDateReason string `json:"due_date_reason"`
DueDateStatus string `json:"due_date_status"`
ExternalReference []int `json:"external_reference"`
FinishedDate time.Time `json:"finished_date"`
GeneratedUserStories []int `json:"generated_user_stories"`
ID int `json:"id"`
IsBlocked bool `json:"is_blocked"`
IsClosed bool `json:"is_closed"`
IsVoter bool `json:"is_voter"`
IsWatcher bool `json:"is_watcher"`
Milestone int `json:"milestone"`
ModifiedDate time.Time `json:"modified_date"`
Neighbors Neighbors `json:"neighbors"`
Owner int `json:"owner"`
OwnerExtraInfo OwnerExtraInfo `json:"owner_extra_info"`
Priority int `json:"priority"`
Project int `json:"project"`
ProjectExtraInfo ProjectExtraInfo `json:"project_extra_info"`
Ref int `json:"ref"`
Severity int `json:"severity"`
Status int `json:"status"`
StatusExtraInfo StatusExtraInfo `json:"status_extra_info"`
Subject string `json:"subject"`
Tags Tags `json:"tags"`
TotalVoters int `json:"total_voters"`
TotalWatchers int `json:"total_watchers"`
Type int `json:"type"`
Version int `json:"version"`
Watchers []int `json:"watchers"`
}
// AsIssue packs the returned IssueDetailGET into a generic Issue struct
func (issueD *IssueDetail) AsIssue() (*Issue, error) {
issue := genericToIssue(&issueD)
issue.IssueDetail = issueD
return issue, nil
}
// IssueQueryParams holds fields to be used as URL query parameters to filter the queried objects
type IssueQueryParams struct {
Project int `url:"project,omitempty"`
Milestone int `url:"milestone,omitempty"`
MilestoneIsNull bool `url:"milestone__isnull,omitempty"`
Status int `url:"status,omitempty"`
StatusIsArchived bool `url:"status__is_archived,omitempty"`
Tags string `url:"tags,omitempty"` // comma-separated strings w/o whitespace
Watchers int `url:"watchers,omitempty"`
AssignedTo int `url:"assigned_to,omitempty"`
Epic int `url:"epic,omitempty"`
Role int `url:"role,omitempty"`
StatusIsClosed bool `url:"status__is_closed,omitempty"`
Type int `url:"type,omitempty"`
Severity int `url:"severity,omitempty"`
Priority int `url:"priority,omitempty"`
Owner int `url:"owner,omitempty"`
ExcludeStatus int `url:"exclude_status,omitempty"`
ExcludeTags string `url:"exclude_tags,omitempty"` // comma-separated strings w/o whitespace
ExcludeAssignedTo int `url:"exclude_assigned_to,omitempty"`
ExcludeRole int `url:"exclude_role,omitempty"`
ExcludeEpic int `url:"exclude_epic,omitempty"`
ExcludeSeverity int `url:"exclude_severity,omitempty"`
ExcludePriority int `url:"exclude_priority,omitempty"`
ExcludeOwner int `url:"exclude_owner,omitempty"`
ExcludeType int `url:"exclude_type,omitempty"`
IncludeAttachments bool `url:"include_attachments,omitempty"`
}