
    7                         S r SSKJr  SSKJr  SSKJr  SSK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S rS rS rS rS rS rS rS rS rS rS rg)z3Helpers for the container cluster related commands.    )absolute_import)division)unicode_literalsN)util)base)admin_users)fleet)resource_args)robin)flags)	resourcesc                 <   [         R                  " U5      n[        U 5      nUR                  UR	                  5       UR
                  UR                  5       R                  5       S9n[        XBU 5        U[        R                  R                  :X  a  [        X@5        U$ )zGet cluster create request message.

Args:
  args: comand line arguments.
  release_track: release track of the command.

Returns:
  message obj, cluster create request message.
)cluster	clusterIdparent)r   GetMessagesModuleGetClusterReference3EdgecontainerProjectsLocationsClustersCreateRequestCluster
clustersIdParentRelativeNamePopulateClusterMessager   ReleaseTrackALPHAPopulateClusterAlphaMessage)argsrelease_trackmessagescluster_refreqs        :lib/googlecloudsdk/api_lib/edge_cloud/container/cluster.pyGetClusterCreateRequestr#   !   s     ##M2(#D)+DD &&!..0 	E 	#
 -d''---*	*    c                    [         R                  " U5      n[        U 5      nUR                  5       nU R                  Ul        U R                  R                  5       S:w  a  [        SU R                  -   5      eUR                  R                  U R                  R                  5       5      Ul        UR                  5       nUR                  5       Ul        XEl        U$ )zGet cluster upgrade request message.

Args:
  args: comand line arguments.
  release_track: release track of the command.

Returns:
  message obj, cluster upgrade request message.
IMMEDIATELYzUnsupported --schedule value: )r   r   r   UpgradeClusterRequestversiontargetVersionscheduleupper
ValueErrorScheduleValueValuesEnum4EdgecontainerProjectsLocationsClustersUpgradeRequestr   nameupgradeClusterRequest)r   r   r   r    upgrade_cluster_reqr!   s         r"   GetClusterUpgradeRequestr2   8   s     ##M2(#D)+ 668&*ll#	]]m+
5E
FF$$<<
--


 
 	EEG#%%'#(1	*r$   c                    UR                  5       U R                  l        UR                  /U R                  R                  l        UR
                  /U R                  R                  l        [        R                  " US5      (       a$  [        UR                  5      U R                  l        [        R                  " US5      (       a  UR                  R                  5       U R                  l        / U R                  R                  l        UR                  R!                  5        Hd  u  p4UR                  R                  R#                  5       nX5l        XEl        U R                  R                  R                  R)                  U5        Mf     [        R                  " US5      (       d9  [        R                  " US5      (       d  [        R                  " US5      (       Ga  UR+                  5       U R                  l        UR/                  5       U R                  R,                  l        UR3                  5       U R                  R,                  R0                  l        [        R                  " US5      (       a9  UR6                  U R                  R,                  R0                  R4                  l        UR;                  5       U R                  R,                  R0                  R4                  l        [        R                  " US5      (       aC  UR<                  U R                  R,                  R0                  R4                  R0                  l        [        R                  " US5      (       aC  UR@                  U R                  R,                  R0                  R4                  R0                  l!        [        R                  " US5      (       aD  URE                  5       U R                  l#        URH                  U R                  RF                  l%        [        R                  " US5      (       aD  URM                  5       U R                  l'        URP                  U R                  RN                  l%        [R        RT                  " XU 5        [V        RX                  " [[        U5      X 5        [        R                  " US5      (       a  UR\                  U R                  l/        [        R                  " US	5      (       a  UR`                  U R                  l1        [        R                  " US
5      (       aB  UR                  Re                  URf                  Ri                  5       5      U R                  l5        [        R                  " US5      (       d9  [        R                  " US5      (       d  [        R                  " US5      (       Ga  URm                  5       U R                  l7        URq                  5       U R                  Rn                  l9        [        R                  " US5      (       a/  URt                  U R                  Rn                  Rr                  l;        [        R                  " US5      (       a8  [        URx                  5      U R                  Rn                  Rr                  l=        [        R                  " US5      (       a/  UR|                  U R                  Rn                  Rr                  l?        [        R                  " US5      (       aV  URp                  R                  UR                  Ri                  5       5      U R                  Rn                  Rr                  lB        [        R                  " US5      (       av  U R                  R                  (       d  UR                  5       U R                  lC        [        R                  " UR                  5      S-   U R                  R                  lH        [        R                  " US5      (       a/  UR                  U R                  Rn                  Rr                  lJ        [        XU5        [        XU5        g)zFill the cluster message from command arguments.

Args:
  req: create cluster request message.
  messages: message module of edgecontainer cluster.
  args: command line arguments.
default_max_pods_per_nodelabelsmaintenance_window_recurrencemaintenance_window_startmaintenance_window_endcontrol_plane_kms_keyzone_storage_kms_keyexternal_lb_ipv4_address_poolsr(   release_channelcontrol_plane_node_locationcontrol_plane_node_countcontrol_plane_machine_filter&control_plane_shared_deployment_policyoffline_reboot_ttls!control_plane_node_storage_schemaN)MClusterNetworkingr   
networkingcluster_ipv4_cidrclusterIpv4CidrBlocksservices_ipv4_cidrservicesIpv4CidrBlocksr   FlagIsExplicitlySetintr4   defaultMaxPodsPerNoder   LabelsValuer5   additionalPropertiesitemsAdditionalPropertykeyvalueappendMaintenancePolicymaintenancePolicyMaintenanceWindowwindowRecurringTimeWindowrecurringWindowr6   
recurrence
TimeWindowr7   	startTimer8   endTimeControlPlaneEncryptioncontrolPlaneEncryptionr9   kmsKeyZoneStorageEncryptionzoneStorageEncryptionr:   r   SetAdminUsersr	   SetFleetProjectPathr   r;   $externalLoadBalancerIpv4AddressPoolsr(   r)   ReleaseChannelValueValuesEnumr<   r+   releaseChannelControlPlanecontrolPlaneLocallocalr=   nodeLocationr>   	nodeCountr?   machineFilter%SharedDeploymentPolicyValueValuesEnumr@   sharedDeploymentPolicysurvivabilityConfigSurvivabilityConfigjsondumpsrA   offlineRebootTtlrC   controlPlaneNodeStorageSchemaSetContainerRuntimeConfigEnableGoogleGroupAuthentication)r!   r   r   rQ   rR   vs         r"   r   r   S   s    $557#++262H2H1I#++.373J3J2K#++/
t%@AA(+D,J,J(KCKK%
tX..!))557CKK.0CKK+kk'')




&
&
9
9
;aeg	kk--44Q7	 * &EFF		"	"4)C	D	D		"	"4)A	B	B$,$>$>$@CKK!+3+E+E+GCKK!!($$& KK!!((8   'FGG

,
, 
kk##**::E 	 KK!!((88?   'ABB

'
' 
kk##**::AAK   '?@@

%
% 
kk##**::AAI t%<==)1)H)H)JCKK&040J0JCKK&&-
t%;<<(0(F(F(HCKK%/3/H/HCKK%%,HC0/5tA
t%EFF++ KK4 tY// $CKK
t%677!)!1!1!O!O""$"CKK &CDD		"	"4)C	D	D		"	"4)G	H	H  (446CKK%-^^%5CKK"  'DEE

*
* 
kk$$1   'ABB14

'
'2ckk$$.   'EFF

+
+ 
kk$$2   6  ..
>
>99??A 
kk$$;
 t%9::;;**(0(D(D(Fckk%

4**+c1 KK##4 t%HII.. KK""@ Cx0!#X6r$   c                    [         R                  " US5      (       a&  UR                  /U R                  R                  l        [         R                  " US5      (       a&  UR                  /U R                  R                  l        [         R                  " US5      (       a  UR                  U R                  l	        [        R                  " X5        [        R                  " X5        [        X5        [        X5        [         R                  " US5      (       a  [        R                   " X5        ["        R$                  " [&        R(                  R*                  5      n[         R                  " US5      (       a  [-        XU5        gg)zFilled the Alpha cluster message from command arguments.

Args:
  req: create cluster request message.
  args: command line arguments.
cluster_ipv6_cidrservices_ipv6_cidrexternal_lb_ipv6_address_poolsenable_robin_cns,control_plane_node_system_partition_size_gibN)r   rJ   r{   r   rE   clusterIpv6CidrBlocksr|   servicesIpv6CidrBlocksr}   $externalLoadBalancerIpv6AddressPoolsr
   SetSystemAddonsConfig)SetExternalLoadBalancerAddressPoolsConfigEnableClusterIsolationConfigEnableRemoteBackupConfigr   EnableRobinCNSInRequestr   r   r   r   r   &SetControlPlaneNodeSystemPartitionSizer!   r   r   s      r"   r   r      s!    t%899484J4J3KCKK0
t%9::595L5L4MCKK1
t%EFF++ KK4 %%d099$Ds)3%
t%788	!!#,##D$5$5$;$;<(

:  +3h?r$   c                     [         R                  " U S5      (       aU  [         R                  " U S5      (       a9  [         R                  " U S5      (       d  [         R                  " U S5      (       a  gg)zIdentify if the command is creating LCP cluster.

Args:
  args: command line arguments.

Returns:
  Boolean, indication of LCP cluster.
r=   r>   r;   external_lb_address_poolsTFr   rJ   r   s    r"   IsLCPClusterr      s\     &CDD

#
#D*D
E
E

#
#D*J
K
K&&t-HII 	r$   c                 >    [         R                  " U S5      (       a  gg)zIdentify if the command is requesting an offline credential for LCP cluster.

Args:
  args: command line arguments.

Returns:
  Boolean, indication of requesting offline credential.
offline_credentialTFr   r   s    r"   IsOfflineCredentialr      s     t%9::	r$   c                     [         R                  R                  U R                  R                  R                  5       R                  5       SS9$ )zyGet edgecontainer cluster resources.

Args:
  args: command line arguments.

Returns:
  edgecontainer cluster resources.
z)edgecontainer.projects.locations.clusters)
collection)r   REGISTRYParseRelativeNameCONCEPTSr   Parser   r   s    r"   r   r      sD     
			-	-
mm!!#002< 
. 
 r$   c                     [         R                  " U5      nU R                  R                  UR                  R
                  R                  :X  a  U R                  R                  b   gg)zValidate cluster create request message.

Args:
  req: Create cluster request message.
  release_track: Release track of the command.

Returns:
  Single string of error message.
NzSInvalid Argument: REGULAR release channel does not support specification of version)r   r   r   rg   r   rf   REGULARr)   )r!   r   r   s      r"   ValidateClusterCreateRequestr     s[     ##M2(	kk  				7	7	?	?@
++
#
#
/	$ 
r$   c                 
   [         R                  " US5      (       a  UR                  5       U R                  l        UR
                  R                  5       S:X  a:  UR                  R                  R                  U R                  R                  l	        gUR
                  R                  5       S:X  a:  UR                  R                  R                  U R                  R                  l	        g[        SUR
                  -   5      eg)zSet container runtime config in the cluster request message.

Args:
  req: Create cluster request message.
  args: Command line arguments.
  messages: Message module of edgecontainer cluster.
container_default_runtime_classGVISORRUNCz5Unsupported --container_default_runtime_class value: N)r   rJ   ContainerRuntimeConfigr   containerRuntimeConfigr   r+   &DefaultContainerRuntimeValueValuesEnumr   defaultContainerRuntimer   r,   r   s      r"   rw   rw   %  s     t%FGG)1)H)H)JCKK&++113x?

)
)
P
P
W
W 
kk((@ 
	-	-	3	3	5	?

)
)
P
P
U
U 
kk((@ 
A001  Hr$   c                 ,   [         R                  " US5      (       ax  UR                  R                  5       S:X  a  SU R                  l        gUR                  R                  5       S:X  a  SU R                  l        g[        SUR                  -   5      eg)zSet secure cluster isolation config in the cluster request message.

Args:
 req: Create cluster request message.
 args: Command line arguments.
enable_cluster_isolationTRUETFALSEFz.Unsupported --enable_cluster_isolation value: N)r   rJ   r   r+   r   enableClusterIsolationr,   r!   r   s     r"   r   r   >  s     t%?@@$$**,6+/ckk(		&	&	,	,	.'	9+0ckk(
:))*  Ar$   c                     [         R                  " US5      (       aE  UR                  5       U R                  l        UR
                  U R                  R                  l        gg)zSet Google Group authentication config in the cluster request message.

Args:
 req: Create cluster request message.
 args: Command line arguments.
 messages: Message module of edgecontainer cluster.
"enable_google_group_authenticationN)r   rJ   GoogleGroupAuthenticationConfigr   googleGroupAuthenticationr   enabler   s      r"   rx   rx   R  sS     t%IJJ002 KK) 	// KK))0	 Kr$   c                 t    [         R                  " US5      (       a  UR                  U R                  l        gg)zSet remote backup config in the cluster request message.

Args:
 req: Create cluster request message.
 args: Command line arguments.
enable_remote_backupN)r   rJ   r   r   enableRemoteBackupr   s     r"   r   r   c  s/     t%;<<%)%>%>CKK" =r$   c                    UR                   S:X  aD  UR                  R                  R                  U R                  R
                  R                  l        gUR                   S:X  aD  UR                  R                  R                  U R                  R
                  R                  l        g[        SUR                   -   S-   5      e)zSet control plane node system partition size in the cluster request message.

Args:
 req: Create cluster request message.
 args: Command line arguments.
 messages: Message module of edgecontainer cluster.
d   i,  zBUnsupported --control_plane_node_system_partition_size_gib value: z; valid values are 100 and 300.N)
r   rj   2ControlPlaneNodeSystemPartitionSizeValueValuesEnumSYSTEM_PARTITION_GIB_SIZE100r   ri   rk   #controlPlaneNodeSystemPartitionSizeSYSTEM_PARTITION_GIB_SIZE300r,   r   s      r"   r   r   o  s     
66#=IIff KK""F 88C?IIff KK""F L

;
;	<
+	, r$   ) __doc__
__future__r   r   r   rs   +googlecloudsdk.api_lib.edge_cloud.containerr   googlecloudsdk.callioper   /googlecloudsdk.command_lib.edge_cloud.containerr   r	   r
   r   googlecloudsdk.command_lib.runr   googlecloudsdk.corer   r#   r2   r   r   r   r   r   r   rw   r   rx   r   r    r$   r"   <module>r      sr    : &  '  < ( G A I A 0 ).6i7X@:*.2(1"	?r$   