
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ dd
l
mZ ddlmZ ddlmZ  G d dej&                        Z G d de      Zy)zPUtilities for gkeonprem API clients for Bare Metal Standalone cluster resources.    )absolute_import)division)unicode_literals)
list_pager)client)update_mask)arg_parsers)
exceptions)parser_extensions)
properties)gkeonprem_v1_messagesc                   8   e Zd ZdZdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZ	dej
                  fdZ
d Zdej
                  fd	Zd
 Zdej
                  fdZd Zd Zdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZd Zdej
                  fdZd Zdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZdej
                  fdZ dej
                  fdZ!d Z"dej
                  fd Z#dej
                  fd!Z$dej
                  fd"Z%d# Z&d$ Z'dej
                  fd%Z(d& Z)dej
                  fd'Z*dej
                  fd(Z+dej
                  fd)Z,dej
                  fd*Z-dej
                  fd+Z.dej
                  fd,Z/dej
                  fd-Z0dej
                  fd.Z1dej
                  fd/Z2dej
                  fd0Z3dej
                  fd1Z4dej
                  fd2Z5dej
                  fd3Z6dej
                  fd4Z7dej
                  fd5Z8dej
                  fd6Z9dej
                  fd7Z:dej
                  fd8Z;dej
                  fd9Z<d: Z=dej
                  fd;Z>dej
                  fd<Z?d= Z@y>)?!_BareMetalStandaloneClusterClientz<Base class for GKE OnPrem Bare Metal Standalone API clients.argsc                 P    d|j                         v ryd|j                         v ryy )Nenable_sr_iov_configTdisable_sr_iov_configF)GetSpecifiedArgsDictselfr   s     Elib/googlecloudsdk/api_lib/container/gkeonprem/standalone_clusters.py_sr_iov_config_enabledz8_BareMetalStandaloneClusterClient._sr_iov_config_enabled"   s-    !:!:!<<	 D$=$=$?	?    c                 v    d| j                  |      i}| j                  |      rt        j                  di |S y)z8Constructs proto message BareMetalStandaloneSrIovConfig.enabledN )r   IsSetmessagesBareMetalStandaloneSrIovConfigr   r   kwargss      r   _sr_iov_configz0_BareMetalStandaloneClusterClient._sr_iov_config*   s@     	4..t4F zz&44>v>>r   c                 ~    dt        |dg       i}t        |j                               rt        j                  di |S y)zAConstructs proto message BareMetalStandaloneIslandModeCidrConfig.serviceAddressCidrBlocks'island_mode_service_address_cidr_blocksNr   )getattranyvaluesr   'BareMetalStandaloneIslandModeCidrConfigr    s      r   _island_mode_cidr_configz:_BareMetalStandaloneClusterClient._island_mode_cidr_config5   sD     	#G;R%
F 6==?==GGGr   c                     | j                  |      | j                  |      d}t        |j                               rt	        j
                  di |S y)z:Constructs proto message BareMetalStandaloneNetworkConfig.)islandModeCidrsrIovConfigNr   )r*   r"   r'   r(   r    BareMetalStandaloneNetworkConfigr    s      r   _network_configz1_BareMetalStandaloneClusterClient._network_configB   sN     77=**40F
 6==?66@@@r   c                     |j                   sg S |j                   j                  dg       }|s| j                  ddd       |D cg c]  }| j                  |       }}|S c c}w )-Constructs proto message field address_pools.addressPools"--metal_lb_address_pools_from_fileMetal LB address pools file) metal_lb_address_pools_from_fileget#_raise_bad_argument_exception_error_metal_lb_address_pool)r   r   address_poolsaddress_pooladdress_pool_messagess        r   _address_pools_from_filez:_BareMetalStandaloneClusterClient._address_pools_from_fileN   s    00i99==M 
..
.

' *)L 	##L1)  
 ! s   A c                    |j                  dg       }|s| j                  ddd       |j                  dd      }|s| j                  ddd       ||j                  dd      |j                  dd      |d}t        j                  d	i |S )
DConstructs proto message BareMetalStandaloneLoadBalancerAddressPool.	addressesr3   r4   poolNavoidBuggyIPsmanualAssignr?   avoidBuggyIpsrB   r@   r   r6   r7   r   *BareMetalStandaloneLoadBalancerAddressPoolr   r:   r?   r@   r!   s        r   r8   z8_BareMetalStandaloneClusterClient._metal_lb_address_poole   s      b1I
..
.

