
    m                         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rSrS rS rS rS rS rSS jrS rS rS rS rS rS r S r!S r"g)z8Shared resource flags for edge-cloud container commands.    )absolute_import)division)unicode_literals)util)messages)
exceptions)concepts)deps)concept_parsers)
propertiessystemAddonsConfig externalLoadBalancerAddressPoolsc                  ,    [         R                  " SSS9$ )NclusterzCluster of the {resource}.name	help_textr	    ResourceParameterAttributeConfig     Dlib/googlecloudsdk/command_lib/edge_cloud/container/resource_args.pyClusterAttributeConfigr   !   s    		2	2 <
> >r   c                  ,    [         R                  " SSS9$ )Nlocationz)Google Cloud location for the {resource}.r   r   r   r   r   LocationAttributeConfigr   &   s    		2	2!L
N Nr   c                     [         R                  " S5      [         R                  " [        R                  R
                  R                  5      /n [        5       nXl        [        R                  " SSU[        R                  S9$ )z6Gets the location resource spec for listing resources.
--locationz edgecontainer.projects.locationsr   )resource_namelocationsId
projectsId)r
   ArgFallthroughPropertyFallthroughr   VALUESedge_containerr   r   fallthroughsr	   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIG)r&   configs     r   GetLocationsListingResourceSpecr*   +   sn    
 ,'
z00??HHI	, #$&$			(::	
< <r   c                  n    [         R                  " SS[        5       [        5       [         R                  S9$ )Nz)edgecontainer.projects.locations.clustersr   )r   
clustersIdr    r!   )r	   r'   r   r   r(   r   r   r   GetClusterResourceSpecr-   A   s0    			1'))+::
< <r   c                     [         R                  R                  S[        5       SR	                  S5      SS9R                  U 5        g)zzAdds a resource argument for an Edge Container location.

Args:
  parser: The argparse parser to add the resource arg to.
r   zEdge Container location {}.zto listFrequiredN)r   ConceptParserForResourcer*   formatAddToParser)parsers    r   (AddLocationOptionalResourceArgForListingr6   J   sC     ++%'#**95	 ,  "k&)r   c                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)zAdds a resource argument for an Edge Container cluster.

Args:
  parser: The argparse parser to add the resource arg to.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, whether the argument is positional or not.
r   z	--clusterzEdge Container cluster {}.Tr/   N)r   r1   r2   r-   r3   r4   )r5   verb
positionalr   s       r   AddClusterResourceArgr:   W   sL     !k$++
"))$/	 ,  ![(r   c                  ,    [         R                  " SSS9$ )NnodePoolzNode pool of the {resource}.r   r   r   r   r   NodePoolAttributeConfigr=   g   s    		2	2!?
A Ar   c            	          [         R                  " SS[        5       [        5       [	        5       [         R
                  S9$ )Nz3edgecontainer.projects.locations.clusters.nodePoolsz	node pool)r   r,   nodePoolsIdr    r!   )r	   r'   r   r=   r   r(   r   r   r   GetNodePoolResourceSpecr@   l   s6    			;'))+)+::
< <r   c                     Sn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)zAdds a resource argument for an Edge Container node pool.

Args:
  parser: The argparse parser to add the resource arg to.
  verb: str, the verb to describe the resource, such as 'to update'.
	node_poolzEdge Container node pool {}.Tr/   N)r   r1   r2   r@   r3   r4   )r5   r8   r   s      r   AddNodePoolResourceArgrC   v   sH     
$++
$++D1	 ,  ![(r   c                    U R                   R                  5       n[        R                  " U5      nU R                  n [
        R                  " U[           UR                  5      nXQR                   l        g! [
        R                  [        [        4 aS  n[        R                  " SSR                  UR                  (       a  UR                  S   5      5      eU5      5      eSnAff = f)zsProcesses the cluster.system_addons_config.

Args:
  args: command line arguments.
  req: API request to be issued
z--system-addons-config'{}'r   N)calliope_commandReleaseTrackr   GetMessagesModulesystem_addons_configmessages_utilDictToMessageWithErrorCheckGDCE_SYS_ADDONS_CONFIGSystemAddonsConfigDecodeErrorAttributeErrorKeyErrorr   InvalidArgumentExceptionr3   argsr   r   )rR   reqrelease_trackmsgsdatarI   errs          r   ProcessSystemAddonsConfigrX      s     ''446-				.$		"	"$;(DD#$d&=&=? $8++ 	 
#
#^X	> ;

-
- sxx9; ;589; ;;s   (A7 7C)AC$$C)c                 H    U R                  S5      (       a  [        X5        gg)zSets the cluster.system_addons_config if specified.

Args:
  args: command line arguments.
  request: API request to be issued
rI   N)IsKnownAndSpecifiedrX   rR   requests     r   SetSystemAddonsConfigr]      s#     
455d, 6r   c                     [        5       nU  H>  nSU;   d  M  US   (       d  M  US   U;   a
  SUS    3s  $ UR                  US   5        M@     g)a  Checks for unique address pool names in the given list of dictionaries.

Args:
  external_lb_address_pools: A list of dictionaries representing
  ExternalLoadBalancerPool messages.

Returns:
  str: An error message if a duplicate address pool name is found,
  otherwise None.
addressPoolzDuplicate address pool name: N)setadd)external_lb_address_poolsaddress_pool_setpools      r   CheckAddressPoolNameUniquenessre      sa     U'dm!4!4	m	 0	0.tM/B.CDD4./	 ( 
r   c                    U R                   R                  5       n[        R                  " U5      nU R                  nU(       d  gUR                  [        5      nU(       d  g[        U5      nU(       a  [        R                  " SSU 35      e/ n U H4  n[        R                  " XR                  5      n	UR                  U	5        M6     U(       a  XqR&                  l        gg! [        R                  [        [         4 aS  n[        R                  " SSR#                  UR$                  (       a  UR$                  S   5      5      eU5      5      eSnAff = f)zProcesses the cluster.externalLoadBalancerAddressPools.

Args:
  args: command line arguments.
  req: API request to be issued
Nz--external-lb-address-poolszDuplicate address pool found: rE   r   )rF   rG   r   rH   rb   getGDCE_EXTERNAL_LB_CONFIGre   r   rQ   rJ   rK   ExternalLoadBalancerPoolappendrN   rO   rP   r3   rR   r   r   )
rR   rS   rT   rU   lbdatapoolsrW   mpoolsrd   mpools
             r   -ProcessExternalLoadBalancerAddressPoolsConfigro      s)    ''446-				.$))&	

**,
-%	
&u-#

-
-%
(. 
 &;77
--/emmE  39KK0 	 
#
#^X	> ;

-
-%sxx9; ;589; ;;s   :C$ $EAEEc                 H    U R                  S5      (       a  [        X5        gg)zSets the cluster.external_lb_address_pools if specified.

Args:
  args: command line arguments.
  request: API request to be issued
rb   N)rZ   ro   r[   s     r   )SetExternalLoadBalancerAddressPoolsConfigrq      s#     
9::1$@ ;r   N)T)#__doc__
__future__r   r   r   +googlecloudsdk.api_lib.edge_cloud.containerr   googlecloudsdk.api_lib.utilr   rJ   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr	   r
   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   rL   rh   r   r   r*   r-   r6   r:   r=   r@   rC   rX   r]   re   ro   rq   r   r   r   <module>rz      s~    ? &  ' < A . 5 1 D *- < >
N
<,<
*) A
<)8,	-.%:P	Ar   