170170 send_raw_request ,
171171 shell_safe_json_parse ,
172172)
173+ from azure .core import MatchConditions
173174from azure .core .exceptions import (
174175 ResourceNotFoundError ,
175176 HttpResponseError ,
184185logger = get_logger (__name__ )
185186
186187
188+ def _get_etag_match_condition (if_match , if_none_match ):
189+ """Convert if_match/if_none_match to etag/match_condition for the new SDK."""
190+ if if_match is not None :
191+ return if_match , MatchConditions .IfNotModified
192+ if if_none_match is not None :
193+ return if_none_match , MatchConditions .IfMissing
194+ return None , None
195+
196+
187197def wait_then_open (url ):
188198 """
189199 Waits for a bit then opens a URL. Useful for waiting for a proxy to come up, and then open the URL.
@@ -1463,12 +1473,15 @@ def aks_delete(cmd, client, resource_group_name, name, no_wait=False,
14631473 logger .warning (
14641474 "The '--if-none-match' option is not applicable to delete operations and will be ignored."
14651475 )
1476+ etag = if_match
1477+ match_condition = MatchConditions .IfNotModified if if_match is not None else None
14661478 return sdk_no_wait (
14671479 no_wait ,
14681480 client .begin_delete ,
14691481 resource_group_name ,
14701482 name ,
1471- if_match = if_match ,
1483+ etag = etag ,
1484+ match_condition = match_condition ,
14721485 ignore_pod_disruption_budget = ignore_pod_disruption_budget ,
14731486 )
14741487
@@ -1509,15 +1522,24 @@ def _remove_nulls(managed_clusters):
15091522 for managed_cluster in managed_clusters :
15101523 for attr in attrs :
15111524 if getattr (managed_cluster , attr , None ) is None :
1512- delattr (managed_cluster , attr )
1525+ try :
1526+ delattr (managed_cluster , attr )
1527+ except AttributeError :
1528+ pass
15131529 if managed_cluster .agent_pool_profiles is not None :
15141530 for ap_profile in managed_cluster .agent_pool_profiles :
15151531 for attr in ap_attrs :
15161532 if getattr (ap_profile , attr , None ) is None :
1517- delattr (ap_profile , attr )
1533+ try :
1534+ delattr (ap_profile , attr )
1535+ except AttributeError :
1536+ pass
15181537 for attr in sp_attrs :
15191538 if getattr (managed_cluster .service_principal_profile , attr , None ) is None :
1520- delattr (managed_cluster .service_principal_profile , attr )
1539+ try :
1540+ delattr (managed_cluster .service_principal_profile , attr )
1541+ except AttributeError :
1542+ pass
15211543 return managed_clusters
15221544
15231545
@@ -1546,14 +1568,14 @@ def aks_get_credentials(
15461568 raise InvalidArgumentValueError ("--format can only be specified when requesting clusterUser credential." )
15471569 if admin :
15481570 credentialResults = client .list_cluster_admin_credentials (
1549- resource_group_name , name , serverType , headers = headers )
1571+ resource_group_name , name , server_fqdn = serverType , headers = headers )
15501572 else :
15511573 if user .lower () == 'clusteruser' :
15521574 credentialResults = client .list_cluster_user_credentials (
1553- resource_group_name , name , serverType , credential_format , headers = headers )
1575+ resource_group_name , name , server_fqdn = serverType , format = credential_format , headers = headers )
15541576 elif user .lower () == 'clustermonitoringuser' :
15551577 credentialResults = client .list_cluster_monitoring_user_credentials (
1556- resource_group_name , name , serverType , headers = headers )
1578+ resource_group_name , name , server_fqdn = serverType , headers = headers )
15571579 else :
15581580 raise InvalidArgumentValueError ("The value of option --user is invalid." )
15591581
@@ -1769,15 +1791,16 @@ def aks_upgrade(cmd,
17691791
17701792 headers = get_aks_custom_headers (aks_custom_headers )
17711793
1794+ etag , match_condition = _get_etag_match_condition (if_match , if_none_match )
17721795 return sdk_no_wait (
17731796 no_wait ,
17741797 client .begin_create_or_update ,
17751798 resource_group_name ,
17761799 name ,
17771800 instance ,
17781801 headers = headers ,
1779- if_match = if_match ,
1780- if_none_match = if_none_match )
1802+ etag = etag ,
1803+ match_condition = match_condition )
17811804
17821805
17831806def _update_upgrade_settings (cmd , instance ,
@@ -2245,6 +2268,7 @@ def aks_agentpool_upgrade(cmd,
22452268 allow_appending_values_to_same_key = True ,
22462269 )
22472270
2271+ etag , match_condition = _get_etag_match_condition (if_match , if_none_match )
22482272 return sdk_no_wait (
22492273 no_wait ,
22502274 client .begin_create_or_update ,
@@ -2253,8 +2277,8 @@ def aks_agentpool_upgrade(cmd,
22532277 nodepool_name ,
22542278 instance ,
22552279 headers = aks_custom_headers ,
2256- if_match = if_match ,
2257- if_none_match = if_none_match ,
2280+ etag = etag ,
2281+ match_condition = match_condition ,
22582282 )
22592283
22602284
@@ -2481,13 +2505,16 @@ def aks_agentpool_delete(cmd, # pylint: disable=unused-argument
24812505 "use 'aks nodepool list' to get current node pool list"
24822506 )
24832507
2508+ etag = if_match
2509+ match_condition = MatchConditions .IfNotModified if if_match is not None else None
24842510 return sdk_no_wait (
24852511 no_wait ,
24862512 client .begin_delete ,
24872513 resource_group_name ,
24882514 cluster_name ,
24892515 nodepool_name ,
2490- if_match = if_match ,
2516+ etag = etag ,
2517+ match_condition = match_condition ,
24912518 ignore_pod_disruption_budget = ignore_pod_disruption_budget ,
24922519 )
24932520
0 commit comments