' FD)D
..
.

' %))/4@$((>	F >>HHHr   c                    |j                   sg S g }|j                   D ]j  }|j                  t        j                  |j	                  dg       |j	                  dd       |j	                  dd       |j	                  dd                    l |S Nr?   zavoid-buggy-ipszmanual-assignr@   rC   )metal_lb_address_poolsappendr   rF   r6   r   r   r9   r:   s       r   _address_pools_from_flagz:_BareMetalStandaloneClusterClient._address_pools_from_flag   s    &&iM33

=
=$((b9(,,->E'++OTB##FD1	 4 r   c                     |j                  dd      }|s| j                  ddd       || j                  |j                  di             d}t        j                  di |S )	-Constructs proto message BareMetalNodeConfig.nodeIP /--metal_lb_load_balancer_node_configs_from_filenodeIpMetal LB Node configs filelabelsrS   rU   r   r6   r7   _node_labelsr   BareMetalNodeConfig)r   metal_lb_node_confignode_ipr!   s       r   _metal_lb_node_configz7_BareMetalStandaloneClusterClient._metal_lb_node_config   sl    "&&x4G
..
;

& ##$8$<$<Xr$JKF
 ''1&11r   c                     |j                   sg S |j                   j                  dg       }|s| j                  ddd       g }|D ]"  }|j                  | j	                  |             $ |S ),Constructs proto message field node_configs.nodeConfigsrR   rT   )-metal_lb_load_balancer_node_configs_from_filer6   r7   rK   r\   )r   r   metal_lb_node_configsmetal_lb_node_configs_messagesrZ   s        r    _metal_lb_node_configs_from_filezB_BareMetalStandaloneClusterClient._metal_lb_node_configs_from_file   s    ==i 	::>>2	
  !
..
;

& &(" 5$++

$
$%9
: !6
 *)r   c                    |j                  d      sy|j                  dd      j                  d      }g }|D ]  }|j                  d      }t        |      dk7  r$t        j                  dj                  |            |j                  t        j                  j                  j                  |d   |d	   
              t        j                  j                  |      }|S )ad  Validates and parses a 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
      }
    rU   NrQ   ;=   z8Node Label [{}] not in correct format, expect KEY=VALUE.r      keyvalueadditionalProperties)r6   splitlenr	   ArgumentTypeErrorformatrK   r   rY   LabelsValueAdditionalProperty)r   node_labelsinput_node_labelsadditional_property_messageslabelkey_val_pairlabels_value_messages          r   parse_node_labelsz3_BareMetalStandaloneClusterClient.parse_node_labels   s     ??8$#"5;;C@#% "[[%l	\	a	++FMM!
 	

 #))

&
&
2
2
E
Eq/a F  # $77CC9 D   r   c                     |j                  dd      | j                  |      d}| j                  t        j                  |      S )rO   znode-iprQ   rV   )r6   rz   _set_config_if_existsr   rY   )r   node_config_argsr!   s      r   node_configz-_BareMetalStandaloneClusterClient.node_config   sE     #&&y"5(()9:F
 %%h&B&BFKKr   c                     |j                   rt        |dg       ng }|D cg c]  }| j                  |       c}S c c}w )r^   #metal_lb_load_balancer_node_configs)r   r&   r~   r   r   node_config_flag_valuer~   s       r    _metal_lb_node_configs_from_flagzB_BareMetalStandaloneClusterClient._metal_lb_node_configs_from_flag   sT     33 	;R@  :P9O+%9O     ;c                     g }t        |di       }|sg S |j                         D ]7  }| j                  |      }|j                  t	        j
                  di |       9 |S )#Constructs proto message NodeTaint."metal_lb_load_balancer_node_taintsr   r&   items_parse_node_taintrK   r   	NodeTaintr   r   taint_messagesnode_taints
node_tainttaint_objects         r   _metal_lb_node_taintsz7_BareMetalStandaloneClusterClient._metal_lb_node_taints   se    N$ DbIKi!'')
++J7lH..>>? * r   c                    t        |di       }g }|sy|j                         D ]?  \  }}|j                  t        j                  j
                  j                  ||             A t        j                  j                  |      }|S )%Constructs proto message LabelsValue."metal_lb_load_balancer_node_labelsNri   rl   r&   r   rK   r   BareMetalNodePoolConfigrr   rs   r   r   rt   rv   rj   rk   ry   s          r   _metal_lb_labelsz2_BareMetalStandaloneClusterClient._metal_lb_labels  s    $ DbIK#% !'')
