VDS Removing
This commit is contained in:
parent
cd950292ac
commit
6e203a5b5a
37
twvdscli.py
37
twvdscli.py
@ -99,6 +99,22 @@ class Server:
|
|||||||
else:
|
else:
|
||||||
return result.json()
|
return result.json()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def remove(vds_id):
|
||||||
|
"""
|
||||||
|
Remove VDS
|
||||||
|
"""
|
||||||
|
uri = "https://public-api.timeweb.com/api/v1/vds/{id}"
|
||||||
|
result = requests.delete(
|
||||||
|
uri.format(id=vds_id),
|
||||||
|
headers=reqHeader
|
||||||
|
)
|
||||||
|
if not result.ok:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return result.json()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.command("balance")
|
@app.command("balance")
|
||||||
def get_balance():
|
def get_balance():
|
||||||
@ -188,6 +204,27 @@ def vds_clone(vds_id: Optional[int] = typer.Argument(None)):
|
|||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
|
@servers_app.command("remove")
|
||||||
|
def vds_remove(vds_id: Optional[int] = typer.Argument(None)):
|
||||||
|
"""
|
||||||
|
Remove VDS
|
||||||
|
"""
|
||||||
|
if vds_id is None:
|
||||||
|
vds_list()
|
||||||
|
vds_id = input("Enter VDS ID: ")
|
||||||
|
result = Server.remove(vds_id)
|
||||||
|
if result is None:
|
||||||
|
print(typer.style("Error", fg=typer.colors.RED))
|
||||||
|
sys.exit(1)
|
||||||
|
for frame in cycle(r'-\|/'):
|
||||||
|
state = Server.get_vds(vds_id)
|
||||||
|
if not state.get('server'):
|
||||||
|
print(typer.style("\nDeleted", fg=typer.colors.RED))
|
||||||
|
break
|
||||||
|
print('\r', frame, sep='', end='', flush=True)
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
@servers_app.command("list")
|
@servers_app.command("list")
|
||||||
def vds_list():
|
def vds_list():
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user