Add order list command

This commit is contained in:
PCoder 2019-09-14 22:45:56 +05:30
parent c91454e0d2
commit a968918eee
2 changed files with 27 additions and 0 deletions

25
commands/order.py Normal file
View file

@ -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))

View file

@ -5,6 +5,7 @@ from commands.user import user
from commands.host import host from commands.host import host
from commands.image import image from commands.image import image
from commands.product import product from commands.product import product
from commands.order import order
@click.group() @click.group()
@ -17,6 +18,7 @@ entry_point.add_command(user)
entry_point.add_command(image) entry_point.add_command(image)
entry_point.add_command(host) entry_point.add_command(host)
entry_point.add_command(product) entry_point.add_command(product)
entry_point.add_command(order)
if __name__ == "__main__": if __name__ == "__main__":
entry_point() entry_point()