U"))

*
*
6
6
I
IU J  * $;;GG9 H   r   c                    d|j                         v r| j                  |      }n| j                  |      }|| j                  |      | j	                  |      d}t        |j                               rt        j                  di |S y)1Constructs proto message BareMetalNodePoolConfig.r`   r_   rU   taintsNr   )	r   rc   r   r   r   r'   r(   r   r   )r   r   ra   r!   s       r   (_metal_lb_load_balancer_node_pool_configzJ_BareMetalStandaloneClusterClient._metal_lb_load_balancer_node_pool_config  s    
 	8$$&	' #CCDI"CCDI -''-,,T2F 6==?--777r   c                     d| j                  |      i}t        |j                               rt        j                  di |S yzGConstructs proto message BareMetalStandaloneLoadBalancerNodePoolConfig.nodePoolConfigNr   )r   r'   r(   r   -BareMetalStandaloneLoadBalancerNodePoolConfigr    s      r   _metal_lb_node_pool_configz<_BareMetalStandaloneClusterClient._metal_lb_node_pool_config3  sB     	$GGMF 6==?CCMfMMr   c                     d|j                         v r| j                  |      }n| j                  |      }|| j                  |      d}t	        |j                               rt        j                  di |S y)z:Constructs proto message BareMetalStandaloneMetalLbConfig.r5   )r2   loadBalancerNodePoolConfigNr   )r   r<   rM   r   r'   r(   r    BareMetalStandaloneMetalLbConfig)r   r   r9   r!   s       r   _metal_lb_configz2_BareMetalStandaloneClusterClient._metal_lb_config>  sr    )T-F-F-HH33D9m33D9m%&*&E&Ed&KF
 6==?66@@@r   c                     |j                   sg S |j                   j                  dg       }|s| j                  ddd       g }|D ]"  }|j                  | j	                  |             $ |S )r1   r2    --bgp_lb_address_pools_from_fileBGP LB address pools file)bgp_lb_address_pools_from_filer6   r7   rK   _bgp_lb_address_pool)r   r   r9   r;   r:   s        r   _bgp_address_pools_from_filez>_BareMetalStandaloneClusterClient._bgp_address_pools_from_fileN  sz    ..i77;;M 
..
,

% %""4#<#<\#JK & ! r   c                    |j                  dg       }|s| j                  ddd       |j                  dd      }|s| j                  ddd       ||j                  dd      |j                  dd      |d}t        j                  d	i |S )
r>   r?   r   r   r@   NrA   rB   rC   r   rE   rG   s        r   r   z6_BareMetalStandaloneClusterClient._bgp_lb_address_poold  s      b1I
..
,

% FD)D
..
,

% %))/4@$((>	F >>HHHr   c                    |j                   sg S g }|j                   D ]j  }|j                  t        j                  |j	                  dg       |j	                  dd       |j	                  dd       |j	                  dd                    l |S rI   )bgp_lb_address_poolsrK   r   rF   r6   rL   s       r   _bgp_address_pools_from_flagz>_BareMetalStandaloneClusterClient._bgp_address_pools_from_flag  s    $$iM11

=
=$((b9(,,->E'++OTB##FD1	 2 r   c                     |j                  dd      }|s| j                  ddd       || j                  |j                  di             d}t        j                  di |S )rO   rP   rQ   ---bgp_lb_load_balancer_node_configs_from_fileBGP LB Node configs filerU   rV   r   rW   )r   bgp_lb_node_configr[   r!   s       r   _bgp_lb_node_configz5_BareMetalStandaloneClusterClient._bgp_lb_node_config  sl     $$Xr2G
..
9

$ ##$6$:$:8R$HIF
 ''1&11r   c                     |j                   sg S |j                   j                  dg       }|s| j                  ddd       g }|D ]"  }|j                  | j	                  |             $ |S )r^   r_   r   r   )+bgp_lb_load_balancer_node_configs_from_filer6   r7   rK   r   )r   r   bgp_lb_node_configsbgp_lb_node_configs_messagesr   s        r   _bgp_lb_node_configs_from_filez@_BareMetalStandaloneClusterClient._bgp_lb_node_configs_from_file  s    ;;i 	88<<2	
  
..
9

$ $& 1"))

"
"#5
6 2
 ('r   c                     |j                   rt        |dg       ng }|D cg c]  }| j                  |       c}S c c}w )r^   !bgp_lb_load_balancer_node_configs)r   r&   r~   r   s       r   _bgp_lb_node_configs_from_flagz@_BareMetalStandaloneClusterClient._bgp_lb_node_configs_from_flag  sT     11 	92>  :P9O+%9O  r   c                     g }t        |di       }|sg S |j                         D ]7  }| j                  |      }|j                  t	        j
                  di |       9 |S )r    bgp_lb_load_balancer_node_taintsr   r   r   s         r   _bgp_lb_node_taintsz5_BareMetalStandaloneClusterClient._bgp_lb_node_taints  se    N$ BBGKi!'')
++J7lH..>>? * r   c                    t        |di       }g }|sy|j                         D ]?  \  }}|j                  t        j                  j
                  j                  ||             A t        j                  j                  |      }|S )r    bgp_lb_load_balancer_node_labelsNri   rl   r   r   s          r   _bgp_lb_labelsz0_BareMetalStandaloneClusterClient._bgp_lb_labels  s    $ BBGK#% !'')
U"))

*
*
6
6
I
IU J  * $;;GG9 H   r   c                    d|j                         v r| j                  |      }n| j                  |      }|| j                  |      | j	                  |      d}t        |j                               rt        j                  di |S y)r   r   r   Nr   )	r   r   r   r   r   r'   r(   r   r   )r   r   r   r!   s       r   &_bgp_lb_load_balancer_node_pool_configzH_BareMetalStandaloneClusterClient._bgp_lb_load_balancer_node_pool_config  s    
 	6$$&	' !??E ??E +%%d+**40F 6==?--777r   c                     d| j                  |      i}t        |j                               rt        j                  di |S yr   )r   r'   r(   r   r   r    s      r   _bgp_lb_node_pool_configz:_BareMetalStandaloneClusterClient._bgp_lb_node_pool_config   sB     	$EEdKF 6==?CCMfMMr   c                     |j                   sg S |j                   j                  dg       }|s| j                  ddd       g }|D ]"  }|j                  | j	                  |             $ |S )r1   bgpPeerConfigs--bgp_lb_peer_configs_from_fileBGP LB peer configs file)bgp_lb_peer_configs_from_filer6   r7   rK   _peer_configs)r   r   peer_configspeer_configs_messagespeer_configs        r   _bgp_peer_configs_from_filez=_BareMetalStandaloneClusterClient._bgp_peer_configs_from_file  sv    --i5599:JBOL
..
+

$ #""4#5#5k#BC $ ! r   c                     |j                  dd      }|s| j                  ddd       |j                  dd      }|s| j                  ddd       |||j                  dg       d}t        j                  di |S )	z:Constructs proto message BareMetalStandaloneBgpPeerConfig.asnNr   r   	ipAddresscontrolPlaneNodes)r   r   r   r   )r6   r7   r    BareMetalStandaloneBgpPeerConfig)r   r   r   
ip_addressr!   s        r   r   z/_BareMetalStandaloneClusterClient._peer_configs  s    
//%
&C
..
+

$ d3J
..
+

$ (__-@"EF 44>v>>r   c                     |j                   sg S g }|j                   D ]Y  }|j                  t        j                  |j	                  dg       |j	                  dd       |j	                  dd                    [ |S )Nzcontrol-plane-nodesr   z
ip-address)r   r   r   )bgp_lb_peer_configsrK   r   r   r6   )r   r   r   r   s       r   _bgp_peer_configs_from_flagz=_BareMetalStandaloneClusterClient._bgp_peer_configs_from_flag9  st    ##iL//

3
3 +0Er J//%.#d; 0 r   c                 v   d|j                         v r| j                  |      }n| j                  |      }d|j                         v r| j                  |      }n| j	                  |      }|t        |dd      | j                  |      |d}t        |j                               rt        j                  di |S y)z8Constructs proto message BareMetalStandaloneBgpLbConfig.r   r   
bgp_lb_asnN)r2   r   r   r   r   )r   r   r   r   r   r&   r   r'   r(   r   BareMetalStandaloneBgpLbConfig)r   r   r9   r   r!   s        r   _bgp_lb_configz0_BareMetalStandaloneClusterClient._bgp_lb_configI  s    '4+D+D+FF77=m77=m&$*C*C*EE55d;l55d;l &t\40&*&C&CD&I&	F 6==?44>v>>r   c                     | j                  |      | j                  |      d}t        |j                               rt	        j
                  di |S y)z?Constructs proto message BareMetalStandaloneLoadBalancerConfig.)metalLbConfigbgpLbConfigNr   )r   r   r'   r(   r   %BareMetalStandaloneLoadBalancerConfigr    s      r   _load_balancer_configz7_BareMetalStandaloneClusterClient._load_balancer_configa  sN     ..t4**40F
 6==?;;EfEEr   c                     g }|sy|j                         D ]?  \  }}|j                  t        j                  j                  j                  ||             A t        j                  j	                  |      }|S )r   Nri   rl   )r   rK   r   rY   rr   rs   )r   rU   rv   rj   rk   ry   s         r   rX   z._BareMetalStandaloneClusterClient._node_labelsm  s    #% lln
U"))

&
&
2
2
E
EU F  % $77CC9 D   r   c                     |j                  dd      }|s| j                  ddd       || j                  |j                  di             d}t        j                  di |S )rO   rP   rQ   &--control_plane_node_configs_from_fileControl Plane Node configs filerU   rV   r   rW   )r   control_plane_node_configr[   r!   s       r   _control_plane_node_configz<_BareMetalStandaloneClusterClient._control_plane_node_config  sn    '++Hb9G
..
2

+ ##%))(B7
F ''1&11r   c                     |j                   sg S |j                   j                  dg       }|s| j                  ddd       g }|D ]"  }|j                  | j	                  |             $ |S )r^   r_   r   r   )$control_plane_node_configs_from_filer6   r7   rK   r   )r   r   control_plane_node_configs#control_plane_node_configs_messagesr   s        r   %_control_plane_node_configs_from_filezG_BareMetalStandaloneClusterClient._control_plane_node_configs_from_file  s     44i!%!J!J!N!Nr" &
..
2

+ +-'%?!)00

)
)*C
D &@
 /.r   c                 @    t        j                  |d|z   dz   |z         )NzMissing field [z] in )r
   BadArgumentException)r   flagfieldfiles       r   r7   zE_BareMetalStandaloneClusterClient._raise_bad_argument_exception_error  s*    

)
)%''1D8 r   c                 v    g }t        |dd      }|r'|D ]"  }|j                  | j                  |             $ |S )r^   r   N)r&   rK   r~   )r   r   node_configsr   r~   s        r   %_control_plane_node_configs_from_flagzG_BareMetalStandaloneClusterClient._control_plane_node_configs_from_flag  sG     L$T+GN/+D,,[9: 0 r   c                     g }t        |di       }|sg S |j                         D ]7  }| j                  |      }|j                  t	        j
                  di |       9 |S )r   control_plane_node_taintsr   r   r   s         r   _control_plane_node_taintsz<_BareMetalStandaloneClusterClient._control_plane_node_taints  se    N$ ;R@Ki!'')
++J7lH..>>? * r   c                    t        |di       }g }|sy|j                         D ]?  \  }}|j                  t        j                  j
                  j                  ||             A t        j                  j                  |      }|S )r   control_plane_node_labelsNri   rl   r   r   s          r   _control_plane_node_labelsz<_BareMetalStandaloneClusterClient._control_plane_node_labels  s    $ ;R@K#% !'')
U"))

*
*
6
6
I
IU J  * $;;GG9 H   r   c                     d|j                         v r| j                  |      }n| j                  |      }|| j                  |      | j	                  |      d}| j                  t        j                  |      S )r   r   r   )r   r   r   r   r   r|   r   r   )r   r   r   r!   s       r   _node_pool_configz3_BareMetalStandaloneClusterClient._node_pool_config  sv    -1J1J1LL??El??El $11$711$7F %%h&F&FOOr   c                 h    d| j                  |      i}| j                  t        j                  |      S )zGConstructs proto message BareMetalStandaloneControlPlaneNodePoolConfig.r   )r   r|   r   -BareMetalStandaloneControlPlaneNodePoolConfigr    s      r   _control_plane_node_pool_configzA_BareMetalStandaloneClusterClient._control_plane_node_pool_config  s;     	$006F %%>> r   c                     g }t        |dd      }|r>|j                         D ]+  \  }}|j                  t        j                  ||             - |S )z>Constructs proto message BareMetalStandaloneApiServerArgument.api_server_argsN)argumentrk   )r&   r   rK   r   $BareMetalStandaloneApiServerArgument)r   r   r  api_server_args_flag_valuerj   vals         r   _api_server_argsz2_BareMetalStandaloneClusterClient._api_server_args  sZ    O!(/@$!G!0668(#s99C	
 9 r   c                     | j                  |      | j                  |      d}| j                  t        j                  |      S )z?Constructs proto message BareMetalStandaloneControlPlaneConfig.)controlPlaneNodePoolConfigapiServerArgs)r  r  r|   r   %BareMetalStandaloneControlPlaneConfigr    s      r   _control_plane_configz7_BareMetalStandaloneClusterClient._control_plane_config  sL     '+&J&J'
 ..t4	F %%66 r   c                 `    dt        |dd      i}| j                  t        j                  |      S )zDConstructs proto message BareMetalStandaloneClusterOperationsConfig.enableApplicationLogsenable_application_logsN)r&   r|   r   *BareMetalStandaloneClusterOperationsConfigr    s      r   _cluster_operations_configz<_BareMetalStandaloneClusterClient._cluster_operations_config  s:     	 /H$!OF %%;;V r   c                 `    dt        |dg       i}| j                  t        j                  |      S )z>Constructs proto message BareMetalStandaloneMaintenanceConfig.maintenanceAddressCidrBlocksmaintenance_address_cidr_blocks)r&   r|   r   $BareMetalStandaloneMaintenanceConfigr    s      r   _maintenance_configz5_BareMetalStandaloneClusterClient._maintenance_config  s=     	'3R)
F %%55v r   c                 T   g }t        |dd      }|r$|D cg c]  }t        j                  |       c}S |j                  d   dk(  ryt        j
                  j                  j                  j                         }|r't        j                  |      }|j                  |      S yc c}w )z.Constructs repeated proto message ClusterUser.admin_usersN)usernameupdate)
r&   r   ClusterUsercommand_pathr   VALUEScoreaccountGetrK   )r   r   cluster_user_messagesr  
admin_usergcloud_config_core_accountdefault_admin_user_messages          r   _cluster_usersz0_BareMetalStandaloneClusterClient._cluster_users*  s    $t4K ('j 



3'  ( ",!2!2!7!7!?!?!C!C!E!#+#7#7-$  #))*DEE#s   B%c                 h    d| j                  |      i}| j                  t        j                  |      S )z'Constructs proto message Authorization.
adminUsers)r'  r|   r   Authorizationr    s      r   _authorizationz0_BareMetalStandaloneClusterClient._authorizationB  s6     	d))$/F %%h&<&<fEEr   c                 h    d| j                  |      i}| j                  t        j                  |      S )z;Constructs proto message BareMetalStandaloneSecurityConfig.authorization)r+  r|   r   !BareMetalStandaloneSecurityConfigr    s      r   _security_configz2_BareMetalStandaloneClusterClient._security_configJ  s;     	,,T2F %%22F r   c                 `    dt        |dd      i}| j                  t        j                  |      S )z=Constructs proto message BareMetalStandaloneNodeAccessConfig.	loginUser
login_userroot)r&   r|   r   #BareMetalStandaloneNodeAccessConfigr    s      r   _node_access_configz5_BareMetalStandaloneClusterClient._node_access_configT  s9     	WT<8F %%44f r   c                     | j                  |      }|j                  j                         D ]
  \  }}|||<    | j                  |      S )zEConstructs proto message AnnotationsValue for adding new annotations.)_get_current_annotationsadd_annotationsr   _dict_to_annotations_message)r   r   curr_annotationsrj   rk   s        r   _add_annotationsz2_BareMetalStandaloneClusterClient._add_annotations^  sO    44T:**002
