|
| 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"] |
0 commit comments