-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathstop_pod.py
More file actions
32 lines (25 loc) · 907 Bytes
/
stop_pod.py
File metadata and controls
32 lines (25 loc) · 907 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
from urllib.parse import urljoin
import click
from latch_sdk_config.latch import NUCLEUS_URL
from .. import tinyrequests
from ..utils import get_auth_header
def stop_pod(pod_id: int) -> None:
"""Stops a pod given a pod_id"""
res = tinyrequests.post(
urljoin(NUCLEUS_URL, "/pods/stop"),
headers={"Authorization": get_auth_header()},
json={"pod_id": pod_id},
)
if res.status_code == 200:
click.secho(f"Pod with ID `{pod_id}` stopped.", fg="green")
return
if res.status_code == 403 or res.status_code == 404:
click.secho("Pod does not exist or permission denied.", fg="red")
return
if res.status_code != 200:
click.secho(
f"Internal error while stopping Pod `{pod_id}`. Please try again."
" contact `support@latch.bio` if the issue persists.",
fg="red",
)
return