U#s 3 ,,-=>>r   c                 >    t         j                  j                         S )zCConstructs proto message AnnotationsValue for clearing annotations.)r   BareMetalStandaloneClusterAnnotationsValuer   s     r   _clear_annotationsz4_BareMetalStandaloneClusterClient._clear_annotationsf  s    ..??AAr   c                     | j                  |      }|j                         D ci c]  \  }}||j                  vr|| }}}| j                  |      S c c}}w )zCConstructs proto message AnnotationsValue for removing annotations.)r7  r   remove_annotationsr9  )r   r   r:  rj   rk   updated_annotationss         r   _remove_annotationsz5_BareMetalStandaloneClusterClient._remove_annotationsj  sm    44T: +0022JCd--- 	U
2   ,,-@AAs   Ac                 8    | j                  |j                        S )zBConstructs proto message AnnotationsValue for setting annotations.)r9  set_annotationsr   s     r   _set_annotationsz2_BareMetalStandaloneClusterClient._set_annotationsu  s    ,,T-A-ABBr   c                     |j                   j                  j                         }| j                  |      }i }|j                  r4|j                  j
                  D ]  }|j                  ||j                  <    |S )z+Fetches the standalone cluster annotations.)CONCEPTSstandalone_clusterParseDescribeannotationsrm   rk   rj   )r   r   cluster_refcluster_responser:  
