Skip to content

Commit 26f92ae

Browse files
committed
add support for azure stack
1 parent 0081d17 commit 26f92ae

File tree

16 files changed

+4367
-53
lines changed

16 files changed

+4367
-53
lines changed

src/azure-cli/azure/cli/command_modules/vm/aaz/profile_2018_03_01_hybrid/disk/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
# flake8: noqa
1010

1111
from .__cmd_group import *
12+
from ._create import *
1213
from ._delete import *
14+
from ._grant_access import *
1315
from ._list import *
1416
from ._revoke_access import *
1517
from ._show import *
18+
from ._update import *
1619
from ._wait import *

src/azure-cli/azure/cli/command_modules/vm/aaz/profile_2018_03_01_hybrid/disk/_create.py

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

src/azure-cli/azure/cli/command_modules/vm/aaz/profile_2018_03_01_hybrid/disk/_delete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ def _build_schema_on_200(cls):
184184
serialized_name="endTime",
185185
flags={"read_only": True},
186186
)
187-
_schema_on_200.error = AAZObjectType()
187+
_schema_on_200.error = AAZObjectType(
188+
flags={"read_only": True},
189+
)
188190
_schema_on_200.name = AAZStrType(
189191
flags={"read_only": True},
190192
)
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
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+
"disk grant-access",
16+
)
17+
class GrantAccess(AAZCommand):
18+
"""Grant a resource access to a managed disk.
19+
20+
:example: Grant a resource read access to a managed disk.
21+
az disk grant-access --access-level Read --duration-in-seconds 3600 --name MyManagedDisk --resource-group MyResourceGroup
22+
23+
:example: Grant a resource read access to a disk to generate access SAS and security data access SAS
24+
az disk grant-access --access-level Read --duration-in-seconds 3600 --name MyDisk --resource-group MyResourceGroup --secure-vm-guest-state-sas
25+
"""
26+
27+
_aaz_info = {
28+
"version": "2017-03-30",
29+
"resources": [
30+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/disks/{}/begingetaccess", "2017-03-30"],
31+
]
32+
}
33+
34+
AZ_SUPPORT_NO_WAIT = True
35+
36+
def _handler(self, command_args):
37+
super()._handler(command_args)
38+
return self.build_lro_poller(self._execute_operations, self._output)
39+
40+
_args_schema = None
41+
42+
@classmethod
43+
def _build_arguments_schema(cls, *args, **kwargs):
44+
if cls._args_schema is not None:
45+
return cls._args_schema
46+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
47+
48+
# define Arg Group ""
49+
50+
_args_schema = cls._args_schema
51+
_args_schema.disk_name = AAZStrArg(
52+
options=["-n", "--name", "--disk-name"],
53+
help="The name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters.",
54+
required=True,
55+
id_part="name",
56+
)
57+
_args_schema.resource_group = AAZResourceGroupNameArg(
58+
required=True,
59+
)
60+
61+
# define Arg Group "GrantAccessData"
62+
63+
_args_schema = cls._args_schema
64+
_args_schema.access_level = AAZStrArg(
65+
options=["--access", "--access-level"],
66+
arg_group="GrantAccessData",
67+
help="Access level.",
68+
required=True,
69+
default="Read",
70+
enum={"None": "None", "Read": "Read"},
71+
)
72+
_args_schema.duration_in_seconds = AAZIntArg(
73+
options=["--duration-in-seconds"],
74+
arg_group="GrantAccessData",
75+
help="Time duration in seconds until the SAS access expires.",
76+
required=True,
77+
)
78+
return cls._args_schema
79+
80+
def _execute_operations(self):
81+
self.pre_operations()
82+
yield self.DisksGrantAccess(ctx=self.ctx)()
83+
self.post_operations()
84+
85+
@register_callback
86+
def pre_operations(self):
87+
pass
88+
89+
@register_callback
90+
def post_operations(self):
91+
pass
92+
93+
def _output(self, *args, **kwargs):
94+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
95+
return result
96+
97+
class DisksGrantAccess(AAZHttpOperation):
98+
CLIENT_TYPE = "MgmtClient"
99+
100+
def __call__(self, *args, **kwargs):
101+
request = self.make_request()
102+
session = self.client.send_request(request=request, stream=False, **kwargs)
103+
if session.http_response.status_code in [202]:
104+
return self.client.build_lro_polling(
105+
self.ctx.args.no_wait,
106+
session,
107+
self.on_200,
108+
self.on_error,
109+
lro_options={"final-state-via": "azure-async-operation"},
110+
path_format_arguments=self.url_parameters,
111+
)
112+
if session.http_response.status_code in [200]:
113+
return self.client.build_lro_polling(
114+
self.ctx.args.no_wait,
115+
session,
116+
self.on_200,
117+
self.on_error,
118+
lro_options={"final-state-via": "azure-async-operation"},
119+
path_format_arguments=self.url_parameters,
120+
)
121+
122+
return self.on_error(session.http_response)
123+
124+
@property
125+
def url(self):
126+
return self.client.format_url(
127+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess",
128+
**self.url_parameters
129+
)
130+
131+
@property
132+
def method(self):
133+
return "POST"
134+
135+
@property
136+
def error_format(self):
137+
return "MgmtErrorFormat"
138+
139+
@property
140+
def url_parameters(self):
141+
parameters = {
142+
**self.serialize_url_param(
143+
"diskName", self.ctx.args.disk_name,
144+
required=True,
145+
),
146+
**self.serialize_url_param(
147+
"resourceGroupName", self.ctx.args.resource_group,
148+
required=True,
149+
),
150+
**self.serialize_url_param(
151+
"subscriptionId", self.ctx.subscription_id,
152+
required=True,
153+
),
154+
}
155+
return parameters
156+
157+
@property
158+
def query_parameters(self):
159+
parameters = {
160+
**self.serialize_query_param(
161+
"api-version", "2017-03-30",
162+
required=True,
163+
),
164+
}
165+
return parameters
166+
167+
@property
168+
def header_parameters(self):
169+
parameters = {
170+
**self.serialize_header_param(
171+
"Content-Type", "application/json",
172+
),
173+
**self.serialize_header_param(
174+
"Accept", "application/json",
175+
),
176+
}
177+
return parameters
178+
179+
@property
180+
def content(self):
181+
_content_value, _builder = self.new_content_builder(
182+
self.ctx.args,
183+
typ=AAZObjectType,
184+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
185+
)
186+
_builder.set_prop("access", AAZStrType, ".access_level", typ_kwargs={"flags": {"required": True}})
187+
_builder.set_prop("durationInSeconds", AAZIntType, ".duration_in_seconds", typ_kwargs={"flags": {"required": True}})
188+
189+
return self.serialize_content(_content_value)
190+
191+
def on_200(self, session):
192+
data = self.deserialize_http_content(session)
193+
self.ctx.set_var(
194+
"instance",
195+
data,
196+
schema_builder=self._build_schema_on_200
197+
)
198+
199+
_schema_on_200 = None
200+
201+
@classmethod
202+
def _build_schema_on_200(cls):
203+
if cls._schema_on_200 is not None:
204+
return cls._schema_on_200
205+
206+
cls._schema_on_200 = AAZObjectType()
207+
208+
_schema_on_200 = cls._schema_on_200
209+
_schema_on_200.properties = AAZObjectType(
210+
flags={"client_flatten": True},
211+
)
212+
213+
properties = cls._schema_on_200.properties
214+
properties.output = AAZObjectType(
215+
flags={"client_flatten": True},
216+
)
217+
218+
output = cls._schema_on_200.properties.output
219+
output.access_sas = AAZStrType(
220+
serialized_name="accessSAS",
221+
flags={"read_only": True},
222+
)
223+
224+
return cls._schema_on_200
225+
226+
227+
class _GrantAccessHelper:
228+
"""Helper class for GrantAccess"""
229+
230+
231+
__all__ = ["GrantAccess"]

0 commit comments

Comments
 (0)