Skip to content

Commit fbe7fd0

Browse files
Upgrading to the latest databox stable api version (Azure#8769)
* Upgrading to latest stable version * Upgrading to latest stable version * Upgrading to latest stable version * fixing linter errors * recorded tests * recorded tests * recorded tests * test recording * updating version and history. * Updating the version as per comment on the pr * Test recoring with latest dev changes * moving to using non microsoft email ids. * moving to using non microsoft email ids. * removing files with sensitive data --------- Co-authored-by: Govardhana D K <govardhanadk@microsoft.com>
1 parent 242db56 commit fbe7fd0

23 files changed

+4132
-10841
lines changed

src/databox/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
33
Release History
44
===============
5+
1.2.0
6+
++++++
7+
* `az databox job create`: Add new parameters `--model` to support new generation of databox devices.
8+
* `az databox available-skus`: Add new command to fetch list of available databox skus.
9+
* `az databox job`: Add new subcommand `mitigate` to support customer intervention for databox jobs.
510

611
1.1.0
712
++++++

src/databox/azext_databox/aaz/latest/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
#
55
# Code generated by aaz-dev-tools
66
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+

src/databox/azext_databox/aaz/latest/databox/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
# flake8: noqa
1010

1111
from .__cmd_group import *
12+
from ._available_skus import *
Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
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+
"databox available-skus",
16+
)
17+
class AvailableSkus(AAZCommand):
18+
"""This method provides the list of available skus for the given subscription, resource group and location.
19+
20+
:example: AvailableSkusPost
21+
az databox available-skus --g YourResourceGroupName --country US --l westus --transfer-type ImportToAzure
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2025-02-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databox/locations/{}/availableskus", "2025-02-01"],
28+
]
29+
}
30+
31+
AZ_SUPPORT_PAGINATION = True
32+
33+
def _handler(self, command_args):
34+
super()._handler(command_args)
35+
return self.build_paging(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.location = AAZResourceLocationArg(
49+
required=True,
50+
fmt=AAZResourceLocationArgFormat(
51+
resource_group_arg="resource_group",
52+
),
53+
)
54+
_args_schema.resource_group = AAZResourceGroupNameArg(
55+
required=True,
56+
)
57+
58+
# define Arg Group "AvailableSkuRequest"
59+
60+
_args_schema = cls._args_schema
61+
_args_schema.country = AAZStrArg(
62+
options=["--country"],
63+
arg_group="AvailableSkuRequest",
64+
help="ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements",
65+
required=True,
66+
)
67+
_args_schema.sku_names = AAZListArg(
68+
options=["--sku-names"],
69+
arg_group="AvailableSkuRequest",
70+
help="Sku Names to filter for available skus",
71+
)
72+
_args_schema.transfer_type = AAZStrArg(
73+
options=["--transfer-type"],
74+
arg_group="AvailableSkuRequest",
75+
help="Type of the transfer.",
76+
required=True,
77+
enum={"ExportFromAzure": "ExportFromAzure", "ImportToAzure": "ImportToAzure"},
78+
)
79+
80+
sku_names = cls._args_schema.sku_names
81+
sku_names.Element = AAZStrArg(
82+
enum={"DataBox": "DataBox", "DataBoxCustomerDisk": "DataBoxCustomerDisk", "DataBoxDisk": "DataBoxDisk", "DataBoxHeavy": "DataBoxHeavy"},
83+
)
84+
return cls._args_schema
85+
86+
def _execute_operations(self):
87+
self.pre_operations()
88+
self.ServiceListAvailableSkusByResourceGroup(ctx=self.ctx)()
89+
self.post_operations()
90+
91+
@register_callback
92+
def pre_operations(self):
93+
pass
94+
95+
@register_callback
96+
def post_operations(self):
97+
pass
98+
99+
def _output(self, *args, **kwargs):
100+
result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True)
101+
next_link = self.deserialize_output(self.ctx.vars.instance.next_link)
102+
return result, next_link
103+
104+
class ServiceListAvailableSkusByResourceGroup(AAZHttpOperation):
105+
CLIENT_TYPE = "MgmtClient"
106+
107+
def __call__(self, *args, **kwargs):
108+
request = self.make_request()
109+
session = self.client.send_request(request=request, stream=False, **kwargs)
110+
if session.http_response.status_code in [200]:
111+
return self.on_200(session)
112+
113+
return self.on_error(session.http_response)
114+
115+
@property
116+
def url(self):
117+
return self.client.format_url(
118+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/availableSkus",
119+
**self.url_parameters
120+
)
121+
122+
@property
123+
def method(self):
124+
return "POST"
125+
126+
@property
127+
def error_format(self):
128+
return "ODataV4Format"
129+
130+
@property
131+
def url_parameters(self):
132+
parameters = {
133+
**self.serialize_url_param(
134+
"location", self.ctx.args.location,
135+
required=True,
136+
),
137+
**self.serialize_url_param(
138+
"resourceGroupName", self.ctx.args.resource_group,
139+
required=True,
140+
),
141+
**self.serialize_url_param(
142+
"subscriptionId", self.ctx.subscription_id,
143+
required=True,
144+
),
145+
}
146+
return parameters
147+
148+
@property
149+
def query_parameters(self):
150+
parameters = {
151+
**self.serialize_query_param(
152+
"api-version", "2025-02-01",
153+
required=True,
154+
),
155+
}
156+
return parameters
157+
158+
@property
159+
def header_parameters(self):
160+
parameters = {
161+
**self.serialize_header_param(
162+
"Content-Type", "application/json",
163+
),
164+
**self.serialize_header_param(
165+
"Accept", "application/json",
166+
),
167+
}
168+
return parameters
169+
170+
@property
171+
def content(self):
172+
_content_value, _builder = self.new_content_builder(
173+
self.ctx.args,
174+
typ=AAZObjectType,
175+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
176+
)
177+
_builder.set_prop("country", AAZStrType, ".country", typ_kwargs={"flags": {"required": True}})
178+
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
179+
_builder.set_prop("skuNames", AAZListType, ".sku_names")
180+
_builder.set_prop("transferType", AAZStrType, ".transfer_type", typ_kwargs={"flags": {"required": True}})
181+
182+
sku_names = _builder.get(".skuNames")
183+
if sku_names is not None:
184+
sku_names.set_elements(AAZStrType, ".")
185+
186+
return self.serialize_content(_content_value)
187+
188+
def on_200(self, session):
189+
data = self.deserialize_http_content(session)
190+
self.ctx.set_var(
191+
"instance",
192+
data,
193+
schema_builder=self._build_schema_on_200
194+
)
195+
196+
_schema_on_200 = None
197+
198+
@classmethod
199+
def _build_schema_on_200(cls):
200+
if cls._schema_on_200 is not None:
201+
return cls._schema_on_200
202+
203+
cls._schema_on_200 = AAZObjectType()
204+
205+
_schema_on_200 = cls._schema_on_200
206+
_schema_on_200.next_link = AAZStrType(
207+
serialized_name="nextLink",
208+
)
209+
_schema_on_200.value = AAZListType(
210+
flags={"read_only": True},
211+
)
212+
213+
value = cls._schema_on_200.value
214+
value.Element = AAZObjectType()
215+
216+
_element = cls._schema_on_200.value.Element
217+
_element.enabled = AAZBoolType(
218+
flags={"read_only": True},
219+
)
220+
_element.properties = AAZObjectType(
221+
flags={"client_flatten": True, "read_only": True},
222+
)
223+
_element.sku = AAZObjectType(
224+
flags={"read_only": True},
225+
)
226+
227+
properties = cls._schema_on_200.value.Element.properties
228+
properties.api_versions = AAZListType(
229+
serialized_name="apiVersions",
230+
flags={"read_only": True},
231+
)
232+
properties.capacity = AAZObjectType(
233+
flags={"read_only": True},
234+
)
235+
properties.costs = AAZListType(
236+
flags={"read_only": True},
237+
)
238+
properties.countries_within_commerce_boundary = AAZListType(
239+
serialized_name="countriesWithinCommerceBoundary",
240+
flags={"read_only": True},
241+
)
242+
properties.data_location_to_service_location_map = AAZListType(
243+
serialized_name="dataLocationToServiceLocationMap",
244+
flags={"read_only": True},
245+
)
246+
properties.disabled_reason = AAZStrType(
247+
serialized_name="disabledReason",
248+
flags={"read_only": True},
249+
)
250+
properties.disabled_reason_message = AAZStrType(
251+
serialized_name="disabledReasonMessage",
252+
flags={"read_only": True},
253+
)
254+
properties.required_feature = AAZStrType(
255+
serialized_name="requiredFeature",
256+
flags={"read_only": True},
257+
)
258+
259+
api_versions = cls._schema_on_200.value.Element.properties.api_versions
260+
api_versions.Element = AAZStrType()
261+
262+
capacity = cls._schema_on_200.value.Element.properties.capacity
263+
capacity.individual_sku_usable = AAZStrType(
264+
serialized_name="individualSkuUsable",
265+
flags={"read_only": True},
266+
)
267+
capacity.maximum = AAZStrType(
268+
flags={"read_only": True},
269+
)
270+
capacity.usable = AAZStrType(
271+
flags={"read_only": True},
272+
)
273+
274+
costs = cls._schema_on_200.value.Element.properties.costs
275+
costs.Element = AAZObjectType()
276+
277+
_element = cls._schema_on_200.value.Element.properties.costs.Element
278+
_element.meter_id = AAZStrType(
279+
serialized_name="meterId",
280+
flags={"read_only": True},
281+
)
282+
_element.meter_type = AAZStrType(
283+
serialized_name="meterType",
284+
flags={"read_only": True},
285+
)
286+
_element.multiplier = AAZFloatType(
287+
flags={"read_only": True},
288+
)
289+
290+
countries_within_commerce_boundary = cls._schema_on_200.value.Element.properties.countries_within_commerce_boundary
291+
countries_within_commerce_boundary.Element = AAZStrType()
292+
293+
data_location_to_service_location_map = cls._schema_on_200.value.Element.properties.data_location_to_service_location_map
294+
data_location_to_service_location_map.Element = AAZObjectType()
295+
296+
_element = cls._schema_on_200.value.Element.properties.data_location_to_service_location_map.Element
297+
_element.data_location = AAZStrType(
298+
serialized_name="dataLocation",
299+
flags={"read_only": True},
300+
)
301+
_element.service_location = AAZStrType(
302+
serialized_name="serviceLocation",
303+
flags={"read_only": True},
304+
)
305+
306+
sku = cls._schema_on_200.value.Element.sku
307+
sku.display_name = AAZStrType(
308+
serialized_name="displayName",
309+
)
310+
sku.family = AAZStrType()
311+
sku.model = AAZStrType()
312+
sku.name = AAZStrType(
313+
flags={"required": True},
314+
)
315+
316+
return cls._schema_on_200
317+
318+
319+
class _AvailableSkusHelper:
320+
"""Helper class for AvailableSkus"""
321+
322+
323+
__all__ = ["AvailableSkus"]

src/databox/azext_databox/aaz/latest/databox/job/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
from ._list import *
1616
from ._list_credential import *
1717
from ._mark_devices_shipped import *
18+
from ._mitigate import *
1819
from ._show import *
1920
from ._update import *

src/databox/azext_databox/aaz/latest/databox/job/_cancel.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ class Cancel(AAZCommand):
2020
2121
:example: Cancel job
2222
az databox job cancel -g rg --job-name name --reason reason
23+
24+
:example: JobsCancelPost
25+
az databox job cancel --resource-group YourResourceGroupName --job-name TestJobName1 --reason CancelTest
2326
"""
2427

2528
_aaz_info = {
26-
"version": "2022-12-01",
29+
"version": "2025-02-01",
2730
"resources": [
28-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databox/jobs/{}/cancel", "2022-12-01"],
31+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databox/jobs/{}/cancel", "2025-02-01"],
2932
]
3033
}
3134

@@ -51,7 +54,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
5154
required=True,
5255
id_part="name",
5356
fmt=AAZStrArgFormat(
54-
pattern="^[-\w\.]+$",
57+
pattern="^[-\\w\\.]+$",
5558
max_length=24,
5659
min_length=3,
5760
),
@@ -132,7 +135,7 @@ def url_parameters(self):
132135
def query_parameters(self):
133136
parameters = {
134137
**self.serialize_query_param(
135-
"api-version", "2022-12-01",
138+
"api-version", "2025-02-01",
136139
required=True,
137140
),
138141
}

0 commit comments

Comments
 (0)