Skip to content

Commit

Permalink
API-1821 Add more examples to collections
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanmartins committed Dec 7, 2023
1 parent e0e8be9 commit 8d00359
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ make executeSdkSample sample-file-name=file.py
```
All sample files are located in the `./samples` directory.

> :warning: Caution: The sample scripts are provided as examples. It is crucial to review and modify the commands before execution. The container updates automatically with changes, ensuring a seamless development experience. Always exercise caution when executing scripts.
> :warning: Caution: The sample scripts are provided as examples. It is crucial to review, add and/or modify the commands before execution. The container updates automatically with changes, ensuring a seamless development experience. Always exercise caution when executing scripts.
## Stopping the Docker Container

Expand Down
44 changes: 42 additions & 2 deletions samples/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,54 @@

# Get the collections client
collection_client = bynder_client.collection_client
print('\n> Create a new collection:')
new_collection = collection_client.create_collection(
name='testing collection python sdk'
)
pp.pprint(new_collection)

print('\n> Get collections list:')
collections = collection_client.collections()
collections = collection_client.collections(query={'keyword': 'testing collection python sdk'})
collection_id = collections[0]['id']
pp.pprint(collections)

print('\n> Get specific collection info:')
collection = collection_client.collection_info(collection_id)
pp.pprint(collection)


# Get the asset bank client to get media id
asset_bank_client = bynder_client.asset_bank_client
media_list = asset_bank_client.media_list({
'count': True,
'limit': 2,
'type': 'image',
'versions': 1
})
media_id = media_list.get('media')[0].get('id')

print('\n> Add media assets to specific collection:')
collection = collection_client.add_media_to_collection(
collection_id,
media_ids=[media_id]
)
pp.pprint(collection)

print('\n> Get media ids of a collection:')
collection_id = collections[0]['id']
collection_media_ids = collection_client.collection_media_ids(
collection_id=collection_id
)
pp.pprint(collection_media_ids)

print('\n> Remove media from specific collection:')
collection = collection_client.remove_media_from_collection(
collection_id,
media_ids=[media_id]
)
pp.pprint(collection)

print('\n> Delete a collection:')
deleted_collection = collection_client.delete_collection(
collection_id=collection_id
)
pp.pprint(deleted_collection)

0 comments on commit 8d00359

Please sign in to comment.