Skip to content

Commit 2e8a000

Browse files
author
Mohamed Yilmaz Ibrahim
committed
add files
1 parent 8d0c503 commit 2e8a000

File tree

4 files changed

+1128
-0
lines changed

4 files changed

+1128
-0
lines changed
Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
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+
"identity create",
16+
)
17+
class Create(AAZCommand):
18+
"""Create an identity in the specified subscription and resource group.
19+
"""
20+
21+
_aaz_info = {
22+
"version": "2025-05-31-preview",
23+
"resources": [
24+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.managedidentity/userassignedidentities/{}", "2025-05-31-preview"],
25+
]
26+
}
27+
28+
def _handler(self, command_args):
29+
super()._handler(command_args)
30+
self._execute_operations()
31+
return self._output()
32+
33+
_args_schema = None
34+
35+
@classmethod
36+
def _build_arguments_schema(cls, *args, **kwargs):
37+
if cls._args_schema is not None:
38+
return cls._args_schema
39+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
40+
41+
# define Arg Group ""
42+
43+
_args_schema = cls._args_schema
44+
_args_schema.resource_group = AAZResourceGroupNameArg(
45+
required=True,
46+
)
47+
_args_schema.resource_name = AAZStrArg(
48+
options=["-n", "--name", "--resource-name"],
49+
help="The name of the identity resource.",
50+
required=True,
51+
)
52+
53+
# define Arg Group "Parameters"
54+
55+
_args_schema = cls._args_schema
56+
_args_schema.location = AAZResourceLocationArg(
57+
arg_group="Parameters",
58+
help="The geo-location where the resource lives",
59+
required=True,
60+
fmt=AAZResourceLocationArgFormat(
61+
resource_group_arg="resource_group",
62+
),
63+
)
64+
_args_schema.tags = AAZDictArg(
65+
options=["--tags"],
66+
arg_group="Parameters",
67+
help="Resource tags.",
68+
)
69+
70+
tags = cls._args_schema.tags
71+
tags.Element = AAZStrArg()
72+
73+
# define Arg Group "Properties"
74+
75+
_args_schema = cls._args_schema
76+
_args_schema.assignment_restrictions = AAZObjectArg(
77+
options=["--assignment-restrictions"],
78+
arg_group="Properties",
79+
help="Restrictions on which resource providers this identity can be assigned to.",
80+
)
81+
_args_schema.isolation_scope = AAZStrArg(
82+
options=["--isolation-scope"],
83+
arg_group="Properties",
84+
help="Enum to configure regional restrictions on identity assignment, as necessary.",
85+
enum={"None": "None", "Regional": "Regional"},
86+
)
87+
88+
assignment_restrictions = cls._args_schema.assignment_restrictions
89+
assignment_restrictions.providers = AAZListArg(
90+
options=["providers"],
91+
help="List of resource provider types that this identity can be assigned to (case-insensitive). Examples: 'Microsoft.Compute', 'Microsoft.Storage/Accounts', 'Microsoft.Network/VirtualNetworks'.",
92+
fmt=AAZListArgFormat(
93+
unique=True,
94+
),
95+
)
96+
97+
providers = cls._args_schema.assignment_restrictions.providers
98+
providers.Element = AAZStrArg()
99+
return cls._args_schema
100+
101+
def _execute_operations(self):
102+
self.pre_operations()
103+
self.UserAssignedIdentitiesCreateOrUpdate(ctx=self.ctx)()
104+
self.post_operations()
105+
106+
@register_callback
107+
def pre_operations(self):
108+
pass
109+
110+
@register_callback
111+
def post_operations(self):
112+
pass
113+
114+
def _output(self, *args, **kwargs):
115+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
116+
return result
117+
118+
class UserAssignedIdentitiesCreateOrUpdate(AAZHttpOperation):
119+
CLIENT_TYPE = "MgmtClient"
120+
121+
def __call__(self, *args, **kwargs):
122+
request = self.make_request()
123+
session = self.client.send_request(request=request, stream=False, **kwargs)
124+
if session.http_response.status_code in [200, 201]:
125+
return self.on_200_201(session)
126+
127+
return self.on_error(session.http_response)
128+
129+
@property
130+
def url(self):
131+
return self.client.format_url(
132+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}",
133+
**self.url_parameters
134+
)
135+
136+
@property
137+
def method(self):
138+
return "PUT"
139+
140+
@property
141+
def error_format(self):
142+
return "ODataV4Format"
143+
144+
@property
145+
def url_parameters(self):
146+
parameters = {
147+
**self.serialize_url_param(
148+
"resourceGroupName", self.ctx.args.resource_group,
149+
required=True,
150+
),
151+
**self.serialize_url_param(
152+
"resourceName", self.ctx.args.resource_name,
153+
required=True,
154+
),
155+
**self.serialize_url_param(
156+
"subscriptionId", self.ctx.subscription_id,
157+
required=True,
158+
),
159+
}
160+
return parameters
161+
162+
@property
163+
def query_parameters(self):
164+
parameters = {
165+
**self.serialize_query_param(
166+
"api-version", "2025-05-31-preview",
167+
required=True,
168+
),
169+
}
170+
return parameters
171+
172+
@property
173+
def header_parameters(self):
174+
parameters = {
175+
**self.serialize_header_param(
176+
"Content-Type", "application/json",
177+
),
178+
**self.serialize_header_param(
179+
"Accept", "application/json",
180+
),
181+
}
182+
return parameters
183+
184+
@property
185+
def content(self):
186+
_content_value, _builder = self.new_content_builder(
187+
self.ctx.args,
188+
typ=AAZObjectType,
189+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
190+
)
191+
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
192+
_builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}})
193+
_builder.set_prop("tags", AAZDictType, ".tags")
194+
195+
properties = _builder.get(".properties")
196+
if properties is not None:
197+
properties.set_prop("assignmentRestrictions", AAZObjectType, ".assignment_restrictions")
198+
properties.set_prop("isolationScope", AAZStrType, ".isolation_scope")
199+
200+
assignment_restrictions = _builder.get(".properties.assignmentRestrictions")
201+
if assignment_restrictions is not None:
202+
assignment_restrictions.set_prop("providers", AAZListType, ".providers")
203+
204+
providers = _builder.get(".properties.assignmentRestrictions.providers")
205+
if providers is not None:
206+
providers.set_elements(AAZStrType, ".")
207+
208+
tags = _builder.get(".tags")
209+
if tags is not None:
210+
tags.set_elements(AAZStrType, ".")
211+
212+
return self.serialize_content(_content_value)
213+
214+
def on_200_201(self, session):
215+
data = self.deserialize_http_content(session)
216+
self.ctx.set_var(
217+
"instance",
218+
data,
219+
schema_builder=self._build_schema_on_200_201
220+
)
221+
222+
_schema_on_200_201 = None
223+
224+
@classmethod
225+
def _build_schema_on_200_201(cls):
226+
if cls._schema_on_200_201 is not None:
227+
return cls._schema_on_200_201
228+
229+
cls._schema_on_200_201 = AAZObjectType()
230+
231+
_schema_on_200_201 = cls._schema_on_200_201
232+
_schema_on_200_201.id = AAZStrType(
233+
flags={"read_only": True},
234+
)
235+
_schema_on_200_201.location = AAZStrType(
236+
flags={"required": True},
237+
)
238+
_schema_on_200_201.name = AAZStrType(
239+
flags={"read_only": True},
240+
)
241+
_schema_on_200_201.properties = AAZObjectType(
242+
flags={"client_flatten": True},
243+
)
244+
_schema_on_200_201.system_data = AAZObjectType(
245+
serialized_name="systemData",
246+
flags={"read_only": True},
247+
)
248+
_schema_on_200_201.tags = AAZDictType()
249+
_schema_on_200_201.type = AAZStrType(
250+
flags={"read_only": True},
251+
)
252+
253+
properties = cls._schema_on_200_201.properties
254+
properties.assignment_restrictions = AAZObjectType(
255+
serialized_name="assignmentRestrictions",
256+
)
257+
properties.client_id = AAZStrType(
258+
serialized_name="clientId",
259+
flags={"read_only": True},
260+
)
261+
properties.isolation_scope = AAZStrType(
262+
serialized_name="isolationScope",
263+
)
264+
properties.principal_id = AAZStrType(
265+
serialized_name="principalId",
266+
flags={"read_only": True},
267+
)
268+
properties.tenant_id = AAZStrType(
269+
serialized_name="tenantId",
270+
flags={"read_only": True},
271+
)
272+
273+
assignment_restrictions = cls._schema_on_200_201.properties.assignment_restrictions
274+
assignment_restrictions.providers = AAZListType()
275+
276+
providers = cls._schema_on_200_201.properties.assignment_restrictions.providers
277+
providers.Element = AAZStrType()
278+
279+
system_data = cls._schema_on_200_201.system_data
280+
system_data.created_at = AAZStrType(
281+
serialized_name="createdAt",
282+
)
283+
system_data.created_by = AAZStrType(
284+
serialized_name="createdBy",
285+
)
286+
system_data.created_by_type = AAZStrType(
287+
serialized_name="createdByType",
288+
)
289+
system_data.last_modified_at = AAZStrType(
290+
serialized_name="lastModifiedAt",
291+
)
292+
system_data.last_modified_by = AAZStrType(
293+
serialized_name="lastModifiedBy",
294+
)
295+
system_data.last_modified_by_type = AAZStrType(
296+
serialized_name="lastModifiedByType",
297+
)
298+
299+
tags = cls._schema_on_200_201.tags
300+
tags.Element = AAZStrType()
301+
302+
return cls._schema_on_200_201
303+
304+
305+
class _CreateHelper:
306+
"""Helper class for Create"""
307+
308+
309+
__all__ = ["Create"]

0 commit comments

Comments
 (0)