diff --git a/commands/order.py b/commands/order.py new file mode 100644 index 0000000..beb6b70 --- /dev/null +++ b/commands/order.py @@ -0,0 +1,25 @@ +import click +import requests + +from decouple import config +from .helper import OTPCredentials, load_dump_pretty + + +@click.group() +def order(): + pass + + +@order.command("list") +@click.option("--name", envvar="OTP_NAME", required=True) +@click.option("--realm", envvar="OTP_REALM", required=True) +@click.option("--seed", envvar="OTP_SEED", required=True) +@click.option("--email", required=True) +def list(name, realm, seed, email): + data = { + **OTPCredentials(name, realm, seed).get_json(), + "email": email + } + r = requests.get("{}/order/list".format(config('UCLOUD_PAY_SERVER')), + json=data) + print(load_dump_pretty(r.content)) diff --git a/ucloud.py b/ucloud.py index 7f80b92..964ade8 100755 --- a/ucloud.py +++ b/ucloud.py @@ -5,6 +5,7 @@ from commands.user import user from commands.host import host from commands.image import image from commands.product import product +from commands.order import order @click.group() @@ -17,6 +18,7 @@ entry_point.add_command(user) entry_point.add_command(image) entry_point.add_command(host) entry_point.add_command(product) +entry_point.add_command(order) if __name__ == "__main__": entry_point()