
    e>                     .   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SKJr  SSKJr  SSKJr  S rS r\R2                  \R4                  " \R6                  R8                  5       " S S\R:                  \R:                  5      5       5       r\R2                  \R4                  " \R6                  R>                  \R6                  R@                  5       " S S\R:                  \R:                  5      5       5       r!g)z+The command to update Service Mesh Feature.    )absolute_import)division)unicode_literals)
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_RunUpdateV2r[   !   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&   )r]   r(   r+   r-   )*r.   r   r/   r-   r0   r1   
GetFeaturer2   rE   MembershipFeatureSpec	hubclientToPyDictr]   itemsr   MembershipShortnamer,   ServiceMeshMembershipSpecr;   r   r<   r=   r   r>   r3   r:   r?   r@   rA   r!   rB   rC   rF   ToMembershipSpecsr
   rG   rH   ParseFleetDefaultMemberConfigrJ   rK   rL   rM   )rN   rO   rP   rQ   rR   rW   membership_specsr   patchnamer'   r   r?   r!   rX   rY   s                   rZ   
_RunUpdaterj      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
r9   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   rt   action--originr   &Changing the origin of the membership.choicesrt   --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   rt   r{   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         rZ   ArgsUpdateAlpha.Args2  se   44d4CJ'R  	 "++ .JJL&&%	 '')((
	 (  /88$8G((	5 )  	 <<> " "..)$5 / 
 "..80 / 
 "..65((o
	 / rk   c                     [        US5      =(       a    UR                  S:H  nU(       d  [        X5        g [        X5        g Nr   r   r;   r   r[   rj   selfrO   use_fleet_default_configs      rZ   RunUpdateAlpha.Run  9     	h 	#KK7"  $4rk    N__name__
__module____qualname____firstlineno____doc__feature_namemf_namestaticmethodr   r   __static_attributes__r   rk   rZ   rm   rm     s-     ,'J JX
rk   rm   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
r9   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 )NTro   rq   rr   rs   ru   rv   r|   r   r}   r~   r   r#   r%   r   r   r   r   r   r   r   r   r   ry   r   r   )r   r   r   r   membership_configs_groupr   s         rZ   r   UpdateGA.Args  s/   44d4CJ'R  	 "++--JJL&&%	  09949H))	5 *  	!==? " "..)$5 / 
 "..h'0 / 
 "..65((o
	 / rk   c                     [        US5      =(       a    UR                  S:H  nU(       d  [        X5        g [        X5        g r   r   r   s      rZ   r   UpdateGA.Run  r   rk   r   Nr   r   rk   rZ   r   r     s+     ,'; ;z
rk   r   N)"r   
__future__r   r   r   apitools.base.pyr   r6   &googlecloudsdk.api_lib.container.fleetr   googlecloudsdk.callioper   r	   (googlecloudsdk.command_lib.anthos.commonr
   *googlecloudsdk.command_lib.container.fleetr   3googlecloudsdk.command_lib.container.fleet.featuresr0   =googlecloudsdk.command_lib.container.fleet.membershipfeaturesmf_base/googlecloudsdk.command_lib.container.fleet.meshr   r[   rj   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAUpdateCommandrm   BETAGAr   r   rk   rZ   <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rk   