annotations         r   r7  z:_BareMetalStandaloneClusterClient._get_current_annotationsy  sl    --2288:K}}[1##(44II*+5+;+;( J r   c                    d|j                         v r| j                  |      S d|j                         v r| j                  |      S d|j                         v r| j                  |      S d|j                         v r| j	                  |      S y)z=Constructs proto message AnnotationsValue for update command.r8  clear_annotationsrA  rE  N)r   r;  r?  rC  rF  r   s     r   _update_annotationsz5_BareMetalStandaloneClusterClient._update_annotations  s    D5577""4((d7799$$T**t88::%%d++D5577""4((r   c                     g }|sy|j                         D ]?  \  }}|j                  t        j                  j                  j                  ||             A t        j                  j	                  |      }|S )z9Converts key-val pairs to proto message AnnotationsValue.Nri   rl   )r   rK   r   r=  r>  rs   )r   rL  rv   rj   rk   annotation_value_messages         r   r9  z>_BareMetalStandaloneClusterClient._dict_to_annotations_message  s    #% !'')
U"))11BBUU5 V D" * 	++<<!= 	= 	
 
 $#r   c                 J    |j                   d   dk(  r| j                  |      S y)z*Constructs proto message AnnotationsValue.r  r  N)r  rR  r   s     r   _annotationsz._BareMetalStandaloneClusterClient._annotations  s)    (%%d++r   c                    | j                  |      t        |dd      t        |dd      | j                  |      | j                  |      | j	                  |      | j                  |      | j                  |      | j                  |      | j                  |      | j                  |      | j                  |      d}| j                  t        j                  |      S )z7Constructs proto message Bare Metal Standalone Cluster.descriptionNversion)namerX  bareMetalVersionnetworkConfigloadBalancercontrolPlaneclusterOperationsmaintenanceConfigsecurityConfignodeAccessConfigrL  binaryAuthorization)_standalone_cluster_namer&   r/   r   r  r  r  r/  r5  rV  _binary_authorizationr|   r   r=  r    s      r   _bare_metal_standalone_clusterz@_BareMetalStandaloneClusterClient._bare_metal_standalone_cluster  s     --d3t]D9#D)T:--d322482248!<<TB!55d;//5 44T:((.#99$?F %%++V r   c                 F    t        |j                               r |di |S y Nr   )r'   r(   )r   config_typer!   s      r   r|   z7_BareMetalStandaloneClusterClient._set_config_if_exists  s!    
6==?"6""r   N)A__name__
__module____qualname____doc__r   	Namespacer   r"   r*   r/   r<   r8   rM   r\   rc   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rX   r   r   r7   r   r   r   r   r  r  r  r  r  r'  r+  r/  r5  r;  r?  rC  rF  r7  rR  r9  rV  rf  r|   r   r   r   r   r      s   D):)D)D 	!2!<!< 	+<+F+F 
"3"="= 
!+<+F+F !.I6+<+F+F "2"*3D3N3N *4' RL
3D3N3N 
(9(C(C  #4#>#>  *#--.	->-H-H 	#4#>#>  !/@/J/J !,I6/@/J/J "2"(1B1L1L (4
1B1L1L 
&7&A&A  !2!<!<  *#--.	+<+F+F 	!.?.I.I !(?4.?.I.I  !2!<!< 0
(9(C(C 
 &2&/#--/4

#--
->-H-H  ->-H-H  (P$5$?$? P2C2M2M #4#>#> (9(C(C ->-H-H 
&7&A&A 
!2!<!< 0F!2!<!< F#4#>#> &7&A&A ?#4#>#> ?B%6%@%@ B	B&7&A&A 	BC#4#>#> C
+<+F+F 
&7&A&A  $(0:: 1B1L1L *r   r   c                        e Zd ZdZ fdZd
dZd Zdej                  fdZ	dej                  fdZ
dej                  fdZdej                  fd	Z xZS )StandaloneClustersClientz;Client for clusters in gkeonprem bare metal standalone API.c                 b    t        t        | 
  di | | j                  j                  | _        y rh  )superrp  __init___client.projects_locations_bareMetalStandaloneClusters_service)r   r!   	__class__s     r   rs  z!StandaloneClustersClient.__init__  s'    	
"D2<V<LLOODMr   c                     t        j                  |j                               }t        j                  | j
                  |d||d      S )z<Lists Clusters in the GKE On-Prem Bare Metal Standalone API.)parentbareMetalStandaloneClusterspageSize)r   
batch_sizelimitbatch_size_attribute)r   @GkeonpremProjectsLocationsBareMetalStandaloneClustersListRequestRelativeNamer   YieldFromListrv  )r   location_refr}  	page_sizelist_reqs        r   ListzStandaloneClustersClient.List  sI    XX((*H ##+') )r   c                     t        j                  |j                               }| j                  j	                  |      S )z>Gets a GKE On-Prem Bare Metal Standalone API cluster resource.)rZ  )r   ?GkeonpremProjectsLocationsBareMetalStandaloneClustersGetRequestr  rv  r"  )r   resource_refreqs      r   rK  z!StandaloneClustersClient.Describe  s5    

R
R&&(C ==S!!r   r   c                     | j                  |      | j                  |      d}t        j                  | j	                  |      t        j
                  di |      }| j                  j                  |      S )zmEnrolls an existing bare metal standalone cluster to the GKE on-prem API within a given project and location.)
