Manage collections
How to create and manage collections.
阅读时间2 分钟最后更新于 10 个月前
Before you begin
To access any collections, ensure that the application has all the right accesses. Read more about managing Identity.How do I...?
Create a collection
To create a collection, follow these steps:- Create a object with:
CollectionCreation- the collection name
- the parent collection if any
- the collection description
- Call with the organization and project IDs.
create_collection
create_collection = CollectionCreation("my_collection", parent_path="", description="Collection description")collection = unity_cloud.assets.create_collection(create_collection, org_id, project_id)
Update a collection
To update a collection, follow these steps:- Create aobject with the new name and/or the new description.
CollectionUpdate - Call with the organization and project IDs, followed by the original name of the collection.
update_collection
collection_update = CollectionUpdate(name="New name", description="new description")unity_cloud.assets.update_collection(collection_update, org_id, project_id, original_collection_name)
Delete a collection
To delete a collection, pass the organization and project IDs followed by the collection's name.unity_cloud.assets.delete_collection(config.org_id, config.project_id, collection.name)
Get a collection
To get a collection, pass the organization and project IDs followed by the collection's name.collection = unity_cloud.assets.get_collection(org_id, project_id, collection_name)
List all collections in a project
To list all collections in a project, follow these steps:- Pass the organization and project IDs.
- (Optional) Add the parameter to limit the amount of returned results. Leave it untouched or set it to 0 to return everything.
limit_to - (Optional) Add the parameter to specify the number of collection to skip in the results. Use in combination with limit_to to page through results.
skip
unity_cloud.assets.list_collections(org_id, project_id, limit_to=10, skip=0)
Link an asset to a collection
To link an asset to a collection, follow these steps:- Pass the organization and project IDs containing the collection.
- Pass the name of the collection.
- Pass the IDs of the assets you want to link.
unity_cloud.assets.link_assets_to_collection( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", collection_path = "your-collection-name", asset_ids = ["0123456789abcdefghijklmn", "1123456789abcdefghijklmn", "2123456789abcdefghijklmn"])
Unlink an asset from a collection
To remove assets from a collection, follow these steps:- Pass the organization and project IDs containing the collection.
- Pass the name of the collection.
- Pass the IDs of the assets you want to remove.
unity_cloud.assets.unlink_assets_from_collection( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", collection_path = "your-collection-name", asset_ids = ["0123456789abcdefghijklmn", "1123456789abcdefghijklmn", "2123456789abcdefghijklmn"])