-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathpkgs.go
136 lines (112 loc) · 3.07 KB
/
pkgs.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
package design
import . "goa.design/goa/dsl"
var _ = Service("indexes", func() {
Description("The indexes service manages the package_index files")
Error("invalid_url", ErrorResult, "url invalid")
HTTP(func() {
Response("invalid_url", StatusBadRequest)
})
Method("list", func() {
Result(ArrayOf(String))
HTTP(func() {
GET("/pkgs/indexes")
Response(StatusOK)
})
})
Method("add", func() {
Payload(IndexPayload)
Result(Operation)
HTTP(func() {
POST("/pkgs/indexes/add")
Response(StatusOK)
})
})
Method("remove", func() {
Payload(IndexPayload)
Result(Operation)
HTTP(func() {
POST("/pkgs/indexes/delete")
Response(StatusOK)
})
})
})
var _ = Service("tools", func() {
Description("The tools service manages the available and installed tools")
Method("available", func() {
Result(CollectionOf(Tool))
HTTP(func() {
GET("/pkgs/tools/available")
Response(StatusOK)
})
})
Method("installed", func() {
Result(CollectionOf(Tool))
HTTP(func() {
GET("/pkgs/tools/installed")
Response(StatusOK)
})
})
Method("install", func() {
Error("not_found", ErrorResult, "tool not found")
HTTP(func() {
Response("not_found", StatusBadRequest)
})
Payload(ToolPayload)
Result(Operation)
HTTP(func() {
POST("/pkgs/tools/installed")
Response(StatusOK)
})
})
Method("remove", func() {
Payload(ToolPayload)
Result(Operation)
HTTP(func() {
DELETE("/pkgs/tools/installed/{packager}/{name}/{version}")
Response(StatusOK)
})
})
})
var IndexPayload = Type("arduino.index", func() {
TypeName("IndexPayload")
Attribute("url", String, "The url of the index file", func() {
Example("https://downloads.arduino.cc/packages/package_index.json")
})
Required("url")
})
var ToolPayload = Type("arduino.tool", func() {
Description(`A tool is an executable program that can upload sketches.
If url is absent the tool will be searched among the package index installed`)
TypeName("ToolPayload")
Attribute("name", String, "The name of the tool", func() {
Example("avrdude")
})
Attribute("version", String, "The version of the tool", func() {
Example("6.3.0-arduino9")
})
Attribute("packager", String, "The packager of the tool", func() {
Example("arduino")
})
Attribute("url", String, `The url where the package can be found. Optional.
If present checksum must also be present.`)
Attribute("checksum", String, `A checksum of the archive. Mandatory when url is present.
This ensures that the package is downloaded correcly.`)
Required("name", "version", "packager")
})
var Tool = ResultType("application/vnd.arduino.tool", func() {
Description("A tool is an executable program that can upload sketches.")
TypeName("Tool")
Reference(ToolPayload)
Attribute("name")
Attribute("version")
Attribute("packager")
Required("name", "version", "packager")
})
var Operation = ResultType("application/vnd.arduino.operation", func() {
Description("Describes the result of an operation.")
TypeName("Operation")
Attribute("status", String, "The status of the operation", func() {
Example("ok")
})
Required("status")
})