forked from fabric8-services/fabric8-wit
/
resources.go
139 lines (123 loc) · 2.43 KB
/
resources.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
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
var _ = Resource("workitem", func() {
BasePath("/workitem")
Action("show", func() {
Routing(
GET("/:id"),
)
Description("Retrieve work item with given id.")
Params(func() {
Param("id", String, "id")
})
Response(OK, func() {
Media(WorkItem)
})
Response(BadRequest, func() {
Media(ErrorMedia)
})
Response(InternalServerError)
Response(NotFound)
})
Action("create", func() {
Routing(
POST(""),
)
Description("create work item with type and id.")
Payload(CreateWorkItemPayload)
Response(OK, func() {
Media(WorkItem)
})
Response(BadRequest, func() {
Media(ErrorMedia)
})
Response(InternalServerError)
Response(NotFound)
})
Action("delete", func() {
Routing(
DELETE("/:id"),
)
Description("Delete work item with given id.")
Params(func() {
Param("id", String, "id")
})
Response(OK)
Response(BadRequest, func() {
Media(ErrorMedia)
})
Response(InternalServerError)
Response(NotFound)
})
Action("update", func() {
Routing(
PUT(""),
)
Description("update the given work item.")
Payload(WorkItem)
Response(OK, func() {
Media(WorkItem)
})
Response(BadRequest, func() {
Media(ErrorMedia)
})
Response(InternalServerError)
Response(NotFound)
})
})
var _ = Resource("workitemtype", func() {
BasePath("/workitemtype")
Action("show", func() {
Routing(
GET("/:id"),
)
Description("Retrieve work item type with given id.")
Params(func() {
Param("id", String, "id")
})
Response(OK, func() {
Media(WorkItemType)
})
Response(NotFound)
})
})
var _ = Resource("version", func() {
DefaultMedia(ALMVersion)
BasePath("/version")
Action("show", func() {
Security("jwt", func() {
Scope("system")
})
Routing(
GET(""),
)
Description("Show current running version")
Response(OK)
})
})
var _ = Resource("login", func() {
BasePath("/login")
Action("authorize", func() {
Routing(
GET("authorize"),
)
Description("Authorize with the ALM")
Response(OK, func() {
Media(AuthToken)
})
Response(Unauthorized)
})
Action("generate", func() {
Routing(
GET("generate"),
)
Description("Generates a set of Tokens for different Auth levels. NOT FOR PRODUCTION. Only available if server is running in dev mode")
Response(OK, func() {
Media(CollectionOf(AuthToken))
})
Response(Unauthorized)
})
})