-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Nginx.NginxPlus 2025-11-01 changes #9678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
224 changes: 224 additions & 0 deletions
224
src/nginx/azext_nginx/aaz/latest/nginx/deployment/waf_policy/_analyze_waf_policy.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"], | ||
| 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"] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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-nameargument does not provide the standard-n/--namealiases that the othernginx deployment waf-policycommands use (e.g., create/show/update). For CLI consistency and usability, align the options list with the rest of the waf-policy commands.