
                             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Zdeeeef      dej&                  j(                  fdZd Zdej.                  defdZy
)z.Flags for the compute ha-controllers commands.    )messages)concepts)	arg_utils)	yaml_data)concept_parsers)presentation_specs)
properties)compute_alpha_messagesNc                    t         j                  j                  d      }t        j                  j                  |j                         d|      }t        j                  d|dd      }t        j                  |g      j                  |        y)z-Adds an HA Controller name resource 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_specpresentation_specs        >lib/googlecloudsdk/command_lib/compute/ha_controllers/utils.pyAddHaControllerNameArgToParserr       s     11::, ''00  "$K 1 - )AA ,	 !2 34@@H    zone_configreturnc                 h   g }| D ]	  }d|vr	i }d|v rt        j                  t         j                  j                  |d               |d<   d|v rNdt        j                  j
                  j                  j                         z   dz   |d   _        |d   g|d   _	        d|v rt        j                  |d   	      |d
<   |j                  t         j                  j                  j                  |d   t        j                  di |              t         j                  j                  |      }|S )z?Convert zone-configuration to the zoneConfigurations api field.zonezreservation-affinity)consumeReservationTypereservationAffinityreservationzcompute.z/reservation-nameznode-affinity)operatornodeAffinity)keyvalue)additionalProperties )r
   0HaControllerZoneConfigurationReservationAffinity%ConsumeReservationTypeValueValuesEnumr	   VALUEScoreuniverse_domainGetr+   values)HaControllerZoneConfigurationNodeAffinityappendHaControllerZoneConfigurationsValueAdditionalPropertyHaControllerZoneConfiguration)r"   zone_configs_parsedconfigsingle_zone_configress        r   MakeZoneConfigurationr@   ,   sn    	  fV'
 
Q
Q%;%l%l  &S  &S/0& ./ 
&	 $$4488:;!" 	015 =!<
018 & 
 
J
Jo. (
 ++CCVVv(FF $ 	W 	
7 H 	++CC. 	D 	# 
*r!   c                 h    t        |j                  d      r|j                  |j                  _        |S )zSet resource.name to the provided haController ID.

  Args:
    unused_ref: An unused resource ref to the parsed resource.
    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   SetResourceNamerH   ^   s-     W))62(/(<(<G  %	.r!   	enum_typec                     dj                  d t        | j                         D cg c]  }t        j                  |       c}      D              S c c}w )z;Converts an enum type to a comma-separated list of choices.z, c              3       K   | ]  }|  y wNr.   ).0cs     r   	<genexpr>z$EnumTypeToChoices.<locals>.<genexpr>p   s      ! s   )joinsortednamesr   EnumNameToChoice)rI   ns     r   EnumTypeToChoicesrU   n   sQ    	 2;//2C
D2CQ9%%a(2C
D 
  Es   ArL   )__doc__apitools.base.protorpcliter    googlecloudsdk.calliope.conceptsr   $googlecloudsdk.command_lib.util.apisr   r   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.corer	   3googlecloudsdk.generated_clients.apis.compute.alphar
   r    listdictstrr8   r9   r@   rH   EnumrU   r.   r!   r   <module>ra      ss    5 / 5 : : D G * VI"/d38n%/((@@/d  3 r!   