This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
core-command.yaml
572 lines (570 loc) · 22.1 KB
/
core-command.yaml
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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
openapi: 3.0.0
info:
title: Edgex Foundry - Core Command API
description: This is the definition of the API for the Core Command service in the EdgeX Foundry IOT microservice platform. Core Command is responsible for storing command definitions and also for executing those commands as reads and writes against target devices.
version: 2.x
servers:
- url: http://localhost:48082/api/v2
description: URL for local development and testing
components:
schemas:
ActionResponse:
type: object
properties:
code:
type: string
description:
type: string
expectedValues:
type: array
items:
type: string
Command:
type: object
properties:
created:
type: integer
get:
$ref: '#/components/schemas/CommandAction'
id:
type: string
format: uuid
modified:
type: integer
name:
type: string
put:
$ref: '#/components/schemas/CommandAction'
CommandAction:
type: object
properties:
path:
type: string
responses:
type: array
items:
$ref: '#/components/schemas/ActionResponse'
url:
type: string
CommandResponse:
allOf:
- $ref: '#/components/schemas/CorrelatedResponse'
description: "For the specified device, provides a list of the associated commands."
type: object
properties:
device:
description: "Indicates a device. Will be either the device ID or name depending on how the request was made."
type: string
commands:
type: array
items:
$ref: '#/components/schemas/Command'
CorrelatedRequest:
description: "Provides a correlation ID that can be used when grouping multiple requests into a single batch. For example, multiple commands can be issued at once. Each IssueCommandRequest has its own request identifier while the batch has an overall identifier. This allows for visibility into whether or not a response was obtained for every request in the batch."
type: object
properties:
correlationId:
description: "Identifies the batch to which this request belongs. If used via REST, this value should be the same as that of the ''X-Correlation-ID'' HTTP header."
type: string
format: uuid
example: "82eb2e26-0f24-48aa-ae4c-de9dac3fb9bc"
requestId:
description: "Uniquely identifies this request apart from its peers in the batch. For implementation, recommend this value be generated by the type's constructor."
type: string
format: uuid
example: "e6e8a2f4-eb14-4649-9e2b-175247911369"
required:
- correlationId
- requestId
CorrelatedResponse:
description: "Provides a correlation ID that can be used when grouping multiple responses into a single batch. For example, multiple commands can be issued at once. The responses can be returned as a batch or individually. It doesn't matter as long as both of these properties are correctly set because either way the caller will have visibility into whether or not a response was obtained for every request in the batch."
type: object
properties:
correlationId:
description: "Identifies the batch to which this response belongs. If used via REST, this value should be the same as that of the ''X-Correlation-ID'' HTTP header."
type: string
format: uuid
example: "82eb2e26-0f24-48aa-ae4c-de9dac3fb9bc"
requestId:
description: "Uniquely identifies the request within the larger batch resulting in this response."
type: string
format: uuid
example: "e6e8a2f4-eb14-4649-9e2b-175247911369"
statusCode:
description: "A numeric code signifying the operational status of the response."
type: integer
message:
description: "A field that can contain a free-form message, such as an error message."
type: string
required:
- correlationId
- requestId
IssueCommandRequest:
allOf:
- $ref: '#/components/schemas/CorrelatedRequest'
description: "A request type specifying an individual command for execution."
type: object
properties:
deviceId:
type: string
format: uuid
description: "Refers to the device targeted by the command. Could be either the device ID or name."
commandId:
type: string
format: uuid
description: "Refers to the command being invoked. Could be either the command ID or name."
required:
- device
- command
IssueCommandResponse:
allOf:
- $ref: '#/components/schemas/CorrelatedResponse'
description: "Provides a response with details about whether invocation of a given command was successful."
type: object
properties:
device:
type: string
description: "Refers to the device targeted by the command. Could be either the device ID or name."
command:
type: string
description: "Refers to the command being invoked. Could be either the command ID or name."
required:
- device
- command
PingResponse:
allOf:
- $ref: '#/components/schemas/CorrelatedResponse'
type: object
properties:
timestamp:
type: string
description: "Outputs the current server timestamp in RFC1123 format"
example: "Mon, 02 Jan 2006 15:04:05 MST"
RequestEnvelope:
description: "A wrapper type for use when sending a request to the /batch endpoint. Each individual request type in the HTTP request should be wrapped in an envelope to facilitate instantiation of the correct routing handler. See property descriptions below for more details."
type: object
properties:
action:
type: string
description: "Indicates the type of operation applicable to the wrapped request. Valid values are 'create','read','update','delete', and 'command'"
content:
type: string
format: byte
description: "A byte array containing a marshalled request type instance. This is the specific, semantically identifiable request -- such as an AddDeviceRequest."
strategy:
type: string
description: "Indicates the expectation of whether a response should be produced synchronously or asynchronously. If asynchronously, desire for either a polling or push/callback should be provided. Valid values are 'sync','async-push','async-poll'"
type:
type: string
description: "The name of the type applicable to the request instance contained in the 'content' property."
version:
description: "Proposed field for explicitly defining version of request DTO. This is for advertising compatibility between a publisher/subscriber or requester/receiver"
type: string
example: "2.0.x"
required:
- action
- content
- strategy
- type
- version
ResponseEnvelope:
description: "A wrapper type for use when receiving a response from the /batch endpoint. Each individual response type in the HTTP response should be wrapped in an envelope to facilitate unmarshalling by the client. See property descriptions below for more details."
type: object
properties:
action:
type: string
description: "Indicates the type of operation applicable to the wrapped response. This should be recapitulated from the originating request. Valid values are 'create','read','update','delete', and 'command'"
content:
type: string
format: byte
description: "A byte array containing a marshalled response type instance. This is the specific, semantically identifiable response -- such as an AddDeviceResponse."
strategy:
type: string
description: "Recapitulates the expectation with regard to the delivery of response that was specified on the originating request. Valid values are 'sync','async-push','async-poll'"
type:
type: string
description: "The name of the type applicable to the response instance contained in the 'content' property."
version:
description: "Proposed field for explicitly defining version of response DTO. This is for advertising compatibility between a publisher/subscriber or requester/receiver"
type: string
example: "2.0.x"
required:
- action
- content
- strategy
- type
- version
parameters:
offsetParam:
in: query
name: offset
required: false
schema:
type: integer
minimum: 0
description: "The number of items to skip before starting to collect the result set."
limitParam:
in: query
name: limit
required: false
schema:
type: integer
minimum: 1
maximum: 50
default: 20
description: "The numbers of items to return."
correlatedRequestHeader:
in: header
name: X-Correlation-ID
description: "A unique identifier correlating a request to its associated response, facilitating tracing through being included on requests originating from the initiating request."
schema:
type: string
format: uuid
required: true
example: "14a42ea6-c394-41c3-8bcd-a29b9f5e6835"
headers:
correlatedResponseHeader:
description: "A response header that returns the unique correlation ID used to initiate the request."
schema:
type: string
format: uuid
required: true
example: "14a42ea6-c394-41c3-8bcd-a29b9f5e6835"
paths:
/batch:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
post:
summary: "Accepts an arbitrary number of RequestEnvelope instances. Each RequestEnvelope has a 'content' property that holds a specific request type. This endpoint is operation agnostic will route the request to the appropriate handler implementation within the service."
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/RequestEnvelope'
responses:
'207':
description: "Indicates a multi-part response supportive of accepting multiple requests at once. The 'statusCode' property of each response in the returned array will indicate success or failure."
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ResponseEnvelope'
/command:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
put:
summary: "Allows for the issuance of multiple commands in a batch. Commands will be executed as either read or write according to their definition."
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/IssueCommandRequest'
responses:
'207':
description: "Indicates a multi-part response supportive of accepting multiple requests at once. The 'statusCode' property of each response in the returned array will indicate success or failure."
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/IssueCommandResponse'
/device/id/{deviceid}/command/{commandid}:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
- name: deviceid
in: path
required: true
schema:
type: string
format: uuid
description: "An ID of datatype string, by default a GUID. Uniquely identifies a device."
- name: commandid
in: path
required: true
schema:
type: string
format: uuid
description: "An ID of datatype string, by default a GUID. Uniquely identifies a command."
get:
summary: "Issue the specified read command referenced by the command id to the device/sensor, also referenced by id."
responses:
'200':
description: "OK"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'400':
description: "Request is in an invalid state"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'404':
description: "The requested resource does not exist"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'423':
description: "The device is locked (AdminState)"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'500':
description: "An unexpected error occurred on the server"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
put:
summary: "Issue the specified write command referenced by the command id to the device/sensor, also referenced by id."
responses:
'207':
description: "Indicates a multi-part response supportive of accepting multiple requests at once. The 'statusCode' property of each response in the returned array will indicate success or failure."
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/IssueCommandResponse'
/device/name/{deviceName}/command/{commandName}:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
- name: deviceName
in: path
required: true
schema:
type: string
description: "A name uniquely identifying a device."
- name: commandName
in: path
required: true
schema:
type: string
description: "A name uniquely identifying a command."
get:
summary: "Issue the specified read command referenced by the command name to the device/sensor, also referenced by name."
responses:
'200':
description: "OK"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'400':
description: "Request is in an invalid state"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'404':
description: "The requested resource does not exist"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'423':
description: "The device is locked (AdminState)"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
'500':
description: "An unexpected error occurred on the server"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCommandResponse'
put:
summary: "Issue the specified write command referenced by the command name to the device/sensor, also referenced by name."
responses:
'207':
description: "Indicates a multi-part response supportive of accepting multiple requests at once. The 'statusCode' property of each response in the returned array will indicate success or failure."
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/IssueCommandResponse'
/device/id/{id}:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
- name: id
in: path
required: true
schema:
type: string
format: uuid
description: "An ID of datatype string, by default a GUID. Uniquely identifies a device."
get:
summary: "Returns all commands associated with the specified device."
responses:
'200':
description: "OK"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/CommandResponse'
'404':
description: "The requested resource does not exist"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/CommandResponse'
'500':
description: "An unexpected error occurred on the server"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/CommandResponse'
/device/name/{name}:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
- name: name
in: path
required: true
schema:
type: string
description: "The unique name of a device."
get:
summary: "Returns all commands associated with the specified device."
responses:
'200':
description: "OK"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/CommandResponse'
'404':
description: "The requested resource does not exist"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/CommandResponse'
'500':
description: "An unexpected error occurred on the server"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/CommandResponse'
/device/all:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
- $ref: '#/components/parameters/offsetParam'
- $ref: '#/components/parameters/limitParam'
get:
summary: "Returns a paginated list of CommandResponses. The list contains all of the commands in the system associated with their respective device."
responses:
'200':
description: "OK"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CommandResponse'
'500':
description: "An unexpected error occurred on the server"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CommandResponse'
/ping:
get:
summary: "A simple 'ping' endpoint that can be used as a service healthcheck"
responses:
'200':
description: "OK"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/PingResponse'
'500':
description: "An unexpected error occurred on the server"
headers:
X-Correlation-ID:
$ref: '#/components/headers/correlatedResponseHeader'
content:
application/json:
schema:
$ref: '#/components/schemas/PingResponse'