Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
from ._wait import *
from ._get_failover_all_tests_detail import *
from ._get_failover_single_test_detail import *
from ._get_resiliency_information import *
from ._get_routes_information import *
from ._list import *
from ._show import *
from ._start_site_failover_test import *
from ._stop_site_failover_test import *
from ._update import *
from ._wait import *
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ def _build_arguments_schema(cls, *args, **kwargs):
options=["--pip-addresses"],
help="Space-separated list of public IP addresses (Names or IDs).",
)
_args_schema.pip_addresses_v6 = AAZListArg(
options=["--pip-addresses-v6"],
_args_schema.pip_addrs_v6 = AAZListArg(
options=["--pip-addrs-v6"],
help="An array of public ip addresses V6 associated with the nat gateway resource.",
)
_args_schema.pip_prefixes = AAZListArg(
options=["--pip-prefixes"],
help="Space-separated list of public IP prefixes (Names or IDs).",
)
_args_schema.pip_prefixes_v6 = AAZListArg(
options=["--pip-prefixes-v6"],
_args_schema.pip_prefs_v6 = AAZListArg(
options=["--pip-prefs-v6"],
help="An array of public ip prefixes V6 associated with the nat gateway resource.",
)
_args_schema.source_vnet = AAZObjectArg(
Expand Down Expand Up @@ -108,9 +108,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="Resource ID.",
)

pip_addresses_v6 = cls._args_schema.pip_addresses_v6
pip_addresses_v6.Element = AAZObjectArg()
cls._build_args_sub_resource_create(pip_addresses_v6.Element)
pip_addrs_v6 = cls._args_schema.pip_addrs_v6
pip_addrs_v6.Element = AAZObjectArg()
cls._build_args_sub_resource_create(pip_addrs_v6.Element)

pip_prefixes = cls._args_schema.pip_prefixes
pip_prefixes.Element = AAZObjectArg()
Expand All @@ -121,9 +121,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="Resource ID.",
)

pip_prefixes_v6 = cls._args_schema.pip_prefixes_v6
pip_prefixes_v6.Element = AAZObjectArg()
cls._build_args_sub_resource_create(pip_prefixes_v6.Element)
pip_prefs_v6 = cls._args_schema.pip_prefs_v6
pip_prefs_v6.Element = AAZObjectArg()
cls._build_args_sub_resource_create(pip_prefs_v6.Element)

tags = cls._args_schema.tags
tags.Element = AAZStrArg()
Expand Down Expand Up @@ -268,9 +268,9 @@ def content(self):
if properties is not None:
properties.set_prop("idleTimeoutInMinutes", AAZIntType, ".idle_timeout")
properties.set_prop("publicIpAddresses", AAZListType, ".pip_addresses")
properties.set_prop("publicIpAddressesV6", AAZListType, ".pip_addresses_v6")
properties.set_prop("publicIpAddressesV6", AAZListType, ".pip_addrs_v6")
properties.set_prop("publicIpPrefixes", AAZListType, ".pip_prefixes")
properties.set_prop("publicIpPrefixesV6", AAZListType, ".pip_prefixes_v6")
properties.set_prop("publicIpPrefixesV6", AAZListType, ".pip_prefs_v6")
_CreateHelper._build_schema_sub_resource_create(properties.set_prop("sourceVirtualNetwork", AAZObjectType, ".source_vnet"))

public_ip_addresses = _builder.get(".properties.publicIpAddresses")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="Space-separated list of public IP addresses (Names or IDs).",
nullable=True,
)
_args_schema.pip_addresses_v6 = AAZListArg(
options=["--pip-addresses-v6"],
_args_schema.pip_addrs_v6 = AAZListArg(
options=["--pip-addrs-v6"],
help="An array of public ip addresses V6 associated with the nat gateway resource.",
nullable=True,
)
Expand All @@ -76,8 +76,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="Space-separated list of public IP prefixes (Names or IDs).",
nullable=True,
)
_args_schema.pip_prefixes_v6 = AAZListArg(
options=["--pip-prefixes-v6"],
_args_schema.pip_prefs_v6 = AAZListArg(
options=["--pip-prefs-v6"],
help="An array of public ip prefixes V6 associated with the nat gateway resource.",
nullable=True,
)
Expand Down Expand Up @@ -105,11 +105,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
nullable=True,
)

