
    f                     X    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Z	d	 Z
d
 Zy)zDUtility methods for the `compute sole-tenancy node-groups` commands.    )absolute_import)division)unicode_literals)
exceptions)ChoiceToEnumNameNc                 0    | j                  |||dd      S )aq  Parses a node template resource and returns a resource reference.

  Args:
    resources: Resource registry used to parse the node template.
    name: The name of the node template.
    project: The project the node template is associated with.
    region: The region the node temlpate is associated with.

  Returns:
    The parsed node template resource reference.
  )projectregionzcompute.nodeTemplates)
collection)Parse)	resourcesnamer	   r
   s       Glib/googlecloudsdk/command_lib/compute/sole_tenancy/node_groups/util.pyParseNodeTemplater      s'     

62( 
 
* *    c                    |j                  | j                  r.|j                   j                  t        | j                              nd| j	                  d      r| j
                  nd| j	                  d      r| j                  nd      }|S )z2Build NodeGroupAutoscalingPolicy object from args.N	min_nodes	max_nodes)modeminNodesmaxNodes)NodeGroupAutoscalingPolicyautoscaler_modeModeValueValuesEnumr   IsSpecifiedr   r   )argsmessagesautoscaling_policys      r   BuildAutoscalingr   *   s      :: ## //CC
4//
02)-!%!1!1+!>t~~D!%!1!1+!>t~~D ; J 
r   c           	      b   |j                   dk(  r$|j                  sd}t        j                  d|      |j                   dk(  s|j                   dk(  r=|j                  r1dj	                  |j                         }t        j
                  d|      |j                   dk(  rg }|j                  D ]H  }|j                  | j                  j                  j                  || j                  |                   J | j                  | j                  j                  j                  | j                  j                  |	      
      S |j                   dk(  r0| j                  | j                  j                  j                        S | j                  | j                  j                  j                        S )z+Build ShareSettings object from parameters.projectsz@[--share-setting=projects] must be specified with [--share-with]z--share-withorganizationlocalz7List of shared projects must be empty for {} share type)	projectId)keyvalue)additionalProperties)	shareType
projectMap)r(   )share_setting
share_withr   RequiredArgumentExceptionformatInvalidArgumentExceptionappendShareSettingsProjectMapValueAdditionalPropertyShareSettingsProjectConfigShareTypeValueValuesEnumSPECIFIC_PROJECTSORGANIZATIONLOCAL)r   r   msgadditional_propertiesr	   s        r   BuildShareSettingsr:   6   s   
J&
LC

.
.~s
CC
N*
G#
C
J
JC

-
-nc
BB	:%??""

 
 
0
0
C
C77'7J D LM #
 !!"";;MM))99!6 : 8 " 9 9
 ^+!!"";;HH " K K 
		''@@FF 
  
I Ir   )NN)__doc__
__future__r   r   r   googlecloudsdk.callioper   .googlecloudsdk.command_lib.util.apis.arg_utilsr   r   r   r:    r   r   <module>r@      s*    K &  ' . K*"	Ir   