membershipbareMetalStandaloneClusterId)ry  'enrollBareMetalStandaloneClusterRequestr   )#_standalone_cluster_membership_name_standalone_cluster_idr   BGkeonpremProjectsLocationsBareMetalStandaloneClustersEnrollRequest_standalone_cluster_parent'EnrollBareMetalStandaloneClusterRequestrv  Enrollr   r   r!   r  s       r   r  zStandaloneClustersClient.Enroll  st     >>tD(,(C(CD(IF 
U
U..t4080`0` 1
1
C ==$$r   c                     | j                  |      t        |dd      t        |dd      d}t        j                  di |}| j                  j                  |      S )z5Unenrolls an Anthos on bare metal standalone cluster.allow_missingNignore_errors)rZ  allowMissingignoreErrorsr   )rd  r&   r   DGkeonpremProjectsLocationsBareMetalStandaloneClustersUnenrollRequestrv  Unenrollr  s       r   r  z!StandaloneClustersClient.Unenroll  sb     --d3ot<ot<F
 
W
W 
C ==!!#&&r   c                     | j                  |      | j                  |      j                         d}t        j                  di |}| j
                  j                  |      S )zDQuery Anthos on bare metal standalone cluster version configuration.)upgradeConfig_clusterNamery  r   )rd  _location_refr  r   NGkeonpremProjectsLocationsBareMetalStandaloneClustersQueryVersionConfigRequestrv  QueryVersionConfigr  s       r   r  z+StandaloneClustersClient.QueryVersionConfig  sa     &*%B%B4%H$$T*779F
 
