-
Notifications
You must be signed in to change notification settings - Fork 5
/
epics.models.go
272 lines (249 loc) · 13.1 KB
/
epics.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
package taigo
import (
"time"
)
func genericToEpic(anyEpicObject interface{}) *Epic {
payloadEpic := Epic{}
convertStructViaJSON(&anyEpicObject, &payloadEpic)
return &payloadEpic
}
func genericToEpics(anyEpicObjectSlice interface{}) []Epic {
payloadEpicsSlice := []Epic{}
convertStructViaJSON(&anyEpicObjectSlice, &payloadEpicsSlice)
return payloadEpicsSlice
}
// Epic represents the mandatory fields of an Epic only
type Epic 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"`
ClientRequirement bool `json:"client_requirement,omitempty"`
Color string `json:"color,omitempty"`
Description string `json:"description,omitempty"`
EpicsOrder int64 `json:"epics_order,omitempty"`
IsBlocked bool `json:"is_blocked,omitempty"`
Project int `json:"project,omitempty"`
Status int `json:"status,omitempty"`
Subject string `json:"subject,omitempty"`
Tags []string `json:"tags,omitempty"`
TeamRequirement bool `json:"team_requirement,omitempty"`
Watchers []int `json:"watchers,omitempty"`
EpicDetail *EpicDetail
EpicDetailGET *EpicDetailGET
EpicDetailLIST *EpicDetailLIST
}
// GetID returns the ID
func (e *Epic) GetID() int {
return e.ID
}
// GetRef returns the Ref
func (e *Epic) GetRef() int {
return e.Ref
}
// GetVersion return the version
func (e *Epic) GetVersion() int {
return e.Version
}
// GetSubject returns the subject
func (e *Epic) GetSubject() string {
return e.Subject
}
// GetProject returns the project ID
func (e *Epic) GetProject() int {
return e.Project
}
// ListRelatedUserStories => https://taigaio.github.io/taiga-doc/dist/api.html#epics-related-user-stories-list
func (e *Epic) ListRelatedUserStories(client *Client) ([]EpicRelatedUserStoryDetail, error) {
return client.Epic.ListRelatedUserStories(e.ID)
}
// EpicDetailLIST -> Epic detail (LIST)
// https://taigaio.github.io/taiga-doc/dist/api.html#object-epic-detail-list
type EpicDetailLIST []struct {
AssignedTo int `json:"assigned_to,omitempty"`
AssignedToExtraInfo AssignedToExtraInfo `json:"assigned_to_extra_info,omitempty"`
Attachments []GenericObjectAttachment `json:"attachments,omitempty"`
BlockedNote string `json:"blocked_note,omitempty"`
ClientRequirement bool `json:"client_requirement,omitempty"`
Color string `json:"color,omitempty"`
CreatedDate time.Time `json:"created_date,omitempty"`
EpicsOrder int64 `json:"epics_order,omitempty"`
ID int `json:"id,omitempty"`
IsBlocked bool `json:"is_blocked,omitempty"`
IsClosed bool `json:"is_closed,omitempty"`
IsVoter bool `json:"is_voter,omitempty"`
IsWatcher bool `json:"is_watcher,omitempty"`
ModifiedDate time.Time `json:"modified_date,omitempty"`
Owner int `json:"owner,omitempty"`
OwnerExtraInfo OwnerExtraInfo `json:"owner_extra_info,omitempty"`
Project int `json:"project,omitempty"`
ProjectExtraInfo Project `json:"project_extra_info,omitempty"`
Ref int `json:"ref,omitempty"`
Status int `json:"status,omitempty"`
StatusExtraInfo StatusExtraInfo `json:"status_extra_info,omitempty"`
Subject string `json:"subject,omitempty"`
Tags Tags `json:"tags,omitempty"`
TeamRequirement bool `json:"team_requirement,omitempty"`
TotalVoters int `json:"total_voters,omitempty"`
TotalWatchers int `json:"total_watchers,omitempty"`
UserStoriesCounts UserStoriesCounts `json:"user_stories_counts,omitempty"`
Version int `json:"version,omitempty"`
Watchers []int `json:"watchers,omitempty"`
}
// AsEpics packs the returned EpicDetailLIST into a generic Epic struct
func (e *EpicDetailLIST) AsEpics() ([]Epic, error) {
epics := genericToEpics(&e)
for i := 0; i < len(epics); i++ {
epics[i].EpicDetailLIST = e
}
return epics, nil
}
// EpicDetailGET => Epic detail (GET) https://taigaio.github.io/taiga-doc/dist/api.html#object-epic-detail-get
type EpicDetailGET struct {
AssignedTo int `json:"assigned_to,omitempty"`
AssignedToExtraInfo AssignedToExtraInfo `json:"assigned_to_extra_info,omitempty"`
Attachments []GenericObjectAttachment `json:"attachments,omitempty"`
BlockedNote string `json:"blocked_note,omitempty"`
BlockedNoteHTML string `json:"blocked_note_html,omitempty"`
ClientRequirement bool `json:"client_requirement,omitempty"`
Color string `json:"color,omitempty"`
Comment string `json:"comment,omitempty"`
CreatedDate time.Time `json:"created_date,omitempty"`
Description string `json:"description,omitempty"`
DescriptionHTML string `json:"description_html,omitempty"`
EpicsOrder int64 `json:"epics_order,omitempty"`
ID int `json:"id,omitempty"`
IsBlocked bool `json:"is_blocked,omitempty"`
IsClosed bool `json:"is_closed,omitempty"`
IsVoter bool `json:"is_voter,omitempty"`
IsWatcher bool `json:"is_watcher,omitempty"`
ModifiedDate time.Time `json:"modified_date,omitempty"`
Neighbors Neighbors `json:"neighbors,omitempty"`
Owner int `json:"owner,omitempty"`
OwnerExtraInfo OwnerExtraInfo `json:"owner_extra_info,omitempty"`
Project int `json:"project,omitempty"`
ProjectExtraInfo ProjectExtraInfo `json:"project_extra_info,omitempty"`
Ref int `json:"ref,omitempty"`
Status int `json:"status,omitempty"`
StatusExtraInfo StatusExtraInfo `json:"status_extra_info,omitempty"`
Subject string `json:"subject,omitempty"`
Tags Tags `json:"tags,omitempty"`
TeamRequirement bool `json:"team_requirement,omitempty"`
TotalVoters int `json:"total_voters,omitempty"`
TotalWatchers int `json:"total_watchers,omitempty"`
UserStoriesCounts UserStoriesCounts `json:"user_stories_counts,omitempty"`
Version int `json:"version,omitempty"`
Watchers []int `json:"watchers,omitempty"`
}
// AsEpic packs the returned EpicDetailGET into a generic Epic struct
func (e *EpicDetailGET) AsEpic() (*Epic, error) {
epic := genericToEpic(&e)
epic.EpicDetailGET = e // Backmap original EpicDetailLIST
return epic, nil
}
// EpicDetail => Epic detail https://taigaio.github.io/taiga-doc/dist/api.html#object-epic-detail
type EpicDetail struct {
AssignedTo int `json:"assigned_to,omitempty"`
AssignedToExtraInfo AssignedToExtraInfo `json:"assigned_to_extra_info,omitempty"`
Attachments []GenericObjectAttachment `json:"attachments,omitempty"`
BlockedNote string `json:"blocked_note,omitempty"`
BlockedNoteHTML string `json:"blocked_note_html,omitempty"`
ClientRequirement bool `json:"client_requirement,omitempty"`
Color string `json:"color,omitempty"`
Comment string `json:"comment,omitempty"`
CreatedDate time.Time `json:"created_date,omitempty"`
Description string `json:"description,omitempty"`
DescriptionHTML string `json:"description_html,omitempty"`
EpicsOrder int64 `json:"epics_order,omitempty"`
ID int `json:"id,omitempty"`
IsBlocked bool `json:"is_blocked,omitempty"`
IsClosed bool `json:"is_closed,omitempty"`
IsVoter bool `json:"is_voter,omitempty"`
IsWatcher bool `json:"is_watcher,omitempty"`
ModifiedDate time.Time `json:"modified_date,omitempty"`
Neighbors Neighbors `json:"neighbors,omitempty"`
Owner int `json:"owner,omitempty"`
OwnerExtraInfo OwnerExtraInfo `json:"owner_extra_info,omitempty"`
Project int `json:"project"` // Mandatory
ProjectExtraInfo ProjectExtraInfo `json:"project_extra_info,omitempty"`
Ref int `json:"ref,omitempty"`
Status int `json:"status,omitempty"`
StatusExtraInfo StatusExtraInfo `json:"status_extra_info,omitempty"`
Subject string `json:"subject"` // Mandatory
Tags [][]string `json:"tags,omitempty"`
TeamRequirement bool `json:"team_requirement,omitempty"`
TotalVoters int `json:"total_voters,omitempty"`
TotalWatchers int `json:"total_watchers,omitempty"`
UserStoriesCounts UserStoriesCounts `json:"user_stories_counts,omitempty"`
Version int `json:"version,omitempty"`
Watchers []int `json:"watchers,omitempty"`
}
// AsEpic packs the returned EpicDetail into a generic Epic struct
func (e *EpicDetail) AsEpic() (*Epic, error) {
epic := genericToEpic(&e)
epic.EpicDetail = e
return epic, nil
}
// EpicFiltersDataDetail => Epic filters data detail https://taigaio.github.io/taiga-doc/dist/api.html#object-epic-filters-data
type EpicFiltersDataDetail struct {
AssignedTo []struct {
Count int `json:"count,omitempty"`
FullName string `json:"full_name,omitempty"`
ID int `json:"id,omitempty"`
} `json:"assigned_to,omitempty"`
Owners []struct {
Count int `json:"count,omitempty"`
FullName string `json:"full_name,omitempty"`
ID int `json:"id,omitempty"`
} `json:"owners,omitempty"`
Statuses []struct {
Color string `json:"color,omitempty"`
Count int `json:"count,omitempty"`
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Order int `json:"order,omitempty"`
} `json:"statuses,omitempty"`
Tags []struct {
Color TagsColors `json:"color,omitempty"`
Count int `json:"count,omitempty"`
Name string `json:"name,omitempty"`
} `json:"tags,omitempty"`
}
// EpicRelatedUserStoryDetail => Epic related user story detail https://taigaio.github.io/taiga-doc/dist/api.html#object-epic-related-user-story-detail
type EpicRelatedUserStoryDetail struct {
EpicID int `json:"epic,omitempty"`
Order int64 `json:"order,omitempty"`
UserStoryID int `json:"user_story,omitempty"`
}
// GetUserStory returns the UserStory referred in the EpicRelatedUserStoryDetail
func (e *EpicRelatedUserStoryDetail) GetUserStory(c *Client) (*UserStory, error) {
return c.UserStory.Get(e.UserStoryID)
}
// GetEpic returns the Epic referred in the EpicRelatedUserStoryDetail
func (e *EpicRelatedUserStoryDetail) GetEpic(c *Client) (*Epic, error) {
return c.Epic.Get(e.EpicID)
}
// EpicWatcherDetail => Epic watcher detail https://taigaio.github.io/taiga-doc/dist/api.html#object-epic-watcher-detail
type EpicWatcherDetail struct {
FullName string `json:"full_name,omitempty"`
ID int `json:"id,omitempty"`
Username string `json:"username,omitempty"`
}
// EpicsQueryParams holds fields to be used as URL query parameters to filter the queried objects
type EpicsQueryParams struct {
IncludeAttachments bool `url:"include_attachments,omitempty"`
Project int `url:"project,omitempty"`
ProjectSlug string `url:"project__slug,omitempty"`
AssignedTo int `url:"assigned_to,omitempty"`
StatusIsClosed bool `url:"status__is_closed,omitempty"`
}
// EpicMinimal represent a small subset of a full Epic object
type EpicMinimal struct {
Color string `json:"color"`
ID int `json:"id"`
Project Project `json:"project"`
Ref int `json:"ref"`
Subject string `json:"subject"`
}