|
| 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 | + "network virtual-appliance get-boot-diagnostic-log", |
| 16 | +) |
| 17 | +class GetBootDiagnosticLog(AAZCommand): |
| 18 | + """Retrieve the boot diagnostic logs for a VM instance belonging to the specified Network Virtual Appliance. |
| 19 | +
|
| 20 | + :example: Get boot diagnostic logs |
| 21 | + az network virtual-appliance get-boot-diagnostic-log --resource-group rg --network-virtual-appliance-name name --scs-sas-url serialconsole-sas-url --css-sas-url consoleScreenshot-sas-url |
| 22 | + """ |
| 23 | + |
| 24 | + _aaz_info = { |
| 25 | + "version": "2024-07-01", |
| 26 | + "resources": [ |
| 27 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkvirtualappliances/{}/getbootdiagnosticlogs", "2024-07-01"], |
| 28 | + ] |
| 29 | + } |
| 30 | + |
| 31 | + AZ_SUPPORT_NO_WAIT = True |
| 32 | + |
| 33 | + def _handler(self, command_args): |
| 34 | + super()._handler(command_args) |
| 35 | + return self.build_lro_poller(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.network_virtual_appliance_name = AAZStrArg( |
| 49 | + options=["-n", "--name", "--network-virtual-appliance-name"], |
| 50 | + help="The name of Network Virtual Appliance.", |
| 51 | + required=True, |
| 52 | + id_part="name", |
| 53 | + fmt=AAZStrArgFormat( |
| 54 | + pattern="^[A-Za-z0-9_]+", |
| 55 | + ), |
| 56 | + ) |
| 57 | + _args_schema.resource_group = AAZResourceGroupNameArg( |
| 58 | + required=True, |
| 59 | + ) |
| 60 | + |
| 61 | + # define Arg Group "Request" |
| 62 | + |
| 63 | + _args_schema = cls._args_schema |
| 64 | + _args_schema.console_screenshot_storage_sas_url = AAZStrArg( |
| 65 | + options=["--css-sas-url", "--console-screenshot-storage-sas-url"], |
| 66 | + arg_group="Request", |
| 67 | + help="Specify the sas-url to the storage blob into which console screen shot for the requested instance will be written", |
| 68 | + ) |
| 69 | + _args_schema.instance_id = AAZIntArg( |
| 70 | + options=["--instance-id"], |
| 71 | + arg_group="Request", |
| 72 | + help="The network virtual appliance instance id for which boot diagnostic logs is being requested", |
| 73 | + ) |
| 74 | + _args_schema.serial_console_storage_sas_url = AAZStrArg( |
| 75 | + options=["--scs-sas-url", "--serial-console-storage-sas-url"], |
| 76 | + arg_group="Request", |
| 77 | + help="Specify the sas-url to the storage blob into which serial console logs for the requested instance will be written", |
| 78 | + ) |
| 79 | + return cls._args_schema |
| 80 | + |
| 81 | + def _execute_operations(self): |
| 82 | + self.pre_operations() |
| 83 | + yield self.NetworkVirtualAppliancesGetBootDiagnosticLogs(ctx=self.ctx)() |
| 84 | + self.post_operations() |
| 85 | + |
| 86 | + @register_callback |
| 87 | + def pre_operations(self): |
| 88 | + pass |
| 89 | + |
| 90 | + @register_callback |
| 91 | + def post_operations(self): |
| 92 | + pass |
| 93 | + |
| 94 | + def _output(self, *args, **kwargs): |
| 95 | + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) |
| 96 | + return result |
| 97 | + |
| 98 | + class NetworkVirtualAppliancesGetBootDiagnosticLogs(AAZHttpOperation): |
| 99 | + CLIENT_TYPE = "MgmtClient" |
| 100 | + |
| 101 | + def __call__(self, *args, **kwargs): |
| 102 | + request = self.make_request() |
| 103 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 104 | + if session.http_response.status_code in [202]: |
| 105 | + return self.client.build_lro_polling( |
| 106 | + self.ctx.args.no_wait, |
| 107 | + session, |
| 108 | + self.on_200, |
| 109 | + self.on_error, |
| 110 | + lro_options={"final-state-via": "location"}, |
| 111 | + path_format_arguments=self.url_parameters, |
| 112 | + ) |
| 113 | + if session.http_response.status_code in [200]: |
| 114 | + return self.client.build_lro_polling( |
| 115 | + self.ctx.args.no_wait, |
| 116 | + session, |
| 117 | + self.on_200, |
| 118 | + self.on_error, |
| 119 | + lro_options={"final-state-via": "location"}, |
| 120 | + path_format_arguments=self.url_parameters, |
| 121 | + ) |
| 122 | + |
| 123 | + return self.on_error(session.http_response) |
| 124 | + |
| 125 | + @property |
| 126 | + def url(self): |
| 127 | + return self.client.format_url( |
| 128 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/getBootDiagnosticLogs", |
| 129 | + **self.url_parameters |
| 130 | + ) |
| 131 | + |
| 132 | + @property |
| 133 | + def method(self): |
| 134 | + return "POST" |
| 135 | + |
| 136 | + @property |
| 137 | + def error_format(self): |
| 138 | + return "ODataV4Format" |
| 139 | + |
| 140 | + @property |
| 141 | + def url_parameters(self): |
| 142 | + parameters = { |
| 143 | + **self.serialize_url_param( |
| 144 | + "networkVirtualApplianceName", self.ctx.args.network_virtual_appliance_name, |
| 145 | + required=True, |
| 146 | + ), |
| 147 | + **self.serialize_url_param( |
| 148 | + "resourceGroupName", self.ctx.args.resource_group, |
| 149 | + required=True, |
| 150 | + ), |
| 151 | + **self.serialize_url_param( |
| 152 | + "subscriptionId", self.ctx.subscription_id, |
| 153 | + required=True, |
| 154 | + ), |
| 155 | + } |
| 156 | + return parameters |
| 157 | + |
| 158 | + @property |
| 159 | + def query_parameters(self): |
| 160 | + parameters = { |
| 161 | + **self.serialize_query_param( |
| 162 | + "api-version", "2024-07-01", |
| 163 | + required=True, |
| 164 | + ), |
| 165 | + } |
| 166 | + return parameters |
| 167 | + |
| 168 | + @property |
| 169 | + def header_parameters(self): |
| 170 | + parameters = { |
| 171 | + **self.serialize_header_param( |
| 172 | + "Content-Type", "application/json", |
| 173 | + ), |
| 174 | + **self.serialize_header_param( |
| 175 | + "Accept", "application/json", |
| 176 | + ), |
| 177 | + } |
| 178 | + return parameters |
| 179 | + |
| 180 | + @property |
| 181 | + def content(self): |
| 182 | + _content_value, _builder = self.new_content_builder( |
| 183 | + self.ctx.args, |
| 184 | + typ=AAZObjectType, |
| 185 | + typ_kwargs={"flags": {"required": True, "client_flatten": True}} |
| 186 | + ) |
| 187 | + _builder.set_prop("consoleScreenshotStorageSasUrl", AAZStrType, ".console_screenshot_storage_sas_url") |
| 188 | + _builder.set_prop("instanceId", AAZIntType, ".instance_id") |
| 189 | + _builder.set_prop("serialConsoleStorageSasUrl", AAZStrType, ".serial_console_storage_sas_url") |
| 190 | + |
| 191 | + return self.serialize_content(_content_value) |
| 192 | + |
| 193 | + def on_200(self, session): |
| 194 | + data = self.deserialize_http_content(session) |
| 195 | + self.ctx.set_var( |
| 196 | + "instance", |
| 197 | + data, |
| 198 | + schema_builder=self._build_schema_on_200 |
| 199 | + ) |
| 200 | + |
| 201 | + _schema_on_200 = None |
| 202 | + |
| 203 | + @classmethod |
| 204 | + def _build_schema_on_200(cls): |
| 205 | + if cls._schema_on_200 is not None: |
| 206 | + return cls._schema_on_200 |
| 207 | + |
| 208 | + cls._schema_on_200 = AAZObjectType() |
| 209 | + |
| 210 | + _schema_on_200 = cls._schema_on_200 |
| 211 | + _schema_on_200.instance_id = AAZIntType( |
| 212 | + serialized_name="instanceId", |
| 213 | + ) |
| 214 | + |
| 215 | + return cls._schema_on_200 |
| 216 | + |
| 217 | + |
| 218 | +class _GetBootDiagnosticLogHelper: |
| 219 | + """Helper class for GetBootDiagnosticLog""" |
| 220 | + |
| 221 | + |
| 222 | +__all__ = ["GetBootDiagnosticLog"] |
0 commit comments