# Manage asset versions

> How to manage asset versions and version labels

## Before you begin

To access any assets, make sure the app has the right permissions. Read more about [managing Identity](/asset-manager/python-sdk/manage-identity.md).

> **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](/asset-manager/python-sdk/get-started.md).

## Submit or freeze an asset version

When you see an asset version as complete, to freeze a specific version, call `freeze_asset_version` with the information of the asset version and a changelog.

```python
unity_cloud.assets.freeze_asset_version(
      org_id = "012345678912",
        project_id = "1234abcd-ab12-cd34-ef56-123456abcdef",
        asset_id = "0123456789abcdefghijklmn",
        asset_version = '1234abcd-ab12-cd34-ef56-123456abcdef',
        changelog = "Initial version")
```

## Create a new unfrozen version

To create a new unfrozen version from a frozen version, call `create_unfrozen_asset_version` with the frozen version information.

```python
new_version = unity_cloud.assets.create_unfrozen_asset_version(
  org_id = "012345678912",
  project_id = "1234abcd-ab12-cd34-ef56-123456abcdef",
  asset_id = "0123456789abcdefghijklmn",
  asset_version = '1234abcd-ab12-cd34-ef56-123456abcdef')
```

## Search for versions of assets

To search for a version of an asset, follow these steps:

1. Create your filters as dictionaries or objects that will contain the conditions.
2. Create an array that will contain the collections in which to look up. Leave the array empty to search across all collections and assets version not linked to a collection.
3. Call `search_versions_in_asset` with the organization ID, your project IDs, your filters, the amount of matches required in `any_filter`, the collections, and optionally the maximum number of results returned and the amount to skip for paging purpose.

```python
include_filter = dict()
exclude_filter = dict()
any_filter = dict()

include_filter[SearchableProperties.NAME] = StringFilter(StringLookUpTypes.REGEX, "asset\-.*")

collections = []

search_result = unity_cloud.assets.search_versions_in_asset(org_id, project_id, asset_id, include_filter=include_filter, exclude_filter=exclude_filter, any_filter=any_filter, any_query_minimum_match=1, collections=collections, limit_to=10, skip=0)
```

## Create a version label

To create a version label, follow these steps:

1. Create a `LabelCreation` object by passing the name, the description, and the color in hex code that it will display in the dashboard.
2. Call `create_label` with the organization id and the previously created `LabelCreation`.

```python

label_creation = LabelCreation(name="my new version label", description="label_description", color="#FFFFFF")
label = unity_cloud.assets.create_label(org_id="1234567890", label=label_creation)
```

## Update a version label

To update a version label, follow these steps:

1. Create a `LabelUpdate` object and pass the name, the new description, and the new color in hex code that will display in the dashboard.
2. Call `update_label` with the organization id and the previously created `LabelUpdate`.

```python
    label_update = LabelUpdate(name=label.name, description= "new description", color="#000000")

    unity_cloud.assets.update_label(org_id="1234567890", label=label_update)
```

## Get a version label

To get a single version label, call `get_label` with the organization id and the name of the version label.

```python
label = unity_cloud.assets.get_label(org_id="1234567890", name="the name")
```

## List all version labels in an organization

To list all created version labels in an organization, call `list_organization_labels` with the organization id and whether or not you want archived labels or non archived labels.

```python
labels = unity_cloud.assets.list_organization_labels(org_id="1234567890", is_archived=False)
```

## Archive or unarchive a version label

To archive or unarchive a version label, call `archive_label` or `unarchive_label` with the organization id and the name of the label.

```python
unity_cloud.assets.archive_label(org_id="1234567890", name="label name")
unity_cloud.assets.unarchive_label(org_id="1234567890", name="label name")
```

## Assign or unassign version labels to an asset version

Once version labels are created, to assign or unassign them to a specific asset version, call `assign_labels` or `unassign_labels` with the asset version information and an array with the names of the version labels to assign or unassign.

```python
unity_cloud.assets.assign_labels(
  org_id = "012345678912",
  project_id = "1234abcd-ab12-cd34-ef56-123456abcdef",
  asset_id = "0123456789abcdefghijklmn",
  asset_version = '1234abcd-ab12-cd34-ef56-123456abcdef',
  labels = ["label1", "label2"])

  unity_cloud.assets.unassign_labels(
  org_id = "012345678912",
  project_id = "1234abcd-ab12-cd34-ef56-123456abcdef",
  asset_id = "0123456789abcdefghijklmn",
  asset_version = '1234abcd-ab12-cd34-ef56-123456abcdef',
  labels = ["label1", "label2"])
```

## List the version labels assigned to an asset version

Once labels have been assigned to an asset version, to list them, call `list_asset_labels` with the asset version information and whether or not you want to see archived version labels or non archived versions. You can also use limit and skip parameter for paging purpose.

```python
asset_labels_names = unity_cloud.assets.list_asset_labels(
  org_id = "012345678912",
  project_id = "1234abcd-ab12-cd34-ef56-123456abcdef",
  asset_id = "0123456789abcdefghijklmn",
  asset_version = '1234abcd-ab12-cd34-ef56-123456abcdef',
  is_archived = false,
  limit = 100,
  skip = 0
)
```
