Skip to content

Commit 24b4937

Browse files
committed
[Identity] Add support for claims matching expressions with 2025-01-31-PREVIEW API version
1 parent c91b480 commit 24b4937

File tree

19 files changed

+2516
-61
lines changed

19 files changed

+2516
-61
lines changed

src/azure-cli/azure/cli/command_modules/identity/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ def __init__(self, cli_ctx=None):
1919

2020
def load_command_table(self, args):
2121
from azure.cli.command_modules.identity.commands import load_command_table
22+
from azure.cli.core.aaz import load_aaz_command_table
23+
try:
24+
from . import aaz
25+
except ImportError:
26+
aaz = None
27+
if aaz:
28+
load_aaz_command_table(
29+
loader=self,
30+
aaz_pkg_name=aaz.__name__,
31+
args=args
32+
)
2233
load_command_table(self, args)
2334
return self.command_table
2435

src/azure-cli/azure/cli/command_modules/identity/_params.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
from azure.cli.core.commands.parameters import get_location_type, tags_type
1010

11-
1211
name_arg_type = CLIArgumentType(options_list=('--name', '-n'), metavar='NAME',
1312
help='The name of the identity resource.')
1413

15-
1614
def load_arguments(self, _):
1715

1816
with self.argument_context('identity') as c:
@@ -21,13 +19,3 @@ def load_arguments(self, _):
2119
with self.argument_context('identity create') as c:
2220
c.argument('location', get_location_type(self.cli_ctx), required=False)
2321
c.argument('tags', tags_type)
24-
25-
with self.argument_context('identity federated-credential', min_api='2022-01-31-preview') as c:
26-
c.argument('federated_credential_name', options_list=('--name', '-n'), help='The name of the federated identity credential resource.')
27-
c.argument('identity_name', help='The name of the identity resource.')
28-
29-
for scope in ['identity federated-credential create', 'identity federated-credential update']:
30-
with self.argument_context(scope) as c:
31-
c.argument('issuer', help='The openId connect metadata URL of the issuer of the identity provider that Azure AD would use in the token exchange protocol for validating tokens before issuing a token as the user-assigned managed identity.')
32-
c.argument('subject', help='The sub value in the token sent to Azure AD for getting the user-assigned managed identity token. The value configured in the federated credential and the one in the incoming token must exactly match for Azure AD to issue the access token.')
33-
c.argument('audiences', nargs='+', help='The aud value in the token sent to Azure for getting the user-assigned managed identity token. The value configured in the federated credential and the one in the incoming token must exactly match for Azure to issue the access token.')
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+
"identity",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Managed Identity
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 ._create import *
13+
from ._delete import *
14+
from ._show import *
15+
from ._update import *
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
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": "2024-11-30",
23+
"resources": [
24+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.managedidentity/userassignedidentities/{}", "2024-11-30"],
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+
return cls._args_schema
73+
74+
def _execute_operations(self):
75+
self.pre_operations()
76+
self.UserAssignedIdentitiesCreateOrUpdate(ctx=self.ctx)()
77+
self.post_operations()
78+
79+
@register_callback
80+
def pre_operations(self):
81+
pass
82+
83+
@register_callback
84+
def post_operations(self):
85+
pass
86+
87+
def _output(self, *args, **kwargs):
88+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
89+
return result
90+
91+
class UserAssignedIdentitiesCreateOrUpdate(AAZHttpOperation):
92+
CLIENT_TYPE = "MgmtClient"
93+
94+
def __call__(self, *args, **kwargs):
95+
request = self.make_request()
96+
session = self.client.send_request(request=request, stream=False, **kwargs)
97+
if session.http_response.status_code in [200, 201]:
98+
return self.on_200_201(session)
99+
100+
return self.on_error(session.http_response)
101+
102+
@property
103+
def url(self):
104+
return self.client.format_url(
105+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resourceName}",
106+
**self.url_parameters
107+
)
108+
109+
@property
110+
def method(self):
111+
return "PUT"
112+
113+
@property
114+
def error_format(self):
115+
return "ODataV4Format"
116+
117+
@property
118+
def url_parameters(self):
119+
parameters = {
120+
**self.serialize_url_param(
121+
"resourceGroupName", self.ctx.args.resource_group,
122+
required=True,
123+
),
124+
**self.serialize_url_param(
125+
"resourceName", self.ctx.args.resource_name,
126+
required=True,
127+
),
128+
**self.serialize_url_param(
129+
"subscriptionId", self.ctx.subscription_id,
130+
required=True,
131+
),
132+
}
133+
return parameters
134+
135+
@property
136+
def query_parameters(self):
137+
parameters = {
138+
**self.serialize_query_param(
139+
"api-version", "2024-11-30",
140+
required=True,
141+
),
142+
}
143+
return parameters
144+
145+
@property
146+
def header_parameters(self):
147+
parameters = {
148+
**self.serialize_header_param(
149+
"Content-Type", "application/json",
150+
),
151+
**self.serialize_header_param(
152+
"Accept", "application/json",
153+
),
154+
}
155+
return parameters
156+
157+
@property
158+
def content(self):
159+
_content_value, _builder = self.new_content_builder(
160+
self.ctx.args,
161+
typ=AAZObjectType,
162+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
163+
)
164+
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
165+
_builder.set_prop("tags", AAZDictType, ".tags")
166+
167+
tags = _builder.get(".tags")
168+
if tags is not None:
169+
tags.set_elements(AAZStrType, ".")
170+
171+
return self.serialize_content(_content_value)
172+
173+
def on_200_201(self, session):
174+
data = self.deserialize_http_content(session)
175+
self.ctx.set_var(
176+
"instance",
177+
data,
178+
schema_builder=self._build_schema_on_200_201
179+
)
180+
181+
_schema_on_200_201 = None
182+
183+
@classmethod
184+
def _build_schema_on_200_201(cls):
185+
if cls._schema_on_200_201 is not None:
186+
return cls._schema_on_200_201
187+
188+
cls._schema_on_200_201 = AAZObjectType()
189+
190+
_schema_on_200_201 = cls._schema_on_200_201
191+
_schema_on_200_201.id = AAZStrType(
192+
flags={"read_only": True},
193+
)
194+
_schema_on_200_201.location = AAZStrType(
195+
flags={"required": True},
196+
)
197+
_schema_on_200_201.name = AAZStrType(
198+
flags={"read_only": True},
199+
)
200+
_schema_on_200_201.properties = AAZObjectType(
201+
flags={"client_flatten": True, "read_only": True},
202+
)
203+
_schema_on_200_201.system_data = AAZObjectType(
204+
serialized_name="systemData",
205+
flags={"read_only": True},
206+
)
207+
_schema_on_200_201.tags = AAZDictType()
208+
_schema_on_200_201.type = AAZStrType(
209+
flags={"read_only": True},
210+
)
211+
212+
properties = cls._schema_on_200_201.properties
213+
properties.client_id = AAZStrType(
214+
serialized_name="clientId",
215+
flags={"read_only": True},
216+
)
217+
properties.isolation_scope = AAZStrType(
218+
serialized_name="isolationScope",
219+
)
220+
properties.principal_id = AAZStrType(
221+
serialized_name="principalId",
222+
flags={"read_only": True},
223+
)
224+
properties.tenant_id = AAZStrType(
225+
serialized_name="tenantId",
226+
flags={"read_only": True},
227+
)
228+
229+
system_data = cls._schema_on_200_201.system_data
230+
system_data.created_at = AAZStrType(
231+
serialized_name="createdAt",
232+
)
233+
system_data.created_by = AAZStrType(
234+
serialized_name="createdBy",
235+
)
236+
system_data.created_by_type = AAZStrType(
237+
serialized_name="createdByType",
238+
)
239+
system_data.last_modified_at = AAZStrType(
240+
serialized_name="lastModifiedAt",
241+
)
242+
system_data.last_modified_by = AAZStrType(
243+
serialized_name="lastModifiedBy",
244+
)
245+
system_data.last_modified_by_type = AAZStrType(
246+
serialized_name="lastModifiedByType",
247+
)
248+
249+
tags = cls._schema_on_200_201.tags
250+
tags.Element = AAZStrType()
251+
252+
return cls._schema_on_200_201
253+
254+
255+
class _CreateHelper:
256+
"""Helper class for Create"""
257+
258+
259+
__all__ = ["Create"]

0 commit comments

Comments
 (0)