from commands.helper import load_dump_pretty from decouple import config import click import requests @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("{}/image/list-public".format(config('UCLOUD_API_SERVER'))) print(load_dump_pretty(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("{}/image/create".format(config('UCLOUD_API_SERVER')), json=data) print(load_dump_pretty(r.content))