|
| 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 vnet move-ip-configurations", |
| 16 | + is_preview=True, |
| 17 | +) |
| 18 | +class MoveIpConfigurations(AAZCommand): |
| 19 | + """Move IP configurations from one virtual network to another. |
| 20 | +
|
| 21 | + :example: Move an IP configuration to a virtual network. |
| 22 | + az network vnet move-ip-configurations -g MyResourceGroup -n MyVnet --move-ip-configuration-items "[0].source-ip-configuration.id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Network/networkInterfaces/nic1/ipConfigurations/ipconfig1" "[0].target-ip-configuration.id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Network/networkInterfaces/nic2/ipConfigurations/ipconfig2" |
| 23 | + """ |
| 24 | + |
| 25 | + _aaz_info = { |
| 26 | + "version": "2025-09-01", |
| 27 | + "resources": [ |
| 28 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/virtualnetworks/{}/moveipconfigurations", "2025-09-01"], |
| 29 | + ] |
| 30 | + } |
| 31 | + |
| 32 | + AZ_SUPPORT_NO_WAIT = True |
| 33 | + |
| 34 | + def _handler(self, command_args): |
| 35 | + super()._handler(command_args) |
| 36 | + return self.build_lro_poller(self._execute_operations, None) |
| 37 | + |
| 38 | + _args_schema = None |
| 39 | + |
| 40 | + @classmethod |
| 41 | + def _build_arguments_schema(cls, *args, **kwargs): |
| 42 | + if cls._args_schema is not None: |
| 43 | + return cls._args_schema |
| 44 | + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) |
| 45 | + |
| 46 | + _args_schema = cls._args_schema |
| 47 | + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) |
| 48 | + _args_schema.name = AAZStrArg( |
| 49 | + options=["-n", "--name"], |
| 50 | + help="Name of the virtual network.", |
| 51 | + required=True, |
| 52 | + id_part="name", |
| 53 | + ) |
| 54 | + _args_schema.move_ip_configuration_items = AAZListArg( |
| 55 | + options=["--move-items", "--move-ip-configuration-items"], |
| 56 | + help="List of source and target IP configuration resource ID pairs.", |
| 57 | + required=True, |
| 58 | + ) |
| 59 | + _args_schema.move_ip_configuration_items.Element = AAZObjectArg() |
| 60 | + _element = _args_schema.move_ip_configuration_items.Element |
| 61 | + _element.source_ip_configuration = AAZObjectArg( |
| 62 | + options=["source-ip-configuration"], |
| 63 | + help="Source IP configuration.", |
| 64 | + required=True, |
| 65 | + ) |
| 66 | + _element.source_ip_configuration.id = AAZResourceIdArg( |
| 67 | + options=["id"], |
| 68 | + help="ARM resource ID of the source IP configuration.", |
| 69 | + required=True, |
| 70 | + ) |
| 71 | + _element.target_ip_configuration = AAZObjectArg( |
| 72 | + options=["target-ip-configuration"], |
| 73 | + help="Target IP configuration.", |
| 74 | + required=True, |
| 75 | + ) |
| 76 | + _element.target_ip_configuration.id = AAZResourceIdArg( |
| 77 | + options=["id"], |
| 78 | + help="ARM resource ID of the target IP configuration.", |
| 79 | + required=True, |
| 80 | + ) |
| 81 | + return cls._args_schema |
| 82 | + |
| 83 | + def _execute_operations(self): |
| 84 | + self.pre_operations() |
| 85 | + yield self.VirtualNetworksMoveIpConfigurations(ctx=self.ctx)() |
| 86 | + self.post_operations() |
| 87 | + |
| 88 | + @register_callback |
| 89 | + def pre_operations(self): |
| 90 | + pass |
| 91 | + |
| 92 | + @register_callback |
| 93 | + def post_operations(self): |
| 94 | + pass |
| 95 | + |
| 96 | + class VirtualNetworksMoveIpConfigurations(AAZHttpOperation): |
| 97 | + CLIENT_TYPE = "MgmtClient" |
| 98 | + |
| 99 | + def __call__(self, *args, **kwargs): |
| 100 | + request = self.make_request() |
| 101 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 102 | + if session.http_response.status_code in [200, 202]: |
| 103 | + return self.client.build_lro_polling( |
| 104 | + self.ctx.args.no_wait, |
| 105 | + session, |
| 106 | + self.on_200, |
| 107 | + self.on_error, |
| 108 | + lro_options={"final-state-via": "azure-async-operation"}, |
| 109 | + path_format_arguments=self.url_parameters, |
| 110 | + ) |
| 111 | + return self.on_error(session.http_response) |
| 112 | + |
| 113 | + @property |
| 114 | + def url(self): |
| 115 | + return self.client.format_url( |
| 116 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/moveIpConfigurations", |
| 117 | + **self.url_parameters |
| 118 | + ) |
| 119 | + |
| 120 | + @property |
| 121 | + def method(self): |
| 122 | + return "POST" |
| 123 | + |
| 124 | + @property |
| 125 | + def error_format(self): |
| 126 | + return "ODataV4Format" |
| 127 | + |
| 128 | + @property |
| 129 | + def url_parameters(self): |
| 130 | + return { |
| 131 | + **self.serialize_url_param("resourceGroupName", self.ctx.args.resource_group, required=True), |
| 132 | + **self.serialize_url_param("subscriptionId", self.ctx.subscription_id, required=True), |
| 133 | + **self.serialize_url_param("virtualNetworkName", self.ctx.args.name, required=True), |
| 134 | + } |
| 135 | + |
| 136 | + @property |
| 137 | + def query_parameters(self): |
| 138 | + return { |
| 139 | + **self.serialize_query_param("api-version", "2025-09-01", required=True), |
| 140 | + } |
| 141 | + |
| 142 | + @property |
| 143 | + def header_parameters(self): |
| 144 | + return { |
| 145 | + **self.serialize_header_param("Content-Type", "application/json"), |
| 146 | + **self.serialize_header_param("Accept", "application/json"), |
| 147 | + } |
| 148 | + |
| 149 | + @property |
| 150 | + def content(self): |
| 151 | + _content_value, _builder = self.new_content_builder( |
| 152 | + self.ctx.args, |
| 153 | + typ=AAZObjectType, |
| 154 | + typ_kwargs={"flags": {"required": True, "client_flatten": True}} |
| 155 | + ) |
| 156 | + _builder.set_prop( |
| 157 | + "moveIpConfigurationItems", AAZListType, ".move_ip_configuration_items", |
| 158 | + typ_kwargs={"flags": {"required": True}} |
| 159 | + ) |
| 160 | + items = _builder.get(".moveIpConfigurationItems") |
| 161 | + if items is not None: |
| 162 | + items.set_elements(AAZObjectType, ".") |
| 163 | + element = _builder.get(".moveIpConfigurationItems[]") |
| 164 | + if element is not None: |
| 165 | + element.set_prop( |
| 166 | + "sourceIpConfiguration", AAZObjectType, ".source_ip_configuration", |
| 167 | + typ_kwargs={"flags": {"required": True}} |
| 168 | + ) |
| 169 | + source = element.get(".sourceIpConfiguration") |
| 170 | + if source is not None: |
| 171 | + source.set_prop("id", AAZStrType, ".id", typ_kwargs={"flags": {"required": True}}) |
| 172 | + element.set_prop( |
| 173 | + "targetIpConfiguration", AAZObjectType, ".target_ip_configuration", |
| 174 | + typ_kwargs={"flags": {"required": True}} |
| 175 | + ) |
| 176 | + target = element.get(".targetIpConfiguration") |
| 177 | + if target is not None: |
| 178 | + target.set_prop("id", AAZStrType, ".id", typ_kwargs={"flags": {"required": True}}) |
| 179 | + return self.serialize_content(_content_value) |
| 180 | + |
| 181 | + def on_200(self, session): |
| 182 | + pass |
| 183 | + |
| 184 | + |
| 185 | +__all__ = ["MoveIpConfigurations"] |
0 commit comments