-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.py
More file actions
40 lines (32 loc) · 1.16 KB
/
delete.py
File metadata and controls
40 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json as json_lib
import click
from together import Together
from together.lib.cli._track_cli import auto_track_command
from together.lib.cli.api._utils import handle_api_errors
@click.command()
@click.argument(
"volume-id",
required=True,
)
@click.option(
"--json",
is_flag=True,
help="Output in JSON format",
)
@click.pass_context
@handle_api_errors("Clusters Storage")
@auto_track_command("clusters storage delete")
def delete(ctx: click.Context, volume_id: str, json: bool) -> None:
"""Delete a storage volume"""
client: Together = ctx.obj
if json:
response = client.beta.clusters.storage.delete(volume_id)
click.echo(json_lib.dumps(response.model_dump(), indent=2))
return
storage = client.beta.clusters.storage.retrieve(volume_id)
ctx.obj.print_storage([storage])
if not click.confirm(f"Clusters Storage: Are you sure you want to delete storage volume {storage.volume_name}?"):
return
click.echo("Clusters Storage: Deleting storage volume...")
response = client.beta.clusters.storage.delete(volume_id)
click.echo(f"Clusters Storage: Deleted storage volume {storage.volume_name}")