diff --git a/pillarsdk/nodes.py b/pillarsdk/nodes.py index 01ac525..884c460 100755 --- a/pillarsdk/nodes.py +++ b/pillarsdk/nodes.py @@ -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'])