Skip to content

Commit 7f85e5e

Browse files
Ptnan7JingnanXu
andauthored
{FrontDoor} Add sub command for waf (#9532)
* sub command * fix * add exceptions * remove unused sdk * update * fix line too long * version update --------- Co-authored-by: JingnanXu <jingnanxu@microsoft.com>
1 parent 4496952 commit 7f85e5e

16 files changed

Lines changed: 3598 additions & 1037 deletions

linter_exclusions.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,36 @@ network front-door waf-policy update:
21972197
captcha_expiration_in_minutes:
21982198
rule_exclusions:
21992199
- option_length_too_long
2200+
network front-door waf-policy managed-rules:
2201+
rule_exclusions:
2202+
- require_wait_command_if_no_wait
2203+
network front-door waf-policy managed-rules exclusion:
2204+
rule_exclusions:
2205+
- require_wait_command_if_no_wait
2206+
network front-door waf-policy managed-rules exclusion list:
2207+
rule_exclusions:
2208+
- no_ids_for_list_commands
2209+
network front-door waf-policy managed-rules list:
2210+
rule_exclusions:
2211+
- no_ids_for_list_commands
2212+
network front-door waf-policy managed-rules override:
2213+
rule_exclusions:
2214+
- require_wait_command_if_no_wait
2215+
network front-door waf-policy managed-rules override list:
2216+
rule_exclusions:
2217+
- no_ids_for_list_commands
2218+
network front-door waf-policy rule:
2219+
rule_exclusions:
2220+
- require_wait_command_if_no_wait
2221+
network front-door waf-policy rule list:
2222+
rule_exclusions:
2223+
- no_ids_for_list_commands
2224+
network front-door waf-policy rule match-condition:
2225+
rule_exclusions:
2226+
- require_wait_command_if_no_wait
2227+
network front-door waf-policy rule match-condition list:
2228+
rule_exclusions:
2229+
- no_ids_for_list_commands
22002230
network manager connect-config create:
22012231
parameters:
22022232
delete_existing_peering:

src/front-door/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
2.0.0
7+
++++++
8+
* Fix a bug in ddos rule set creation.
9+
610
1.4.0
711
++++++
812
* Bump swagger version to 2025-10-01
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command_group(
15+
"network front-door waf-policy managed-rule-definition",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Managed Rule Definition
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from .__cmd_group import *
12+
from ._list import *
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command(
15+
"network front-door waf-policy managed-rule-definition list",
16+
)
17+
class List(AAZCommand):
18+
"""List all available managed rule sets.
19+
20+
:example: List Policies ManagedRuleSets in a Resource Group
21+
az network front-door waf-policy managed-rule-definition list
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2025-10-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/providers/microsoft.network/frontdoorwebapplicationfirewallmanagedrulesets", "2025-10-01"],
28+
]
29+
}
30+
31+
AZ_SUPPORT_PAGINATION = True
32+
33+
def _handler(self, command_args):
34+
super()._handler(command_args)
35+
return self.build_paging(self._execute_operations, self._output)
36+
37+
_args_schema = None
38+
39+
@classmethod
40+
def _build_arguments_schema(cls, *args, **kwargs):
41+
if cls._args_schema is not None:
42+
return cls._args_schema
43+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
44+
45+
# define Arg Group ""
46+
return cls._args_schema
47+
48+
def _execute_operations(self):
49+
self.pre_operations()
50+
self.ManagedRuleSetsList(ctx=self.ctx)()
51+
self.post_operations()
52+
53+
@register_callback
54+
def pre_operations(self):
55+
pass
56+
57+
@register_callback
58+
def post_operations(self):
59+
pass
60+
61+
def _output(self, *args, **kwargs):
62+
result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True)
63+
next_link = self.deserialize_output(self.ctx.vars.instance.next_link)
64+
return result, next_link
65+
66+
class ManagedRuleSetsList(AAZHttpOperation):
67+
CLIENT_TYPE = "MgmtClient"
68+
69+
def __call__(self, *args, **kwargs):
70+
request = self.make_request()
71+
session = self.client.send_request(request=request, stream=False, **kwargs)
72+
if session.http_response.status_code in [200]:
73+
return self.on_200(session)
74+
75+
return self.on_error(session.http_response)
76+
77+
@property
78+
def url(self):
79+
return self.client.format_url(
80+
"/subscriptions/{subscriptionId}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallManagedRuleSets",
81+
**self.url_parameters
82+
)
83+
84+
@property
85+
def method(self):
86+
return "GET"
87+
88+
@property
89+
def error_format(self):
90+
return "ODataV4Format"
91+
92+
@property
93+
def url_parameters(self):
94+
parameters = {
95+
**self.serialize_url_param(
96+
"subscriptionId", self.ctx.subscription_id,
97+
required=True,
98+
),
99+
}
100+
return parameters
101+
102+
@property
103+
def query_parameters(self):
104+
parameters = {
105+
**self.serialize_query_param(
106+
"api-version", "2025-10-01",
107+
required=True,
108+
),
109+
}
110+
return parameters
111+
112+
@property
113+
def header_parameters(self):
114+
parameters = {
115+
**self.serialize_header_param(
116+
"Accept", "application/json",
117+
),
118+
}
119+
return parameters
120+
121+
def on_200(self, session):
122+
data = self.deserialize_http_content(session)
123+
self.ctx.set_var(
124+
"instance",
125+
data,
126+
schema_builder=self._build_schema_on_200
127+
)
128+
129+
_schema_on_200 = None
130+
131+
@classmethod
132+
def _build_schema_on_200(cls):
133+
if cls._schema_on_200 is not None:
134+
return cls._schema_on_200
135+
136+
cls._schema_on_200 = AAZObjectType()
137+
138+
_schema_on_200 = cls._schema_on_200
139+
_schema_on_200.next_link = AAZStrType(
140+
serialized_name="nextLink",
141+
)
142+
_schema_on_200.value = AAZListType(
143+
flags={"read_only": True},
144+
)
145+
146+
value = cls._schema_on_200.value
147+
value.Element = AAZObjectType()
148+
149+
_element = cls._schema_on_200.value.Element
150+
_element.id = AAZStrType(
151+
flags={"read_only": True},
152+
)
153+
_element.location = AAZStrType()
154+
_element.name = AAZStrType(
155+
flags={"read_only": True},
156+
)
157+
_element.properties = AAZObjectType(
158+
flags={"client_flatten": True},
159+
)
160+
_element.tags = AAZDictType()
161+
_element.type = AAZStrType(
162+
flags={"read_only": True},
163+
)
164+
165+
properties = cls._schema_on_200.value.Element.properties
166+
properties.provisioning_state = AAZStrType(
167+
serialized_name="provisioningState",
168+
flags={"read_only": True},
169+
)
170+
properties.rule_groups = AAZListType(
171+
serialized_name="ruleGroups",
172+
flags={"read_only": True},
173+
)
174+
properties.rule_set_id = AAZStrType(
175+
serialized_name="ruleSetId",
176+
flags={"read_only": True},
177+
)
178+
properties.rule_set_type = AAZStrType(
179+
serialized_name="ruleSetType",
180+
flags={"read_only": True},
181+
)
182+
properties.rule_set_version = AAZStrType(
183+
serialized_name="ruleSetVersion",
184+
flags={"read_only": True},
185+
)
186+
187+
rule_groups = cls._schema_on_200.value.Element.properties.rule_groups
188+
rule_groups.Element = AAZObjectType()
189+
190+
_element = cls._schema_on_200.value.Element.properties.rule_groups.Element
191+
_element.description = AAZStrType(
192+
flags={"read_only": True},
193+
)
194+
_element.rule_group_name = AAZStrType(
195+
serialized_name="ruleGroupName",
196+
flags={"read_only": True},
197+
)
198+
_element.rules = AAZListType(
199+
flags={"read_only": True},
200+
)
201+
202+
rules = cls._schema_on_200.value.Element.properties.rule_groups.Element.rules
203+
rules.Element = AAZObjectType()
204+
205+
_element = cls._schema_on_200.value.Element.properties.rule_groups.Element.rules.Element
206+
_element.default_action = AAZStrType(
207+
serialized_name="defaultAction",
208+
flags={"read_only": True},
209+
)
210+
_element.default_sensitivity = AAZStrType(
211+
serialized_name="defaultSensitivity",
212+
flags={"read_only": True},
213+
)
214+
_element.default_state = AAZStrType(
215+
serialized_name="defaultState",
216+
flags={"read_only": True},
217+
)
218+
_element.description = AAZStrType(
219+
flags={"read_only": True},
220+
)
221+
_element.rule_id = AAZStrType(
222+
serialized_name="ruleId",
223+
flags={"read_only": True},
224+
)
225+
226+
tags = cls._schema_on_200.value.Element.tags
227+
tags.Element = AAZStrType()
228+
229+
return cls._schema_on_200
230+
231+
232+
class _ListHelper:
233+
"""Helper class for List"""
234+
235+
236+
__all__ = ["List"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"azext.minCliCoreVersion": "2.70.0"
2+
"azext.minCliCoreVersion": "2.75.0"
33
}

0 commit comments

Comments
 (0)