31 lines
971 B
Python
Executable file
31 lines
971 B
Python
Executable file
import click
|
|
import json
|
|
import requests
|
|
|
|
from decouple import config
|
|
from .helper import OTPCredentials, load_dump_pretty
|
|
|
|
|
|
@click.group()
|
|
def user():
|
|
pass
|
|
|
|
|
|
@user.command("files")
|
|
@click.option("--name", envvar="OTP_NAME", required=True)
|
|
@click.option("--realm", envvar="OTP_REALM", required=True)
|
|
@click.option("--seed", envvar="OTP_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(load_dump_pretty(r.content))
|
|
|
|
|
|
@user.command("vms")
|
|
@click.option("--name", envvar="OTP_NAME", required=True)
|
|
@click.option("--realm", envvar="OTP_REALM", required=True)
|
|
@click.option("--seed", envvar="OTP_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(load_dump_pretty(r.content))
|