
    &                         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 rS	 rS
 rS rS rS rS rS rS rg)z5Helpers for the container node pool related commands.    )util)base)
exceptions)flags)labels_util)	resourcesc                     [         R                  R                  U R                  R                  R                  5       R                  5       SS9$ )z}Get edgecontainer node pool resources.

Args:
  args: command line arguments.

Returns:
  edgecontainer node pool resources.
z3edgecontainer.projects.locations.clusters.nodePools)
collection)r   REGISTRYParseRelativeNameCONCEPTS	node_poolParseRelativeName)argss    ;lib/googlecloudsdk/api_lib/edge_cloud/container/nodepool.pyGetNodePoolReferencer      sD     
			-	-
mm##%224F 
. 
     c                     [         R                  " U5      nUR                  U R                  R                  R                  5       R                  5       S9nU$ )zGet node pool get request message.

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

Returns:
  message obj, node pool get request message.
)name)r   GetMessagesModule9EdgecontainerProjectsLocationsClustersNodePoolsGetRequestr   r   r   r   )r   release_trackmessagesreqs       r   GetNodePoolGetRequestr   (   sP     ##M2(JJ==""((*779 	K 	# 
*r   c                 <   [         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 node pool create request message.

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

Returns:
  message obj, node pool create request message.
)nodePool
nodePoolIdparent)r   r   r   <EdgecontainerProjectsLocationsClustersNodePoolsCreateRequestNodePoolnodePoolsIdParentr   PopulateNodePoolCreateMessager   ReleaseTrackALPHA"PopulateNodePoolAlphaCreateMessage)r   r   r   node_pool_refr   s        r   GetNodePoolCreateRequestr*   9   s     ##M2(&t,-MM  "**!!#002 	N 	#
  t4d''---&s1	*r   c                    [         R                  " U5      nUR                  U R                  R                  R                  5       R                  5       UR                  5       S9n/ n[        XCXU5        SR                  U5      Ul
        U$ )zGet node pool update request message.

Args:
  args: comand line arguments.
  release_track: release track of the command.
  existing_node_pool: existing node pool.

Returns:
  message obj, node pool update request message.
)r   r   ,)r   r   ;EdgecontainerProjectsLocationsClustersNodePoolsPatchRequestr   r   r   r   r"   PopulateNodePoolUpdateMessagejoin
updateMask)r   r   existing_node_poolr   r   update_mask_piecess         r   GetNodePoolUpdateRequestr3   P   s     ##M2(LL==""((*779  " 	M 	# 	T/A 88./#.	*r   c                    [        UR                  5      U R                  l        UR                  U R                  l        [        R                  " US5      (       a  UR                  U R                  l	        [        R                  " US5      (       aD  UR                  5       U R                  l        UR                  U R                  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      (       Ga  UR/                  5       U R                  l        UR.                  R                  5       U R                  R0                  l        / U R                  R0                  R                   l        UR2                  R%                  5        Hn  u  p4UR.                  R                  R'                  5       nX5l        XEl        U R                  R0                  R                   R"                  R-                  U5        Mp     [        R                  " US5      (       a`  U R                  R0                  (       d  UR/                  5       U R                  l        UR4                  U R                  R0                  l        gg)zFill the node pool message from command arguments.

Args:
  req: create node pool request message.
  messages: message module of edgecontainer node pool.
  args: command line arguments.
machine_filterlocal_disk_kms_keylabelsnode_labelsnode_storage_schemaN)int
node_countr   	nodeCountnode_locationnodeLocationr   FlagIsExplicitlySetr5   machineFilterLocalDiskEncryptionlocalDiskEncryptionr6   kmsKeyr"   LabelsValuer7   additionalPropertiesitemsAdditionalPropertykeyvalueappend
NodeConfig
nodeConfigr8   r9   nodeStorageSchema)r   r   r   rH   rI   vs         r   r%   r%   h   sH    t/#,,"00#,,
t%566!%!4!4CLL
t%9::'/'C'C'ECLL$.2.E.ECLL$$+
tX.."++779CLL/1CLL,kk'')




