
    r$                     *   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KJr  \R*                  " SS5      rS!S jr " S S\R.                  5      rS"S jrS\\\\4      S\R:                  R<                  4S jrS\\\\4      S\R@                  4S jr!S r"S\\\4   S\\RF                     4S jr$S\RJ                  S\4S jr&S\\\4   S\\\4   4S jr'S\\\4   S\\\4   4S  jr(g)#z.Flags for the compute ha-controllers commands.    )messages)encoding)apis)
exceptions)concepts)	arg_utils)	yaml_data)concept_parsers)presentation_specs)
properties)yamlcomputealphac                 0    [         R                  " SU 5      $ )Nr   )r   GetMessagesModule)versions    >lib/googlecloudsdk/command_lib/compute/ha_controllers/utils.pyr   r   "   s    				7	33    c                       \ rS rSrSrSrg)NodeAffinityFileParseError&   z0Exception for invalid node affinity file format. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r   &   s    8r   r   Nc                    [         R                  R                  S5      n[        R                  R                  UR                  5       SUS9n[        R                  " SUSSS9n[        R                  " U/5      R                  U 5        g)z2Adds an HA Controller name resource_data argument.z$compute.ha_controllers.ha_controllerT)is_positionalapi_versionha_controllerzName of an HA Controller.)nameconcept_specrequired
group_helpN)r	   ResourceYAMLDataFromPathr   ResourceSpecFromYamlGetDatar   ResourcePresentationSpecr
   ConceptParserAddToParser)parserr!   ha_controller_dataresource_data_specpresentation_specs        r   AddHaControllerNameArgToParserr3   *   s     11::,  ,,55  "$K 6  )AA%,	 !2 34@@Hr   zone_configreturnc                 V   / nU  GH  nSU;  a  M  0 nSU;   a  [         R                  [         R                  R                  US   5      S9US'   SU;   aN  S[        R                  R
                  R                  R                  5       -   S-   US   l        US   /US   l	        [        U5      nU(       a  XCS'   UR                  [         R                  R                  R                  US   [         R                  " S0 UD6S	95        GM     [         R                  R                  US
9nU$ )z?Convert zone-configuration to the zoneConfigurations api field.zonezreservation-affinity)consumeReservationTypereservationAffinityreservationcompute.z/reservation-namenodeAffinities)keyvalue)additionalPropertiesr   )	_MESSAGES0HaControllerZoneConfigurationReservationAffinity%ConsumeReservationTypeValueValuesEnumr   VALUEScoreuniverse_domainGetr=   values_GetNodeAffinitiesappendHaControllerZoneConfigurationsValueAdditionalPropertyHaControllerZoneConfiguration)r4   zone_configs_parsedconfigsingle_zone_confignode_affinitiesress         r   MakeZoneConfigurationrS   ;   s_    	  fV'

