> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vessl.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Storage

### create\_storage

```python theme={null}
vessl.storage.create_storage(
    name: str,
    storage_type: vessl.storage.StorageType,
    path: str,
    credential_name: Optional[str],
    cluster_name: Optional[str],
)
```

Create an external storage.

<Note>
  VESSL External Storage acts as a bridge to external storage services (e.g., S3, GCS, etc.).
  Make sure to configure the external storage settings before proceeding.

  If you do not want to use external storage, you can use the default VESSL storage, `vessl-storage`.
</Note>

**Args**

* `name` (str) : The name of the storage to create.
* `storage_type` (StorageType) : The type of storage to create. Options: `StorageType.S3`, `StorageType.GCS`, `StorageType.NFS`, `StorageType.HOST_PATH`
* `path` (str) : The path of the storage.
  * For `s3` : Path must in `{bucket_name}/{path}` (e.g. my-bucket)
  * For `gcs` : Path must in `{bucket_name}/{path}` (e.g. my-bucket)
  * For `nfs` : Path must be in `{server}:{path}` format (e.g. 192.168.1.100:/shared/data)
  * For `host-path` : Path must be an absolute local path (e.g. /data/host-folder)
* `credential_name` (str) : The name of the credential to use. Required if `storage_type` is `S3` or `GCS`
* `cluster_name` (str) : The name of the cluster to use. Required if `storage_type` is `NFS` or `HOST_PATH`

**Examples**

* Create an S3 storage:
  ```python theme={null}
  vessl.storage.create_storage(
      name="my-s3-storage",
      storage_type=vessl.storage.StorageType.S3,
      path="my-bucket",
      credential_name="my-aws-credential",
  )
  ```
* Create a GCS(Google Cloud Storage) storage:
  ```python theme={null}
  vessl.storage.create_storage(
      name="my-gcs-storage",
      storage_type=vessl.storage.StorageType.GCS,
      path="my-bucket",
      credential_name="my-aws-credential",
  )
  ```
* Create an NFS storage:
  ```python theme={null}
  vessl.storage.create_storage(
      name="my-nfs-storage",
      storage_type=vessl.storage.StorageType.NFS,
      path="my.nfs.com:/shared/data",
      cluster_name="my-cluster",
  )
  ```
* Create an HOST PATH storage:
  ```python theme={null}
  vessl.storage.create_storage(
      name="my-host-path-storage",
      storage_type=vessl.storage.StorageType.HOST_PATH,
      path=" /data/host-folder",
      cluster_name="my-cluster",
  )
  ```

### list\_storages

```python theme={null}
vessl.storage.list_storages(**kwargs)
```

List storages in the default organization. If you want to override the default organization, then pass `organization_name` as `**kwargs`.

**Example**

```python theme={null}
vessl.storage.list_storages()
```

### delete\_storage

```python theme={null}
vessl.storage.delete_storage(
    name: str,
)
```

Delete storage.

**Args**

* name (str) : Name of the storage to delete.

**Example**

```python theme={null}
vessl.storage.delete_storage(name="my-storage")
```

### create\_volume

```python theme={null}
vessl.storage.create_volume(
    name: str,
    storage_name: str,
    tags: tuple[str, ...],
)
```

Create a volume in storage.

**Args**

* name (str) : Name of the volume.
* storage\_name (str) : Name of the storage.
* tags (tuple\[str, ...]) : Tags of the volume.

**Example**

```python theme={null}
vessl.storage.create_volume(
    name="my-volume",
    storage_name="my-storage",
    tags=("my-tag1", "my-tag2"),
)
```

### list\_volumes

```python theme={null}
vessl.storage.list_volumes(
    storage_name: str,
    keyword: Optional[str],
)
```

List volumes in storage.

**Args**

* storage\_name (str) : Name of the storage.
* keyword (str) : Optional search keyword.

**Example**

```python theme={null}
vessl.storage.list_volumes(storage_name="my-storage")
```

### delete\_volume

```python theme={null}
vessl.storage.delete_volume(
    name: str,
    storage_name: str,
)
```

Delete volume in storage.

**Args**

* name (str) : Name of the volume.
* storage\_name (str) : Name of the storage.

**Example**

```python theme={null}
vessl.storage.delete_volume(
    name="my-volume",
    storage_name="my-storage",
)
```

### list\_volume\_files

```python theme={null}
vessl.storage.list_volume_files(
    storage_name: str,
    volume_name: str,
    path: Optional[str],
)
```

List all files in a volume.

**Args**

* storage\_name (str) : Name of the storage.
* volume\_name (str) : Name of the volume.
* path (Optional\[str]) : Path of directory to list. Defaults to "".

**Example**

```python theme={null}
vessl.storage.list_volume_files(
    storage_name="my-storage",
    volume_name="my-volume",
)
```

### upload\_volume\_file

```python theme={null}
vessl.storage.upload_volume_file(
    source_path: str,
    dest_storage_name: str,
    dest_volume_name: str,
    dest_path: Optional[str],
)
```

Upload a file to a volume.

**Args**

* source\_path (str) : Path of local directory of file to upload.
* dest\_storage\_name (str) : Name of the storage.
* dest\_volume\_name (str) : Name of the volume.
* dest\_path (str) : Path of volume directory to upload the file to. Defaults to "/".

**Example**

```python theme={null}
vessl.storage.upload_volume_file(
    source_path="/path/to/file",
    dest_storage_name="my-storage",
    dest_volume_name="my-volume",
)
```

### download\_volume\_file

```python theme={null}
vessl.storage.download_volume_file(
    source_storage_name: str,
    source_volume_name: str,
    dest_path: str,
)
```

Download a file from a volume.

**Args**

* source\_storage\_name (str) : Name of the storage.
* source\_volume\_name (str) : Name of the volume in the storage.
* dest\_path (str) : Path of local directory to download the file to.

**Example**

```python theme={null}
vessl.storage.download_volume_file(
    source_storage_name="my-storage",
    source_volume_name="my-volume",
    dest_path="models"
)
```

### delete\_volume\_file

```python theme={null}
vessl.storage.delete_volume_file(
    storage_name: str, 
    volume_name: str, 
    path: str, 
    recursive: Optional[bool],
)
```

Delete a file from a volume.

**Args**

* storage\_name (str) : Name of the storage.
* volume\_name (str) : Name of the volume in the storage.
* path (str) : Path of directory or file in volume to delete.
* recursive (Optional\[bool]) : If true, delete all files in this directory. Defaults to False.

**Example**

```python theme={null}
vessl.storage.delete_volume_file(
    storage_name="my-storage",
    volume_name="my-volume",
    path="model.pth"
)
```
