Skip to content

Commit c648946

Browse files
author
Danny Tundwe (from Dev Box)
committed
Add edge-action extension with 2025-09-01-preview API
- Generated extension structure from AAZ - Added custom deploy-from-file command for file/zip deployment - Migrated 5 test scenarios with recordings from main CLI repo - Supports both file (.js) and zip deployment types - Auto-detection of deployment type from file extension
1 parent 8b6ea4b commit c648946

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+10512
-0
lines changed

src/edge-action/HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. :changelog:
2+
3+
Release History
4+
===============
5+
6+
1.0.0b1
7+
++++++
8+
* Initial release.

src/edge-action/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Azure CLI EdgeAction Extension #
2+
This is an extension to Azure CLI to manage EdgeAction resources.
3+
4+
## How to use ##
5+
Please add commands usage here.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
from azure.cli.core import AzCommandsLoader
9+
from azext_edge_action._help import helps # pylint: disable=unused-import
10+
11+
12+
class EdgeActionCommandsLoader(AzCommandsLoader):
13+
14+
def __init__(self, cli_ctx=None):
15+
from azure.cli.core.commands import CliCommandType
16+
custom_command_type = CliCommandType(
17+
operations_tmpl='azext_edge_action.custom#{}')
18+
super().__init__(cli_ctx=cli_ctx,
19+
custom_command_type=custom_command_type)
20+
21+
def load_command_table(self, args):
22+
from azext_edge_action.commands import load_command_table
23+
from azure.cli.core.aaz import load_aaz_command_table
24+
try:
25+
from . import aaz
26+
except ImportError:
27+
aaz = None
28+
if aaz:
29+
load_aaz_command_table(
30+
loader=self,
31+
aaz_pkg_name=aaz.__name__,
32+
args=args
33+
)
34+
load_command_table(self, args)
35+
return self.command_table
36+
37+
def load_arguments(self, command):
38+
from azext_edge_action._params import load_arguments
39+
load_arguments(self, command)
40+
41+
42+
COMMAND_LOADER_CLS = EdgeActionCommandsLoader
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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: disable=line-too-long
9+
# pylint: disable=too-many-lines
10+
11+
from knack.help_files import helps # pylint: disable=unused-import
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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: disable=too-many-lines
9+
# pylint: disable=too-many-statements
10+
11+
12+
def load_arguments(self, _): # pylint: disable=unused-argument
13+
pass
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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+
# --------------------------------------------------------------------------------------------
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
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+
"edge-action",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Edge Action
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 ._add_attachment import *
13+
from ._create import *
14+
from ._delete import *
15+
from ._delete_attachment import *
16+
from ._list import *
17+
from ._show import *
18+
from ._update import *
19+
from ._wait import *
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
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+
"edge-action add-attachment",
16+
)
17+
class AddAttachment(AAZCommand):
18+
"""A long-running operation for adding an EdgeAction attachment.
19+
20+
:example: EdgeActions_AddAttachment
21+
az edge-action add-attachment --resource-group testrg --edge-action-name edgeAction1 --attached-resource-id /subscriptions/sub1/resourceGroups/rs1/providers/Microsoft.Cdn/Profiles/myProfile/afdEndpoints/ep1/routes/route1
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2025-09-01-preview",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.cdn/edgeactions/{}/addattachment", "2025-09-01-preview"],
28+
]
29+
}
30+
31+
AZ_SUPPORT_NO_WAIT = True
32+
33+
def _handler(self, command_args):
34+
super()._handler(command_args)
35+
return self.build_lro_poller(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+
47+
_args_schema = cls._args_schema
48+
_args_schema.edge_action_name = AAZStrArg(
49+
options=["--edge-action-name"],
50+
help="The name of the Edge Action",
51+
required=True,
52+
id_part="name",
53+
fmt=AAZStrArgFormat(
54+
pattern="[a-zA-Z0-9]+",
55+
max_length=50,
56+
),
57+
)
58+
_args_schema.resource_group = AAZResourceGroupNameArg(
59+
required=True,
60+
)
61+
62+
# define Arg Group "Body"
63+
64+
_args_schema = cls._args_schema
65+
_args_schema.attached_resource_id = AAZResourceIdArg(
66+
options=["--attached-resource-id"],
67+
arg_group="Body",
68+
help="The attached resource Id",
69+
required=True,
70+
)
71+
return cls._args_schema
72+
73+
def _execute_operations(self):
74+
self.pre_operations()
75+
yield self.EdgeActionsAddAttachment(ctx=self.ctx)()
76+
self.post_operations()
77+
78+
@register_callback
79+
def pre_operations(self):
80+
pass
81+
82+
@register_callback
83+
def post_operations(self):
84+
pass
85+
86+
def _output(self, *args, **kwargs):
87+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
88+
return result
89+
90+
class EdgeActionsAddAttachment(AAZHttpOperation):
91+
CLIENT_TYPE = "MgmtClient"
92+
93+
def __call__(self, *args, **kwargs):
94+
request = self.make_request()
95+
session = self.client.send_request(request=request, stream=False, **kwargs)
96+
if session.http_response.status_code in [202]:
97+
return self.client.build_lro_polling(
98+
self.ctx.args.no_wait,
99+
session,
100+
self.on_200,
101+
self.on_error,
102+
lro_options={"final-state-via": "location"},
103+
path_format_arguments=self.url_parameters,
104+
)
105+
if session.http_response.status_code in [200]:
106+
return self.client.build_lro_polling(
107+
self.ctx.args.no_wait,
108+
session,
109+
self.on_200,
110+
self.on_error,
111+
lro_options={"final-state-via": "location"},
112+
path_format_arguments=self.url_parameters,
113+
)
114+
115+
return self.on_error(session.http_response)
116+
117+
@property
118+
def url(self):
119+
return self.client.format_url(
120+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/addAttachment",
121+
**self.url_parameters
122+
)
123+
124+
@property
125+
def method(self):
126+
return "POST"
127+
128+
@property
129+
def error_format(self):
130+
return "MgmtErrorFormat"
131+
132+
@property
133+
def url_parameters(self):
134+
parameters = {
135+
**self.serialize_url_param(
136+
"edgeActionName", self.ctx.args.edge_action_name,
137+
required=True,
138+
),
139+
**self.serialize_url_param(
140+
"resourceGroupName", self.ctx.args.resource_group,
141+
required=True,
142+
),
143+
**self.serialize_url_param(
144+
"subscriptionId", self.ctx.subscription_id,
145+
required=True,
146+
),
147+
}
148+
return parameters
149+
150+
@property
151+
def query_parameters(self):
152+
parameters = {
153+
**self.serialize_query_param(
154+
"api-version", "2025-09-01-preview",
155+
required=True,
156+
),
157+
}
158+
return parameters
159+
160+
@property
161+
def header_parameters(self):
162+
parameters = {
163+
**self.serialize_header_param(
164+
"Content-Type", "application/json",
165+
),
166+
**self.serialize_header_param(
167+
"Accept", "application/json",
168+
),
169+
}
170+
return parameters
171+
172+
@property
173+
def content(self):
174+
_content_value, _builder = self.new_content_builder(
175+
self.ctx.args,
176+
typ=AAZObjectType,
177+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
178+
)
179+
_builder.set_prop("attachedResourceId", AAZStrType, ".attached_resource_id", typ_kwargs={"flags": {"required": True}})
180+
181+
return self.serialize_content(_content_value)
182+
183+
def on_200(self, session):
184+
data = self.deserialize_http_content(session)
185+
self.ctx.set_var(
186+
"instance",
187+
data,
188+
schema_builder=self._build_schema_on_200
189+
)
190+
191+
_schema_on_200 = None
192+
193+
@classmethod
194+
def _build_schema_on_200(cls):
195+
if cls._schema_on_200 is not None:
196+
return cls._schema_on_200
197+
198+
cls._schema_on_200 = AAZObjectType()
199+
200+
_schema_on_200 = cls._schema_on_200
201+
_schema_on_200.edge_action_id = AAZStrType(
202+
serialized_name="edgeActionId",
203+
flags={"required": True},
204+
)
205+
206+
return cls._schema_on_200
207+
208+
209+
class _AddAttachmentHelper:
210+
"""Helper class for AddAttachment"""
211+
212+
213+
__all__ = ["AddAttachment"]

0 commit comments

Comments
 (0)