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.0b9
++++++
* Added support for WAF v2.

2.0.0b8
++++++
* Added support for updating subnet.
Expand Down
16 changes: 16 additions & 0 deletions src/nginx/azext_nginx/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,19 @@
# pylint: disable=too-many-lines

from knack.help_files import helps # pylint: disable=unused-import

helps['nginx deployment waf-policy create'] = """
type: command
short-summary: Command to create an Nginx Deployment WAF Policy.
examples:
- name: Create a WAF policy for a Nginx deployment
text: az nginx deployment waf-policy create --name mypolicyname --deployment-name mydeploymentname --resource-group myresourcegroupname --filepath /path/to/my/policy.json --content mycontentfileinbase64encoding
"""

helps['nginx deployment waf-policy update'] = """
type: command
short-summary: Command to update an Nginx Deployment WAF Policy.
examples:
- name: Update a WAF policy for a Nginx deployment
text: az nginx deployment waf-policy update --name mypolicyname --deployment-name mydeploymentname --resource-group myresourcegroupname --filepath /path/to/my/policy.json --content mycontentfileinbase64encoding
"""
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ._create import *
from ._delete import *
from ._list import *
from ._list_default_waf_policy import *
from ._show import *
from ._update import *
from ._wait import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# --------------------------------------------------------------------------------------------
# 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 list-default-waf-policy",
)
class ListDefaultWafPolicy(AAZCommand):
"""Lists the default WAF policies for a deployment.

:example: DefaultWafPolicy_List
az nginx deployment list-default-waf-policy --resource-group myResourceGroup --deployment-name myDeployment
"""

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

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,
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.DefaultWafPolicyList(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 DefaultWafPolicyList(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}/listDefaultWafPolicies",
**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,
),
}
return parameters

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

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

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.next_link = AAZStrType(
serialized_name="nextLink",
)
_schema_on_200.value = AAZListType()

value = cls._schema_on_200.value
value.Element = AAZObjectType()

_element = cls._schema_on_200.value.Element
_element.content = AAZStrType(
flags={"read_only": True},
)
_element.filepath = AAZStrType(
flags={"read_only": True},
)

return cls._schema_on_200


class _ListDefaultWafPolicyHelper:
"""Helper class for ListDefaultWafPolicy"""


__all__ = ["ListDefaultWafPolicy"]
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.root_file = AAZStrArg(
options=["--root-file"],
arg_group="Properties",
help="root file",
help="The root file of the Nginx Configuration",
nullable=True,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# 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_group(
"nginx deployment waf-policy",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Waf Policy
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------------------------
# 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 .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
from ._wait import *
Loading
Loading