'
'
:
:
<aeg	ll..55a8	 *
 t]33&113CLL%-%8%8%D%D%FCLL":<CLL""7&&,,.




)
)
<
<
>aeg	ll$$99@@C	 /
 t%:;;<<"" ( 3 3 5cll040H0HCLL- <r   c                 &   [         R                  " US5      (       au  [        R                  " [        R
                  R                  5      nU R                  R                  (       d  UR                  5       U R                  l        [        XU5        gg)zFill the Alpha create node pool message from command arguments.

Args:
  req: create node pool request message.
  args: command line arguments.
node_system_partition_size_gibN)r   r?   r   r   r   r&   r'   r   rL   rK   SetNodeSystemPartitionSizer   r   r   s      r   r(   r(      sf     t%EFF%%d&7&7&=&=>H<<"" ( 3 3 5clls(3	 Gr   c                 V   [         R                  " US5      (       a3  [         R                  " US5      (       a  [        R                  " SS5      e[         R                  " US5      (       aL  UR	                  S5        UR                  5       U R                  l        SU R                  R                  l        g[         R                  " US5      (       aV  UR	                  S5        UR                  5       U R                  l        UR                  U R                  R                  l        gg)zFilled the Alpha node pool message from command arguments.

Args:
  req: create node pool request message.
  messages: message module of edgecontainer node pool.
  update_mask_pieces: update masks.
  args: command line arguments.
use_google_managed_keyr6   .--use-google-managed-key, --local-disk-kms-key$cannot be specified at the same timerB    N)
r   r?   r   InvalidArgumentExceptionrJ   rA   r   rB   rC   r6   )r   r   r2   r   s       r   "PopulateNodePoolUpdateAlphaMessagerY      s     
$ !!$(<==

-
-8.  t%=>>34'/'C'C'ECLL$.0CLL$$+

t%9::34'/'C'C'ECLL$.2.E.ECLL$$+
	 ;r   c                 V   [         R                  " US5      (       a,  UR                  S5        UR                  U R                  l        [         R                  " US5      (       a5  UR                  S5        [        UR                  5      U R                  l        [        R                  " U5      n[        R                  " U5      nUR                  R                  n[        R                  " XVUR                  S9R!                  XtR"                  5      nUR$                  (       a,  UR                  S5        UR"                  U R                  l        [         R                  " US5      (       Ga  UR                  S5        UR'                  5       U R                  l        UR&                  R                  5       U R                  R(                  l        / U R                  R(                  R"                  l        UR,                  R/                  5        Hn  u  pUR&                  R                  R1                  5       nXl        Xl        U R                  R(                  R"                  R*                  R                  U5        Mp     [         R                  " US	5      (       a3  [         R                  " US
5      (       a  [6        R8                  " SS5      e[         R                  " US	5      (       aK  UR                  S5        UR;                  5       U R                  l        SU R                  R<                  l        [         R                  " US
5      (       aV  UR                  S5        UR;                  5       U R                  l        UR@                  U R                  R<                  l        gg)a  Fill the node pool message from command arguments.

Args:
  req: update node pool request message.
  messages: message module of edgecontainer node pool.
  args: command line arguments.
  update_mask_pieces: update mask pieces.
  existing_node_pool: existing node pool.
r5   r@   r;   r<   )	additionssubtractionsclearr7   r8   znodeConfig.labelsrT   r6   rU   rV   rB   rW   N)!r   r?   rJ   r5   r   r@   r:   r;   r<   r   GetUpdateLabelsDictFromArgsGetRemoveLabelsListFromArgsr"   rD   Diffclear_labelsApplyr7   needs_updaterK   rL   rE   r8   rF   rG   rH   rI   r   rX   rA   rB   rC   r6   )r   r   r   r2   r1   
add_labelsremove_labels
value_typelabel_update_resultrH   rI   rN   s               r   r.   r.      s    t%566o.!%!4!4CLL
t\22k* 1CLL66t<*99$?-  ,,*#((d>O>O	E*//0  %%h'-44CLL
t]3312&113CLL%-%8%8%D%D%FCLL":<CLL""7&&,,.




)
)
<
<
>aeg	ll$$99@@C	 /
 
$ !!$(<==

-
-8.  t%=>>34'/'C'C'ECLL$.0CLL$$+
t%9::34'/'C'C'ECLL$.2.E.ECLL$$+ ;r   c                 `   UR                   S:X  a:  UR                  R                  R                  U R                  R
                  l        gUR                   S:X  a:  UR                  R                  R                  U R                  R
                  l        g[        SUR                   -   S-   5      e)zSet node system partition size in the node pool request message.

Args:
 req: Create node pool request message.
 args: Command line arguments.
 messages: Message module of edgecontainer node pool.
d   i,  z4Unsupported --node_system_partition_size_gib value: z; valid values are 100 and 300.N)	rP   rK   &NodeSystemPartitionSizeValueValuesEnumSYSTEM_PARTITION_GIB_SIZE100r   rL   nodeSystemPartitionSizeSYSTEM_PARTITION_GIB_SIZE300
ValueErrorrR   s      r   rQ   rQ      s     
((C/BB__ LL3 **c1BB__ LL3 >

-
-	.
+	, r   N)__doc__+googlecloudsdk.api_lib.edge_cloud.containerr   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.runr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   r*   r3   r%   r(   rY   r.   rQ    r   r   <module>rv      sM    < < ( . 0 < )".0#IL483Flr   