Skip to content
Draft
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 @@ -853,4 +853,5 @@ def load_arguments(self, _):
c.argument('detection_mode', arg_group='Detection Rules', help='The detection mode for the DDoS detection rule.')
c.argument('traffic_type', arg_group='Detection Rules', help='The traffic type (one of Tcp, Udp, TcpSyn) that the detection rule will be applied upon.')
c.argument('packets_per_second', arg_group='Detection Rules', help='The customized packets per second threshold.')
c.argument('front_end_ip_configuration', options_list=['--fip-config', '--front-end-ip-configuration'], nargs='+', arg_group='Properties', help='The list of frontend IP configuration resource IDs associated with the custom policy.')
# endregion
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ def build_vpn_connection_resource(cmd, name, location, tags, gateway1, gateway2,


def build_ddos_custom_policy(cmd, ddos_custom_policy_name, location=None, tags=None, detection_rule_name=None,
detection_mode=None, packets_per_second=None, traffic_type=None):
detection_mode=None, packets_per_second=None, traffic_type=None,
front_end_ip_configuration=None):
policy = {'ddos_custom_policy_name': ddos_custom_policy_name}

if location:
Expand All @@ -547,4 +548,7 @@ def build_ddos_custom_policy(cmd, ddos_custom_policy_name, location=None, tags=N
detection_rules['traffic_detection_rule'] = traffic_detection_rule
policy['detection_rules'] = [detection_rules]

if front_end_ip_configuration:
policy['front_end_ip_configuration'] = [{'id': ip_id} for ip_id in front_end_ip_configuration]

return policy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
from ._wait import *
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Create(AAZCommand):
"""

_aaz_info = {
"version": "2025-03-01",
"version": "2025-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/ddoscustompolicies/{}", "2025-03-01"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/ddoscustompolicies/{}", "2025-07-01"],
]
}

Expand Down Expand Up @@ -81,6 +81,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
arg_group="Properties",
help="The list of DDoS detection rules associated with the custom policy.",
)
_args_schema.front_end_ip_configuration = AAZListArg(
options=["--fip-config", "--front-end-ip-configuration"],
arg_group="Properties",
help="The list of frontend IP configurations associated with the custom policy.",
)

detection_rules = cls._args_schema.detection_rules
detection_rules.Element = AAZObjectArg()
Expand Down Expand Up @@ -110,6 +115,15 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="The traffic type (one of Tcp, Udp, TcpSyn) that the detection rule will be applied upon.",
enum={"Tcp": "Tcp", "TcpSyn": "TcpSyn", "Udp": "Udp"},
)

front_end_ip_configuration = cls._args_schema.front_end_ip_configuration
front_end_ip_configuration.Element = AAZObjectArg()

_element = cls._args_schema.front_end_ip_configuration.Element
_element.id = AAZStrArg(
options=["id"],
help="Resource ID.",
)
return cls._args_schema

def _execute_operations(self):
Expand Down Expand Up @@ -193,7 +207,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2025-03-01",
"api-version", "2025-07-01",
required=True,
),
}
Expand Down Expand Up @@ -225,6 +239,7 @@ def content(self):
properties = _builder.get(".properties")
if properties is not None:
properties.set_prop("detectionRules", AAZListType, ".detection_rules")
properties.set_prop("frontEndIpConfiguration", AAZListType, ".front_end_ip_configuration")

detection_rules = _builder.get(".properties.detectionRules")
if detection_rules is not None:
Expand All @@ -245,6 +260,14 @@ def content(self):
traffic_detection_rule.set_prop("packetsPerSecond", AAZIntType, ".packets_per_second")
traffic_detection_rule.set_prop("trafficType", AAZStrType, ".traffic_type")

front_end_ip_configuration = _builder.get(".properties.frontEndIpConfiguration")
if front_end_ip_configuration is not None:
front_end_ip_configuration.set_elements(AAZObjectType, ".")

_elements = _builder.get(".properties.frontEndIpConfiguration[]")
if _elements is not None:
_elements.set_prop("id", AAZStrType, ".id")

tags = _builder.get(".tags")
if tags is not None:
tags.set_elements(AAZStrType, ".")
Expand Down Expand Up @@ -296,6 +319,10 @@ def _build_schema_on_200_201(cls):
serialized_name="provisioningState",
flags={"read_only": True},
)
properties.public_ip_addresses = AAZListType(
serialized_name="publicIPAddresses",
flags={"read_only": True},
)
properties.resource_guid = AAZStrType(
serialized_name="resourceGuid",
flags={"read_only": True},
Expand Down Expand Up @@ -341,9 +368,11 @@ def _build_schema_on_200_201(cls):

front_end_ip_configuration = cls._schema_on_200_201.properties.front_end_ip_configuration
front_end_ip_configuration.Element = AAZObjectType()
_CreateHelper._build_schema_common_sub_resource_read(front_end_ip_configuration.Element)

_element = cls._schema_on_200_201.properties.front_end_ip_configuration.Element
_element.id = AAZStrType()
public_ip_addresses = cls._schema_on_200_201.properties.public_ip_addresses
public_ip_addresses.Element = AAZObjectType()
_CreateHelper._build_schema_common_sub_resource_read(public_ip_addresses.Element)

tags = cls._schema_on_200_201.tags
tags.Element = AAZStrType()
Expand All @@ -354,5 +383,20 @@ def _build_schema_on_200_201(cls):
class _CreateHelper:
"""Helper class for Create"""

_schema_common_sub_resource_read = None

@classmethod
def _build_schema_common_sub_resource_read(cls, _schema):
if cls._schema_common_sub_resource_read is not None:
_schema.id = cls._schema_common_sub_resource_read.id
return

cls._schema_common_sub_resource_read = _schema_common_sub_resource_read = AAZObjectType()

common_sub_resource_read = _schema_common_sub_resource_read
common_sub_resource_read.id = AAZStrType()

_schema.id = cls._schema_common_sub_resource_read.id


__all__ = ["Create"]
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Delete(AAZCommand):
"""

_aaz_info = {
"version": "2025-03-01",
"version": "2025-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/ddoscustompolicies/{}", "2025-03-01"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/ddoscustompolicies/{}", "2025-07-01"],
]
}

Expand Down Expand Up @@ -143,7 +143,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2025-03-01",
"api-version", "2025-07-01",
required=True,
),
}
Expand Down
Loading
Loading