|
| 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 | + "databoxedge list-node", |
| 16 | +) |
| 17 | +class ListNode(AAZCommand): |
| 18 | + """List all the nodes currently configured under this Data Box Edge device |
| 19 | +
|
| 20 | + :example: Get all the nodes currently configured under this Data Box Edge device. |
| 21 | + az databoxedge list-node --device-name testedgedevice --resource-group GroupForEdgeAutomation |
| 22 | + """ |
| 23 | + |
| 24 | + _aaz_info = { |
| 25 | + "version": "2021-02-01-preview", |
| 26 | + "resources": [ |
| 27 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.databoxedge/databoxedgedevices/{}/nodes", "2021-02-01-preview"], |
| 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.device_name = AAZStrArg( |
| 49 | + options=["-d", "--device-name"], |
| 50 | + help="The device name.", |
| 51 | + required=True, |
| 52 | + ) |
| 53 | + _args_schema.resource_group = AAZResourceGroupNameArg( |
| 54 | + required=True, |
| 55 | + ) |
| 56 | + return cls._args_schema |
| 57 | + |
| 58 | + def _execute_operations(self): |
| 59 | + self.pre_operations() |
| 60 | + self.NodesListByDataBoxEdgeDevice(ctx=self.ctx)() |
| 61 | + self.post_operations() |
| 62 | + |
| 63 | + @register_callback |
| 64 | + def pre_operations(self): |
| 65 | + pass |
| 66 | + |
| 67 | + @register_callback |
| 68 | + def post_operations(self): |
| 69 | + pass |
| 70 | + |
| 71 | + def _output(self, *args, **kwargs): |
| 72 | + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) |
| 73 | + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) |
| 74 | + return result, next_link |
| 75 | + |
| 76 | + class NodesListByDataBoxEdgeDevice(AAZHttpOperation): |
| 77 | + CLIENT_TYPE = "MgmtClient" |
| 78 | + |
| 79 | + def __call__(self, *args, **kwargs): |
| 80 | + request = self.make_request() |
| 81 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 82 | + if session.http_response.status_code in [200]: |
| 83 | + return self.on_200(session) |
| 84 | + |
| 85 | + return self.on_error(session.http_response) |
| 86 | + |
| 87 | + @property |
| 88 | + def url(self): |
| 89 | + return self.client.format_url( |
| 90 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", |
| 91 | + **self.url_parameters |
| 92 | + ) |
| 93 | + |
| 94 | + @property |
| 95 | + def method(self): |
| 96 | + return "GET" |
| 97 | + |
| 98 | + @property |
| 99 | + def error_format(self): |
| 100 | + return "ODataV4Format" |
| 101 | + |
| 102 | + @property |
| 103 | + def url_parameters(self): |
| 104 | + parameters = { |
| 105 | + **self.serialize_url_param( |
| 106 | + "deviceName", self.ctx.args.device_name, |
| 107 | + required=True, |
| 108 | + ), |
| 109 | + **self.serialize_url_param( |
| 110 | + "resourceGroupName", self.ctx.args.resource_group, |
| 111 | + required=True, |
| 112 | + ), |
| 113 | + **self.serialize_url_param( |
| 114 | + "subscriptionId", self.ctx.subscription_id, |
| 115 | + required=True, |
| 116 | + ), |
| 117 | + } |
| 118 | + return parameters |
| 119 | + |
| 120 | + @property |
| 121 | + def query_parameters(self): |
| 122 | + parameters = { |
| 123 | + **self.serialize_query_param( |
| 124 | + "api-version", "2021-02-01-preview", |
| 125 | + required=True, |
| 126 | + ), |
| 127 | + } |
| 128 | + return parameters |
| 129 | + |
| 130 | + @property |
| 131 | + def header_parameters(self): |
| 132 | + parameters = { |
| 133 | + **self.serialize_header_param( |
| 134 | + "Accept", "application/json", |
| 135 | + ), |
| 136 | + } |
| 137 | + return parameters |
| 138 | + |
| 139 | + def on_200(self, session): |
| 140 | + data = self.deserialize_http_content(session) |
| 141 | + self.ctx.set_var( |
| 142 | + "instance", |
| 143 | + data, |
| 144 | + schema_builder=self._build_schema_on_200 |
| 145 | + ) |
| 146 | + |
| 147 | + _schema_on_200 = None |
| 148 | + |
| 149 | + @classmethod |
| 150 | + def _build_schema_on_200(cls): |
| 151 | + if cls._schema_on_200 is not None: |
| 152 | + return cls._schema_on_200 |
| 153 | + |
| 154 | + cls._schema_on_200 = AAZObjectType() |
| 155 | + |
| 156 | + _schema_on_200 = cls._schema_on_200 |
| 157 | + _schema_on_200.next_link = AAZStrType( |
| 158 | + serialized_name="nextLink", |
| 159 | + ) |
| 160 | + _schema_on_200.value = AAZListType( |
| 161 | + flags={"read_only": True}, |
| 162 | + ) |
| 163 | + |
| 164 | + value = cls._schema_on_200.value |
| 165 | + value.Element = AAZObjectType() |
| 166 | + |
| 167 | + _element = cls._schema_on_200.value.Element |
| 168 | + _element.id = AAZStrType( |
| 169 | + flags={"read_only": True}, |
| 170 | + ) |
| 171 | + _element.name = AAZStrType( |
| 172 | + flags={"read_only": True}, |
| 173 | + ) |
| 174 | + _element.properties = AAZObjectType( |
| 175 | + flags={"client_flatten": True, "read_only": True}, |
| 176 | + ) |
| 177 | + _element.type = AAZStrType( |
| 178 | + flags={"read_only": True}, |
| 179 | + ) |
| 180 | + |
| 181 | + properties = cls._schema_on_200.value.Element.properties |
| 182 | + properties.node_chassis_serial_number = AAZStrType( |
| 183 | + serialized_name="nodeChassisSerialNumber", |
| 184 | + flags={"read_only": True}, |
| 185 | + ) |
| 186 | + properties.node_display_name = AAZStrType( |
| 187 | + serialized_name="nodeDisplayName", |
| 188 | + flags={"read_only": True}, |
| 189 | + ) |
| 190 | + properties.node_friendly_software_version = AAZStrType( |
| 191 | + serialized_name="nodeFriendlySoftwareVersion", |
| 192 | + flags={"read_only": True}, |
| 193 | + ) |
| 194 | + properties.node_hcs_version = AAZStrType( |
| 195 | + serialized_name="nodeHcsVersion", |
| 196 | + flags={"read_only": True}, |
| 197 | + ) |
| 198 | + properties.node_instance_id = AAZStrType( |
| 199 | + serialized_name="nodeInstanceId", |
| 200 | + flags={"read_only": True}, |
| 201 | + ) |
| 202 | + properties.node_serial_number = AAZStrType( |
| 203 | + serialized_name="nodeSerialNumber", |
| 204 | + flags={"read_only": True}, |
| 205 | + ) |
| 206 | + properties.node_status = AAZStrType( |
| 207 | + serialized_name="nodeStatus", |
| 208 | + flags={"read_only": True}, |
| 209 | + ) |
| 210 | + |
| 211 | + return cls._schema_on_200 |
| 212 | + |
| 213 | + |
| 214 | +class _ListNodeHelper: |
| 215 | + """Helper class for ListNode""" |
| 216 | + |
| 217 | + |
| 218 | +__all__ = ["ListNode"] |
0 commit comments