Skip to content

Commit 14377fa

Browse files
author
Jingnan Xu
committed
add edge action
1 parent 2b87b6c commit 14377fa

28 files changed

+6167
-0
lines changed
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+
"cdn 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: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
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+
"cdn edge-action add-attachment",
16+
)
17+
class AddAttachment(AAZCommand):
18+
"""A long-running operation for adding an EdgeAction attachment.
19+
"""
20+
21+
_aaz_info = {
22+
"version": "2024-07-22-preview",
23+
"resources": [
24+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.cdn/edgeactions/{}/addattachment", "2024-07-22-preview"],
25+
]
26+
}
27+
28+
AZ_SUPPORT_NO_WAIT = True
29+
30+
def _handler(self, command_args):
31+
super()._handler(command_args)
32+
return self.build_lro_poller(self._execute_operations, self._output)
33+
34+
_args_schema = None
35+
36+
@classmethod
37+
def _build_arguments_schema(cls, *args, **kwargs):
38+
if cls._args_schema is not None:
39+
return cls._args_schema
40+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
41+
42+
# define Arg Group ""
43+
44+
_args_schema = cls._args_schema
45+
_args_schema.edge_action_name = AAZStrArg(
46+
options=["--edge-action-name"],
47+
help="The name of the Edge Action",
48+
required=True,
49+
id_part="name",
50+
fmt=AAZStrArgFormat(
51+
pattern="[a-zA-Z0-9]+",
52+
max_length=50,
53+
),
54+
)
55+
_args_schema.resource_group = AAZResourceGroupNameArg(
56+
required=True,
57+
)
58+
59+
# define Arg Group "Body"
60+
61+
_args_schema = cls._args_schema
62+
_args_schema.attached_resource_id = AAZResourceIdArg(
63+
options=["--attached-resource-id"],
64+
arg_group="Body",
65+
help="The attached resource Id",
66+
required=True,
67+
)
68+
return cls._args_schema
69+
70+
def _execute_operations(self):
71+
self.pre_operations()
72+
yield self.EdgeActionsAddAttachment(ctx=self.ctx)()
73+
self.post_operations()
74+
75+
@register_callback
76+
def pre_operations(self):
77+
pass
78+
79+
@register_callback
80+
def post_operations(self):
81+
pass
82+
83+
def _output(self, *args, **kwargs):
84+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
85+
return result
86+
87+
class EdgeActionsAddAttachment(AAZHttpOperation):
88+
CLIENT_TYPE = "MgmtClient"
89+
90+
def __call__(self, *args, **kwargs):
91+
request = self.make_request()
92+
session = self.client.send_request(request=request, stream=False, **kwargs)
93+
if session.http_response.status_code in [202]:
94+
return self.client.build_lro_polling(
95+
self.ctx.args.no_wait,
96+
session,
97+
self.on_200,
98+
self.on_error,
99+
lro_options={"final-state-via": "location"},
100+
path_format_arguments=self.url_parameters,
101+
)
102+
if session.http_response.status_code in [200]:
103+
return self.client.build_lro_polling(
104+
self.ctx.args.no_wait,
105+
session,
106+
self.on_200,
107+
self.on_error,
108+
lro_options={"final-state-via": "location"},
109+
path_format_arguments=self.url_parameters,
110+
)
111+
112+
return self.on_error(session.http_response)
113+
114+
@property
115+
def url(self):
116+
return self.client.format_url(
117+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/addAttachment",
118+
**self.url_parameters
119+
)
120+
121+
@property
122+
def method(self):
123+
return "POST"
124+
125+
@property
126+
def error_format(self):
127+
return "MgmtErrorFormat"
128+
129+
@property
130+
def url_parameters(self):
131+
parameters = {
132+
**self.serialize_url_param(
133+
"edgeActionName", self.ctx.args.edge_action_name,
134+
required=True,
135+
),
136+
**self.serialize_url_param(
137+
"resourceGroupName", self.ctx.args.resource_group,
138+
required=True,
139+
),
140+
**self.serialize_url_param(
141+
"subscriptionId", self.ctx.subscription_id,
142+
required=True,
143+
),
144+
}
145+
return parameters
146+
147+
@property
148+
def query_parameters(self):
149+
parameters = {
150+
**self.serialize_query_param(
151+
"api-version", "2024-07-22-preview",
152+
required=True,
153+
),
154+
}
155+
return parameters
156+
157+
@property
158+
def header_parameters(self):
159+
parameters = {
160+
**self.serialize_header_param(
161+
"Content-Type", "application/json",
162+
),
163+
**self.serialize_header_param(
164+
"Accept", "application/json",
165+
),
166+
}
167+
return parameters
168+
169+
@property
170+
def content(self):
171+
_content_value, _builder = self.new_content_builder(
172+
self.ctx.args,
173+
typ=AAZObjectType,
174+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
175+
)
176+
_builder.set_prop("attachedResourceId", AAZStrType, ".attached_resource_id", typ_kwargs={"flags": {"required": True}})
177+
178+
return self.serialize_content(_content_value)
179+
180+
def on_200(self, session):
181+
data = self.deserialize_http_content(session)
182+
self.ctx.set_var(
183+
"instance",
184+
data,
185+
schema_builder=self._build_schema_on_200
186+
)
187+
188+
_schema_on_200 = None
189+
190+
@classmethod
191+
def _build_schema_on_200(cls):
192+
if cls._schema_on_200 is not None:
193+
return cls._schema_on_200
194+
195+
cls._schema_on_200 = AAZObjectType()
196+
197+
_schema_on_200 = cls._schema_on_200
198+
_schema_on_200.edge_action_id = AAZStrType(
199+
serialized_name="edgeActionId",
200+
flags={"required": True},
201+
)
202+
203+
return cls._schema_on_200
204+
205+
206+
class _AddAttachmentHelper:
207+
"""Helper class for AddAttachment"""
208+
209+
210+
__all__ = ["AddAttachment"]

0 commit comments

Comments
 (0)