forked from openedx-unsupported/registrar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.yaml
686 lines (654 loc) · 19.6 KB
/
api.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
---
################################################################################
# Please read before updating! #
# api.yaml - #
# This is the source of the api spec. Any api-doc changes should be #
# made to this file . #
# .api-generated.yaml - #
# This is an expanded version of api.yaml since the consuming tools are #
# unable to parse YAML anchors. This file is generated using: #
# `make api_generated` #
################################################################################
swagger: '2.0'
program_path_param: &program_path_param
in: path
name: program_key
required: true
type: string
description: edX program key
example: 'uexample-master-of-science'
course_path_param: &course_path_param
in: path
name: course_id
required: true
type: string
description: edX course run identifier, or an external course run key
example: 'course-v1:ExU+Science-101+Fall2050'
format_param: &format_param
in: query
name: fmt
required: false
type: string
enum: [json, csv]
description: format of file to generate
example: 'json'
program_enrollment_body: &program_enrollment_body
in: body
name: body
required: true
schema:
type: array
items:
$ref: '#/models/ProgramEnrollmentRequest'
course_enrollment_body: &course_enrollment_body
in: body
name: body
required: true
schema:
type: array
items:
$ref: '#/models/CourseEnrollmentRequest'
student_key: &student_key
type: string
description: >
Key that uniquely identifies student within organization.
For data privacy reasons, this cannot be, or include,
sensitive personal information like a student's official university ID
number, social security number, or some other government-issued ID number.
program_input_status: &program_input_status
type: string
enum:
- enrolled
- pending
- suspended
- canceled
- ended
program_output_status: &program_output_status
type: string
enum:
- enrolled
- pending
- suspended
- canceled
- ended
- invalid-status
- duplicated
- conflict
- not-found
- illegal-operation
- internal-error
course_input_status: &course_input_status
type: string
enum:
- active
- inactive
course_output_status: &course_output_status
type: string
enum:
- active
- inactive
- invalid-status
- duplicated
- conflict
- not-in-program
- not-found
- illegal-operation
- internal-error
################################################################################
# Base Endpoint Definitions #
################################################################################
endpoints:
get_program: &get_program
summary: Get Program
parameters:
- *program_path_param
responses:
200:
description: OK
schema:
$ref: '#/models/Program'
examples:
application/json:
program_title: Master of Science
program_key: uexample-master-of-science
program_url: https://uexample.edx.org/uexample-master-of-science
403:
description: User is not authorized to view program.
404:
description: Program was not found.
list_programs: &list_programs
summary: List programs
description: List all programs, requires an organization key for non-admins
parameters:
- in: query
name: org
required: false
type: string
description: Organization key
responses:
200:
description: OK
schema:
type: array
items:
$ref: '#/models/Program'
examples:
application/json:
- program_title: Master of Science
program_key: uexample-master-of-science
program_url: https://uexample.edx.org/uexample-master-of-science
403:
description: User is not authorized to list specified programs.
404:
description: Organization was not found.
get_job_status: &get_job_status
summary: Get the status of a job
parameters:
- in: path
name: job_id
required: true
type: string
format: uuid
description: UUID-4 job identifier
example: 3869c0d5-e88f-4088-bf1d-409222492869
responses:
200:
description: OK
schema:
$ref: '#/models/JobStatus'
list_program_courses: &list_courses
summary: List program courses
parameters:
- *program_path_param
responses:
200:
description: OK
schema:
type: array
items:
$ref: '#/models/Course'
examples:
application/json:
- course_id: course-v1:ExU+Science-101+Fall2050,
external_course_key: ExU-IntroToScience50,
course_title: Introduction to Science,
course_url: https://courses.edx.org/course-v1:ExU+Science-101+Fall2050
403:
description: User is not authorized to list courses of program.
404:
description: Program was not found.
get_program_enrollments: &get_program_enrollments
summary: Request program enrollment data
description: Submit a job to retrieve program enrollment data
parameters:
- *program_path_param
- *format_param
responses:
202:
description: Job submitted.
schema:
$ref: '#/models/NewJob'
403:
description: User is not authorized to retrieve enrollment of program.
404:
description: Program was not found.
post_program_enrollments: &post_program_enrollments
summary: Enroll students in a program
parameters:
- *program_path_param
- *program_enrollment_body
responses:
200:
description: All students were successfully listed.
schema:
$ref: '#/models/ProgramEnrollmentResult'
examples:
application/json:
student_0128fe4a: pending
student_aae45c81: enrolled
207:
description: Some, but not all, students were successfully listed.
schema:
$ref: '#/models/ProgramEnrollmentResult'
examples:
application/json:
student_0128fe4a: pending
student_aae45c81: conflict
403:
description: >
User is not authorized to modify enrollments for program course.
404:
description: >
Course does not exist within program, or program was not found.
413:
description: >
Payload too large; at most 25 students may be supplied per request.
422:
description: None of the students were successfully listed.
schema:
$ref: '#/models/ProgramEnrollmentResult'
examples:
application/json:
student_0128fe4a: invalid-status
student_aae45c81: conflict
patch_program_enrollments: &patch_program_enrollments
summary: Modify program enrollments
parameters:
- *program_path_param
- *program_enrollment_body
responses:
200:
description: All students' enrollments were successfully modified.
schema:
$ref: '#/models/ProgramEnrollmentResult'
examples:
application/json:
student_0128fe4a: enrolled
student_aae45c81: canceled
207:
description: >
Some, but not all, students' enrollments were successfully modified.
schema:
$ref: '#/models/ProgramEnrollmentResult'
examples:
application/json:
student_0128fe4a: enrolled
student_aae45c81: not-found
403:
description: >
User is not authorized to modify enrollments for program course.
404:
description: >
Course does not exist within program, or program was not found.
413:
description: >
Payload too large; at most 25 students' enrollments may be modified
per request.
422:
description: >
None of the students' enrollments were successfully modified.
schema:
$ref: '#/models/ProgramEnrollmentResult'
examples:
application/json:
student_0128fe4a: invalid-status
student_aae45c81: not-found
get_course_enrollments: &get_course_enrollments
summary: Request course enrollment data
description: Submit a job to retrieve course enrollment data
parameters:
- *program_path_param
- *course_path_param
- *format_param
responses:
202:
description: Job submitted.
schema:
$ref: '#/models/NewJob'
403:
description: >
User is not authorized to retrieve enrollments for program course.
404:
description: >
Course does not exist within program, or program was not found.
post_course_enrollments: &post_course_enrollments
summary: Enroll students in a course
parameters:
- *program_path_param
- *course_path_param
- *course_enrollment_body
responses:
200:
description: All students were successfully listed.
schema:
$ref: '#/models/CourseEnrollmentResult'
examples:
application/json:
student_0128fe4a: inactive
student_aae45c81: active
207:
description: Some, but not all, students were successfully listed.
schema:
$ref: '#/models/CourseEnrollmentResult'
examples:
application/json:
student_0128fe4a: inactive
student_aae45c81: conflict
403:
description: >
User is not authorized to modify enrollments for program course.
404:
description: >
Course does not exist within program, or program was not found.
413:
description: >
Payload too large; at most 25 students may be supplied per request.
422:
description: None of the students were successfully listed.
schema:
$ref: '#/models/CourseEnrollmentResult'
examples:
application/json:
student_0128fe4a: invalid-status
student_aae45c81: conflict
patch_course_enrollments: &patch_course_enrollments
summary: Modify course enrollments
parameters:
- *program_path_param
- *course_path_param
- *course_enrollment_body
responses:
200:
description: All students' enrollments were successfully modified.
schema:
$ref: '#/models/CourseEnrollmentResult'
examples:
application/json:
student_0128fe4a: active
student_aae45c81: inactive
207:
description: >
Some, but not all, students' enrollments were successfully modified.
schema:
$ref: '#/models/CourseEnrollmentResult'
examples:
application/json:
student_0128fe4a: active
student_aae45c81: not-found
403:
description: >
User is not authorized to modify enrollments for program course.
404:
description: >
Course does not exist within program, or program was not found.
413:
description: >
Payload too large; at most 25 students' enrollments may be modified
per request.
422:
description: >
None of the students' enrollments were successfully modified.
schema:
$ref: '#/models/CourseEnrollmentResult'
examples:
application/json:
student_0128fe4a: invalid-status
student_aae45c81: not-found
get_course_grades: &get_course_grades
summary: Request course run grade data
description: Submit a job to retrieve course run grade data
parameters:
- *program_path_param
- *course_path_param
- *format_param
responses:
202:
description: Job submitted.
schema:
$ref: '#/models/NewJob'
403:
description: >
User is not authorized to retrieve enrollments for program course.
404:
description: >
Course does not exist within program, or program was not found.
list_program_reports: &list_program_reports
summary: List program reports
description: List the reports in a program
parameters:
- *program_path_param
- in: query
name: min_created_date
type: date
description: >
The ISO-format date used to limit the reports
returned based on their created date
required: false
example: '2019-12-18'
responses:
200:
description: OK
schema:
type: array
items:
$ref: '#/models/ProgramReport'
403:
description: User is not authorized to view program reports.
404:
description: Program was not found.
swagger:
get:
operationId: registrar_get_api_docs
responses:
200:
description: OK
static:
get:
responses:
200:
description: OK
login:
get:
responses:
302:
description: Found
logout:
get:
responses:
302:
description: Found
################################################################################
# API Information #
################################################################################
info:
title: Registrar API
description: |
Registrar API
basePath: '/api'
produces:
- application/json
consumes:
- application/json
################################################################################
# Path Config #
################################################################################
paths:
### V1 API ###
'/v1/jobs/{job_id}/':
get:
<<: *get_job_status
operationId: registrar_v1_get_job_status
tags: ['v1']
'/v1/programs/':
get:
<<: *list_programs
operationId: registrar_v1_list_programs
tags: ['v1']
'/v1/programs/{program_key}/':
get:
<<: *get_program
operationId: registrar_v1_get_program
tags: ['v1']
'/v1/programs/{program_key}/courses/':
get:
<<: *list_courses
operationId: registrar_v1_list_courses
tags: ['v1']
'/v1/programs/{program_key}/courses/{course_id}/enrollments/':
get:
<<: *get_course_enrollments
operationId: registrar_v1_get_course_enrollments
tags: ['v1']
post:
<<: *post_course_enrollments
operationId: registrar_v1_post_course_enrollments
tags: ['v1']
patch:
<<: *patch_course_enrollments
operationId: registrar_v1_patch_course_enrollments
tags: ['v1']
'/v1/programs/{program_key}/courses/{course_id}/grades/':
get:
<<: *get_course_grades
operationId: registrar_v1_get_course_grades
tags: ['v1']
'/v1/programs/{program_key}/enrollments/':
get:
<<: *get_program_enrollments
operationId: registrar_v1_get_program_enrollments
tags: ['v1']
post:
<<: *post_program_enrollments
operationId: registrar_v1_post_program_enrollments
tags: ['v1']
patch:
<<: *patch_program_enrollments
operationId: registrar_v1_patch_program_enrollments
tags: ['v1']
'/v1/programs/{program_key}/reports':
get:
<<: *list_program_reports
operationId: registrar_v1_list_program_reports
tags: ['v1']
### V2 API ###
'/v2/jobs/{job_id}/':
get:
<<: *get_job_status
operationId: registrar_v2_get_job_status
tags: ['v2']
'/v2/programs/':
get:
<<: *list_programs
operationId: registrar_v2_list_programs
tags: ['v2']
'/v2/programs/{program_key}/':
get:
<<: *get_program
operationId: registrar_v2_get_program
tags: ['v2']
'/v2/programs/{program_key}/courses/':
get:
<<: *list_courses
operationId: registrar_v2_list_courses
tags: ['v2']
'/v2/programs/{program_key}/courses/{course_id}/enrollments/':
get:
<<: *get_course_enrollments
operationId: registrar_v2_get_course_enrollments
tags: ['v2']
post:
<<: *post_course_enrollments
operationId: registrar_v2_post_course_enrollments
tags: ['v2']
patch:
<<: *patch_course_enrollments
operationId: registrar_v2_patch_course_enrollments
tags: ['v2']
'/v2/programs/{program_key}/courses/{course_id}/grades/':
get:
<<: *get_course_grades
operationId: registrar_v2_get_course_grades
tags: ['v2']
'/v2/programs/{program_key}/enrollments/':
get:
<<: *get_program_enrollments
operationId: registrar_v2_get_program_enrollments
tags: ['v2']
post:
<<: *post_program_enrollments
operationId: registrar_v2_post_program_enrollments
tags: ['v2']
patch:
<<: *patch_program_enrollments
operationId: registrar_v2_patch_program_enrollments
tags: ['v2']
'/v2/programs/{program_key}/reports':
get:
<<: *list_program_reports
operationId: registrar_v2_list_program_reports
tags: ['v2']
################################################################################
# Data Models #
################################################################################
models:
Program:
type: object
properties:
program_key:
type: string
program_title:
type: string
program_url:
type: string
format: uri
Course:
type: object
properties:
course_id:
type: string
external_course_key:
type: string
course_title:
type: string
course_url:
type: string
format: uri
ProgramEnrollmentRequest:
type: object
properties:
student_key: *student_key
status: *program_input_status
CourseEnrollmentRequest:
type: object
properties:
student_key: *student_key
status: *course_input_status
ProgramEnrollmentResult:
type: object
additionalProperties: *program_output_status
description: Mapping from student_keys to program enrollment statuses
CourseEnrollmentResult:
type: object
additionalProperties: *course_output_status
description: Mapping from student_keys to course enrollment statuses
NewJob:
type: object
properties:
job_id:
type: string
format: uuid
description: UUID-4 job identifier
job_url:
type: string
format: uri
description: URL to get status of job
JobStatus:
type: object
properties:
created:
type: string
format: date-time
description: The ISO-format date-time that the job was created
state:
type: string
enum: [Queued, In Progress, Canceled, Failed, Succeeded]
result:
type: string
format: uri
nullable: true
description: URL to result file; null if result unavailable
ProgramReport:
type: object
properties:
name:
type: string
description: The name of the program report
created_date:
type: string
format: date
description: >
The ISO-format date-time that the program report was created
download_url:
type: string
format: uri
description: URL to download the program report