-
Notifications
You must be signed in to change notification settings - Fork 0
/
subvt_app_service.yml
828 lines (828 loc) · 26.9 KB
/
subvt_app_service.yml
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
swagger: "2.0"
info:
description: "SubVT application service endpoints."
version: "0.1.0"
title: "SubVT Application Service"
termsOfService: "https://subvt-test.helikon.io"
contact:
email: "info@helikon.io"
license:
name: "GPL-3.0"
url: "https://www.gnu.org/licenses/gpl-3.0.en.html"
host: "78.181.100.160:17778"
basePath: "/app"
tags:
- name: "network"
description: "Services related to the networks supported by SubVT."
- name: "notification"
description: "All the services related to notifications, and notification metadata."
- name: "user"
description: "User services."
- name: "validator"
description: "User-validator services."
schemes:
- "http"
paths:
/network:
get:
tags:
- "network"
summary: "Get network list"
description: "Get a list of all supported networks."
produces:
- "application/json"
operationId: "getNetworkList"
responses:
"200":
description: "Operation successful"
schema:
type: "array"
items:
$ref: "#/definitions/Network"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/notification/channel:
get:
tags:
- "notification"
summary: "Get notification channel list"
description: "Get a list of all notification channels (email, sms, apns, fcm, etc.)."
produces:
- "application/json"
operationId: "getNotificationChannelList"
responses:
"200":
description: "Operation successful"
schema:
type: "array"
items:
$ref: "#/definitions/NotificationChannel"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/notification/type:
get:
tags:
- "notification"
summary: "Get notification type list"
description: "Get a list of all notification types (block authored, new/lost/changed nomination, validator chilled, offline offence etc.)."
produces:
- "application/json"
operationId: "getNotificationTypeList"
responses:
"200":
description: "Operation successful"
schema:
type: "array"
items:
$ref: "#/definitions/NotificationType"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/user:
post:
tags:
- "user"
summary: "Create new user"
description: "Create a new SubVT user. Request body has only the public key of the user."
consumes:
- "application/json"
produces:
- "application/json"
operationId: "createUser"
parameters:
- name: "user"
in: "body"
description: "User public key."
required: true
schema:
$ref: "#/definitions/CreateUserRequest"
responses:
"200":
description: "Operation successful"
schema:
type: "array"
items:
$ref: "#/definitions/User"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"409":
description: "User exists with the provided public key"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/user/{user_id}/notification/channel:
get:
tags: [ "notification", "user" ]
summary: "Get user notification channels list"
description: "Get the list of the user's notification channels."
produces:
- "application/json"
operationId: "getUserNotificationChannelList"
parameters:
- name: "signature"
in: "header"
description: "Relative request path (e.g. `/user/7465/notification/channel`) signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
responses:
"200":
description: "Operation successful"
schema:
type: "array"
items:
$ref: "#/definitions/UserNotificationChannel"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User not found"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
post:
tags: [ "notification", "user" ]
summary: "Create user notification channel"
description: "Create a new notification channel for the user."
consumes:
- "application/json"
produces:
- "application/json"
operationId: "createUserNotificationChannel"
parameters:
- name: "signature"
in: "header"
description: "Request body signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
- name: "notification_channel"
in: "body"
description: "Notification channel."
required: true
schema:
$ref: "#/definitions/CreateNotificationChannelRequest"
responses:
"200":
description: "Operation successful"
schema:
$ref: "#/definitions/UserNotificationChannel"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User or notification channel not found"
schema:
$ref: "#/definitions/Error"
"409":
description: "Given notification channel exists for the user"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/user/{user_id}/notification/channel/{channel_id}:
delete:
tags: [ "notification", "user" ]
summary: "Delete user notification channel"
description: "Delete the notification channel from the user's notification channels."
produces:
- "application/json"
operationId: "deleteUserNotificationChannel"
parameters:
- name: "signature"
in: "header"
description: "Relative request path (e.g. `/user/7465/notification/channel/2`) signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
- name: "channel_id"
in: "path"
description: "User notification channel id."
required: true
type: "integer"
format: "int64"
responses:
"204":
description: "Operation successful"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User notification channel not found"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/user/{user_id}/notification/rule:
get:
tags: [ "notification", "user" ]
summary: "Get user notification rule list"
description: "Get the list of the user's notification rules."
produces:
- "application/json"
operationId: "getUserNotificationRuleList"
parameters:
- name: "signature"
in: "header"
description: "Relative request path (e.g. `/user/7465/notification/rule`) signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
responses:
"200":
description: "Operation successful"
schema:
type: "array"
items:
$ref: "#/definitions/UserNotificationRule"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User not found"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
post:
tags: [ "notification", "user" ]
summary: "Create a user notification rule"
description: "Create a new notification rule for the user."
consumes:
- "application/json"
produces:
- "application/json"
operationId: "createUserNotificationRule"
parameters:
- name: "signature"
in: "header"
description: "Request body signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
- name: "notification_rule"
in: "body"
description: "Notificaiton rule."
required: true
schema:
$ref: "#/definitions/CreateUserNotificationRuleRequest"
responses:
"200":
description: "Operation successful"
schema:
$ref: "#/definitions/UserNotificationRule"
"400":
description: "Bad request - could be a validation error"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User, notification type, network, validator or user notification channel not found."
schema:
$ref: "#/definitions/Error"
"409":
description: "User validator exists with the same network and account ids"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/user/{user_id}/notification/rule/{user_notification_rule_id}:
delete:
tags: [ "notification", "user" ]
summary: "Delete user notification rule"
description: "Delete the notification rule from the user's rule list."
produces:
- "application/json"
operationId: "deleteUserNoticationRule"
parameters:
- name: "signature"
in: "header"
description: "Relative request path (e.g. `/user/7465/notification/rule/214`) signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
- name: "user_notification_rule_id"
in: "path"
description: "User notification rule id."
required: true
type: "integer"
format: "int64"
responses:
"204":
description: "Operation successful"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User notification rule not found"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/user/{user_id}/validator:
get:
tags: [ "validator", "user" ]
summary: "Get user validator list"
description: "Get the list of the user's validators."
produces:
- "application/json"
operationId: "getUserValidatorList"
parameters:
- name: "signature"
in: "header"
description: "Relative request path (e.g. `/user/7465/validator`) signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
responses:
"200":
description: "Operation successful"
schema:
type: "array"
items:
$ref: "#/definitions/UserValidator"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User not found"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
post:
tags: [ "validator", "user" ]
summary: "Create user validator"
description: "Create a new validator for the user."
consumes:
- "application/json"
produces:
- "application/json"
operationId: "createUserValidator"
parameters:
- name: "signature"
in: "header"
description: "Request body signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
- name: "validator"
in: "body"
description: "Validator."
required: true
schema:
$ref: "#/definitions/CreateUserValidatorRequest"
responses:
"200":
description: "Operation successful"
schema:
$ref: "#/definitions/UserValidator"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User or network not found"
schema:
$ref: "#/definitions/Error"
"409":
description: "User validator exists with the same network and account ids"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
/user/{user_id}/validator/{user_validator_id}:
delete:
tags: [ "validator", "user" ]
summary: "Delete user validator"
description: "Delete the validator from the user's validator list."
produces:
- "application/json"
operationId: "deleteUserValidator"
parameters:
- name: "signature"
in: "header"
description: "Relative request path (e.g. `/user/7465/validator/214`) signed with the user's private key."
required: true
type: "string"
- name: "user_id"
in: "path"
description: "User id."
required: true
type: "integer"
format: "int64"
- name: "user_validator_id"
in: "path"
description: "User validator id."
required: true
type: "integer"
format: "int64"
responses:
"204":
description: "Operation successful"
"400":
description: "Bad request"
schema:
$ref: "#/definitions/Error"
"403":
description: "Forbidden: invalid signature"
schema:
$ref: "#/definitions/Error"
"404":
description: "User notification channel not found"
schema:
$ref: "#/definitions/Error"
"500":
description: "Internal server error"
schema:
$ref: "#/definitions/Error"
definitions:
CreateNotificationChannelRequest:
type: "object"
required: [ "channel_code", "target" ]
properties:
channel_code:
type: "string"
description: "Short code of the notification channel (email, fcm, apns, etc.)."
target:
type: "string"
description: "Notification target (e.g. phone number for SMS, email address for email, etc.)."
CreateUserNotificationRuleRequest:
type: "object"
required: [ "notification_type_code" ]
properties:
notification_type_code:
type: "string"
description: "Notification type."
name:
type: "string"
description: "Optional arbitrary name given to the rule by the user."
network_id:
type: "integer"
format: "int64"
description: "Id of the network that the notification is to be defined for. Null if for all networks."
is_for_all_validators:
type: "boolean"
description: "True if the rule is defined for all validators of the selected network, or for all validators if network is null."
user_validator_ids:
type: "array"
description: "Database ids of the user-validators that the notification rule is to be defined for. Empty if for all validators."
items:
type: "integer"
format: "int64"
period_type:
type: "string"
enum: [ "off", "immediate", "hour", "day", "era", "epoch" ]
description: "Period type for the notification rule."
period:
type: "integer"
format: "int32"
description: "Together with `period_type` it defines the notification period. E.g. every 2 epoch."
user_notification_channel_ids:
type: "array"
description: "Database ids of the user's notification channels that the notifications resulting from this rule would be targeted at."
items:
type: "integer"
format: "int64"
parameters:
type: "array"
description: "Parameters for the rule. Non-optional parameters have to be supplied."
items:
type: "object"
properties:
parameter_type_id:
type: "integer"
format: "int64"
description: "Database id of the parameter type."
value:
type: "string"
description: "Parameter value."
CreateUserRequest:
type: "object"
required: [ "public_key_hex" ]
properties:
public_key_hex:
type: "string"
description: "Hex-encoded 32-byte public key of the user public key, 0x-prefixed or not."
CreateUserValidatorRequest:
type: "object"
required: [ "network_id", "validator_account_id" ]
properties:
network_id:
type: "integer"
format: "int64"
description: "Id of the network that the validator is on."
validator_account_id:
type: "string"
description: "Hex-encoded 32-byte account id of the validator, 0x-prefixed."
Error:
type: "object"
required: [ "description" ]
properties:
description:
type: "string"
description: "Error description."
Network:
type: "object"
required: [ "id", "hash", "name", "ss58_prefix" ]
properties:
id:
type: "integer"
format: "int64"
description: "SubVT network id."
hash:
type: "string"
description: "Hex-encoded 32-byte genesis block hash of the network (0x-prefixed)."
name:
type: "string"
description: "Network name (e.g. Polkadot, Kusama)."
ss58_prefix:
type: "integer"
format: "int64"
description: "Network's SS58 prefix as defined in the SS58 [registry](https://github.com/paritytech/ss58-registry/blob/main/ss58-registry.json)."
network_status_service_url:
type: "string"
description: "URL for the SubVT network status WS RPC service for the network."
report_service_url:
type: "string"
description: "URL for the SubVT report REST service for the network."
validator_details_service_url:
type: "string"
description: "URL for the SubVT validator details WS RPC service for the network."
active_validator_list_service_url:
type: "string"
description: "URL for the SubVT active validator list WS RPC service for the network."
inactive_validator_list_service_url:
type: "string"
description: "URL for the SubVT inactive validator list WS RPC service for the network."
NotificationChannel:
type: "object"
required: [ "code" ]
properties:
code:
type: "string"
description: "Short code of the notification channel (email, fcm, apns, etc.)."
NotificationType:
type: "object"
required: [ "code", "param_types" ]
properties:
code:
type: "string"
description: "Code name of the notification type."
param_types:
type: "array"
items:
$ref: "#/definitions/NotificationParamType"
description: "Notification parameter definition list."
NotificationParamType:
type: "object"
required: [ "id", "notification_type_code", "order", "code", "type", "is_optional" ]
properties:
id:
type: "integer"
format: "int64"
notification_type_code:
type: "string"
description: "Code name of the notification type that the parameter belongs to."
order:
type: "integer"
format: "int32"
description: "Order of the parameter. Used when displaying the parameters in the correct order."
code:
type: "string"
description: "Code name for the parameter."
type:
type: "string"
enum: [ "string", "integer", "balance", "float", "boolean" ]
description: "Data type of the parameter. Balance type is the string representation of a 64-bit unsigned integer."
min:
type: "string"
description: "(Optional) Minimum value of the parameter. Used for validation."
max:
type: "string"
description: "(Optional) Minimum value of the parameter. Used for validation."
is_optional:
type: "boolean"
description: "Whether the parameter is optional."
User:
type: "object"
required: [ "id", "public_key_hex" ]
properties:
id:
type: "integer"
format: "int64"
description: "User id."
public_key_hex:
type: "string"
description: "Hex-encoded 32-byte public key of the user public key, 0x-prefixed or not."
UserNotificationChannel:
type: "object"
required: [ "id", "user_id", "channel_code", "target" ]
properties:
id:
type: "integer"
format: "int64"
description: "User notification channel id."
user_id:
type: "integer"
format: "int64"
description: "User id."
channel_code:
type: "string"
description: "Short code of the notification channel (email, fcm, apns, etc.)."
target:
type: "string"
description: "Notification target (e.g. phone number for SMS, email address for email, etc.)."
UserNotificationRule:
type: "object"
required: [ "id", "user_id", "notification_type", "is_for_all_validators", "period_type", "period", "validators", "notification_channels", "parameters" ]
properties:
id:
type: "integer"
format: "int64"
description: "User notification rule id."
user_id:
type: "integer"
format: "int64"
description: "User id."
notification_type:
$ref: "#/definitions/NotificationType"
name:
type: "string"
description: "Optional arbitrary name given to the rule by the user."
network:
$ref: "#/definitions/Network"
is_for_all_validators:
type: "boolean"
description: "True if the rule is defined for all validators of the selected network, or for all validators if network is null."
period_type:
type: "string"
enum: [ "off", "immediate", "hour", "day", "era", "epoch" ]
description: "Period type for the notification rule."
period:
type: "integer"
format: "int32"
description: "Together with `period_type` it defines the notification period. E.g. every 2 epoch."
validators:
type: "array"
description: "List of the validators that the notification rule is defined for. Empty for a rule for all validators."
items:
$ref: "#/definitions/UserValidator"
notification_channels:
type: "array"
description: "Notification target channels."
items:
$ref: "#/definitions/UserNotificationChannel"
parameters:
type: "array"
description: "Notification rule parameters."
items:
$ref: "#/definitions/UserNotificationRuleParameter"
notes:
type: "string"
description: "Optional arbitrary notes for the rule by the user."
UserNotificationRuleParameter:
type: "object"
required: [ "" ]
properties:
user_notification_rule_id:
type: "integer"
format: "int64"
description: "Database id of the notification rule that this parameter belongs to."
parameter_type_id:
type: "integer"
format: "int64"
description: "Database id of the parameter type."
parameter_type_code:
type: "string"
description: "The descriptive code for the parameter, copied from the parameter type."
order:
type: "integer"
format: "int32"
description: "Order of the parameter. copied from the parameter type."
value:
type: "string"
description: "Parameter value."
UserValidator:
type: "object"
required: [ "id", "user_id", "network_id", "validator_account_id" ]
properties:
id:
type: "integer"
format: "int64"
description: "User notification channel id."
user_id:
type: "integer"
format: "int64"
description: "User id."
network_id:
type: "integer"
format: "int64"
description: "Id of the network that the validator is on."
validator_account_id:
type: "string"
description: "Hex-encoded 32-byte account id of the validator, 0x-prefixed."