uncloud-cli/commands/user.py

32 lines
834 B
Python
Raw Normal View History

2019-07-17 14:58:39 +00:00
import click
import json
import requests
from decouple import config
from helper import OTPCredentials
@click.group()
def user():
pass
@user.command("list-files")
@click.option("--name", required=True)
@click.option("--realm", required=True)
@click.option("--seed", required=True)
def list_files(name, realm, seed):
data = OTPCredentials(name, realm, seed).get_json()
r = requests.get(f"{config('UCLOUD_API_SERVER')}/user/files", json=data)
print(json.loads(r.content))
@user.command("list-vms")
@click.option("--name", required=True)
@click.option("--realm", required=True)
@click.option("--seed", required=True)
def list_vms(name, realm, seed):
data = OTPCredentials(name, realm, seed).get_json()
r = requests.get(f"{config('UCLOUD_API_SERVER')}/user/vms", json=data)
print(json.loads(r.content))