diff --git a/pillarsdk/nodes.py b/pillarsdk/nodes.py index ba15852..2b654c7 100755 --- a/pillarsdk/nodes.py +++ b/pillarsdk/nodes.py @@ -78,6 +78,7 @@ class Node(List, Find, Create, Post, Update, Delete, Replace): @classmethod def create_asset_from_file(cls, project_id, parent_node_id, asset_type, filename, always_create_new_node=False, + extra_where=None, api=None): """Uploads the file to the Cloud and creates an asset node. @@ -91,6 +92,9 @@ class Node(List, Find, Create, Post, Update, Delete, Replace): :param filename: path of the file to upload. Must be readable. :param always_create_new_node: when True, a new node is always created, possibly with the same name & parent as an existing one. + :param extra_where: dict of properties to use, in addition to project, node_type + and name, to find any existing node. Use this to restrict the + nodes that may be re-used to attach this file to. :returns: the updated/created node :rtype: Node """ @@ -117,6 +121,9 @@ class Node(List, Find, Create, Post, Update, Delete, Replace): if not always_create_new_node: # Try to find an existing one to see if there is anything to update. + where = copy.deepcopy(basic_properties) + if extra_where: + where.update(extra_where) existing_node = cls.find_first({'where': basic_properties}, api=api) if existing_node: # Just update the file ID and we're done.