
    v6                         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\R(                  5      r " S S\5      rg)zNUtilities for node pool resources in Anthos standalone clusters on bare metal.    )absolute_import)division)unicode_literals)messages)
list_pager)standalone_clusters)update_mask)arg_parsers)
exceptions)parser_extensions)gkeonprem_v1_messagesc                   b   \ 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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)_StandaloneNodePoolsClient   zFBase class for GKE OnPrem Bare Metal Standalone Node Pool 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_module	NodeTaint)selfr   taint_messagesr   
node_tainttaint_objects         Glib/googlecloudsdk/api_lib/container/gkeonprem/standalone_node_pools.py_node_taints'_StandaloneNodePoolsClient._node_taints"   sd    N$r2Ki!'')
++J7lO55EEF *     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   !BareMetalStandaloneNodePoolConfigLabelsValueAdditionalProperty)r   r   r%   additional_property_messagesr'   r(   labels_value_messages          r   _node_labels'_StandaloneNodePoolsClient._node_labels/   s    $r2K#% !'')
"))

;
;
G
G
Z
Z [  * 	99EE!= 	F 	
   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_file2_StandaloneNodePoolsClient._node_configs_from_fileE   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$ )7Constructs proto message BareMetalStandaloneNodeConfig.nodeIP r5   z,Missing field [nodeIP] in Node configs file.labelsnodeIprC   r   )r7   r   r8   _node_config_labelsr   BareMetalStandaloneNodeConfig)r   r<   node_ipkwargss       r   r9   2_StandaloneNodePoolsClient._bare_metal_node_configY   si    ooh+G++
$
8  **;??8R+HIF
 88B6BBr"   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   rG   r,   r-   )r   rC   r.   r'   r(   r/   s         r   rF   ._StandaloneNodePoolsClient._node_config_labelsi   s}    #% lln
"))

7
7
C
C
V
V W  % 	55AA!= 	B 	
   r"   c                    UR                  S5      (       d  gUR                  SS5      R                  S5      n/ nU H  nUR                  S5      n[        U5      S:w  a%  [        R                  " SR                  U5      5      eUR                  [        R                  R                  R                  US   US	   S
95        M     [        R                  R                  US9nU$ )aC  Validates and parses a standalone node label object.

Args:
  node_labels: str of key-val pairs separated by ';' delimiter.

Returns:
  If label is valid, returns a dict mapping message LabelsValue to its
  value, otherwise, raise ArgumentTypeError.
  For example,
  {
      'key': LABEL_KEY
      'value': LABEL_VALUE
  }
rC   NrB   ;=   z8Node Label [{}] not in correct format, expect KEY=VALUE.r      r&   r)   )r7   splitlenr
   ArgumentTypeErrorformatr   r   rG   r,   r-   )r   r%   input_node_labelsr.   labelkey_val_pairr/   s          r   parse_standalone_node_labels7_StandaloneNodePoolsClient.parse_standalone_node_labels~   s     ??8$$#"5;;C@#% "[[%l	\	a	++FMM!
 	

 #))

7
7
C
C
V
Vq/a W  # 	55AA!= 	B 	
   r"   c                     UR                  SS5      U R                  U5      S.nU R                  [        R                  U5      $ )r@   znode-iprB   rD   )r7   rY   _set_config_if_existsr   rG   )r   node_config_argsrI   s      r   standalone_node_config1_StandaloneNodePoolsClient.standalone_node_config   sJ     #&&y"5334DEF
 %%55v r"   c                     / n[        USS5      nU(       a)  U H#  nUR                  U R                  U5      5        M%     U$ )r3   r:   N)r   r   r^   )r   r   r:   node_config_flag_valuer<   s        r   _node_configs_from_flag2_StandaloneNodePoolsClient._node_configs_from_flag   sD    L$T>4@/+D77DE 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;_StandaloneNodePoolsClient._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   )GetFlagrh   anyvaluesr    BareMetalStandaloneKubeletConfigr   r   rI   s      r   _kubelet_config*_StandaloneNodePoolsClient._kubelet_config   sb    <<.ABd,<='+'L'L(
F 6==?==GGG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)z;Constructs proto message BareMetalStandaloneNodePoolConfig.r6   )r4   rC   taintskubeletConfigNr   )
rg   r=   rb   r0   r    ru   rq   rr   r   r+   )r   r   r:   rI   s       r   _node_pool_config,_StandaloneNodePoolsClient._node_pool_config   s    4#<#<#>>11$7l11$7l###D)##D)--d3	F 6==?>>HHH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   BareMetalStandaloneNodePoolAnnotationsValuer-   )r   r   r}   r.   r'   r(   annotation_value_messages          r   _annotations'_StandaloneNodePoolsClient._annotations   s    $r2K#% !'')
"))

5
5
F
F
Y
Y Z  * 	33DD!= 	E 	
 
 $#r"   c                     U R                  U5      U R                  U5      [        USS5      U R                  U5      S.n[        R
                  " S0 UD6$ )z5Constructs proto message BareMetalStandaloneNodePool.display_nameN)namenodePoolConfigdisplayNamer}   r   )_node_pool_namerz   r   r   r   r~   rt   s      r    _bare_metal_standalone_node_pool;_StandaloneNodePoolsClient._bare_metal_standalone_node_pool   sW     $$T*006t^T:((.	F 66@@@r"   r   N)__name__
__module____qualname____firstlineno____doc__r   	Namespacer    r0   r=   r9   rF   rY   r^   rb   rh   ru   rz   r   r   __static_attributes__r   r"   r   r   r      s    N0::  0::  , *;*E*E  (C  *) X	*;*E*E 3D3N3N 
"3"="= 
$5$?$? $$0:: $*	A3D3N3N 	Ar"   r   c                   ~  ^  \ rS rSrSrU 4S jr  SS\R                  S\R                  4S jjrS r	S\
R                  S\R                  4S	 jrS\
R                  S\R                  4S
 jrS\