pip_addresses_v6 = cls._args_schema.pip_addresses_v6
pip_addresses_v6.Element = AAZObjectArg(
pip_addrs_v6 = cls._args_schema.pip_addrs_v6
pip_addrs_v6.Element = AAZObjectArg(
nullable=True,
)
cls._build_args_sub_resource_update(pip_addresses_v6.Element)
cls._build_args_sub_resource_update(pip_addrs_v6.Element)

pip_prefixes = cls._args_schema.pip_prefixes
pip_prefixes.Element = AAZObjectArg(
Expand All @@ -123,11 +123,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
nullable=True,
)

pip_prefixes_v6 = cls._args_schema.pip_prefixes_v6
pip_prefixes_v6.Element = AAZObjectArg(
pip_prefs_v6 = cls._args_schema.pip_prefs_v6
pip_prefs_v6.Element = AAZObjectArg(
nullable=True,
)
cls._build_args_sub_resource_update(pip_prefixes_v6.Element)
cls._build_args_sub_resource_update(pip_prefs_v6.Element)

tags = cls._args_schema.tags
tags.Element = AAZStrArg(
Expand Down Expand Up @@ -400,9 +400,9 @@ def _update_instance(self, instance):
if properties is not None:
properties.set_prop("idleTimeoutInMinutes", AAZIntType, ".idle_timeout")
properties.set_prop("publicIpAddresses", AAZListType, ".pip_addresses")
properties.set_prop("publicIpAddressesV6", AAZListType, ".pip_addresses_v6")
properties.set_prop("publicIpAddressesV6", AAZListType, ".pip_addrs_v6")
properties.set_prop("publicIpPrefixes", AAZListType, ".pip_prefixes")
properties.set_prop("publicIpPrefixesV6", AAZListType, ".pip_prefixes_v6")
properties.set_prop("publicIpPrefixesV6", AAZListType, ".pip_prefs_v6")
_UpdateHelper._build_schema_sub_resource_update(properties.set_prop("sourceVirtualNetwork", AAZObjectType, ".source_vnet"))

public_ip_addresses = _builder.get(".properties.publicIpAddresses")
Expand Down
123 changes: 121 additions & 2 deletions src/azure-cli/azure/cli/command_modules/network/operations/nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class GatewayCreate(_GatewayCreate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
from azure.cli.core.aaz import AAZListArg, AAZResourceIdArg, AAZResourceIdArgFormat
from azure.cli.core.aaz import AAZListArg, AAZResourceIdArg, AAZResourceIdArgFormat, AAZStrArg
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.public_ip_addresses = AAZListArg(
options=["--public-ip-addresses"],
Expand All @@ -35,8 +35,20 @@ def _build_arguments_schema(cls, *args, **kwargs):
"/publicIPPrefixes/{}",
),
)
args_schema.pip_addresses_v6_input = AAZListArg(
options=["--pip-addresses-v6"],
help="Space-separated list of public IPv6 addresses (Names or IDs).",
)
args_schema.pip_addresses_v6_input.Element = AAZStrArg()
args_schema.pip_prefixes_v6_input = AAZListArg(
options=["--pip-prefixes-v6"],
help="Space-separated list of public IPv6 prefixes (Names or IDs).",
)
args_schema.pip_prefixes_v6_input.Element = AAZStrArg()
args_schema.pip_addresses._registered = False
args_schema.pip_prefixes._registered = False
args_schema.pip_addrs_v6._registered = False
args_schema.pip_prefs_v6._registered = False
return args_schema

def pre_operations(self):
Expand All @@ -51,13 +63,60 @@ def pre_operations(self):
args.public_ip_prefixes,
element_transformer=lambda _, prefix_id: {"id": prefix_id}
)

from azure.cli.core.aaz import has_value
from azure.cli.core.util import shell_safe_json_parse

sub = self.ctx.subscription_id
rg = args.resource_group.to_serialized_data()

# ---------- v6 addresses ----------
if has_value(args.pip_addresses_v6_input):
serialized = args.pip_addresses_v6_input.to_serialized_data() or []

# legacy JSON string --pip-addresses-v6 "[{'id':'/.../id'}]"
if len(serialized) == 1 and isinstance(serialized[0], str) and serialized[0].lstrip().startswith('['):
parsed = shell_safe_json_parse(serialized[0])
ids = [it.get("id") for it in parsed if isinstance(it, dict) and it.get("id")]
args.pip_addrs_v6 = [{"id": rid} for rid in ids]
else:
args.pip_addrs_v6 = assign_aaz_list_arg(
args.pip_addrs_v6,
args.pip_addresses_v6_input,
element_transformer=lambda _, v: {
"id": v if str(v).strip().startswith("/")
else f"/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network"
f"/publicIPAddresses/{str(v).strip()}"
}
)

# ---------- v6 prefixes ----------
if has_value(args.pip_prefixes_v6_input):
serialized = args.pip_prefixes_v6_input.to_serialized_data() or []

# legacy JSON string --pip-prefixes-v6 "[{'id':'/.../id'}]"
if len(serialized) == 1 and isinstance(serialized[0], str) and serialized[0].lstrip().startswith('['):
parsed = shell_safe_json_parse(serialized[0])
ids = [it.get("id") for it in parsed if isinstance(it, dict) and it.get("id")]
args.pip_prefs_v6 = [{"id": rid} for rid in ids]
else:
args.pip_prefs_v6 = assign_aaz_list_arg(
args.pip_prefs_v6,
args.pip_prefixes_v6_input,
element_transformer=lambda _, v: {
"id": v if str(v).strip().startswith("/")
else f"/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network"
f"/publicIPPrefixes/{str(v).strip()}"
}
)

args.sku.name = "Standard"


class GatewayUpdate(_GatewayUpdate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
from azure.cli.core.aaz import AAZListArg, AAZResourceIdArg, AAZResourceIdArgFormat
from azure.cli.core.aaz import AAZListArg, AAZResourceIdArg, AAZResourceIdArgFormat, AAZStrArg
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.public_ip_addresses = AAZListArg(
options=["--public-ip-addresses"],
Expand All @@ -83,8 +142,22 @@ def _build_arguments_schema(cls, *args, **kwargs):
),
nullable=True,
)
args_schema.pip_addresses_v6_input = AAZListArg(
options=["--pip-addresses-v6"],
help="Space-separated list of public IPv6 addresses (Names or IDs).",
nullable=True,
)
args_schema.pip_addresses_v6_input.Element = AAZStrArg(nullable=True)
args_schema.pip_prefixes_v6_input = AAZListArg(
options=["--pip-prefixes-v6"],
help="Space-separated list of public IPv6 prefixes (Names or IDs).",
nullable=True,
)
args_schema.pip_prefixes_v6_input.Element = AAZStrArg(nullable=True)
args_schema.pip_addresses._registered = False
args_schema.pip_prefixes._registered = False
args_schema.pip_addrs_v6._registered = False
args_schema.pip_prefs_v6._registered = False
return args_schema

def pre_operations(self):
Expand All @@ -99,3 +172,49 @@ def pre_operations(self):
args.public_ip_prefixes,
element_transformer=lambda _, prefix_id: {"id": prefix_id}
)

from azure.cli.core.aaz import has_value
from azure.cli.core.util import shell_safe_json_parse

sub = self.ctx.subscription_id
rg = args.resource_group.to_serialized_data()

# ---------- v6 addresses ----------
if has_value(args.pip_addresses_v6_input):
serialized = args.pip_addresses_v6_input.to_serialized_data() or []

# legacy JSON string --pip-addresses-v6 "[{'id':'/.../id'}]"
if len(serialized) == 1 and isinstance(serialized[0], str) and serialized[0].lstrip().startswith('['):
parsed = shell_safe_json_parse(serialized[0])
ids = [it.get("id") for it in parsed if isinstance(it, dict) and it.get("id")]
args.pip_addrs_v6 = [{"id": rid} for rid in ids]
else:
args.pip_addrs_v6 = assign_aaz_list_arg(
args.pip_addrs_v6,
args.pip_addresses_v6_input,
element_transformer=lambda _, v: {
"id": v if str(v).strip().startswith("/")
else f"/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network"
f"/publicIPAddresses/{str(v).strip()}"
}
)

# ---------- v6 prefixes ----------
if has_value(args.pip_prefixes_v6_input):
serialized = args.pip_prefixes_v6_input.to_serialized_data() or []

# legacy JSON string --pip-prefixes-v6 "[{'id':'/.../id'}]"
if len(serialized) == 1 and isinstance(serialized[0], str) and serialized[0].lstrip().startswith('['):
parsed = shell_safe_json_parse(serialized[0])
ids = [it.get("id") for it in parsed if isinstance(it, dict) and it.get("id")]
args.pip_prefs_v6 = [{"id": rid} for rid in ids]
else:
args.pip_prefs_v6 = assign_aaz_list_arg(
args.pip_prefs_v6,
args.pip_prefixes_v6_input,
element_transformer=lambda _, v: {
"id": v if str(v).strip().startswith("/")
else f"/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network"
f"/publicIPPrefixes/{str(v).strip()}"
}
)
Loading
Loading