Skip to content

Commit 0dc0e66

Browse files
authored
[Storage] az storage sku list: Support listing storage skus (#32182)
1 parent 9419cae commit 0dc0e66

File tree

5 files changed

+305
-0
lines changed

5 files changed

+305
-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+
"storage sku",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Sku
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 ._list import *
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
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+
"storage sku list",
16+
)
17+
class List(AAZCommand):
18+
"""List the available SKUs supported by Microsoft.Storage for given subscription.
19+
20+
:example: List Sku
21+
az storage sku list
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2025-01-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/providers/microsoft.storage/skus", "2025-01-01"],
28+
]
29+
}
30+
31+
def _handler(self, command_args):
32+
super()._handler(command_args)
33+
self._execute_operations()
34+
return self._output()
35+
36+
_args_schema = None
37+
38+
@classmethod
39+
def _build_arguments_schema(cls, *args, **kwargs):
40+
if cls._args_schema is not None:
41+
return cls._args_schema
42+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
43+
44+
# define Arg Group ""
45+
return cls._args_schema
46+
47+
def _execute_operations(self):
48+
self.pre_operations()
49+
self.SkusList(ctx=self.ctx)()
50+
self.post_operations()
51+
52+
@register_callback
53+
def pre_operations(self):
54+
pass
55+
56+
@register_callback
57+
def post_operations(self):
58+
pass
59+
60+
def _output(self, *args, **kwargs):
61+
result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True)
62+
return result
63+
64+
class SkusList(AAZHttpOperation):
65+
CLIENT_TYPE = "MgmtClient"
66+
67+
def __call__(self, *args, **kwargs):
68+
request = self.make_request()
69+
session = self.client.send_request(request=request, stream=False, **kwargs)
70+
if session.http_response.status_code in [200]:
71+
return self.on_200(session)
72+
73+
return self.on_error(session.http_response)
74+
75+
@property
76+
def url(self):
77+
return self.client.format_url(
78+
"/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus",
79+
**self.url_parameters
80+
)
81+
82+
@property
83+
def method(self):
84+
return "GET"
85+
86+
@property
87+
def error_format(self):
88+
return "MgmtErrorFormat"
89+
90+
@property
91+
def url_parameters(self):
92+
parameters = {
93+
**self.serialize_url_param(
94+
"subscriptionId", self.ctx.subscription_id,
95+
required=True,
96+
),
97+
}
98+
return parameters
99+
100+
@property
101+
def query_parameters(self):
102+
parameters = {
103+
**self.serialize_query_param(
104+
"api-version", "2025-01-01",
105+
required=True,
106+
),
107+
}
108+
return parameters
109+
110+
@property
111+
def header_parameters(self):
112+
parameters = {
113+
**self.serialize_header_param(
114+
"Accept", "application/json",
115+
),
116+
}
117+
return parameters
118+
119+
def on_200(self, session):
120+
data = self.deserialize_http_content(session)
121+
self.ctx.set_var(
122+
"instance",
123+
data,
124+
schema_builder=self._build_schema_on_200
125+
)
126+
127+
_schema_on_200 = None
128+
129+
@classmethod
130+
def _build_schema_on_200(cls):
131+
if cls._schema_on_200 is not None:
132+
return cls._schema_on_200
133+
134+
cls._schema_on_200 = AAZObjectType()
135+
136+
_schema_on_200 = cls._schema_on_200
137+
_schema_on_200.value = AAZListType(
138+
flags={"read_only": True},
139+
)
140+
141+
value = cls._schema_on_200.value
142+
value.Element = AAZObjectType()
143+
144+
_element = cls._schema_on_200.value.Element
145+
_element.capabilities = AAZListType(
146+
flags={"read_only": True},
147+
)
148+
_element.kind = AAZStrType(
149+
flags={"read_only": True},
150+
)
151+
_element.location_info = AAZListType(
152+
serialized_name="locationInfo",
153+
)
154+
_element.locations = AAZListType(
155+
flags={"read_only": True},
156+
)
157+
_element.name = AAZStrType(
158+
flags={"required": True},
159+
)
160+
_element.resource_type = AAZStrType(
161+
serialized_name="resourceType",
162+
flags={"read_only": True},
163+
)
164+
_element.restrictions = AAZListType()
165+
_element.tier = AAZStrType(
166+
flags={"read_only": True},
167+
)
168+
169+
capabilities = cls._schema_on_200.value.Element.capabilities
170+
capabilities.Element = AAZObjectType()
171+
172+
_element = cls._schema_on_200.value.Element.capabilities.Element
173+
_element.name = AAZStrType(
174+
flags={"read_only": True},
175+
)
176+
_element.value = AAZStrType(
177+
flags={"read_only": True},
178+
)
179+
180+
location_info = cls._schema_on_200.value.Element.location_info
181+
location_info.Element = AAZObjectType()
182+
183+
_element = cls._schema_on_200.value.Element.location_info.Element
184+
_element.location = AAZStrType(
185+
flags={"read_only": True},
186+
)
187+
_element.zones = AAZListType(
188+
flags={"read_only": True},
189+
)
190+
191+
zones = cls._schema_on_200.value.Element.location_info.Element.zones
192+
zones.Element = AAZStrType()
193+
194+
locations = cls._schema_on_200.value.Element.locations
195+
locations.Element = AAZStrType()
196+
197+
restrictions = cls._schema_on_200.value.Element.restrictions
198+
restrictions.Element = AAZObjectType()
199+
200+
_element = cls._schema_on_200.value.Element.restrictions.Element
201+
_element.reason_code = AAZStrType(
202+
serialized_name="reasonCode",
203+
)
204+
_element.type = AAZStrType(
205+
flags={"read_only": True},
206+
)
207+
_element.values = AAZListType(
208+
flags={"read_only": True},
209+
)
210+
211+
values = cls._schema_on_200.value.Element.restrictions.Element.values
212+
values.Element = AAZStrType()
213+
214+
return cls._schema_on_200
215+
216+
217+
class _ListHelper:
218+
"""Helper class for List"""
219+
220+
221+
__all__ = ["List"]

src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_storage_sku_list.yaml

Lines changed: 42 additions & 0 deletions
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_account_scenarios.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,3 +2873,10 @@ def test_storage_account_local_user(self, resource_group, storage_account):
28732873
)
28742874

28752875
self.cmd('{cmd} delete --account-name {sa} -g {rg} -n {username}')
2876+
2877+
class StorageSkuTests(ScenarioTest):
2878+
@AllowLargeResponse(size_kb=10000)
2879+
def test_storage_sku_list(self):
2880+
sku_list = self.cmd('storage sku list').get_output_in_json()
2881+
assert sku_list is not None
2882+
assert len(sku_list) > 0

0 commit comments

Comments
 (0)