1"""Restore a file volume from a snapshot."""
2# :license: MIT, see LICENSE for more details.
3
4import click
5import SoftLayer
6from SoftLayer.CLI import environment
7
8
9@click.command()
10@click.argument('volume_id')
11@click.option('--snapshot-id', '-s',
12              help='The id of the snapshot which will be used'
13              ' to restore the block volume')
14@environment.pass_env
15def cli(env, volume_id, snapshot_id):
16    """Restore file volume using a given snapshot"""
17    file_manager = SoftLayer.FileStorageManager(env.client)
18    success = file_manager.restore_from_snapshot(volume_id, snapshot_id)
19
20    if success:
21        click.echo('File volume %s is being restored using snapshot %s'
22                   % (volume_id, snapshot_id))
23