-
Notifications
You must be signed in to change notification settings - Fork 10
/
openapi.yaml
857 lines (777 loc) · 22.9 KB
/
openapi.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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
openapi: 3.0.3
info:
title: CasaOS Message Bus API
version: v2
description: |
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_dark_night_800px.png">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_twilight_blue_800px.png">
<img alt="CasaOS" src="https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_twilight_blue_800px.png">
</picture>
CasaOS Message Bus accepts events and actions from various sources and delivers them to subscribers.
For issues and discussions, please visit the [GitHub repository](https://github.com/IceWhaleTech/CasaOS) or join [our Discord](https://discord.gg/knqAbbBbeX).
servers:
- url: /v2/message_bus
tags:
- name: Event methods
description: |-
methods for managing event types, as well as publishing and subscribing to events
- name: Action methods
description: |-
methods for managing action types, as well as publishing and subscribing to actions
- name: Websocket Endpoints
description: |-
Endpoint paths for subscribing to events and actions via WebSocket
- name: SocketIO Endpoints
description: |-
Endpoint paths for subscribing to events and actions via SocketIO
- name: YSK Endpoints
description: |-
Endpoint paths for YSK card via RESTful API
- name: EventType
description: |-
<SchemaDefinition schemaRef="#/components/schemas/EventType" />
- name: Event
description: |-
<SchemaDefinition schemaRef="#/components/schemas/Event" />
- name: ActionType
description: |-
<SchemaDefinition schemaRef="#/components/schemas/ActionType" />
- name: Action
description: |-
<SchemaDefinition schemaRef="#/components/schemas/Action" />
- name: PropertyType
description: |-
<SchemaDefinition schemaRef="#/components/schemas/PropertyType" />
- name: YSK methods
description: |-
methods for managing YSK card
x-tagGroups:
- name: Methods
tags:
- EventType methods
- Event methods
- ActionType methods
- Action methods
- YSK methods
- name: Endpoints
tags:
- WebSocket Endpoints
- SocketIO Endpoints
- YSK Endpoints
- name: Schemas
tags:
- EventType
- Event
- ActionType
- Action
- PropertyType
security:
- access_token: []
paths:
/event_type:
get:
summary: List event types
description: |
List all event types that are currently registered with the message bus.
operationId: getEventTypes
tags:
- EventType methods
responses:
"200":
$ref: "#/components/responses/GetEventTypesOK"
"500":
$ref: "#/components/responses/ResponseInternalServerError"
post:
summary: Register one or more event types
description: |
Register one or more new event types with the message bus.
operationId: RegisterEventTypes
tags:
- EventType methods
requestBody:
$ref: "#/components/requestBodies/RegisterEventTypes"
responses:
"200":
$ref: "#/components/responses/ResponseOK"
"400":
$ref: "#/components/responses/ResponseBadRequest"
"409":
$ref: "#/components/responses/ResponseConflict"
/event_type/{source_id}:
get:
summary: Get event types by source ID
description: |
Get all event types that are registered with the message bus for a specific source ID.
operationId: getEventTypesBySourceID
tags:
- EventType methods
parameters:
- $ref: "#/components/parameters/SourceID"
responses:
"200":
$ref: "#/components/responses/GetEventTypesOK"
"404":
$ref: "#/components/responses/ResponseNotFound"
/event_type/{source_id}/{name}:
get:
summary: Get an event type by source ID and name
description: |
Get an event type that is registered with the message bus for a specific source ID and event name.
operationId: getEventType
tags:
- EventType methods
parameters:
- $ref: "#/components/parameters/SourceID"
- $ref: "#/components/parameters/EventName"
responses:
"200":
$ref: "#/components/responses/GetEventTypeOK"
"404":
$ref: "#/components/responses/ResponseNotFound"
/event/{source_id}/{name}:
post:
summary: Publish an event
description: |
Publish an event to the message bus.
operationId: publishEvent
tags:
- Event methods
parameters:
- $ref: "#/components/parameters/SourceID"
- $ref: "#/components/parameters/EventName"
requestBody:
$ref: "#/components/requestBodies/PublishEvent"
responses:
"200":
$ref: "#/components/responses/PublishEventOK"
"400":
$ref: "#/components/responses/ResponseBadRequest"
"404":
$ref: "#/components/responses/ResponseNotFound"
/event/{source_id}:
get:
summary: Subscribe to events by source ID (WebSocket)
description: |
Subscribe to event by `source_id` via WebSocket.
> `names` can be specified in the query string to subscribe to specific event types.
operationId: subscribeEventWS
tags:
- WebSocket Endpoints
parameters:
- $ref: "#/components/parameters/SourceID"
- $ref: "#/components/parameters/EventNames"
responses:
"101":
description: |
The connection will be upgraded to a WebSocket connection and the client will receive events as they are published.
/action_type:
get:
summary: List action types
description: |
List all action types that are currently registered with the message bus.
operationId: getActionTypes
tags:
- ActionType methods
responses:
"200":
$ref: "#/components/responses/GetActionTypesOK"
post:
summary: Register one or more action types
description: |
Register one or more new action types with the message bus.
operationId: RegisterActionTypes
tags:
- ActionType methods
requestBody:
$ref: "#/components/requestBodies/RegisterActionTypes"
responses:
"200":
$ref: "#/components/responses/ResponseOK"
"400":
$ref: "#/components/responses/ResponseBadRequest"
"409":
$ref: "#/components/responses/ResponseConflict"
/action_type/{source_id}:
get:
summary: Get action types by source ID
description: |
Get all action types that are registered with the message bus for a specific source ID.
operationId: getActionTypesBySourceID
tags:
- ActionType methods
parameters:
- $ref: "#/components/parameters/SourceID"
responses:
"200":
$ref: "#/components/responses/GetActionTypesOK"
"404":
$ref: "#/components/responses/ResponseNotFound"
/action_type/{source_id}/{name}:
get:
summary: Get an action type by source ID and name
description: |
Get an action type that is registered with the message bus for a specific source ID and action name.
operationId: getActionType
tags:
- ActionType methods
parameters:
- $ref: "#/components/parameters/SourceID"
- $ref: "#/components/parameters/ActionName"
responses:
"200":
$ref: "#/components/responses/GetActionTypeOK"
"404":
$ref: "#/components/responses/ResponseNotFound"
/action/{source_id}/{name}:
post:
summary: Trigger an action
description: |
Trigger an action on the message bus.
operationId: triggerAction
tags:
- Action methods
parameters:
- $ref: "#/components/parameters/SourceID"
- $ref: "#/components/parameters/ActionName"
requestBody:
$ref: "#/components/requestBodies/TriggerAction"
responses:
"200":
$ref: "#/components/responses/TriggerActionOK"
"400":
$ref: "#/components/responses/ResponseBadRequest"
"404":
$ref: "#/components/responses/ResponseNotFound"
/action/{source_id}:
get:
summary: Subscribe to actions by source ID (WebSocket)
description: |
Subscribe to actions by `source_id` via WebSocket.
> `names` can be specified in the query string to subscribe to specific action types.
operationId: subscribeActionWS
tags:
- WebSocket Endpoints
parameters:
- $ref: "#/components/parameters/SourceID"
- $ref: "#/components/parameters/ActionNames"
responses:
"101":
description: |
The connection will be upgraded to a WebSocket connection and the client will receive actions as they are triggered.
/socket.io:
get:
summary: Subscribe to events and actions (SocketIO)
description: |
Subscribe to events and actions via SocketIO.
- SocketIO `room` should be either `event` or `action`
operationId: subscribeSIO
tags:
- SocketIO Endpoints
responses:
"101":
description: |
The connection will be upgraded to a SocketIO connection and the client will receive events as they are published.
"200":
description: |
Polling initialized for SocketIO
post:
summary: Poll events and actions (SocketIO)
description: |
Poll events and actions by via SocketIO.
operationId: pollSIO
tags:
- SocketIO Endpoints
responses:
"200":
description: |
Polling continued from SocketIO
/socket.io/:
get:
summary: Subscribe to events and actions (SocketIO)
description: |
> Same as `/socket.io` except it comes with a trailing slash `/` - a workaround to maximize compatibility
operationId: subscribeSIO2
responses:
"101":
description: |
The connection will be upgraded to a SocketIO connection and the client will receive events as they are published.
"200":
description: |
Polling initialized for SocketIO
post:
summary: Poll events and actions (SocketIO)
description: |
> Same as `/socket.io` except it comes with a trailing slash `/` - a workaround to maximize compatibility
operationId: pollSIO2
responses:
"200":
description: |
Polling continued from SocketIO
/ysk:
get:
description: |-
Get need display YSK card
operationId: getYskCard
tags:
- YSK Endpoints
responses:
"200":
$ref: "#/components/responses/ResponseGetYSKCardListOK"
"500":
$ref: "#/components/responses/ResponseInternalServerError"
/ysk/{id}:
delete:
description: |-
Not display YSK card
operationId: deleteYskCard
tags:
- YSK Endpoints
parameters:
- name: id
in: path
description: YSK card id
required: true
schema:
type: string
responses:
"200":
$ref: "#/components/responses/ResponseOK"
"500":
$ref: "#/components/responses/ResponseInternalServerError"
components:
securitySchemes:
access_token:
type: apiKey
in: header
name: Authorization
parameters:
SourceID:
name: source_id
in: path
required: true
schema:
type: string
example: "local-storage"
EventName:
name: name
in: path
required: true
schema:
type: string
example: "local-storage:disk:added"
EventNames:
name: names
in: query
allowEmptyValue: false
required: false
schema:
type: array
items:
type: string
example: "local-storage:disk:added,local-storage:disk:removed"
ActionName:
name: name
in: path
required: true
schema:
type: string
example: "local-storage:partition:format"
ActionNames:
name: names
in: query
allowEmptyValue: false
required: false
schema:
type: array
items:
type: string
example: "local-storage:partition:format,local-storage:partition:mount"
requestBodies:
RegisterEventTypes:
description: (TODO)
required: true
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/EventType"
PublishEvent:
description: (TODO)
required: true
content:
application/json:
schema:
type: object
description: event properties
additionalProperties:
type: string
example:
local-storage:vendor: SanDisk
local-storage:model: Cruzer
local-storage:uuid: 442e0e5b-9d3e-4fe8-b46f-9c4141fdecd7
RegisterActionTypes:
description: (TODO)
required: true
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ActionType"
TriggerAction:
description: (TODO)
required: true
content:
application/json:
schema:
type: object
description: action properties
additionalProperties:
type: string
example:
local-storage:uuid: 442e0e5b-9d3e-4fe8-b46f-9c4141fdecd7
responses:
ResponseOK:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/BaseResponse"
ResponseInternalServerError:
description: (TODO)
content:
application/json:
schema:
$ref: "#/components/schemas/BaseResponse"
ResponseNotFound:
description: Not Found
content:
application/json:
schema:
$ref: "#/components/schemas/BaseResponse"
example:
message: "Not Found"
ResponseBadRequest:
description: Bad Request
content:
application/json:
schema:
$ref: "#/components/schemas/BaseResponse"
example:
message: "Bad Request"
ResponseConflict:
description: Conflict
content:
application/json:
schema:
$ref: "#/components/schemas/BaseResponse"
example:
message: "Conflict"
GetEventTypesOK:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/EventType"
GetEventTypeOK:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/EventType"
PublishEventOK:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Event"
GetActionTypesOK:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ActionType"
GetActionTypeOK:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/ActionType"
TriggerActionOK:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Action"
ResponseGetYSKCardListOK:
description: OK
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/BaseResponse"
- properties:
data:
$ref: "#/components/schemas/YSKCardList"
schemas:
BaseResponse:
properties:
message:
readOnly: true
description: message returned by server side if there is any
type: string
example: ""
PropertyType:
type: object
required:
- "name"
properties:
name:
type: string
description: |-
property name
> It is recommended for a property name to be as descriptive as possible. One option is to prefix with a namespace.
> - If the property is source specific, prefix with source ID. For example, `local-storage:vendor`
> - Otherwise, prefix with `common:`. For example, `common:email`
>
> Some bad examples are `id`, `avail`, `blk`...which can be ambiguous and confusing.
example: "local-storage:vendor"
description:
type: string
example: "Hardware vendor of this storage"
example:
type: string
example: "SanDisk"
EventType:
type: object
required:
- "sourceID"
- "name"
- "propertyTypeList"
properties:
sourceID:
type: string
description: event source id to identify where the event comes from
example: "local-storage"
name:
type: string
description: |-
event name
(there is no naming convention for event names, but it is recommended to name each as structural and descriptive as possible)
example: "local-storage:disk:added"
propertyTypeList:
type: array
items:
$ref: "#/components/schemas/PropertyType"
Event:
type: object
required:
- "sourceID"
- "name"
- "properties"
properties:
sourceID:
type: string
description: associated source id
example: "local-storage"
name:
type: string
description: event name
example: "local-storage:disk:added"
uuid:
type: string
description: event uuid
example: "442e0e5b-9d3e-4fe8-b46f-9c4141fdecd7"
properties:
type: object
description: event properties
additionalProperties:
type: string
example:
local-storage:vendor: SanDisk
local-storage:model: Cruzer
local-storage:uuid: 442e0e5b-9d3e-4fe8-b46f-9c4141fdecd7
timestamp:
type: string
description: timestamp this event took place
format: date-time
ActionType:
type: object
required:
- "sourceID"
- "name"
- "propertyTypeList"
properties:
sourceID:
type: string
description: action source id to identify where the action will take
example: "local-storage"
name:
type: string
description: |-
action name
(there is no naming convention for action names, but it is recommended to name each as structural and descriptive as possible)
example: "local-storage:disk:format"
propertyTypeList:
type: array
items:
$ref: "#/components/schemas/PropertyType"
Action:
type: object
required:
- "sourceID"
- "name"
- "properties"
properties:
sourceID:
type: string
description: associated source id
example: "local-storage"
name:
type: string
description: action name
example: "local-storage:disk:format"
properties:
type: object
description: event properties
additionalProperties:
type: string
example:
local-storage:vendor: SanDisk
local-storage:model: Cruzer
local-storage:uuid: 442e0e5b-9d3e-4fe8-b46f-9c4141fdecd7
timestamp:
type: string
description: timestamp this action took place
format: date-time
YSKCardList:
type: array
items:
$ref: "#/components/schemas/YSKCard"
YSKCard:
type: object
required:
- "id"
- "cardType"
- "renderType"
- "content"
properties:
id:
type: string
example: "1234567890"
cardType:
type: string
enum:
- "task"
- "long-notice"
- "short-notice"
renderType:
type: string
enum:
- "task"
- "list-notice"
- "icon-text-notice"
- "markdown-notice"
content:
$ref: "#/components/schemas/YSKCardContent"
YSKCardContent:
type: object
required:
- "titleIcon"
- "titleText"
properties:
titleIcon:
$ref: "#/components/schemas/YSKCardIcon"
titleText:
type: string
example: "CasaOS"
bodyProgress:
$ref: "#/components/schemas/YSKCardProgress"
bodyIconWithText:
$ref: "#/components/schemas/YSKCardIconWithText"
bodyList:
type: array
items:
$ref: "#/components/schemas/YSKCardListItem"
footerActions:
type: array
items:
$ref: "#/components/schemas/YSKCardFooterAction"
YSKCardProgress:
type: object
required:
- "label"
- "progress"
properties:
label:
type: string
example: "Installing jellyfin"
progress:
type: integer
example: 50
YSKCardIconWithText:
type: object
required:
- "icon"
- "description"
properties:
icon:
$ref: "#/components/schemas/YSKCardIcon"
description:
type: string
example: "CasaOS"
YSKCardListItem:
type: object
required:
- "icon"
- "description"
- "rightText"
properties:
icon:
$ref: "#/components/schemas/YSKCardIcon"
description:
type: string
example: "CasaOS"
rightText:
type: string
example: "4 TB"
YSKCardFooterAction:
type: object
required:
- "side"
- "style"
- "text"
- "messageBus"
properties:
side:
type: string
example: "View Details"
style:
type: string
example: "view-details"
text:
type: string
example: "https://casaos.com"
messageBus:
$ref: "#/components/schemas/YSKCardMessageBusAction"
YSKCardMessageBusAction:
type: object
required:
- "key"
- "payload"
properties:
key:
type: string
example: "open-url"
payload:
type: string
example: "https://casaos.com"
YSKCardIcon:
type: string
example: "https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_twilight_blue_800px.png"