27 lines
913 B
Python
27 lines
913 B
Python
from commands.helper import load_dump_pretty, OTPCredentials
|
|
from decouple import config
|
|
|
|
import click
|
|
import requests
|
|
|
|
@click.group()
|
|
def network():
|
|
pass
|
|
|
|
|
|
@network.command("create")
|
|
@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("--network-name", required=True)
|
|
@click.option("--network-type", required=True)
|
|
@click.option("--user", required=True, type=bool, default=False)
|
|
def create(name, realm, seed, network_name, network_type, user):
|
|
data = {
|
|
**OTPCredentials(name, realm, seed).get_json(),
|
|
"network_name": network_name,
|
|
"type": network_type,
|
|
"user": user
|
|
}
|
|
r = requests.post("{}/network/create".format(config('UCLOUD_API_SERVER')), json=data)
|
|
print(load_dump_pretty(r.content))
|