From 274885029ae0f2bccba74fe0ba2324688953934c Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 25 May 2020 15:56:16 -0700 Subject: [PATCH 1/3] WIP move_asset() --- frameioclient/client.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frameioclient/client.py b/frameioclient/client.py index 3f3c145d..2d12eee6 100644 --- a/frameioclient/client.py +++ b/frameioclient/client.py @@ -219,6 +219,25 @@ def get_asset_children(self, asset_id, **kwargs): endpoint = '/assets/{}/children'.format(asset_id) return self._api_call('get', endpoint, kwargs) + def move_asset(self, destination_folder, id) + """ + Move an asset. + + :Args: + asset_id (string): The asset you're trying to move. + :Kwargs: + destination_folder (string): The destination folder you're moving the file into + + Example:: + + client.move_asset( + destination_folder="123abc", + id="123abc", + ) + """ + endpoint = '/assets/{}/children'.format(destination_folder) + return self._api_call('post', endpoint, payload=kwargs) + def create_asset(self, parent_asset_id, **kwargs): """ Create an asset. From 07e35c26edc3bba1b7aa17faa077cc002ad1d16a Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 28 May 2020 18:36:25 -0700 Subject: [PATCH 2/3] Fix move_asset() and add bulk_move_asset() --- frameioclient/client.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/frameioclient/client.py b/frameioclient/client.py index 2d12eee6..32f80a8e 100644 --- a/frameioclient/client.py +++ b/frameioclient/client.py @@ -219,7 +219,7 @@ def get_asset_children(self, asset_id, **kwargs): endpoint = '/assets/{}/children'.format(asset_id) return self._api_call('get', endpoint, kwargs) - def move_asset(self, destination_folder, id) + def move_asset(self, destination_folder, **kwargs): """ Move an asset. @@ -235,9 +235,34 @@ def move_asset(self, destination_folder, id) id="123abc", ) """ - endpoint = '/assets/{}/children'.format(destination_folder) + endpoint = '/assets/{}/move'.format(destination_folder) return self._api_call('post', endpoint, payload=kwargs) + def bulk_move_assets(self, destination_folder_id, asset_list=[]): + """ + Bulk copy assets + + :Args: + destination_folder_id (string): The id of the folder you want to move your assets into. + :Kwargs: + asset_list (list): A list of the asset IDs you want to move. + + Example:: + client.bulk_copy_assets("adeffee123342", asset_list=["7ee008c5-49a2-f8b5-997d-8b64de153c30", \ + "7ee008c5-49a2-f8b5-997d-8b64de153c30"]) + """ + + payload = {"batch": []} + new_list = list() + + for asset in asset_list: + payload['batch'].append({"id": asset}) + + print(payload) + + endpoint = '/batch/assets/{}/move'.format(destination_folder_id) + return self._api_call('post', endpoint, payload) + def create_asset(self, parent_asset_id, **kwargs): """ Create an asset. From bb32065a70a1b745c1408492c794dad30afee97d Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 3 Jun 2020 10:24:33 -0700 Subject: [PATCH 3/3] Remove extraneous print statement --- frameioclient/client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/frameioclient/client.py b/frameioclient/client.py index 32f80a8e..cc43b2bb 100644 --- a/frameioclient/client.py +++ b/frameioclient/client.py @@ -258,8 +258,6 @@ def bulk_move_assets(self, destination_folder_id, asset_list=[]): for asset in asset_list: payload['batch'].append({"id": asset}) - print(payload) - endpoint = '/batch/assets/{}/move'.format(destination_folder_id) return self._api_call('post', endpoint, payload)