Added Node.share() and Node.get_share_links() methods.

This commit is contained in:
2016-07-07 15:18:26 +02:00
parent 96ece1540d
commit b34d56d44e

View File

@@ -163,3 +163,33 @@ class Node(List, Find, Create, Post, Update, Delete, Replace):
import mimetypes
mimetype, _ = mimetypes.guess_type(filename, strict=False)
return mimetype
def share(self, api=None):
"""Creates a short-link.
:returns: a dict like {
'short_code': 'XXXXXX',
'short_link': 'https://blender.cloud/r/XXXXX',
'theatre_link': 'https://blender.cloud/r/XXXXX?t',
}
:rtype: dict
"""
api = api or Api.Default()
return api.post('nodes/%s/share' % self['_id'])
def get_share_links(self, api=None):
"""Returns short-link info for this node.
:returns: a dict like {
'short_code': 'XXXXXX',
'short_link': 'https://blender.cloud/r/XXXXX',
'theatre_link': 'https://blender.cloud/r/XXXXX?t',
}, or an empty dict if the node wasn't shared.
:rtype: dict
"""
api = api or Api.Default()
return api.get('nodes/%s/share' % self['_id'])