forked from fabric8-services/fabric8-wit
/
filters.go
62 lines (56 loc) · 1.84 KB
/
filters.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
package design
import (
d "github.com/goadesign/goa/design"
a "github.com/goadesign/goa/design/apidsl"
)
var filter = a.Type("filters", func() {
a.Description(`JSONAPI store for the data of a filter. See also http://jsonapi.org/format/#document-resource-object`)
a.Attribute("type", d.String, func() {
a.Enum("filters")
})
a.Attribute("attributes", filterAttributes)
a.Required("type", "attributes")
})
var filterAttributes = a.Type("filterAttributes", func() {
a.Description(`JSONAPI store for all the "attributes" of a filter. +See also see http://jsonapi.org/format/#document-resource-object-attributes`)
a.Attribute("title", d.String, "The Filter name", func() {
a.Example("Assignee")
})
a.Attribute("description", d.String, "When the filter was created", func() {
a.Example("Filter by assignee")
})
a.Attribute("query", d.String, "Version for optimistic concurrency control (optional during creating)", func() {
a.Example("filter[assignee]={id}")
})
a.Attribute("type", d.String, "Path to the topmost parent", func() {
a.Example("users")
})
a.Attribute("key", d.String, "Filter key to be used in the search query language", func() {
a.Example("label")
})
a.Required("type", "title", "description", "query", "key")
})
var filterList = JSONList(
"filter", "Holds the list of Filters",
filter,
pagingLinks, // pagingLinks would eventually remain nil.
meta) // again, this being a pointer gets auto-assigned nil.
var filterSingle = JSONSingle(
"filter", "Holds filter information",
filter,
nil)
var _ = a.Resource("filter", func() {
a.BasePath("/filters")
a.CanonicalActionName("list")
a.Action("list", func() {
a.Routing(
a.GET(""),
)
a.Description("List filters.")
a.Response(d.OK, func() {
a.Media(filterList)
})
a.Response(d.BadRequest, JSONAPIErrors)
a.Response(d.InternalServerError, JSONAPIErrors)
})
})