Skip to content

Commit

Permalink
Add internal _move_to_folder method for collection (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
tracivar authored Jul 7, 2022
1 parent b0c00e1 commit 658b928
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from setuptools import setup

# Update version here when you want to increment the version in PyPi
sdk_version = '0.4.6'
sdk_version = '0.4.7'

# If no ZEGAMI_SDK_VERSION set use the version
try:
Expand Down
29 changes: 29 additions & 0 deletions zegami_sdk/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,35 @@ def node_statuses(self):
resp = self.client._auth_get(url)
return resp

def _move_to_folder(self, folder_name):
"""
Move current collection into a folder. When folder_name is None, the collection will
not belong to any folder.
This feature is still WIP.
"""
url = '{}/{}/project/{}/collections/{}'.format(
self.client.HOME, self.client.API_0, self.workspace_id, self.id)
collection_body = self.client._auth_get(url)['collection']

if folder_name is None:
if 'folder' in collection_body:
del collection_body['folder']
if 'folder' in self._data:
del self._data['folder']
else:
collection_body['folder'] = folder_name
self._data['folder'] = folder_name

if 'projectId' in collection_body:
del collection_body['projectId']
if 'published' in collection_body:
for record in collection_body['published']:
del record['status']

self.client._auth_put(
url, body=None,
return_response=True, json=collection_body)

def duplicate(self, duplicate_name=None):
"""
Creates a completely separate copy of the collection within the workspace
Expand Down

0 comments on commit 658b928

Please sign in to comment.