forked from fabric8-services/fabric8-wit
/
iterations.go
170 lines (161 loc) · 5.55 KB
/
iterations.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
package design
import (
d "github.com/goadesign/goa/design"
a "github.com/goadesign/goa/design/apidsl"
)
var iteration = a.Type("Iteration", func() {
a.Description(`JSONAPI store for the data of a iteration. See also http://jsonapi.org/format/#document-resource-object`)
a.Attribute("type", d.String, func() {
a.Enum("iterations")
})
a.Attribute("id", d.UUID, "ID of iteration", func() {
a.Example("40bbdd3d-8b5d-4fd6-ac90-7236b669af04")
})
a.Attribute("attributes", iterationAttributes)
a.Attribute("relationships", iterationRelationships)
a.Attribute("links", genericLinks)
a.Required("type", "attributes")
})
var iterationAttributes = a.Type("IterationAttributes", func() {
a.Description(`JSONAPI store for all the "attributes" of a iteration. +See also see http://jsonapi.org/format/#document-resource-object-attributes`)
a.Attribute("name", d.String, "The iteration name", nameValidationFunction)
a.Attribute("description", d.String, "Description of the iteration ", func() {
a.Example("Sprint #42 focusing on UI and build process improvements")
})
a.Attribute("created-at", d.DateTime, "When the iteration was created", func() {
a.Example("2016-11-29T23:18:14Z")
})
a.Attribute("updated-at", d.DateTime, "When the iteration was updated", func() {
a.Example("2016-11-29T23:18:14Z")
})
a.Attribute("startAt", d.DateTime, "When the iteration starts", func() {
a.Example("2016-11-29T23:18:14Z")
})
a.Attribute("endAt", d.DateTime, "When the iteration ends", func() {
a.Example("2016-11-29T23:18:14Z")
})
a.Attribute("state", d.String, "State of an iteration", func() {
a.Enum("new", "start", "close")
})
a.Attribute("user_active", d.Boolean, "Active flag set by user", func() {
})
a.Attribute("active_status", d.Boolean, "Active status of iteration calculated using user_active, startAt and endAt", func() {
})
a.Attribute("parent_path", d.String, "Path string separataed by / having UUIDs of all parent iterations", func() {
a.Example("/8ab013be-6477-41e2-b206-53593dac6543/300d9835-fcf7-4d2f-a629-1919de091663/42f0dabd-16bf-40a6-a521-888ec2ad7461")
})
a.Attribute("resolved_parent_path", d.String, "Path string separataed by / having names of all parent iterations", func() {
a.Example("/beta/Web-App/Sprint 9/Sprint 9.1")
})
})
var iterationRelationships = a.Type("IterationRelations", func() {
a.Attribute("space", relationGeneric, "This defines the owning space")
a.Attribute("parent", relationGeneric, "This defines the parent iteration")
a.Attribute("workitems", relationGeneric, "This defines the workitems associated with the iteration")
})
var iterationList = JSONList(
"Iteration", "Holds the list of iterations",
iteration,
pagingLinks,
meta)
var iterationSingle = JSONSingle(
"Iteration", "Holds the list of iterations",
iteration,
nil)
// new version of "list" for migration
var _ = a.Resource("iteration", func() {
a.BasePath("/iterations")
a.Action("show", func() {
a.Routing(
a.GET("/:iterationID"),
)
a.Description("Retrieve iteration with given id.")
a.Params(func() {
a.Param("iterationID", d.String, "Iteration Identifier")
})
a.UseTrait("conditional")
a.Response(d.OK, iterationSingle)
a.Response(d.NotModified)
a.Response(d.BadRequest, JSONAPIErrors)
a.Response(d.InternalServerError, JSONAPIErrors)
a.Response(d.NotFound, JSONAPIErrors)
})
a.Action("create-child", func() {
a.Security("jwt")
a.Routing(
a.POST("/:iterationID"),
)
a.Params(func() {
a.Param("iterationID", d.String, "Iteration Identifier")
})
a.Description("create child iteration.")
a.Payload(iterationSingle)
a.Response(d.Created, "/iterations/.*", func() {
a.Media(iterationSingle)
})
a.Response(d.BadRequest, JSONAPIErrors)
a.Response(d.NotFound, JSONAPIErrors)
a.Response(d.InternalServerError, JSONAPIErrors)
a.Response(d.Unauthorized, JSONAPIErrors)
a.Response(d.Forbidden, JSONAPIErrors)
a.Response(d.Conflict, JSONAPIErrors)
})
a.Action("update", func() {
a.Security("jwt")
a.Routing(
a.PATCH("/:iterationID"),
)
a.Description("update the iteration for the given id.")
a.Params(func() {
a.Param("iterationID", d.String, "Iteration Identifier")
})
a.Payload(iterationSingle)
a.Response(d.OK, func() {
a.Media(iterationSingle)
})
a.Response(d.BadRequest, JSONAPIErrors)
a.Response(d.InternalServerError, JSONAPIErrors)
a.Response(d.NotFound, JSONAPIErrors)
a.Response(d.Unauthorized, JSONAPIErrors)
a.Response(d.Forbidden, JSONAPIErrors)
})
})
// new version of "list" for migration
var _ = a.Resource("space_iterations", func() {
a.Parent("space")
a.Action("list", func() {
a.Routing(
a.GET("iterations"),
)
a.Description("List iterations.")
/*
a.Params(func() {
a.Param("filter", d.String, "a query language expression restricting the set of found work items")
a.Param("page[offset]", d.String, "Paging start position")
a.Param("page[limit]", d.Integer, "Paging size")
})
*/
a.UseTrait("conditional")
a.Response(d.OK, iterationList)
a.Response(d.NotModified)
a.Response(d.BadRequest, JSONAPIErrors)
a.Response(d.NotFound, JSONAPIErrors)
a.Response(d.InternalServerError, JSONAPIErrors)
})
a.Action("create", func() {
a.Security("jwt")
a.Routing(
a.POST("iterations"),
)
a.Description("Create iteration.")
a.Payload(iterationSingle)
a.Response(d.Created, "/iterations/.*", func() {
a.Media(iterationSingle)
})
a.Response(d.BadRequest, JSONAPIErrors)
a.Response(d.NotFound, JSONAPIErrors)
a.Response(d.InternalServerError, JSONAPIErrors)
a.Response(d.Unauthorized, JSONAPIErrors)
a.Response(d.Forbidden, JSONAPIErrors)
})
})