
    *                         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\	R"                  5      r " S S\5      rg)zCUtilities for node pool resources in Anthos clusters on bare metal.    )absolute_import)division)unicode_literals)
list_pager)bare_metal_clusters)update_mask)
exceptions)parser_extensions)gkeonprem_v1_messagesc                   V   \ rS rSrSrS\R                  4S jrS\R                  4S jrS\R                  4S jr	S r
S rS\R                  4S	 jrS\R                  4S
 jrS\R                  4S jrS\R                  4S jrS\R                  4S jrS\R                  4S jrSrg)_BareMetalNodePoolsClient   z1Base class for GKE OnPrem Bare Metal API clients.argsc                     / n[        US0 5      nU(       d  / $ UR                  5        H9  nU R                  U5      nUR                  [        R
                  " S0 UD65        M;     U$ )z#Constructs proto message NodeTaint.node_taints )getattritems_parse_node_taintappendmessages	NodeTaint)selfr   taint_messagesr   
node_tainttaint_objects         Glib/googlecloudsdk/api_lib/container/gkeonprem/bare_metal_node_pools.py_node_taints&_BareMetalNodePoolsClient._node_taints    sd    N$r2Ki!'')
++J7lH..>>? *     c                    [        US0 5      n/ nU(       d  gUR                  5        H;  u  pEUR                  [        R                  R
                  R                  XES95        M=     [        R                  R                  US9nU$ )%Constructs proto message LabelsValue.node_labelsNkeyvalueadditionalProperties)r   r   r   r   BareMetalNodePoolConfigLabelsValueAdditionalProperty)r   r   r#   additional_property_messagesr%   r&   labels_value_messages          r   _node_labels&_BareMetalNodePoolsClient._node_labels-   s    $r2K#% !'')
"))

*
*
6
6
I
I J  * $;;GG9 H   r    c                     UR                   (       d  / $ UR                   R                  S/ 5      nU(       d  [        R                  " SS5      e/ nU H#  nUR	                  U R                  U5      5        M%     U$ ),Constructs proto message field node_configs.nodeConfigs--node_configs_from_filez1Missing field [nodeConfigs] in Node configs file.)node_configs_from_filegetr	   BadArgumentExceptionr   _bare_metal_node_config)r   r   node_configsnode_config_messagesnode_configs        r   _node_configs_from_file1_BareMetalNodePoolsClient._node_configs_from_fileA   sw    &&i..22="EL++
$
= 
 #!!$">">{"KL $  r    c                     UR                  SS5      nU(       d  [        R                  " SS5      eUU R                  UR                  S0 5      5      S.n[        R
                  " S0 UD6$ )z-Constructs proto message BareMetalNodeConfig.nodeIP r3   z,Missing field [nodeIP] in Node configs file.labels)nodeIpr@   r   )r5   r	   r6   _node_config_labelsr   BareMetalNodeConfig)r   r:   node_ipkwargss       r   r7   1_BareMetalNodePoolsClient._bare_metal_node_configU   si    ooh+G++
$
8  **;??8R+HIF
 ''1&11r    c                     / nU(       d  gUR                  5        H;  u  p4UR                  [        R                  R                  R                  X4S95        M=     [        R                  R	                  US9nU$ )r"   Nr$   r'   )r   r   r   rC   r*   r+   )r   r@   r,   r%   r&   r-   s         r   rB   -_BareMetalNodePoolsClient._node_config_labelse   s{    #% lln
"))

&
&
2
2
E
E F  % $77CC9 D   r    c                     / n[        USS5      nU(       a)  U H#  nUR                  U R                  U5      5        M%     U$ )r1   r8   N)r   r   r:   )r   r   r8   node_config_flag_valuer:   s        r   _node_configs_from_flag1_BareMetalNodePoolsClient._node_configs_from_flagx   sD    L$T>4@/+D,,[9: 0 r    c                 X    SUR                  5       ;   a  gSUR                  5       ;   a  gg )Ndisable_serialize_image_pullsTenable_serialize_image_pullsF)GetSpecifiedArgsDict)r   r   s     r    _serialized_image_pulls_disabled:_BareMetalNodePoolsClient._serialized_image_pulls_disabled   s-    &$*C*C*EE	'4+D+D+F	Fr    c                     U R                  US5      U R                  US5      U R                  U5      S.n[        UR                  5       5      (       a  [        R
                  " S0 UD6$ g )Nregistry_pull_qpsregistry_burst)registryPullQpsregistryBurstserializeImagePullsDisabledr   )GetFlagrQ   anyvaluesr   BareMetalKubeletConfigr   r   rE   s      r   _kubelet_config)_BareMetalNodePoolsClient._kubelet_config   sb    <<.ABd,<='+'L'L(
F 6==?,,6v66r    c                 B   SUR                  5       ;   a  U R                  U5      nOU R                  U5      nUU R                  U5      U R	                  U5      U R                  U5      S.n[        UR                  5       5      (       a  [        R                  " S0 UD6$ g)z1Constructs proto message BareMetalNodePoolConfig.r4   )r2   r@   taintskubeletConfigNr   )
rP   r;   rK   r.   r   r^   rZ   r[   r   r)   )r   r   r8   rE   s       r   _node_pool_config+_BareMetalNodePoolsClient._node_pool_config   s    4#<#<#>>11$7l11$7l###D)##D)--d3	F 6==?--777r    c                    [        US0 5      n/ nU(       d  gUR                  5        H;  u  pEUR                  [        R                  R
                  R                  XES95        M=     [        R                  R                  US9nU$ )z*Constructs proto message AnnotationsValue.annotationsNr$   r'   )r   r   r   r   BareMetalNodePoolAnnotationsValuer+   )r   r   rf   r,   r%   r&   annotation_value_messages          r   _annotations&_BareMetalNodePoolsClient._annotations   s    $r2K#% !'')
"))

$
$
5
5
H
H I  *  (99JJ9  K   $#r    c           	          U R                  U5      U R                  U5      [        USS5      U R                  U5      [        USS5      S.n[        R
                  " S0 UD6$ )z+Constructs proto message BareMetalNodePool.display_nameNversion)namenodePoolConfigdisplayNamerf   bareMetalVersionr   )_node_pool_namerc   r   rj   r   rg   r]   s      r   _bare_metal_node_pool/_BareMetalNodePoolsClient._bare_metal_node_pool   sc     $$T*006t^T:((.#D)T:F %%///r    r   N)__name__
__module____qualname____firstlineno____doc__r
   	Namespacer   r.   r;   r7   rB   rK   rQ   r^   rc   rj   rt   __static_attributes__r   r    r   r   r      s    90::  0::  ( *;*E*E  (2  &*;*E*E 3D3N3N 
"3"="= 
$5$?$? $$0:: $&
0(9(C(C 
0r    r   c                      ^  \ rS rSrSrU 4S jrSS jrS rS\R                  4S jr
S\R                  4S jrS\R                  4S	 jrS\R                  4S
 jrS\R                  4S jrSrU =r$ )NodePoolsClient   z;Client for node pools in Anthos clusters on bare metal API.c                 d   > [         [        U ]
  " S0 UD6  U R                  R                  U l        g )Nr   )superr~   __init___client7projects_locations_bareMetalClusters_bareMetalNodePools_service)r   rE   	__class__s     r   r   NodePoolsClient.__init__   s)    	/4)3F3LL 	Mr    c           	          [         R                  " UR                  5       S9n[        R                  " U R
                  USUUSS9$ )z:Lists Node Pools in the Anthos clusters on bare metal API.)parentbareMetalNodePoolspageSize)field
batch_sizelimitbatch_size_attribute)r   HGkeonpremProjectsLocationsBareMetalClustersBareMetalNodePoolsListRequestRelativeNamer   YieldFromListr   )r   location_refr   	page_sizelist_reqs        r   ListNodePoolsClient.List   sI    ``((*H ##"' r    c                 |    [         R                  " UR                  5       S9nU R                  R	                  U5      $ )z5Gets a GKE On-Prem Bare Metal API node pool resource.)ro   )r   GGkeonpremProjectsLocationsBareMetalClustersBareMetalNodePoolsGetRequestr   r   Get)r   resource_refreqs      r   DescribeNodePoolsClient.Describe   s5    

Z
Z&&(C ==S!!r    r   c                     U R                  U5      U R                  US5      U R                  US5      U R                  US5      S.n[        R                  " S0 UD6nU R                  R                  U5      $ )z8Deletes a GKE On-Prem Bare Metal API node pool resource.allow_missingvalidate_onlyignore_errors)ro   allowMissingvalidateOnlyignoreErrorsr   )rs   rY   r   JGkeonpremProjectsLocationsBareMetalClustersBareMetalNodePoolsDeleteRequestr   Deleter   r   rE   r   s       r   r   NodePoolsClient.Delete   st     $$T*T?;T?;T?;	F 
]
] 
C ==$$r    c                 (   U R                  U5      nUR                  5       R                  5       U R                  US5      U R	                  U5      U R                  U5      S.n[        R                  " S0 UD6nU R                  R                  U5      $ )z8Creates a GKE On-Prem Bare Metal API node pool resource.r   )r   r   bareMetalNodePoolbareMetalNodePoolIdr   )
_node_pool_refParentr   rY   rt   _node_pool_idr   JGkeonpremProjectsLocationsBareMetalClustersBareMetalNodePoolsCreateRequestr   Create)r   r   node_pool_refrE   r   s        r   r   NodePoolsClient.Create   s    ''-M&&(557T?;!77=#11$7	F 
]
] 
C ==$$r    c                 6   U R                  US5      U R                  U5      [        R                  " U[        R                  5      U R                  US5      U R                  U5      S.n[        R                  " S0 UD6nU R                  R                  U5      $ )z8Updates a GKE On-Prem Bare Metal API node pool resource.r   r   )r   ro   
updateMaskr   r   r   )
rY   rs   r   get_update_mask)BARE_METAL_NODE_POOL_ARGS_TO_UPDATE_MASKSrt   r   IGkeonpremProjectsLocationsBareMetalClustersBareMetalNodePoolsPatchRequestr   Patchr   s       r   UpdateNodePoolsClient.Update  s     T?;$$T*!11+GG
 T?;!77=F 
\
\ 
C ==s##r    c                     U R                  U5      U R                  US5      S.n[        R                  " S0 UD6n[        R                  " UU R                  U5      S9nU R                  R                  U5      $ )z<Enrolls an Anthos On-Prem Bare Metal API node pool resource.r   )r   r   )enrollBareMetalNodePoolRequestr   r   )r   rY   r   EnrollBareMetalNodePoolRequestJGkeonpremProjectsLocationsBareMetalClustersBareMetalNodePoolsEnrollRequest_node_pool_parentr   Enroll)r   r   rE   enroll_requestr   s        r   r   NodePoolsClient.Enroll  st      $11$7T?;F <<FvFN

]
]'5%%d+C ==$$r    c                     U R                  US5      U R                  U5      U R                  US5      S.n[        R                  " S0 UD6nU R                  R                  U5      $ )z>Unenrolls an Anthos On-Prem bare metal API node pool resource.r   r   )r   ro   r   r   )rY   rs   r   LGkeonpremProjectsLocationsBareMetalClustersBareMetalNodePoolsUnenrollRequestr   Unenrollr   s       r   r   NodePoolsClient.Unenroll!  sf     T?;$$T*T?;F
 
_
_ 
C ==!!#&&r    )r   )NN)rv   rw   rx   ry   rz   r   r   r   r
   r{   r   r   r   r   r   r|   __classcell__)r   s   @r   r~   r~      sy    C"%*44 %%*44 %$*44 $ %*44 %
',66 
' 
'r    r~   N)rz   
__future__r   r   r   apitools.base.pyr   *googlecloudsdk.api_lib.container.gkeonpremr   clustersr   googlecloudsdk.callioper	   r
   2googlecloudsdk.generated_clients.apis.gkeonprem.v1r   r   ClustersClientr   r~   r   r    r   <module>r      sJ    J &  ' ' V B . 5 `h0 7 7 h0Vc'/ c'r    