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
4 changes: 4 additions & 0 deletions src/nginx/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

2.0.0b11
++++++
* Added support for WAF v2 analysis.

2.0.0b10
++++++
* Updated Nginx Deployment documentation to show new marketplace SKU in examples.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# flake8: noqa

from .__cmd_group import *
from ._analyze_waf_policy import *
from ._create import *
from ._delete import *
from ._list import *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"nginx deployment waf-policy analyze-waf-policy",
)
class AnalyzeWafPolicy(AAZCommand):
"""Analyze an Nginx Deployment WAF Policy

Analyze an Nginx Deployment WAF Policy for correctness

:example: NginxDeploymentWafPolicies_Analysis
az nginx deployment waf-policy analyze-waf-policy --resource-group myResourceGroup --deployment-name myDeployment --waf-policy-name myWafPolicy
"""

_aaz_info = {
"version": "2025-11-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/nginx.nginxplus/nginxdeployments/{}/wafpolicies/{}/analyzewafpolicy", "2025-11-01"],
]
}

def _handler(self, command_args):
super()._handler(command_args)
self._execute_operations()
return self._output()

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.deployment_name = AAZStrArg(
options=["--deployment-name"],
help="The name of targeted NGINX deployment",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
pattern="^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$",
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.waf_policy_name = AAZStrArg(
options=["--waf-policy-name"],
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new command’s --waf-policy-name argument does not provide the standard -n/--name aliases that the other nginx deployment waf-policy commands use (e.g., create/show/update). For CLI consistency and usability, align the options list with the rest of the waf-policy commands.

Suggested change
options=["--waf-policy-name"],
options=["-n", "--name", "--waf-policy-name"],

Copilot uses AI. Check for mistakes.
help="The name of Waf Policy",
required=True,
id_part="child_name_1",
fmt=AAZStrArgFormat(
pattern="^([a-z0-9A-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]|[a-z0-9A-Z])$",
),
)

# define Arg Group "Body"

_args_schema = cls._args_schema
_args_schema.content = AAZStrArg(
options=["--content"],
arg_group="Body",
help="The byte content of the policy",
)
_args_schema.filepath = AAZStrArg(
options=["--filepath"],
arg_group="Body",
help="The absolute file path of the policy as in the virtual machine",
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.NginxDeploymentWafPoliciesAnalysis(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class NginxDeploymentWafPoliciesAnalysis(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [200]:
return self.on_200(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies/{wafPolicyName}/analyzeWafPolicy",
**self.url_parameters
)

@property
def method(self):
return "POST"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"deploymentName", self.ctx.args.deployment_name,
required=True,
),
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
**self.serialize_url_param(
"wafPolicyName", self.ctx.args.waf_policy_name,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2025-11-01",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"client_flatten": True}}
)
_builder.set_prop("content", AAZStrType, ".content")
_builder.set_prop("filepath", AAZStrType, ".filepath")

return self.serialize_content(_content_value)

def on_200(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200
)

_schema_on_200 = None

@classmethod
def _build_schema_on_200(cls):
if cls._schema_on_200 is not None:
return cls._schema_on_200

cls._schema_on_200 = AAZObjectType()

_schema_on_200 = cls._schema_on_200
_schema_on_200.data = AAZObjectType()
_schema_on_200.status = AAZStrType()

data = cls._schema_on_200.data
data.errors = AAZListType()

errors = cls._schema_on_200.data.errors
errors.Element = AAZObjectType()

_element = cls._schema_on_200.data.errors.Element
_element.code = AAZStrType()
_element.field = AAZStrType()
_element.message = AAZStrType()

return cls._schema_on_200


class _AnalyzeWafPolicyHelper:
"""Helper class for AnalyzeWafPolicy"""


__all__ = ["AnalyzeWafPolicy"]
Loading
Loading