-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapiary.apib
191 lines (115 loc) · 3.72 KB
/
apiary.apib
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
FORMAT: 1A
# Pantry
Pantry is a simple API for hardware leasing.
# Group Targets
## Target Collection [/targets]
### List all available targets [GET]
List all available targets in the pool.
+ Response 200 (application/json)
+ Attributes (Targets)
### Create a new target [POST]
Make a new target available for leasing.
+ Request (application/json)
+ Attributes (Target)
+ Response 201 (application/json)
Location: /targets/1
+ Attributes (Target)
## Target [/targets/{targetid}]
Single target operations.
+ Parameters
+ targetid: 1 (number) - Integer id of the target
### Get single target [GET]
Get information on a single target.
+ Response 200 (application/json)
+ Attributes (Target)
### Update single target [PATCH]
Update values for a single target.
+ Request (application/json)
[
{ "op": "add", "path": "/nickname", "value": "Sunissimo" },
{ "op": "replace", "path": "/healthPercent", "value": 99 }
]
+ Response 204
### Delete single target [DELETE]
Delete the target indicated by the id parameter.
+ Response 204
## Events for a single target [/targets/{targetid}/events]
Handles events for a given target.
+ Parameters
+ targetid: 1337 (number) - Integer id of the target
### Get events for a single target [GET]
List events for the target indicated by `targetid`
+ Response 200 (application/json)
### Create an event for a single target [POST]
Create an event for target with id `targetid`
+ Request (application/json)
+ Attributes (Event)
+ Response 201 (application/json)
Location: /targets/14/events/25
+ Attributes (Event)
## Data Structures
### Target
+ hostname: Sune (string, required)
+ nickname: Sunisen (string)
+ description: Sune's machine (string, required)
+ maintainer: Sune Sunesson (string, required)
+ healthPercent: 89 (number)
+ state (enum)
+ ready
+ leased
+ down
+ maintenance
+ tags (array)
+ (object)
+ key: platform (string, required)
+ value: linux (string, required)
### Event
+ timestamp
+ message: "Something happened" (string, required)
+ targetId: 14 (number, required)
### Events
+ events (array[Event])
### Targets
+ targets (array[Target])
# Group Leases
## Lease Collection [/leases]
### List all leases [GET]
List all known leases.
+ Response 200 (application/json)
+ Attributes
+ leases: Lease, Lease (array[Lease], required)
### Create a new lease [POST]
Create a new lease, requesting hardware according to the information in the leas structure.
+ Request (application/json)
+ Attributes (Lease)
+ Response 201 (application/json)
Location: /leases/11
+ Attributes (Lease)
## Single Lease [/leases/{leaseid}]
Single lease operations
+ Parameters
+ leaseid: 14 (number) - Integer id of the lease
### Get a single lease [GET]
Get information on the lease given by `leaseid`.
+ Response 200 (application/json)
+ Attributes (Lease)
### Renew a lease [POST]
Renews the lease with the given `leaseid` and extends the timeout with the `time` value of the lease.
+ Response 204
## Data Structures
### Lease
+ state (enum, required) - State of this lease request
+ assigningtargets
+ ended
+ active
+ fulfilled: true (boolean) - Indicates whether all requests were fulfilled. If this is false and state is `active` it means that the request was partially fulfilled
+ createdAt
+ updatedAt
+ time (number, required) - Time in minutes to lease the hardware for
+ requests (array)
+ (object)
+ tags: linux, 64bit, debian (array)
+ numTargets: 2 (number)
+ assignedTargets: 1, 3, 4 (array[number]) - The targets currently assigned to this request
### Leases
+ leases (array[Lease], required)