Skip to content

Commit e515ca5

Browse files
[Network] az network manager ipam-pool static-cidr update (#9002)
* create static cidr update * fix custom logic * add address prefix to update pool * fix styling * add example * update test --------- Co-authored-by: Zhiyi Huang <[email protected]>
1 parent 8f6f15d commit e515ca5

File tree

7 files changed

+1185
-342
lines changed

7 files changed

+1185
-342
lines changed

src/network-manager/azext_network_manager/aaz/latest/network/manager/ipam_pool/_update.py

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class Update(AAZCommand):
1818
"""Update the Pool resource.
1919
2020
:example: IpamPools_Update
21-
az network manager ipam-pool update --name "myIpamPool" --network-manager-name "myAVNM" --resource-group "myAVNMResourceGroup" --subscription "00000000-0000-0000-0000-000000000000" --display-name "myIpamPoolDisplayName" --description "New Description" --tags ""
21+
az network manager ipam-pool update --name "myIpamPool" --network-manager-name "myAVNM" --resource-group "myAVNMResourceGroup" --subscription "00000000-0000-0000-0000-000000000000" --display-name "myIpamPoolDisplayName" --description --address-prefixes "['10.0.0.0/16']" "New Description" --tags ""
2222
"""
2323

2424
_aaz_info = {
25-
"version": "2024-05-01",
25+
"version": "2024-07-01",
2626
"resources": [
27-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkmanagers/{}/ipampools/{}", "2024-05-01"],
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkmanagers/{}/ipampools/{}", "2024-07-01"],
2828
]
2929
}
3030

@@ -47,6 +47,10 @@ def _build_arguments_schema(cls, *args, **kwargs):
4747
# define Arg Group ""
4848

4949
_args_schema = cls._args_schema
50+
_args_schema.if_match = AAZStrArg(
51+
options=["--if-match"],
52+
help="The entity state (ETag) version of the pool to update. This value can be omitted or set to \"*\" to apply the operation unconditionally.",
53+
)
5054
_args_schema.network_manager_name = AAZStrArg(
5155
options=["--manager-name", "--network-manager-name"],
5256
help="The name of the network manager.",
@@ -87,6 +91,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
8791
# define Arg Group "Properties"
8892

8993
_args_schema = cls._args_schema
94+
_args_schema.address_prefixes = AAZListArg(
95+
options=["--address-prefixes"],
96+
arg_group="Properties",
97+
help="List of IP address prefixes of the resource.",
98+
)
9099
_args_schema.description = AAZStrArg(
91100
options=["--description"],
92101
arg_group="Properties",
@@ -99,6 +108,16 @@ def _build_arguments_schema(cls, *args, **kwargs):
99108
help="String representing a friendly name for the resource.",
100109
nullable=True,
101110
)
111+
_args_schema.parent_pool_name = AAZStrArg(
112+
options=["--parent-pool-name"],
113+
arg_group="Properties",
114+
help="String representing parent IpamPool resource name. If empty the IpamPool will be a root pool.",
115+
nullable=True,
116+
)
117+
118+
address_prefixes = cls._args_schema.address_prefixes
119+
address_prefixes.Element = AAZStrArg(
120+
)
102121
return cls._args_schema
103122

104123
def _execute_operations(self):
@@ -183,7 +202,7 @@ def url_parameters(self):
183202
def query_parameters(self):
184203
parameters = {
185204
**self.serialize_query_param(
186-
"api-version", "2024-05-01",
205+
"api-version", "2024-07-01",
187206
required=True,
188207
),
189208
}
@@ -286,7 +305,7 @@ def url_parameters(self):
286305
def query_parameters(self):
287306
parameters = {
288307
**self.serialize_query_param(
289-
"api-version", "2024-05-01",
308+
"api-version", "2024-07-01",
290309
required=True,
291310
),
292311
}
@@ -295,6 +314,9 @@ def query_parameters(self):
295314
@property
296315
def header_parameters(self):
297316
parameters = {
317+
**self.serialize_header_param(
318+
"If-Match", self.ctx.args.if_match,
319+
),
298320
**self.serialize_header_param(
299321
"Content-Type", "application/json",
300322
),
@@ -349,8 +371,14 @@ def _update_instance(self, instance):
349371

350372
properties = _builder.get(".properties")
351373
if properties is not None:
374+
properties.set_prop("addressPrefixes", AAZListType, ".address_prefixes", typ_kwargs={"flags": {"required": True}})
352375
properties.set_prop("description", AAZStrType, ".description")
353376
properties.set_prop("displayName", AAZStrType, ".display_name")
377+
properties.set_prop("parentPoolName", AAZStrType, ".parent_pool_name")
378+
379+
address_prefixes = _builder.get(".properties.addressPrefixes")
380+
if address_prefixes is not None:
381+
address_prefixes.set_elements(AAZStrType, ".")
354382

355383
tags = _builder.get(".tags")
356384
if tags is not None:
@@ -375,6 +403,7 @@ class _UpdateHelper:
375403
@classmethod
376404
def _build_schema_ipam_pool_read(cls, _schema):
377405
if cls._schema_ipam_pool_read is not None:
406+
_schema.etag = cls._schema_ipam_pool_read.etag
378407
_schema.id = cls._schema_ipam_pool_read.id
379408
_schema.location = cls._schema_ipam_pool_read.location
380409
_schema.name = cls._schema_ipam_pool_read.name
@@ -387,6 +416,9 @@ def _build_schema_ipam_pool_read(cls, _schema):
387416
cls._schema_ipam_pool_read = _schema_ipam_pool_read = AAZObjectType()
388417

389418
ipam_pool_read = _schema_ipam_pool_read
419+
ipam_pool_read.etag = AAZStrType(
420+
flags={"read_only": True},
421+
)
390422
ipam_pool_read.id = AAZStrType(
391423
flags={"read_only": True},
392424
)
@@ -458,6 +490,7 @@ def _build_schema_ipam_pool_read(cls, _schema):
458490
tags = _schema_ipam_pool_read.tags
459491
tags.Element = AAZStrType()
460492

493+
_schema.etag = cls._schema_ipam_pool_read.etag
461494
_schema.id = cls._schema_ipam_pool_read.id
462495
_schema.location = cls._schema_ipam_pool_read.location
463496
_schema.name = cls._schema_ipam_pool_read.name

src/network-manager/azext_network_manager/aaz/latest/network/manager/ipam_pool/static_cidr/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
from ._delete import *
1414
from ._list import *
1515
from ._show import *
16+
from ._update import *
1617
from ._wait import *

0 commit comments

Comments
 (0)