refactoring done
This commit is contained in:
parent
280043659d
commit
dc283251d9
13 changed files with 227 additions and 289 deletions
|
|
@ -1,6 +1,4 @@
|
|||
from uncloud_cli.commands.helper import load_dump_pretty, OTPCredentials
|
||||
from uncloud_cli.config import env_vars
|
||||
from os.path import join as join_path
|
||||
from uncloud_cli.commands.helper import add_otp_options, make_request
|
||||
|
||||
import click
|
||||
import requests
|
||||
|
|
@ -12,20 +10,9 @@ def network():
|
|||
|
||||
|
||||
@network.command("create")
|
||||
@click.option("--name", required=True, default=env_vars.get("OTP_NAME"))
|
||||
@click.option("--realm", required=True, default=env_vars.get("OTP_REALM"))
|
||||
@click.option("--seed", required=True, default=env_vars.get("OTP_SEED"))
|
||||
@add_otp_options
|
||||
@click.option("--network-name", required=True)
|
||||
@click.option("--network-type", required=True)
|
||||
@click.option("--network-type", '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(
|
||||
join_path(env_vars.get("UCLOUD_API_SERVER"), "network", "create"), json=data
|
||||
)
|
||||
print(load_dump_pretty(r.content))
|
||||
def create(**kwargs):
|
||||
make_request('network', 'create', data=kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue