Documentation

Support

Manage collections

How to create and manage collections.
Read time 2 minutesLast updated 10 months ago

Before you begin

To access any collections, ensure that the application has all the right accesses. Read more about managing Identity.
Note
The following code snippets first require an initialization. To learn more about the
initialize()
and
uninitialize()
methods, read about getting started with the Unity Cloud Python SDK.

How do I...?

Create a collection

To create a collection, follow these steps:
  1. Create a
    CollectionCreation
    object with:
    • the collection name
    • the parent collection if any
    • the collection description
  2. Call
    create_collection
    with the organization and project IDs.
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:
  1. Create a
     CollectionUpdate
    object with the new name and/or the new description.
  2. Call
    update_collection
    with the organization and project IDs, followed by the original name of the 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:
  1. Pass the organization and project IDs.
  2. (Optional) Add the parameter
    limit_to
    to limit the amount of returned results. Leave it untouched or set it to 0 to return everything.
  3. (Optional) Add the parameter
    skip
    to specify the number of collection to skip in the results. Use in combination with limit_to to page through results.
unity_cloud.assets.list_collections(org_id, project_id, limit_to=10, skip=0)
To link an asset to a collection, follow these steps:
  1. Pass the organization and project IDs containing the collection.
  2. Pass the name of the collection.
  3. 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"])
To remove assets from a collection, follow these steps:
  1. Pass the organization and project IDs containing the collection.
  2. Pass the name of the collection.
  3. 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"])