-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretrieve.py
More file actions
33 lines (26 loc) · 849 Bytes
/
retrieve.py
File metadata and controls
33 lines (26 loc) · 849 Bytes
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
import json as json_lib
import click
from rich import print
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("cluster-id", required=True)
@click.option(
"--json",
is_flag=True,
help="Output in JSON format",
)
@click.pass_context
@handle_api_errors("Clusters")
@auto_track_command("clusters retrieve")
def retrieve(ctx: click.Context, cluster_id: str, json: bool) -> None:
"""Retrieve a cluster by ID"""
client: Together = ctx.obj
if not json:
click.echo(f"Clusters: Retrieving cluster...")
response = client.beta.clusters.retrieve(cluster_id)
if json:
click.echo(json_lib.dumps(response.model_dump(exclude_none=True), indent=4))
else:
print(response)