R                  S\R                  4S jrS\
R                  4S jrS\
R                  S\R                  4S jrSrU =r$ )StandaloneNodePoolsClienti  zFClient for node pools in Anthos clusters on bare metal standalone API.c                 d   > [         [        U ]
  " S0 UD6  U R                  R                  U l        g )Nr   )superr   __init___clientKprojects_locations_bareMetalStandaloneClusters_bareMetalStandaloneNodePools_service)r   rI   	__class__s     r   r   "StandaloneNodePoolsClient.__init__	  s*    	
#T3=f=`` 	Mr"   location_refreturnc           	          [         R                  " UR                  5       S9n[        R                  " U R
                  USUUSS9$ )zELists Node Pools in the Anthos clusters on bare metal standalone API.)parentbareMetalStandaloneNodePoolspageSize)field
batch_sizelimitbatch_size_attribute)r   \GkeonpremProjectsLocationsBareMetalStandaloneClustersBareMetalStandaloneNodePoolsListRequestRelativeNamer   YieldFromListr   )r   r   r   	page_sizelist_reqs        r   ListStandaloneNodePoolsClient.List  sK     {{((*H ##,' r"   c                 |    [         R                  " UR                  5       S9nU R                  R	                  U5      $ )z@Gets a GKE On-Prem Bare Metal API standalone node pool resource.)r   )r   [GkeonpremProjectsLocationsBareMetalStandaloneClustersBareMetalStandaloneNodePoolsGetRequestr   r   Get)r   resource_refreqs      r   Describe"StandaloneNodePoolsClient.Describe#  s5    

u
u&&(C ==S!!r"   r   c           	          [         R                  " [         R                  " U R                  U5      U R	                  US5      S9U R                  U5      S9nU R                  R                  U5      $ )zEnrolls an Anthos On-Prem Bare Metal API standalone node pool resource.

Args:
  args: parser_extensions.Namespace, known args specified on the command
    line.

Returns:
  (Operation) The response message.
validate_only)bareMetalStandaloneNodePoolIdvalidateOnly)(enrollBareMetalStandaloneNodePoolRequestr   )r   ^GkeonpremProjectsLocationsBareMetalStandaloneClustersBareMetalStandaloneNodePoolsEnrollRequest(EnrollBareMetalStandaloneNodePoolRequest_standalone_node_pool_idrp   _standalone_node_pool_parentr   Enrollr   r   r   s      r   r    StandaloneNodePoolsClient.Enroll+  se     
x
x1@1i1i*.*G*G*MdO<2
 006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      $ )zUnenrolls an Anthos On-Prem bare metal API standalone node pool resource.

Args:
  args: parser_extensions.Namespace, known args specified on the command
    line.

Returns:
  (Operation) The response message.
allow_missingr   )allowMissingr   r   r   )rp   _standalone_node_pool_namer   `GkeonpremProjectsLocationsBareMetalStandaloneClustersBareMetalStandaloneNodePoolsUnenrollRequestr   Unenrollr   r   rI   r   s       r   r   "StandaloneNodePoolsClient.UnenrollA  sf     T?;//5T?;F
 
z
z 
C ==!!#&&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      $ )zCDeletes a GKE On-Prem Bare Metal API standalone node pool resource.r   r   ignore_errors)r   r   r   ignoreErrorsr   )r   rp   r   ^GkeonpremProjectsLocationsBareMetalStandaloneClustersBareMetalStandaloneNodePoolsDeleteRequestr   Deleter   s       r   r    StandaloneNodePoolsClient.DeleteW  st    
 //5T?;T?;T?;	F 
x
x 
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      $ )zCCreates a GKE On-Prem Bare Metal API standalone node pool resource.r   )r   r   bareMetalStandaloneNodePoolr   r   )
_node_pool_refParentr   rp   r   r   r   ^GkeonpremProjectsLocationsBareMetalStandaloneClustersBareMetalStandaloneNodePoolsCreateRequestr   Create)r   r   node_pool_refrI   r   s        r   r    StandaloneNodePoolsClient.Createg  s    ''-M&&(557T?;'+'L'L(
 *.)F)Ft)LF 
x
x 
C ==$$r"   c           	      *   [         R                  " U R                  US5      U R                  U5      [        R
                  " U[        R                  5      U R                  US5      U R                  U5      S9nU R                  R                  U5      $ )zCUpdates a GKE On-Prem Bare Metal API standalone node pool resource.r   r   )r   r   
updateMaskr   r   )
r   ]GkeonpremProjectsLocationsBareMetalStandaloneClustersBareMetalStandaloneNodePoolsPatchRequestrp   r   r	   get_update_mask4BARE_METAL_STANDALONE_NODE_POOL_ARGS_TO_UPDATE_MASKSr   r   Patchr   s      r   Update StandaloneNodePoolsClient.Updatew  s     
w
w\\$8,,T2..LL
 \\$8$($I$I%
C ==s##r"   )r   )NN)r   r   r   r   r   r   protorpc_messageMessager   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r   r   r     s    N 	$,,
 ("%#--%%,'#--'',%#--%% %*44 % $#--$$ $r"   r   N)r   
__future__r   r   r   apitools.base.protorpcliter   r   apitools.base.pyr   *googlecloudsdk.api_lib.container.gkeonpremr   r	   googlecloudsdk.callioper
   r   r   2googlecloudsdk.generated_clients.apis.gkeonprem.v1r   r   StandaloneClustersClientr   r   r   r"   r   <module>r      sS    U &  ' C ' J B / . 5 gdA!4!M!M dANA$ : A$r"   