-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
299 lines (280 loc) · 7.32 KB
/
Copy pathopenapi.yaml
File metadata and controls
299 lines (280 loc) · 7.32 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
openapi: 3.0.3
info:
title: Net Port API
version: 1.0.0
description: |
REST API for Net Port device management, legacy servers, and statistics.
WebSocket events: `device:updated`, `device:removed`, `statistics:device-updated`, `statistics:server-updated`.
servers:
- url: http://localhost:8080/api/v1
description: Backend (direct)
- url: http://localhost/api/v1
description: Backend via nginx
tags:
- name: Authentication
- name: Devices
- name: Servers
- name: Statistics
- name: Settings
- name: Observability
paths:
/authentication:
post:
tags: [Authentication]
summary: Login (JWT)
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [strategy, login, password]
properties:
strategy:
type: string
example: local
login:
type: string
password:
type: string
responses:
'201':
description: Authenticated
content:
application/json:
schema:
$ref: '#/components/schemas/AuthResponse'
/devices:
get:
tags: [Devices]
summary: List devices
security: [{ bearerAuth: [] }]
parameters:
- in: query
name: status
schema: { type: string }
- in: query
name: search
schema: { type: string }
responses:
'200':
description: Device list
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Device'
post:
tags: [Devices]
summary: Create device
security: [{ bearerAuth: [] }]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DeviceCreate'
responses:
'201':
description: Created device (includes one-time auth_token)
/devices/{id}:
get:
tags: [Devices]
summary: Get device
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/DeviceUuid'
responses:
'200':
description: Device
content:
application/json:
schema:
$ref: '#/components/schemas/Device'
patch:
tags: [Devices]
summary: Update device
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/DeviceUuid'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DeviceUpdate'
responses:
'200':
description: Updated device
delete:
tags: [Devices]
summary: Delete device
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/DeviceUuid'
responses:
'200':
description: Deleted
/devices/{deviceId}/connect:
post:
tags: [Devices]
summary: Allow device registration (status connecting)
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/DeviceBusinessId'
responses:
'200':
description: Device ready to register
/devices/{deviceId}/disconnect:
post:
tags: [Devices]
summary: Disconnect active device session
security: [{ bearerAuth: [] }]
parameters:
- $ref: '#/components/parameters/DeviceBusinessId'
responses:
'200':
description: Disconnect initiated
/devices/statistics/summary:
get:
tags: [Statistics]
summary: Device statistics summary
security: [{ bearerAuth: [] }]
responses:
'200':
description: Statistics rows
/settings/auto-connect:
get:
tags: [Settings]
summary: Get auto-connect setting
security: [{ bearerAuth: [] }]
responses:
'200':
description: Current value
content:
application/json:
schema:
type: object
properties:
enabled: { type: boolean }
patch:
tags: [Settings]
summary: Update auto-connect setting
security: [{ bearerAuth: [] }]
requestBody:
content:
application/json:
schema:
type: object
properties:
enabled: { type: boolean }
responses:
'200':
description: Updated
/servers:
get:
tags: [Servers]
summary: List legacy servers
security: [{ bearerAuth: [] }]
responses:
'200':
description: Server list
/statistics:
get:
tags: [Statistics]
summary: Legacy server statistics
security: [{ bearerAuth: [] }]
responses:
'200':
description: Statistics list
/health:
get:
tags: [Observability]
summary: Health check
servers:
- url: http://localhost:8080
responses:
'200':
description: Healthy
'503':
description: Degraded
/metrics:
get:
tags: [Observability]
summary: Prometheus metrics
servers:
- url: http://localhost:8080
responses:
'200':
description: Prometheus text format
content:
text/plain:
schema:
type: string
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
parameters:
DeviceUuid:
in: path
name: id
required: true
schema: { type: string, format: uuid }
DeviceBusinessId:
in: path
name: deviceId
required: true
schema: { type: string }
schemas:
AuthResponse:
type: object
properties:
accessToken: { type: string }
user: { $ref: '#/components/schemas/User' }
User:
type: object
properties:
id: { type: integer }
login: { type: string }
role: { type: string }
Device:
type: object
properties:
id: { type: string, format: uuid }
device_id: { type: string }
name: { type: string }
status:
type: string
enum: [inactive, connecting, active, error]
assigned_port: { type: integer, nullable: true }
preferred_port: { type: integer, nullable: true }
internal_address: { type: string }
internal_port: { type: integer }
online: { type: boolean }
last_heartbeat: { type: string, format: date-time, nullable: true }
DeviceCreate:
type: object
required: [device_id]
properties:
device_id:
type: string
minLength: 3
maxLength: 64
name: { type: string }
type:
type: string
enum: [iot_gateway, sensor, camera, router, other]
internal_address: { type: string }
internal_port: { type: integer }
preferred_port:
type: integer
description: Even port between 6000 and 6998
DeviceUpdate:
allOf:
- $ref: '#/components/schemas/DeviceCreate'