
    =                     
   S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SSKJr  SSKJr  S	 rS
 r\R*                  \R,                  " \R.                  R0                  5       " S S\R2                  \R2                  5      5       5       r\R*                  \R,                  " \R.                  R6                  \R.                  R8                  5       " S S\R2                  \R2                  5      5       5       rg)z+The command to update Service Mesh Feature.    )
exceptions)util)actions)base)file_parsers)	resources)utilsc           	      \	   / nSn/ nUR                  S5      (       a  Sn[        R                  " U5      nO%UR                  c  Sn[        R
                  " USSS9nU GHV  nU(       d  U R                  U5      nU R                  R                  5       n U R                  U5      nUR                  (       a  UR                  nUR                  (       d  U R                  R                  5       Ul        [!        US5      (       a^  UR"                  bQ  UR"                  S:X  aA  U R                  R%                  U R                  R$                  R'                  S5      S	9Ul        [!        US
5      (       a  UR(                  b  U R                  R                  R+                  S5      nUR(                  S:X  a%  U R                  R                  R+                  S5      nUR(                  S:X  a%  U R                  R                  R+                  S5      nXR                  l        UR,                  b  U R                  R                  R/                  S5      n	UR,                  S:X  a&  U R                  R                  R/                  S5      n	O5UR,                  S:X  a%  U R                  R                  R/                  S5      n	XR                  l        [!        US5      (       a  UR2                  b  U R                  R                  R5                  S5      n
UR2                  S:X  a%  U R                  R                  R5                  S5      n
UR2                  S:X  a%  U R                  R                  R5                  S5      n
XR                  l        U R9                  US/U R                  R                  US95        GMY     U R:                  R=                  5       nUR                  (       a|  [>        R@                  " UR                  [        RB                  S9n[        RD                  " XR:                  5      nU R:                  RG                  US9Ul$        URK                  S5        U(       a  U RM                  XK5        gg! [        R                   a    U R                  R                  5       n GNf = f)a  Runs the update command implementation that is common across release tracks.

For membership level spec update, we will use v2alpha API to directly update
the membership feature resource.

Args:
  cmd: the release track specific command
  args: the args passed to the command
F
membershipNTpromptsearchoriginfleetFLEETtype
managementMANAGEMENT_MANUAL	automaticMANAGEMENT_AUTOMATICnot_installedMANAGEMENT_NOT_INSTALLEDMANUAL	AUTOMATICunspecified$CONTROL_PLANE_MANAGEMENT_UNSPECIFIED
config_apiCONFIG_API_UNSPECIFIEDistioCONFIG_API_ISTIOgatewayCONFIG_API_GATEWAYspec)r$   	file_path	item_typemeshfleet_default_member_config)'IsKnownAndSpecifiedr	   ParseMembershipsr*   features_baseParseMembershipsPluralMembershipResourceNamemessages_v2FeatureSpecGetMembershipFeatureapitools_exceptionsHttpNotFoundErrorMembershipFeaturer$   servicemeshServiceMeshSpechasattrr   OriginTypeValueValuesEnumr   ManagementValueValuesEnumcontrol_planeControlPlaneValueValuesEnumcontrolPlaner   ConfigApiValueValuesEnum	configApiUpdateV2messagesFeaturer   YamlConfigFileFleetDefaultMemberConfigObjectParseFleetDefaultMemberConfigV2"CommonFleetDefaultMemberConfigSpecfleetDefaultMemberConfigappendUpdate)cmdargsmembershipsresourceupdate_maskr   patch_v2existing_membership_featuremanagement_v2control_plane_v2r   floaded_configmember_configs                 *lib/surface/container/fleet/mesh/update.py_RunUpdateV2rX      s    +(+ 
l++H((.K''/H66T$K  j--j9j**,HH$'$<$<Z$H! #'',11h __<<>htX4;;#:		//00'';;GD 1 
 t\""t'B
//
)
)
C
C!#  
K	'OO++EE&( 	 
O	+OO++EE*, 	 )6%%
//
)
)
E
E  
		{	*OO++GG 	 .OO++GG68 	 +;'t\""t'B
//
)
)
B
B& 
 
G	#OO++DD" 	
 
I	%OO++DD$ 	
 (2$LLVHcoo??X?NO  V 
ll!	%% //2266M 99||M 	77]7K  45JJ{ k 00 H$'OO$E$E$G!Hs   Q99.R+*R+c                 	   / nSn/ nUR                  S5      (       a  Sn[        R                  " U5      nS/nO(UR                  c  Sn[        R
                  " USSS9nS/nU R                  5       n0 nU GHw  nU(       d  U R                  U5      nU R                  R                  5       nU R                  R                  UR                  5      R                  5        H@  u  p[        R                  " U	5      [        R                  " U5      :X  d  M5  U
(       d  M>  U
nMB     UR                   (       d  U R                  R#                  5       Ul        [%        US5      (       a^  UR&                  bQ  UR&                  S:X  aA  U R                  R)                  U R                  R(                  R+                  S	5      S
9Ul        [%        US5      (       a  UR,                  b  U R                  R"                  R/                  S5      nUR,                  S:X  a%  U R                  R"                  R/                  S5      nUR,                  S:X  a%  U R0                  R2                  R/                  S5      nXR                   l        UR4                  b  U R                  R"                  R7                  S5      nUR4                  S:X  a&  U R                  R"                  R7                  S5      nO5UR4                  S:X  a%  U R                  R"                  R7                  S5      nXR                   l        [%        US5      (       a  UR:                  b  U R                  R"                  R=                  S5      nUR:                  S:X  a%  U R                  R"                  R=                  S5      nUR:                  S:X  a%  U R                  R"                  R=                  S5      nXR                   l        XU'   GMz     U R                  RA                  U R                  RC                  U5      S9nUR                  (       a|  [D        RF                  " UR                  [        RH                  S9n[        RJ                  " XR                  5      nU R                  RM                  US9Ul'        URQ                  S5        U RS                  XE5        g)zRuns the update command implementation that is common across release tracks.

Args:
  cmd: the release track specific command
  args: the args passed to the command
Fr   membershipSpecsNTr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   )rZ   r%   r(   r*   )*r+   r	   r,   r*   r-   r.   
GetFeaturer/   rB   MembershipFeatureSpec	hubclientToPyDictrZ   itemsr   MembershipShortnamer)   ServiceMeshMembershipSpecr8   r   r9   r:   r   r;   r0   r7   r<   r=   r>   r   r?   r@   rC   ToMembershipSpecsr   rD   rE   ParseFleetDefaultMemberConfigrG   rH   rI   rJ   )rK   rL   rM   rN   rO   rT   membership_specsr   patchnamer$   r   r<   r   rU   rV   s                   rW   
_RunUpdaterg      s    +(+ 
l++H((.K$%K''/H66T$K %%K	nn!j--j9jLL..0Emm,,Q->->?EEG


"
"4
(D,D,DZ,P
Pd H ::<<99;ejtX4;;#:		||**$$88A + 
 t\""t'B
,,
0
0
J
J! 
 
K	'LL22LL& 	
 
O	+OO++EE*, 	 )jj%
,,
0
0
L
L 
 
		{	*LL22NN 	
 .LL22NN6 	
 !.jjt\""t'B
,,
0
0
I
I& 
 
G	#LL22KK" 	
 
I	%LL22KK$ 	
 (jj#(Z ]  ` 
llmm556FG  ! 
%% //2266M 77||M 	77]7K  45**[    c                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)UpdateAlphai  a=  Update the configuration of the Service Mesh Feature.

Update the Service Mesh Feature Spec of a membership.

## EXAMPLES

To update the control plane management of comma separated memberships like
`MEMBERSHIP1,MEMBERSHIP2`, run:

  $ {command} --memberships=MEMBERSHIP1,MEMBERSHIP2
    --control-plane=CONTROL_PLANE
r6   c           
         U R                  SS9nUR                  S[        SS9  UR                  S5      nUR                  5       n[        R
                  " USSS9  UR                  S	[        S
[        R                  " S	SS9S9  UR                  SS9nUR                  SS/SS9  UR                  5       nUR                  SSS/SS9  UR                  S/ SQSS9  UR                  S/ SQS[        R                  " SSS9S9  g )NTrequired--fleet-default-member-configThe path to a service-mesh.yaml configuration file.

        To enable the Service Mesh Feature with a fleet-level default
        membership configuration, run:

          $ {command} --fleet-default-member-config=/path/to/service-mesh.yamlr   helpzComponent optionsIMembership names to update, separated by commas if multiple are supplied.pluralmembership_helpz--membershipzMembership name to update.zKThe {flag_name} flag is now deprecated. Please use `--memberships` instead.warn)r   rq   action--originr   &Changing the origin of the membership.choicesrq   --config-apir    r"   &The API to use for mesh configuration.--management)r   manualr   !The management mode to update to.--control-planer   r   r   &Control plane management to update to.The {flag_name} flag is now deprecated. Please use `--management` instead. See https://cloud.google.com/service-mesh/docs/managed/provision-managed-anthos-service-meshr|   rq   rx   add_mutually_exclusive_groupadd_argumentstr	add_groupr   AddMembershipResourceArgr   DeprecationAction)parser
args_groupmembership_groupmembership_names_groupmembership_config_groupmembership_controlplane_groups         rW   ArgsUpdateAlpha.Args/  se   44d4CJ'R  	 "++ .JJL&&%	 '')((
	 (  /88$8G((	5 )  	 <<> " "..)$5 / 
 "..80 / 
 "..65((o
	 / rh   c                     [        US5      =(       a    UR                  S:H  nU(       d  [        X5        g [        X5        g Nr   r   r8   r   rX   rg   selfrL   use_fleet_default_configs      rW   RunUpdateAlpha.Run|  9     	h 	#KK7"  $4rh    N__name__
__module____qualname____firstlineno____doc__feature_namemf_namestaticmethodr   r   __static_attributes__r   rh   rW   rj   rj     s-     ,'J JX
rh   rj   c                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)UpdateGAi  a=  Update the configuration of the Service Mesh Feature.

Update the Service Mesh Feature Spec of a Membership.

## EXAMPLES

To update the control plane management of comma separated Memberships like
`membership1,membership2`, run:

  $ {command} --memberships=membership1,membership2
    --control-plane=CONTROL_PLANE
r6   c           
         U R                  SS9nUR                  S[        SS9  UR                  5       nUR                  5       n[        R
                  " USSS9  UR                  SS9nUR                  SS	/S
S9  UR                  5       nUR                  SSS/SS9  UR                  SSS/SS9  UR                  S/ SQS[        R                  " SSS9S9  g )NTrl   rn   ro   rp   rr   rs   ry   r   rz   r{   r}   r    r"   r~   r   r   r   r   r   r   r   r   rv   r   r   )r   r   r   r   membership_configs_groupr   s         rW   r   UpdateGA.Args  s/   44d4CJ'R  	 "++--JJL&&%	  09949H))	5 *  	!==? " "..)$5 / 
 "..h'0 / 
 "..65((o
	 / rh   c                     [        US5      =(       a    UR                  S:H  nU(       d  [        X5        g [        X5        g r   r   r   s      rW   r   UpdateGA.Run  r   rh   r   Nr   r   rh   rW   r   r     s+     ,'; ;z
rh   r   N)r   apitools.base.pyr   r3   &googlecloudsdk.api_lib.container.fleetr   googlecloudsdk.callioper   r   (googlecloudsdk.command_lib.anthos.commonr   *googlecloudsdk.command_lib.container.fleetr   3googlecloudsdk.command_lib.container.fleet.featuresr-   =googlecloudsdk.command_lib.container.fleet.membershipfeaturesmf_base/googlecloudsdk.command_lib.container.fleet.meshr	   rX   rg   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAUpdateCommandrj   BETAGAr   r   rh   rW   <module>r      s    2 ? 7 + ( A @ U Y Awx~D D%%++,h---w/D/D h - hV D%%**D,=,=,@,@AY}**G,A,A Y B Yrh   