-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path_schemas.py
84 lines (58 loc) · 2.31 KB
/
_schemas.py
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
"""
Schemas for Blackboard API responses.
See: https://developer.blackboard.com/portal/displayApi
"""
from marshmallow import EXCLUDE, Schema, fields, post_load
from marshmallow.validate import OneOf
from lms.validation._base import RequestsResponseSchema
class BlackboardListFilesSchema(RequestsResponseSchema):
"""Schema for Blackboard API /courses/{courseId}/resources responses."""
class FileSchema(Schema):
"""Schema for individual Blackboard file dicts."""
class Meta:
unknown = EXCLUDE
id = fields.Str(required=True)
name = fields.Str(required=True)
modified = fields.Str(required=True)
type = fields.Str(required=True)
mimeType = fields.Str()
size = fields.Integer()
parentId = fields.Str()
results = fields.List(fields.Nested(FileSchema), required=True)
@post_load
def post_load(self, data, **_kwargs):
return data["results"]
class BlackboardPublicURLSchema(RequestsResponseSchema):
"""Schema for Blackboard /courses/{courseId}/resources/{resourceId} responses."""
downloadUrl = fields.Str(required=True)
@post_load
def post_load(self, data, **_kwargs):
return data["downloadUrl"]
class BlackboardListGroupSetsSchema(RequestsResponseSchema):
class GroupSetSchema(Schema):
class Meta:
unknown = EXCLUDE
id = fields.Str(required=True)
name = fields.Str(required=True)
results = fields.List(fields.Nested(GroupSetSchema), required=True)
@post_load
def post_load(self, data, **_kwargs):
return data["results"]
class BlackboardListGroups(RequestsResponseSchema):
class GroupSchema(Schema):
class Meta:
unknown = EXCLUDE
class EnrollmentSchema(Schema):
class Meta:
unknown = EXCLUDE
type = fields.Str(
validate=OneOf(["InstructorOnly", "SelfEnrollment"]), required=True
)
id = fields.Str(required=True)
name = fields.Str(required=True)
groupSetId = fields.Str(required=False, allow_none=True)
enrollment = fields.Nested(EnrollmentSchema, required=True)
results = fields.List(fields.Nested(GroupSchema), required=True)
@post_load
def post_load(self, data, **_kwargs):
return data["results"]