Skip to content

Commit edb2e5e

Browse files
authored
Merge pull request #42 from Frameio/DEVREL-301-copy-asset
Add copy_asset() and bulk_copy_assets() functionality
2 parents 1d698ef + d11f746 commit edb2e5e

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

frameioclient/client.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,48 @@ def update_asset(self, asset_id, **kwargs):
230230
endpoint = '/assets/{}'.format(asset_id)
231231
return self._api_call('put', endpoint, kwargs)
232232

233+
def copy_asset(self, destination_folder_id, **kwargs):
234+
"""
235+
Copy an asset
236+
237+
:Args:
238+
destination_folder_id (string): The id of the folder you want to copy into.
239+
:Kwargs:
240+
id (string): The id of the asset you want to copy.
241+
242+
Example::
243+
client.copy_asset("adeffee123342", id="7ee008c5-49a2-f8b5-997d-8b64de153c30")
244+
"""
245+
endpoint = '/assets/{}/copy'.format(destination_folder_id)
246+
return self._api_call('post', endpoint, kwargs)
247+
248+
def bulk_copy_assets(self, destination_folder_id, asset_list=[], copy_comments=False):
249+
"""
250+
Bulk copy assets
251+
252+
:Args:
253+
destination_folder_id (string): The id of the folder you want to copy into.
254+
:Kwargs:
255+
asset_list (list): A list of the asset IDs you want to copy.
256+
copy_comments (boolean): Whether or not to copy comments: True or False.
257+
258+
Example::
259+
client.bulk_copy_assets("adeffee123342", asset_list=["7ee008c5-49a2-f8b5-997d-8b64de153c30", \
260+
"7ee008c5-49a2-f8b5-997d-8b64de153c30"], copy_comments=True)
261+
"""
262+
263+
payload = {"batch": []}
264+
new_list = list()
265+
266+
if copy_comments:
267+
payload['copy_comments'] = "all"
268+
269+
for asset in asset_list:
270+
payload['batch'].append({"id": asset})
271+
272+
endpoint = '/batch/assets/{}/copy'.format(destination_folder_id)
273+
return self._api_call('post', endpoint, payload)
274+
233275
def delete_asset(self, asset_id):
234276
"""
235277
Delete an asset

0 commit comments

Comments
 (0)