Compare commits
No commits in common. "f9ac1a0850ca54d27bd795dd10fc2c014a63c94d" and "3bab5650a63bd0eec9801d76a49a4ed491fc0771" have entirely different histories.
f9ac1a0850
...
3bab5650a6
36
twvdscli.py
36
twvdscli.py
@ -132,19 +132,6 @@ class Backups:
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def list(vds_id):
|
|
||||||
disk_id = Server.get_vds(vds_id)['server']['disk_stats']['disk_id']
|
|
||||||
uri = "https://public-api.timeweb.com/api/v1/backups/vds/{id}/drive/{disk_id}"
|
|
||||||
result = requests.get(
|
|
||||||
uri.format(id=vds_id, disk_id=disk_id),
|
|
||||||
headers=reqHeader
|
|
||||||
)
|
|
||||||
if result.ok:
|
|
||||||
return result.json()
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
@backups_app.command("create")
|
@backups_app.command("create")
|
||||||
def create_backup(vds_id: Optional[int] = typer.Argument(None)):
|
def create_backup(vds_id: Optional[int] = typer.Argument(None)):
|
||||||
@ -158,28 +145,7 @@ def create_backup(vds_id: Optional[int] = typer.Argument(None)):
|
|||||||
if result is None:
|
if result is None:
|
||||||
print(typer.style("Error", fg=typer.colors.RED))
|
print(typer.style("Error", fg=typer.colors.RED))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
print(result.json())
|
||||||
print(typer.style("Success", fg=typer.colors.GREEN))
|
|
||||||
|
|
||||||
|
|
||||||
@backups_app.command("list")
|
|
||||||
def list_backup(vds_id: Optional[int] = typer.Argument(None)):
|
|
||||||
"""
|
|
||||||
List backups
|
|
||||||
"""
|
|
||||||
if vds_id is None:
|
|
||||||
vds_list()
|
|
||||||
vds_id = input("Enter VDS ID: ")
|
|
||||||
result = Backups.list(vds_id)
|
|
||||||
if result is None:
|
|
||||||
print(typer.style("Error", fg=typer.colors.RED))
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
x = PrettyTable()
|
|
||||||
x.field_names = ["id", "Date", "Size", "Cost", "Mounted"]
|
|
||||||
for i in result['backups']:
|
|
||||||
x.add_row([i['id'], i['c_date'], i['drive_size'], i['cost_backup'], i['mounted']])
|
|
||||||
print(x)
|
|
||||||
|
|
||||||
|
|
||||||
@app.command("balance")
|
@app.command("balance")
|
||||||
|
Loading…
Reference in New Issue
Block a user