-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.yaml
More file actions
754 lines (746 loc) · 22 KB
/
api.yaml
File metadata and controls
754 lines (746 loc) · 22 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
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
openapi: 3.0.3
info:
title: Social Interaction Sensing API
description: API for the Social Interaction Sensing project.
version: 1.0.0
servers:
- url: 'http://localhost:8080/v1/'
description: Local Server
- url: 'https://siapi.timweiss.dev/v1/'
description: Tim's Test Server
paths:
/study:
get:
description:
Gets a list of all available studies in the system.
tags:
- study
responses:
'200':
description: A list of all available studies.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Study'
post:
description:
Creates a new study in the system.
tags:
- study
security:
- token: [ ]
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Study'
responses:
'201':
description: The study was created successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/Study'
/study/{study_id}:
get:
description:
Gets a specific study by ID.
tags:
- study
parameters:
- name: study_id
in: path
description: The ID of the study to get.
required: true
schema:
type: integer
responses:
'200':
description: The study was found.
content:
application/json:
schema:
$ref: '#/components/schemas/Study'
'404':
description: The study was not found.
/study/{study_id}/questionnaire:
get:
description: Gets all available ESM questionnaires for this specific study.
tags:
- esm
parameters:
- name: study_id
in: path
description: The ID of the study to get questionnaires for.
required: true
schema:
type: integer
responses:
'200':
description: A list of all available questionnaires for the study.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ESMQuestionnaire'
'404':
description: The study was not found.
post:
description: Creates a new ESM questionnaire for the study.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study to create the questionnaire for.
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ESMQuestionnaire'
responses:
'201':
description: The questionnaire was created successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMQuestionnaire'
'404':
description: The study was not found.
/study/{study_id}/questionnaire/{questionnaire_id}:
get:
description: Gets a specific ESM questionnaire by ID.
tags:
- esm
parameters:
- name: study_id
in: path
description: The ID of the study to get the questionnaire for.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire to get.
required: true
schema:
type: integer
responses:
'200':
description: The questionnaire was found.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMFullQuestionnaire'
'404':
description: The questionnaire was not found.
put:
description: Updates an existing ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire to update.
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ESMQuestionnaire'
responses:
'200':
description: The questionnaire was updated successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMQuestionnaire'
'404':
description: The questionnaire was not found.
/study/{study_id}/questionnaire/{questionnaire_id}/element:
post:
description: Adds a new element to an existing ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire to add the element to.
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ESMElement'
responses:
'201':
description: The element was added successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMElement'
'404':
description: The questionnaire was not found.
/study/{study_id}/questionnaire/{questionnaire_id}/element/{element_id}:
put:
description: Updates an existing element in an ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire that the element belongs to.
required: true
schema:
type: integer
- name: element_id
in: path
description: The ID of the element to update.
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ESMElement'
responses:
'200':
description: The element was updated successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMElement'
'404':
description: The questionnaire was not found.
delete:
description: Deletes an existing element from an ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire that the element belongs to.
required: true
schema:
type: integer
- name: element_id
in: path
description: The ID of the element to delete.
required: true
schema:
type: integer
responses:
'204':
description: The element was deleted successfully.
'404':
description: The questionnaire was not found.
/study/{study_id}/questionnaire/{questionnaire_id}/trigger:
post:
description: Adds a new trigger to an existing ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire to add the trigger to.
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ESMTrigger'
responses:
'201':
description: The trigger was added successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMTrigger'
'404':
description: The questionnaire was not found.
/study/{study_id}/questionnaire/{questionnaire_id}/trigger/{trigger_id}:
put:
description: Updates an existing trigger in an ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire that the trigger belongs to.
required: true
schema:
type: integer
- name: trigger_id
in: path
description: The ID of the trigger to update.
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ESMTrigger'
responses:
'200':
description: The trigger was updated successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMTrigger'
'404':
description: The questionnaire was not found.
delete:
description: Deletes an existing trigger from an ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire that the trigger belongs to.
required: true
schema:
type: integer
- name: trigger_id
in: path
description: The ID of the trigger to delete.
required: true
schema:
type: integer
responses:
'204':
description: The trigger was deleted successfully.
'404':
description: The questionnaire was not found.
/study/{study_id}/questionnaire/{questionnaire_id}/answer:
post:
description: Adds a new answer to an existing ESM questionnaire.
tags:
- esm
security:
- token: [ ]
parameters:
- name: study_id
in: path
description: The ID of the study that the questionnaire belongs to.
required: true
schema:
type: integer
- name: questionnaire_id
in: path
description: The ID of the questionnaire to add the answer to.
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ESMAnswer'
responses:
'201':
description: The answer was added successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ESMAnswer'
'404':
description: The questionnaire was not found.
/enrolment:
post:
description:
Enrols a participant in a study through the enrolment key.
tags:
- enrolment
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- enrolment_key
properties:
enrolment_key:
type: string
description: The enrolment key for the study.
responses:
'201':
description: The enrolment was created successfully.
content:
application/json:
schema:
type: object
properties:
participantId:
type: string
description: The unique identifier for the participant.
token:
type: string
description: The authentication token for the participant.
studyId:
type: number
description: The database ID for the study.
'400':
description: The enrolment key was invalid (typo or study does not exist).
/enrolment/{participant_id}:
post:
description:
Re-enrols a participant through their participant ID.
tags:
- enrolment
parameters:
- name: participant_id
in: path
description: The ID of the participant to re-enrol.
required: true
schema:
type: string
responses:
'201':
description: Successfully re-enrolled.
content:
application/json:
schema:
type: object
properties:
participantId:
type: string
description: The unique identifier for the participant.
token:
type: string
description: The authentication token for the participant.
studyId:
type: number
description: The database ID for the study.
'400':
description: The participant ID was invalid (does not exist).
/reading:
post:
description:
Adds a new singular sensor reading to the system.
tags:
- reading
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SensorReading'
security:
- token: [ ]
responses:
'201':
description: The sensor reading was added successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/SensorReading'
'400':
description: The sensor reading was invalid (missing data).
'403':
description: The sensor reading was not allowed (participant not enrolled).
'401':
description: The participant is not authenticated.
/reading/batch:
post:
description:
Adds a batch of sensor readings to the system.
tags:
- reading
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/SensorReading'
security:
- token: [ ]
responses:
'201':
description: The sensor readings were added successfully.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/SensorReading'
'400':
description: The sensor readings were invalid (missing data).
'403':
description: The sensor readings were not allowed (participant not enrolled).
'401':
description: The participant is not authenticated.
/reading/{reading_id}/file:
post:
description:
Adds a file to a specific reading.
tags:
- reading
parameters:
- name: reading_id
in: path
description: The ID of the reading to attach the file to.
required: true
schema:
type: integer
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/File'
security:
- token: [ ]
responses:
'201':
description: The file was attached successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/File'
'400':
description: The file was invalid (missing data).
'403':
description: The file was not allowed (participant not enrolled).
'401':
description: The participant is not authenticated.
components:
securitySchemes:
token:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
File:
description: Attached file for a reading
type: object
required:
- readingId
- filename
properties:
id:
type: integer
description: The unique identifier for the file.
readingId:
type: integer
description: The database ID for the reading.
filename:
type: string
description: The name of the file.
path:
type: string
description: The path to the file on the server.
SensorReading:
description: An atomic reading of a sensor. Tied to a specific participant and study.
type: object
required:
- enrolmentId
- sensorType
- data
- timestamp
properties:
id:
type: integer
description: The unique identifier for the sensor reading.
enrolmentId:
type: integer
description: The database ID for the enrolment.
sensorType:
type: string
description: The type of sensor that generated the reading.
data:
type: object
description: The data from the sensor reading.
timestamp:
type: string
description: The timestamp of the reading.
Enrolment:
type: object
description: A single enrolment in a study.
properties:
id:
type: integer
description: The unique identifier for the enrolment.
studyId:
type: integer
description: The database ID for the study.
participantId:
type: string
description: The unique identifier for the participant. Can be used to re-identify the participant.
Study:
type: object
description: A study in the system.
required:
- name
- enrolmentKey
properties:
id:
type: integer
description: The unique identifier for the study.
name:
type: string
description: The name of the study.
enrolmentKey:
type: string
description: The enrolment key for the study. Needs to be unique across all studies.
ESMQuestionnaire:
description: Questionnaire that can be presented to the participant
properties:
id:
type: integer
description: The unique identifier for the questionnaire.
studyId:
type: integer
description: The database ID for the study.
name:
type: string
description: The name of the questionnaire.
enabled:
type: boolean
description: Whether the questionnaire is enabled.
version:
type: number
description: The version of the questionnaire.
ESMElement:
description: A visual or user entry element in a questionnaire
properties:
id:
type: integer
description: The unique identifier for the element.
questionnaireId:
type: integer
description: The database ID for the questionnaire.
type:
type: string
description: The type of element (e.g., text, radio, checkbox).
step:
type: number
description: The step in the questionnaire.
position:
type: number
description: The position of the element in the step.
configuration:
type: object
description: The type-dependent configuration for the element.
ESMTrigger:
description: Conditional trigger for presenting an ESM questionnaire.
properties:
id:
type: integer
description: The unique identifier for the trigger.
questionnaireId:
type: integer
description: The database ID for the questionnaire.
type:
type: string
description: The type of trigger (e.g., time, after an event).
configuration:
type: object
description: The type-dependent configuration for the trigger.
ESMFullQuestionnaire:
description: A full questionnaire with elements and triggers
properties:
questionnaire:
$ref: '#/components/schemas/ESMQuestionnaire'
elements:
type: array
items:
$ref: '#/components/schemas/ESMElement'
triggers:
type: array
items:
$ref: '#/components/schemas/ESMTrigger'
ESMAnswer:
description: Instance of answered questionnaire
properties:
questionnaireId:
type: integer
description: The database ID for the questionnaire.
enrolmentId:
type: integer
description: The unique identifier for the enrolment.
answers:
type: array
description: The answers to the questionnaire.