/
media_types.go
258 lines (240 loc) · 7.27 KB
/
media_types.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
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
// Feed is the feed resource media type.
var Feed = MediaType("application/vnd.feedpushr.feed.v1+json", func() {
Description("A RSS feed")
TypeName("Feed")
ContentType("application/json")
Attributes(func() {
Attribute("id", String, "ID of feed (MD5 of the xmlUrl)", func() {
Example("5bfb841c028281c0051828c115fd1f50")
})
Attribute("xmlUrl", String, "URL of the XML feed", func() {
Example("http://www.hashicorp.com/feed.xml")
})
Attribute("htmlUrl", String, "URL of the feed website", func() {
Example("http://www.hashicorp.com/blog")
})
Attribute("hubUrl", String, "URL of the PubSubHubbud hub", func() {
Example("http://pubsubhubbub.appspot.com")
})
Attribute("text", String, "Text attribute of the Feed", func() {
Example("RSS Feed")
})
Attribute("title", String, "Title of the Feed", func() {
Example("Hashicorp Blog")
})
Attribute("tags", ArrayOf(String), "List of tags", func() {
Example([]string{"foo", "bar"})
})
Attribute("status", String, "Aggregation status", func() {
Enum("running", "stopped")
})
Attribute("lastCheck", DateTime, "Last aggregation pass")
Attribute("nextCheck", DateTime, "Next aggregation pass")
Attribute("errorMsg", String, "Last aggregation error")
Attribute("errorCount", Integer, "Number of consecutive aggregation errors")
Attribute("nbProcessedItems", Integer, "Total number of processed items")
Attribute("cdate", DateTime, "Date of creation")
Attribute("mdate", DateTime, "Date of modification")
Required("id", "xmlUrl", "title", "cdate", "mdate")
})
View("default", func() {
Attribute("id")
Attribute("xmlUrl")
Attribute("htmlUrl")
Attribute("hubUrl")
Attribute("title")
Attribute("text")
Attribute("tags")
Attribute("status")
Attribute("lastCheck")
Attribute("nextCheck")
Attribute("errorMsg")
Attribute("errorCount")
Attribute("nbProcessedItems")
Attribute("cdate")
Attribute("mdate")
})
View("tiny", func() {
Description("tiny is the view used to list feeds")
Attribute("id")
Attribute("xmlUrl")
Attribute("title")
Attribute("tags")
Attribute("cdate")
})
View("link", func() {
Attribute("id")
Attribute("xmlUrl")
})
})
// Filter is the filter resource media type.
var Filter = MediaType("application/vnd.feedpushr.filter.v1+json", func() {
Description("A filter")
TypeName("Filter")
ContentType("application/json")
Attributes(func() {
Attribute("id", Integer, "ID of the filter", func() {
Example(1)
})
Attribute("alias", String, "Alias of the filter", func() {
Example("foo")
})
Attribute("name", String, "Name of the filter", func() {
Example("fetch")
})
Attribute("desc", String, "Description of the filter", func() {
Example("This filter will...")
})
Attribute("props", HashOf(String, Any), "Filter properties", NoExample)
Attribute("condition", String, "Conditional expression of the filter", func() {
Example("\"foo\" in Tags")
})
Attribute("enabled", Boolean, "Status", func() {
Default(false)
})
Required("id", "alias", "name", "desc", "condition")
})
View("default", func() {
Attribute("id")
Attribute("alias")
Attribute("name")
Attribute("desc")
Attribute("props")
Attribute("condition")
Attribute("enabled")
})
})
// Output is the output resource media type.
var Output = MediaType("application/vnd.feedpushr.output.v1+json", func() {
Description("The output channel")
TypeName("Output")
ContentType("application/json")
Attributes(func() {
Attribute("id", Integer, "ID of the output", func() {
Example(1)
})
Attribute("alias", String, "Alias of the output channel", func() {
Example("foo")
})
Attribute("name", String, "Name of the output channel", func() {
Example("fetch")
})
Attribute("desc", String, "Description of the output channel", func() {
Example("New articles are sent as JSON document to...")
})
Attribute("props", HashOf(String, Any), "Output channel properties", NoExample)
Attribute("condition", String, "Conditional expression of the filter", func() {
Example("\"foo\" in Tags")
})
Attribute("enabled", Boolean, "Status", func() {
Default(false)
})
Required("id", "alias", "name", "desc", "condition")
})
View("default", func() {
Attribute("id")
Attribute("name")
Attribute("alias")
Attribute("desc")
Attribute("props")
Attribute("condition")
Attribute("enabled")
})
})
// PropSpec is the property specification media type.
var PropSpec = MediaType("application/vnd.feedpushr.prop-spec.v1+json", func() {
Description("The specification of a property")
TypeName("PropSpec")
ContentType("application/json")
Attributes(func() {
Attribute("name", String, "Name of the property", func() {
Example("url")
})
Attribute("desc", String, "Description of the output channel", func() {
Example("New articles are sent as JSON document to...")
})
Attribute("type", String, "Property type ('text', 'url', ...)", func() {
Example("text")
})
Attribute("options", HashOf(String, String), "Property options")
Required("name", "desc", "type")
})
View("default", func() {
Attribute("name")
Attribute("desc")
Attribute("type")
Attribute("options")
})
})
// OutputSpec is the output specification media type.
var OutputSpec = MediaType("application/vnd.feedpushr.output-spec.v1+json", func() {
Description("The output channel specification")
TypeName("OutputSpec")
ContentType("application/json")
Attributes(func() {
Attribute("name", String, "Name of the output channel", func() {
Example("fetch")
})
Attribute("desc", String, "Description of the output channel", func() {
Example("New articles are sent as JSON document to...")
})
Attribute("props", CollectionOf("application/vnd.feedpushr.prop-spec.v1+json"))
Required("name", "desc", "props")
})
View("default", func() {
Attribute("name")
Attribute("desc")
Attribute("props")
})
})
// FilterSpec is the filter specification media type.
var FilterSpec = MediaType("application/vnd.feedpushr.filter-spec.v1+json", func() {
Description("The filter specification")
TypeName("FilterSpec")
ContentType("application/json")
Attributes(func() {
Attribute("name", String, "Name of the filter", func() {
Example("title")
})
Attribute("desc", String, "Description of the filter", func() {
Example("Add a prefix to the tittle...")
})
Attribute("props", CollectionOf("application/vnd.feedpushr.prop-spec.v1+json"))
Required("name", "desc", "props")
})
View("default", func() {
Attribute("name")
Attribute("desc")
Attribute("props")
})
})
// FeedsPage is a page of feeds media type.
var FeedsPage = MediaType("application/vnd.feedpushr.feeds-page.v1+json", func() {
Description("A pagignated list of feeds")
TypeName("FeedsPage")
ContentType("application/json")
Attributes(func() {
Attribute("total", Integer, "Total number of feeds", func() {
Example(99)
})
Attribute("current", Integer, "Current page number", func() {
Example(1)
})
Attribute("limit", Integer, "Max number of feeds by page", func() {
Example(100)
})
Attribute("data", CollectionOf(Feed), "List of feeds")
Required("total", "current", "limit", "data")
})
View("default", func() {
Attribute("total")
Attribute("current")
Attribute("limit")
Attribute("data")
})
})