2015-03-12 15:05:10 +01:00
|
|
|
import os
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
# Enable reads (GET), inserts (POST) and DELETE for resources/collections
|
|
|
|
# (if you omit this line, the API will default to ['GET'] and provide
|
|
|
|
# read-only access to the endpoint).
|
|
|
|
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
|
|
|
|
|
|
|
|
# Enable reads (GET), edits (PATCH), replacements (PUT) and deletes of
|
|
|
|
# individual items (defaults to read-only item access).
|
2015-04-15 16:21:38 +02:00
|
|
|
ITEM_METHODS = ['GET', 'PUT', 'DELETE', 'PATCH']
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-09-24 15:45:57 +02:00
|
|
|
PAGINATION_LIMIT = 25
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-04-22 08:51:01 -03:00
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
users_schema = {
|
2015-10-13 19:40:25 +02:00
|
|
|
'full_name': {
|
2015-03-10 11:38:57 +01:00
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
2015-10-13 19:40:25 +02:00
|
|
|
'maxlength': 128,
|
2015-04-09 19:06:10 -03:00
|
|
|
},
|
2015-08-31 17:45:29 +02:00
|
|
|
'username': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 60,
|
|
|
|
'required': True,
|
|
|
|
},
|
2015-04-09 19:06:10 -03:00
|
|
|
'email': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 60,
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-10-13 19:40:25 +02:00
|
|
|
'roles': {
|
2015-03-27 15:42:28 +01:00
|
|
|
'type': 'list',
|
2015-10-19 19:09:21 +02:00
|
|
|
'allowed': ["admin", "subscriber"],
|
2015-05-18 11:42:17 -03:00
|
|
|
},
|
|
|
|
'groups': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
2015-05-21 12:04:46 -03:00
|
|
|
'schema': {
|
2015-05-18 11:42:17 -03:00
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'groups',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
}
|
2015-10-13 19:40:25 +02:00
|
|
|
},
|
|
|
|
'auth': {
|
|
|
|
# Storage of authentication credentials (one will be able to auth with
|
|
|
|
# multiple providers on the same account)
|
|
|
|
'type': 'list',
|
|
|
|
'required': True,
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'provider': {
|
|
|
|
'type': 'string',
|
|
|
|
'allowed': ["blender-id",],
|
|
|
|
},
|
|
|
|
'user_id' : {
|
|
|
|
'type': 'string'
|
|
|
|
},
|
|
|
|
'token': {
|
|
|
|
'type': 'string'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-13 01:21:57 +02:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-08-31 17:45:29 +02:00
|
|
|
organizations_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True
|
|
|
|
},
|
2015-10-05 19:57:37 +02:00
|
|
|
'email': {
|
|
|
|
'type': 'string'
|
|
|
|
},
|
2015-08-31 17:45:29 +02:00
|
|
|
'url': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
|
|
|
'website': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
|
|
|
'location': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
|
|
|
'picture': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'nullable': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'files',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'users': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'teams': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
# Team name
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
# List of user ids for the team
|
|
|
|
'users': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
# List of groups assigned to the team (this will automatically
|
|
|
|
# update the groups property of each user in the team)
|
|
|
|
'groups': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'groups',
|
|
|
|
'field': '_id',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-11 22:20:18 +02:00
|
|
|
permissions_embedded_schema = {
|
|
|
|
'groups': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'group': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'groups',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'methods': {
|
|
|
|
'type': 'list',
|
|
|
|
'required': True,
|
|
|
|
'allowed': ['GET', 'PUT', 'POST', 'DELETE']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'users': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'user' : {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'methods': {
|
|
|
|
'type': 'list',
|
|
|
|
'required': True,
|
|
|
|
'allowed': ['GET', 'PUT', 'POST', 'DELETE']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'world': {
|
|
|
|
'type': 'list',
|
|
|
|
#'required': True,
|
|
|
|
'allowed': ['GET',]
|
|
|
|
},
|
|
|
|
'is_free': {
|
|
|
|
'type': 'boolean',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
nodes_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
2015-03-11 16:03:19 +01:00
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
2015-09-12 01:37:16 +02:00
|
|
|
'maxlength': 5000,
|
2015-03-11 16:03:19 +01:00
|
|
|
},
|
2015-04-13 01:21:57 +02:00
|
|
|
'picture': {
|
2015-04-16 15:02:32 -03:00
|
|
|
'type': 'objectid',
|
|
|
|
'nullable': True,
|
2015-04-24 16:15:47 +02:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'files',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'order': {
|
|
|
|
'type': 'integer',
|
|
|
|
'minlength': 0,
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
'revision': {
|
|
|
|
'type': 'integer',
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
'parent': {
|
2015-04-08 18:08:50 +02:00
|
|
|
'type': 'objectid',
|
2015-04-24 12:43:25 +02:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'nodes',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-04-10 13:08:45 -03:00
|
|
|
'user': {
|
2015-04-13 01:21:57 +02:00
|
|
|
'type': 'objectid',
|
2015-04-10 13:08:45 -03:00
|
|
|
'required': True,
|
2015-05-01 11:32:42 -03:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-04-10 13:08:45 -03:00
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'node_type': {
|
2015-04-08 18:08:50 +02:00
|
|
|
'type': 'objectid',
|
2015-03-11 16:03:19 +01:00
|
|
|
'required': True,
|
2015-04-24 12:43:25 +02:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'node_types',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-10-11 22:20:18 +02:00
|
|
|
'properties': {
|
|
|
|
'type' : 'dict',
|
|
|
|
'valid_properties' : True,
|
|
|
|
'required': True,
|
2015-03-27 15:42:28 +01:00
|
|
|
},
|
2015-10-11 22:20:18 +02:00
|
|
|
'permissions': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': permissions_embedded_schema
|
|
|
|
}
|
2015-03-11 16:03:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
node_types_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True,
|
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
2015-03-11 16:03:19 +01:00
|
|
|
'dyn_schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
2015-04-13 15:08:44 -03:00
|
|
|
},
|
|
|
|
'form_schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'parent': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
2015-10-11 22:20:18 +02:00
|
|
|
},
|
|
|
|
'permissions': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
|
|
|
'schema': permissions_embedded_schema
|
2015-03-11 16:03:19 +01:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-04-09 16:36:32 -03:00
|
|
|
tokens_schema = {
|
2015-04-09 19:06:10 -03:00
|
|
|
'user': {
|
|
|
|
'type': 'objectid',
|
2015-03-14 15:08:36 +01:00
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'token': {
|
|
|
|
'type': 'string',
|
2015-04-08 11:47:19 -03:00
|
|
|
'required': True,
|
2015-04-09 16:36:32 -03:00
|
|
|
},
|
|
|
|
'expire_time': {
|
|
|
|
'type': 'datetime',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
}
|
2015-03-14 15:08:36 +01:00
|
|
|
|
2015-04-20 08:56:22 -03:00
|
|
|
files_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
# If the object has a parent, it is a variation of its parent. When querying
|
|
|
|
# for a file we are going to check if the object does NOT have a parent. In
|
|
|
|
# this case we will query for all files with the ObjectID as parent and we
|
|
|
|
# will aggregate them according of the type (if it's an image we will use
|
|
|
|
# some prefix, if it's a video we will combine the contentType and a custom
|
|
|
|
# prefix, such as 720p)
|
|
|
|
'parent': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'files',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-05-08 11:28:58 -03:00
|
|
|
},
|
2015-09-11 15:16:10 +02:00
|
|
|
'content_type': { # MIME type image/png video/mp4
|
2015-09-08 15:06:45 +02:00
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
# Duration in seconds, only if it's a video
|
|
|
|
'duration': {
|
|
|
|
'type': 'integer',
|
|
|
|
},
|
|
|
|
'size': { # xs, s, b, 720p, 2K
|
2015-05-08 11:28:58 -03:00
|
|
|
'type': 'string'
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
'format': { # human readable format, like mp4, HLS, webm, mov
|
2015-05-09 12:26:49 -03:00
|
|
|
'type': 'string'
|
|
|
|
},
|
2015-09-24 15:45:57 +02:00
|
|
|
'width': { # valid for images and video content_type
|
2015-05-09 12:26:49 -03:00
|
|
|
'type': 'integer'
|
|
|
|
},
|
|
|
|
'height': {
|
|
|
|
'type': 'integer'
|
|
|
|
},
|
2015-04-20 08:56:22 -03:00
|
|
|
'user': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
'length': { # Size in bytes
|
2015-04-20 08:56:22 -03:00
|
|
|
'type': 'integer',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'md5': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'filename': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
2015-04-21 17:26:41 -03:00
|
|
|
'backend': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
2015-09-10 12:47:29 +02:00
|
|
|
'allowed': ["attract-web", "pillar", "cdnsun"]
|
2015-04-24 16:15:47 +02:00
|
|
|
},
|
2015-04-20 08:56:22 -03:00
|
|
|
'path': {
|
|
|
|
'type': 'string',
|
2015-09-24 15:45:57 +02:00
|
|
|
#'required': True,
|
2015-05-08 11:28:58 -03:00
|
|
|
'unique': True,
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
'previews': { # Deprecated (see comments above)
|
2015-05-08 11:28:58 -03:00
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'files',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
}
|
2015-09-08 15:06:45 +02:00
|
|
|
},
|
|
|
|
# Preview parameters:
|
|
|
|
'is_preview': { # Deprecated
|
|
|
|
'type': 'boolean'
|
2015-04-20 08:56:22 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 11:42:17 -03:00
|
|
|
groups_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
'permissions': {
|
|
|
|
'type': 'list',
|
2015-04-21 17:26:41 -03:00
|
|
|
'required': True,
|
2015-05-18 11:42:17 -03:00
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'node_type': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'node_types',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'permissions': {
|
|
|
|
'type': 'list',
|
|
|
|
'required': True,
|
|
|
|
'allowed': ['GET', 'POST', 'UPDATE', 'DELETE']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-21 17:26:41 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
nodes = {
|
2015-10-11 22:20:18 +02:00
|
|
|
'schema': nodes_schema,
|
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET']
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
node_types = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-10-11 22:20:18 +02:00
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET'],
|
2015-03-14 15:08:36 +01:00
|
|
|
'schema': node_types_schema,
|
2015-03-11 16:03:19 +01:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
users = {
|
|
|
|
'item_title': 'user',
|
2015-03-10 11:38:57 +01:00
|
|
|
|
|
|
|
# We choose to override global cache-control directives for this resource.
|
|
|
|
'cache_control': 'max-age=10,must-revalidate',
|
|
|
|
'cache_expires': 10,
|
|
|
|
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
'public_methods': ['GET', 'POST'],
|
|
|
|
# 'public_item_methods': ['GET'],
|
|
|
|
|
|
|
|
'schema': users_schema
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-04-09 16:36:32 -03:00
|
|
|
tokens = {
|
2015-04-13 01:21:57 +02:00
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-03-14 15:08:36 +01:00
|
|
|
|
|
|
|
# Allow 'token' to be returned with POST responses
|
2015-04-08 11:47:19 -03:00
|
|
|
#'extra_response_fields': ['token'],
|
2015-03-14 15:08:36 +01:00
|
|
|
|
|
|
|
'schema' : tokens_schema
|
2015-04-09 16:36:32 -03:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-04-20 08:56:22 -03:00
|
|
|
files = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-10-11 22:20:18 +02:00
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET'],
|
|
|
|
'schema': files_schema
|
2015-04-20 08:56:22 -03:00
|
|
|
}
|
|
|
|
|
2015-05-18 11:42:17 -03:00
|
|
|
groups = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-10-11 23:30:41 +02:00
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET'],
|
2015-05-18 11:42:17 -03:00
|
|
|
'schema': groups_schema,
|
|
|
|
}
|
|
|
|
|
2015-08-31 17:45:29 +02:00
|
|
|
organizations = {
|
|
|
|
'schema': organizations_schema,
|
2015-10-11 23:30:41 +02:00
|
|
|
'public_item_methods': ['GET'],
|
|
|
|
'public_methods': ['GET']
|
2015-08-31 17:45:29 +02:00
|
|
|
}
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
DOMAIN = {
|
2015-03-11 16:03:19 +01:00
|
|
|
'users': users,
|
2015-04-08 11:47:19 -03:00
|
|
|
'nodes': nodes,
|
2015-03-11 16:03:19 +01:00
|
|
|
'node_types': node_types,
|
2015-04-09 16:36:32 -03:00
|
|
|
'tokens': tokens,
|
2015-04-20 08:56:22 -03:00
|
|
|
'files': files,
|
2015-08-31 17:45:29 +02:00
|
|
|
'groups': groups,
|
|
|
|
'organizations': organizations
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-08-31 17:45:29 +02:00
|
|
|
|
2015-10-11 22:20:18 +02:00
|
|
|
MONGO_HOST = os.environ.get('MONGO_HOST', 'localhost')
|
|
|
|
MONGO_PORT = os.environ.get('MONGO_PORT', 27017)
|
2015-10-16 17:49:15 +02:00
|
|
|
CACHE_EXPIRES = 60
|
|
|
|
HATEOAS = False
|