a
a 
C ==++C00r   c                    | j                  |      t        |dd      t        j                  |t        j                        t        |dd      | j                  |      d}t        j                  di |}| j                  j                  |      S )z3Updates an Anthos on bare metal standalone cluster.r  Nvalidate_onlyF)rZ  r  
updateMaskvalidateOnlybareMetalStandaloneClusterr   )
rd  r&   r   get_update_mask2BARE_METAL_STANDALONE_CLUSTER_ARGS_TO_UPDATE_MASKSrf  r   AGkeonpremProjectsLocationsBareMetalStandaloneClustersPatchRequestrv  Patchr  s       r   UpdatezStandaloneClustersClient.Update  s     --d3ot<!11+PP
  ou=&*&I&I$&OF 
T
T 
C ==s##r   )NN)rj  rk  rl  rm  rs  r  rK  r   rn  r  r  r  r  __classcell__)rw  s   @r   rp  rp    sb    CP)"%*44 %',66 '
1%6%@%@ 
1$*44 $r   rp  N)rm  
__future__r   r   r   apitools.base.pyr   *googlecloudsdk.api_lib.container.gkeonpremr   r   googlecloudsdk.callioper	   r
   r   googlecloudsdk.corer   2googlecloudsdk.generated_clients.apis.gkeonprem.v1r   r   
ClientBaser   rp  r   r   r   <module>r     sP    W &  ' ' = B / . 5 * `j(9(9 jZT$@ T$r   