# Version

## *class* <mark style="color:purple;">Version</mark>

All datasets on Redivis are versioned. This interface allows you to view detailed information about the version history of a dataset and manage historic versions. However, if you want to get a dataset's contents at a particular version, construct the dataset with the version tag; e.g. `user|organization.dataset(name, version="1.0")`.

## Constructors

<table data-header-hidden><thead><tr><th width="439">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="dataset/dataset.list_versions"><strong><code>Dataset.list_versions</code></strong></a>([max_results])</td><td>Returns the list of all versions of a dataset.</td></tr><tr><td><a href="dataset/dataset.version"><strong><code>Dataset.version</code></strong></a>(tag)</td><td>Construct a new version instance based on a specific version tag (e.g., <code>tag=1.0</code>)</td></tr></tbody></table>

## Examples

{% tabs %}
{% tab title="Basics" %}

```python
my_org = redivis.organization("some_organization")
dataset = my_org.dataset("some_dataset")
current_version = dataset.version("1.0")

current_version.exists() # True

# Get the full API representation of the version and print its properties
print(current_version.get().properties)

for version in dataset.list_versions():
    print(version.properties)
```

{% endtab %}

{% tab title="Jump between versions" %}

```python
my_org = redivis.organization("some_organization")
dataset = my_org.dataset("some_dataset")
current_version = dataset.version("current")

# can also call version.next_version() to go the other direction
previous_version = current_version.previous_version()
if previous_version is not None:
    print(previous_version["tag"])
```

{% endtab %}

{% tab title="Delete a historic version" %}

```python
my_org = redivis.organization("some_organization")
dataset = my_org.dataset("some_dataset")
historic_version = dataset.version("1.0")

# Delete the data in this version, potentially saving storage costs
# Note that users will no longer be able to query or export data in this version!
historic_version.delete()
```

{% endtab %}
{% endtabs %}

## Attributes

| **`properties`** | <p>A dict containing the <a href="../../../resource-definitions/version">API resource representation of the version</a>. This will be fully populated after calling <a href="version/version.get">get()</a>.<br><br>This will also be partially populated for versions returned via the <a href="dataset/dataset.list_versions">Dataset.list\_versions</a> method.</p> |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

## Methods

<table data-header-hidden><thead><tr><th width="450"></th><th></th></tr></thead><tbody><tr><td><a href="version/version.dataset"><strong><code>Version.dataset</code></strong></a>()</td><td>Create a new dataset reference representing this particular version.</td></tr><tr><td><a href="version/version.delete"><strong><code>Version.delete</code></strong></a>()</td><td>Delete an unreleased version, or mark an historic version as deleted.</td></tr><tr><td><a href="version/version.exists"><strong><code>Version.exists</code></strong></a>()</td><td>Check whether the version exists.</td></tr><tr><td><a href="version/version.get"><strong><code>Version.get</code></strong></a>()</td><td>Fetch the version, populating the <code>properties</code> attribute on the current instance.</td></tr><tr><td><a href="version/version.next_version"><strong><code>Version.next_version</code></strong></a>()</td><td>Return the version immediately after this version. If no next version exists, will return <code>None</code>.</td></tr><tr><td><a href="version/version.previous_version"><strong><code>Version.previous_version</code></strong></a>()</td><td>Return the version immediately before this version. If no previous version exists, will return <code>None</code>.</td></tr><tr><td><a href="version/version.undelete"><strong><code>Version.undelete</code></strong></a>()</td><td>Undeletes a deleted version.</td></tr><tr><td><a href="version/version.update"><strong><code>Version.update</code></strong></a>()</td><td>Update properties on a version.</td></tr></tbody></table>
