Repository navigation
Expand file tree
/
Copy pathAPIDesc.json
More file actions
424 lines (424 loc) · 23.9 KB
/
Copy pathAPIDesc.json
File metadata and controls
424 lines (424 loc) · 23.9 KB
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
{
"openapi": "3.0.1",
"info": {
"title": "LightsControllerAPI | v1",
"version": "1.0.0"
},
"servers": [
{
"url": "https://[::]:5042"
}
],
"paths": {
"/rooms": {
"get": {
"tags": [
"Rooms"
],
"summary": "Retrieve all rooms with their floor information",
"description": "Returns all rooms, including their names and floor numbers. This data can be cached for efficiency",
"operationId": "GetRooms",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Room"
}
}
}
}
}
}
}
},
"/rooms/{roomId}": {
"get": {
"tags": [
"Rooms"
],
"summary": "Retrieve a room’s name, floor, and unique ID",
"description": "A room is representing a group of lights where the 'RoomId' is the same. Each room has a unique Name and Floor number associated with the lights with the same RoomId. if a command is addressing the room without specifying the light name then all the lights located in the room should be receiving the command. Remember all the rooms for future use",
"operationId": "GetRoom",
"parameters": [
{
"name": "roomId",
"in": "path",
"description": "Unique identifier for the room",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/lights": {
"get": {
"tags": [
"Rooms",
"Lights"
],
"summary": "Returns all lights with their states, capabilities, and room details",
"description": "Returns a list of all available lights including their states, capabilities, and RoomId that referrences the room where it resides Name and Floor",
"operationId": "GetLights",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Light"
}
}
}
}
}
}
},
"patch": {
"tags": [
"Rooms",
"Lights"
],
"summary": "Batch update multiple lights with new states, colors, or brightness",
"description": "Allows batch updates for multiple lights, adjusting their states, colors, or brightness levels as specified. Returns a list of lights affected by the operation along with their updated values",
"operationId": "UpdateLights",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PatchRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PatchResponse"
}
}
}
},
"207": {
"description": "Multi-Status",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PatchResponse"
}
}
}
},
"400": {
"description": "Bad Request"
}
}
}
},
"/lights/{id}": {
"get": {
"tags": [
"Rooms",
"Lights"
],
"summary": "Retrieve a single light",
"description": "Returns details of a specific light by its ID: LightId",
"operationId": "GetLight",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Light"
}
}
}
},
"404": {
"description": "Not Found"
}
}
}
},
"/lights/floor/{floor}": {
"get": {
"tags": [
"Rooms",
"Lights"
],
"summary": "Fetch lights by floor, including states and capabilities",
"description": "Fetches all lights on a specified floor, detailing their IDs: LightId, current states and capabilities",
"operationId": "GetLightsByFloor",
"parameters": [
{
"name": "floor",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Light"
}
}
}
}
},
"404": {
"description": "Not Found"
}
}
}
}
},
"components": {
"schemas": {
"Capabilities": {
"type": "object",
"properties": {
"canChangeColor": {
"type": "boolean",
"description": "Indicates whether the light supports color changes. If True, Color can be adjusted. If False, Color remains fixed and cannot be altered",
"default": false
},
"isDimmable": {
"type": "boolean",
"description": "Indicates whether the light supports brightness adjustment. If True, Brightness can be adjusted. If False, brightness remains fixed and cannot be altered.",
"default": false
}
},
"description": "Light capabilities such as dimming and color-changing support",
"default": null
},
"Light": {
"required": [
"lightId",
"name",
"roomId",
"state"
],
"type": "object",
"properties": {
"lightId": {
"maximum": 2147483647,
"minimum": 0,
"type": "integer",
"description": "Unique identifier for the light",
"format": "int32"
},
"name": {
"maxLength": 100,
"minLength": 0,
"type": "string",
"description": "Name of the light"
},
"roomId": {
"maximum": 2147483647,
"minimum": 0,
"type": "integer",
"description": "Room ID where the light is located",
"format": "int32"
},
"state": {
"$ref": "#/components/schemas/LightState"
},
"color": {
"pattern": "^[0-9A-Fa-f]{6}$",
"type": "string",
"description": "Color of the light in hex format",
"default": "FFFFFF"
},
"brightness": {
"maximum": 100,
"minimum": 0,
"type": "integer",
"description": "Brightness of the light (0-100)",
"format": "int32",
"default": 100
},
"capabilities": {
"$ref": "#/components/schemas/Capabilities"
}
}
},
"LightState": {
"enum": [
"Off",
"On"
],
"description": "State of the light: On or Off",
"default": "Off"
},
"LightUpdateRequest": {
"required": [
"lightId"
],
"type": "object",
"properties": {
"lightId": {
"minLength": 1,
"type": "integer",
"description": "light LightId to update",
"format": "int32"
},
"state": {
"type": "string",
"description": "Turns a light (\"On\" or \"Off\")",
"nullable": true
},
"color": {
"pattern": "^[0-9A-Fa-f]{6}$",
"type": "string",
"description": "New color in hex format",
"nullable": true
},
"brightness": {
"maximum": 100,
"minimum": 0,
"type": "integer",
"description": "New brightness level (0-100)",
"format": "int32",
"nullable": true
}
}
},
"PatchRequest": {
"type": "object",
"properties": {
"lightUpdates": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LightUpdateRequest"
}
}
}
},
"PatchResponse": {
"required": [
"results"
],
"type": "object",
"properties": {
"successCount": {
"type": "integer",
"description": "Number of successfully updated lights.",
"format": "int32"
},
"failureCount": {
"type": "integer",
"description": "Number of failed updates.",
"format": "int32"
},
"results": {
"type": "array",
"items": {
"$ref": "#/components/schemas/UpdateLightResponse"
},
"description": "List of update results."
}
}
},
"Room": {
"required": [
"roomId",
"name"
],
"type": "object",
"properties": {
"roomId": {
"maximum": 2147483647,
"minimum": 0,
"type": "integer",
"description": "RoomId: Unique identifier for the room",
"format": "int32"
},
"name": {
"maxLength": 100,
"minLength": 0,
"type": "string",
"description": "Room Name"
},
"floor": {
"maximum": 500,
"minimum": -5,
"type": "integer",
"description": "Floor number where the Room is located",
"format": "int32",
"default": 1
}
}
},
"UpdateLightResponse": {
"required": [
"lightId",
"status",
"error"
],
"type": "object",
"properties": {
"lightId": {
"type": "integer",
"description": "Unique Id of the light that was updated",
"format": "int32"
},
"status": {
"type": "string",
"description": "Indicates whether the update was successful ('success' or 'failed')"
},
"error": {
"type": "string",
"description": "Detailed error message if the update status is failed",
"nullable": true
}
}
}
}
},
"tags": [
{
"name": "Rooms"
},
{
"name": "Lights"
}
]
}