much better cli
This commit is contained in:
parent
c4cf097b99
commit
d045d70609
11 changed files with 210 additions and 121 deletions
30
commands/image.py
Normal file
30
commands/image.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import click
|
||||
import json
|
||||
import requests
|
||||
|
||||
from decouple import config
|
||||
from helper import OTPCredentials
|
||||
|
||||
|
||||
@click.group()
|
||||
def image():
|
||||
pass
|
||||
|
||||
|
||||
@image.command("list")
|
||||
@click.option("--public", is_flag=True)
|
||||
@click.option("--private", is_flag=True)
|
||||
def list(public, private):
|
||||
if public:
|
||||
r = requests.get(f"{config('UCLOUD_API_SERVER')}/image/list-public")
|
||||
print(json.loads(r.content))
|
||||
|
||||
|
||||
@image.command("create-from-file")
|
||||
@click.option("--name", required=True)
|
||||
@click.option("--uuid", required=True)
|
||||
@click.option("--image_store_name", required=True)
|
||||
def create_from_file(name, uuid, image_store_name):
|
||||
data = {"name": name, "uuid": uuid, "image_store": image_store_name}
|
||||
r = requests.post(f"{config('UCLOUD_API_SERVER')}/image/create", data)
|
||||
print(r.content.decode("utf-8"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue