|
| 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 | + "networkfabric device upgrade", |
| 16 | +) |
| 17 | +class Upgrade(AAZCommand): |
| 18 | + """Upgrades the version of the Network Device. |
| 19 | + """ |
| 20 | + |
| 21 | + _aaz_info = { |
| 22 | + "version": "2023-06-15", |
| 23 | + "resources": [ |
| 24 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.managednetworkfabric/networkdevices/{}/upgrade", "2023-06-15"], |
| 25 | + ] |
| 26 | + } |
| 27 | + |
| 28 | + AZ_SUPPORT_NO_WAIT = True |
| 29 | + |
| 30 | + def _handler(self, command_args): |
| 31 | + super()._handler(command_args) |
| 32 | + return self.build_lro_poller(self._execute_operations, self._output) |
| 33 | + |
| 34 | + _args_schema = None |
| 35 | + |
| 36 | + @classmethod |
| 37 | + def _build_arguments_schema(cls, *args, **kwargs): |
| 38 | + if cls._args_schema is not None: |
| 39 | + return cls._args_schema |
| 40 | + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) |
| 41 | + |
| 42 | + # define Arg Group "" |
| 43 | + |
| 44 | + _args_schema = cls._args_schema |
| 45 | + _args_schema.resource_name = AAZStrArg( |
| 46 | + options=["--resource-name"], |
| 47 | + help="Name of the Network Device.", |
| 48 | + required=True, |
| 49 | + id_part="name", |
| 50 | + ) |
| 51 | + _args_schema.resource_group = AAZResourceGroupNameArg( |
| 52 | + help="Name of the resource group", |
| 53 | + required=True, |
| 54 | + ) |
| 55 | + |
| 56 | + # define Arg Group "Body" |
| 57 | + |
| 58 | + _args_schema = cls._args_schema |
| 59 | + _args_schema.version = AAZStrArg( |
| 60 | + options=["--version"], |
| 61 | + arg_group="Body", |
| 62 | + help="Specify the version.", |
| 63 | + ) |
| 64 | + return cls._args_schema |
| 65 | + |
| 66 | + def _execute_operations(self): |
| 67 | + self.pre_operations() |
| 68 | + yield self.NetworkDevicesUpgrade(ctx=self.ctx)() |
| 69 | + self.post_operations() |
| 70 | + |
| 71 | + @register_callback |
| 72 | + def pre_operations(self): |
| 73 | + pass |
| 74 | + |
| 75 | + @register_callback |
| 76 | + def post_operations(self): |
| 77 | + pass |
| 78 | + |
| 79 | + def _output(self, *args, **kwargs): |
| 80 | + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) |
| 81 | + return result |
| 82 | + |
| 83 | + class NetworkDevicesUpgrade(AAZHttpOperation): |
| 84 | + CLIENT_TYPE = "MgmtClient" |
| 85 | + |
| 86 | + def __call__(self, *args, **kwargs): |
| 87 | + request = self.make_request() |
| 88 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 89 | + if session.http_response.status_code in [202]: |
| 90 | + return self.client.build_lro_polling( |
| 91 | + self.ctx.args.no_wait, |
| 92 | + session, |
| 93 | + self.on_200, |
| 94 | + self.on_error, |
| 95 | + lro_options={"final-state-via": "location"}, |
| 96 | + path_format_arguments=self.url_parameters, |
| 97 | + ) |
| 98 | + if session.http_response.status_code in [200]: |
| 99 | + return self.client.build_lro_polling( |
| 100 | + self.ctx.args.no_wait, |
| 101 | + session, |
| 102 | + self.on_200, |
| 103 | + self.on_error, |
| 104 | + lro_options={"final-state-via": "location"}, |
| 105 | + path_format_arguments=self.url_parameters, |
| 106 | + ) |
| 107 | + |
| 108 | + return self.on_error(session.http_response) |
| 109 | + |
| 110 | + @property |
| 111 | + def url(self): |
| 112 | + return self.client.format_url( |
| 113 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkDevices/{networkDeviceName}/upgrade", |
| 114 | + **self.url_parameters |
| 115 | + ) |
| 116 | + |
| 117 | + @property |
| 118 | + def method(self): |
| 119 | + return "POST" |
| 120 | + |
| 121 | + @property |
| 122 | + def error_format(self): |
| 123 | + return "MgmtErrorFormat" |
| 124 | + |
| 125 | + @property |
| 126 | + def url_parameters(self): |
| 127 | + parameters = { |
| 128 | + **self.serialize_url_param( |
| 129 | + "networkDeviceName", self.ctx.args.resource_name, |
| 130 | + required=True, |
| 131 | + ), |
| 132 | + **self.serialize_url_param( |
| 133 | + "resourceGroupName", self.ctx.args.resource_group, |
| 134 | + required=True, |
| 135 | + ), |
| 136 | + **self.serialize_url_param( |
| 137 | + "subscriptionId", self.ctx.subscription_id, |
| 138 | + required=True, |
| 139 | + ), |
| 140 | + } |
| 141 | + return parameters |
| 142 | + |
| 143 | + @property |
| 144 | + def query_parameters(self): |
| 145 | + parameters = { |
| 146 | + **self.serialize_query_param( |
| 147 | + "api-version", "2023-06-15", |
| 148 | + required=True, |
| 149 | + ), |
| 150 | + } |
| 151 | + return parameters |
| 152 | + |
| 153 | + @property |
| 154 | + def header_parameters(self): |
| 155 | + parameters = { |
| 156 | + **self.serialize_header_param( |
| 157 | + "Content-Type", "application/json", |
| 158 | + ), |
| 159 | + **self.serialize_header_param( |
| 160 | + "Accept", "application/json", |
| 161 | + ), |
| 162 | + } |
| 163 | + return parameters |
| 164 | + |
| 165 | + @property |
| 166 | + def content(self): |
| 167 | + _content_value, _builder = self.new_content_builder( |
| 168 | + self.ctx.args, |
| 169 | + typ=AAZObjectType, |
| 170 | + typ_kwargs={"flags": {"required": True, "client_flatten": True}} |
| 171 | + ) |
| 172 | + _builder.set_prop("version", AAZStrType, ".version") |
| 173 | + |
| 174 | + return self.serialize_content(_content_value) |
| 175 | + |
| 176 | + def on_200(self, session): |
| 177 | + data = self.deserialize_http_content(session) |
| 178 | + self.ctx.set_var( |
| 179 | + "instance", |
| 180 | + data, |
| 181 | + schema_builder=self._build_schema_on_200 |
| 182 | + ) |
| 183 | + |
| 184 | + _schema_on_200 = None |
| 185 | + |
| 186 | + @classmethod |
| 187 | + def _build_schema_on_200(cls): |
| 188 | + if cls._schema_on_200 is not None: |
| 189 | + return cls._schema_on_200 |
| 190 | + |
| 191 | + cls._schema_on_200 = AAZObjectType() |
| 192 | + _UpgradeHelper._build_schema_common_post_action_response_for_state_update_read(cls._schema_on_200) |
| 193 | + |
| 194 | + return cls._schema_on_200 |
| 195 | + |
| 196 | + |
| 197 | +class _UpgradeHelper: |
| 198 | + """Helper class for Upgrade""" |
| 199 | + |
| 200 | + _schema_common_post_action_response_for_state_update_read = None |
| 201 | + |
| 202 | + @classmethod |
| 203 | + def _build_schema_common_post_action_response_for_state_update_read(cls, _schema): |
| 204 | + if cls._schema_common_post_action_response_for_state_update_read is not None: |
| 205 | + _schema.configuration_state = cls._schema_common_post_action_response_for_state_update_read.configuration_state |
| 206 | + _schema.error = cls._schema_common_post_action_response_for_state_update_read.error |
| 207 | + return |
| 208 | + |
| 209 | + cls._schema_common_post_action_response_for_state_update_read = _schema_common_post_action_response_for_state_update_read = AAZObjectType() |
| 210 | + |
| 211 | + common_post_action_response_for_state_update_read = _schema_common_post_action_response_for_state_update_read |
| 212 | + common_post_action_response_for_state_update_read.configuration_state = AAZStrType( |
| 213 | + serialized_name="configurationState", |
| 214 | + flags={"read_only": True}, |
| 215 | + ) |
| 216 | + common_post_action_response_for_state_update_read.error = AAZObjectType() |
| 217 | + cls._build_schema_error_detail_read(common_post_action_response_for_state_update_read.error) |
| 218 | + |
| 219 | + _schema.configuration_state = cls._schema_common_post_action_response_for_state_update_read.configuration_state |
| 220 | + _schema.error = cls._schema_common_post_action_response_for_state_update_read.error |
| 221 | + |
| 222 | + _schema_error_detail_read = None |
| 223 | + |
| 224 | + @classmethod |
| 225 | + def _build_schema_error_detail_read(cls, _schema): |
| 226 | + if cls._schema_error_detail_read is not None: |
| 227 | + _schema.additional_info = cls._schema_error_detail_read.additional_info |
| 228 | + _schema.code = cls._schema_error_detail_read.code |
| 229 | + _schema.details = cls._schema_error_detail_read.details |
| 230 | + _schema.message = cls._schema_error_detail_read.message |
| 231 | + _schema.target = cls._schema_error_detail_read.target |
| 232 | + return |
| 233 | + |
| 234 | + cls._schema_error_detail_read = _schema_error_detail_read = AAZObjectType() |
| 235 | + |
| 236 | + error_detail_read = _schema_error_detail_read |
| 237 | + error_detail_read.additional_info = AAZListType( |
| 238 | + serialized_name="additionalInfo", |
| 239 | + flags={"read_only": True}, |
| 240 | + ) |
| 241 | + error_detail_read.code = AAZStrType( |
| 242 | + flags={"read_only": True}, |
| 243 | + ) |
| 244 | + error_detail_read.details = AAZListType( |
| 245 | + flags={"read_only": True}, |
| 246 | + ) |
| 247 | + error_detail_read.message = AAZStrType( |
| 248 | + flags={"read_only": True}, |
| 249 | + ) |
| 250 | + error_detail_read.target = AAZStrType( |
| 251 | + flags={"read_only": True}, |
| 252 | + ) |
| 253 | + |
| 254 | + additional_info = _schema_error_detail_read.additional_info |
| 255 | + additional_info.Element = AAZObjectType() |
| 256 | + |
| 257 | + _element = _schema_error_detail_read.additional_info.Element |
| 258 | + _element.type = AAZStrType( |
| 259 | + flags={"read_only": True}, |
| 260 | + ) |
| 261 | + |
| 262 | + details = _schema_error_detail_read.details |
| 263 | + details.Element = AAZObjectType() |
| 264 | + cls._build_schema_error_detail_read(details.Element) |
| 265 | + |
| 266 | + _schema.additional_info = cls._schema_error_detail_read.additional_info |
| 267 | + _schema.code = cls._schema_error_detail_read.code |
| 268 | + _schema.details = cls._schema_error_detail_read.details |
| 269 | + _schema.message = cls._schema_error_detail_read.message |
| 270 | + _schema.target = cls._schema_error_detail_read.target |
| 271 | + |
| 272 | + |
| 273 | +__all__ = ["Upgrade"] |
0 commit comments