converted to python package
This commit is contained in:
parent
51e1130071
commit
8bb860024a
23 changed files with 110 additions and 309 deletions
31
ucloud_cli/commands/network.py
Normal file
31
ucloud_cli/commands/network.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
from ucloud_cli.commands.helper import load_dump_pretty, OTPCredentials
|
||||
from ucloud_cli.config import env_vars
|
||||
from os.path import join as join_path
|
||||
|
||||
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(
|
||||
join_path(env_vars.get("UCLOUD_API_SERVER"), "network", "create"), json=data
|
||||
)
|
||||
print(load_dump_pretty(r.content))
|
||||
Loading…
Add table
Add a link
Reference in a new issue