D
D%.%_%_  &F  &F/0& E  ./ 
&	 $$4488:;!" 	015 =!<
018 )0O-<)*66IIv99 $ 	J 	
3 D 	66. 	7 	# 
*r   network_configc                    0 nU (       a&  [        U 5      S:  a  [        R                  " SS5      eU (       d  gU S   n SU ;   a  U S   US'   SU ;   a  U S   US	'   S
U ;   a  U S
   US'   [        R	                  [        R
                  " S0 UD6S9$ )zNConvert network-auto-configuration args to the networkConfiguration api field.   z--network-auto-configurationz,Only one network interface can be specified.Nr   z
stack-type	stackTypeaddress	ipAddresszinternal-ipv6-addressipv6Address)internalr   )lenr   InvalidArgumentExceptionr@   'HaControllerNetworkingAutoConfiguration/HaControllerNetworkingAutoConfigurationInternal)rT   network_config_parseds     r   MakeNetworkConfigurationra   k   s     N+a/

-
-&6  
!!$.^#)7)E+&. )7	)B+&../ -( 
	:	:HH ! 
; 
 r   c                 r    [        UR                  S5      (       a  UR                  UR                  l        U$ )zSet resource_data.name to the provided haController ID.

Args:
  unused_ref: An unused resource_data ref to the parsed resource_data.
  unused_args: The unused argparse namespace.
  request: The request to modify.

Returns:
  The updated request.
r#   )hasattrhaControllerResourcehaControllerr#   )
unused_refunused_argsrequests      r   SetResourceNameri      s0     W))622(/(<(<G  %	.r   rO   c                    [         R                  R                  n/ nSU ;   a  [        R                  " U S   5      nU(       d  [        S5      eU H  nU(       d  [        S5      e [        R                  " [         R                  U5      nUR                  (       d  [        S5      eUR                  5       (       a3  [        SR                  UR                  UR                  5       5      5      eUR                  U5        M     SU ;   ah  UR                  [         R                  S[        R                  R                  R                   R#                  5       -   S	-   UR$                  U S   /S
95        SU ;   ah  UR                  [         R                  S[        R                  R                  R                   R#                  5       -   S-   UR$                  U S   /S
95        SU ;   ah  UR                  [         R                  S[        R                  R                  R                   R#                  5       -   S-   UR$                  U S   /S
95        U$ ! [         a  n[        U5      eSnAff = f)z0Get node affinities from the zone configuration.znode-affinity-fileziNo node affinity labels specified. You must specify at least one label to create a sole tenancy instance.z"Empty list item in JSON/YAML file.Nz6A key must be specified for every node affinity label.z,Key [{0}] has invalid field formats for: {1}z
node-groupr;   z/node-group-name)r=   operatorrG   nodez
/node-nameznode-projectz/project)r@   )HaControllerZoneConfigurationNodeAffinityOperatorValueValuesEnumr   loadr   r   PyValueToMessage	Exceptionr=   all_unrecognized_fieldsformatrI   r   rC   rD   rE   rF   IN)rO   node_affinity_operator_enumrQ   affinities_yamlaffinitynode_affinityes          r   rH   rH      si   
 99QQ  /V#ii'; <=O&5  $()MNN, 11??
 (D
 	
 
	.	.	0	0(:AA!!=#H#H#J
 	
 ]++ $, V;;$$4488:; ! 133<() 	< 	
 v;;$$4488:; 1336N# 	< 	
 v;;$$4488:; 133>*+ 	< 	
 
[  ,(++,s   &%I
I*I%%I*	enum_typec                     SR                  S [        U R                  5        Vs/ s H  n[        R                  " U5      PM     sn5       5       5      $ s  snf )z;Converts an enum type to a comma-separated list of choices.z, c              3   &   #    U  H  nUv   M	     g 7fNr   ).0cs     r   	<genexpr>$EnumTypeToChoices.<locals>.<genexpr>   s      ! s   )joinsortednamesr   EnumNameToChoice)rz   ns     r   EnumTypeToChoicesr      sQ    	 2;//2C
D2CQ9%%a(2C
D 
  Es    Aresource_datac                 \    SU ;   a  U S   U S'   U S	 SU ;   a  SU S   ;   a  U S   S   U S'   U $ )z2Changes the API structure to the export structure.zoneConfigurationszoneConfigurationnetworkingAutoConfigurationr[   r   r   s    r   FixExportStructurer      s_     ]*)67K)LM%&*+#}4
&CD
D3@%44M/0 
r   c                 H    SU ;   a  U S   U S'   U S	 SU ;   a
  SU S   0U S'   U $ )z@Changes and completes the export structure to the API structure.r   r   r   r[   r   r   s    r   FixImportStructurer      sQ     M)*78K*LM&')*#}44>%A 4M/0 
r   )r   r}   ))r   apitools.base.protorpcliter   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr   $googlecloudsdk.command_lib.util.apisr   r	   (googlecloudsdk.command_lib.util.conceptsr
   r   googlecloudsdk.corecore_exceptionsr   r   r   r@   Errorr   r3   listdictstrrJ   rK   rS   r^   ra   ri   rm   rH   Enumr   r   r   r   r   r   <module>r      sI   5 / % , . 5 : : D G = * $ ""9g6	49!6!6 9I"-d38n%-33-`c3h(66> EtCH~ E$773 EP 3 S>&*38n 
S>
&*38n
r   