
    6                        S r SSKJr  SSKJr  SSKJr  SSK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S jrSS jrS rS rS rS rS rS rS rS r \	RB                  " \	RD                  RF                  \	RD                  RH                  \	RD                  RJ                  5       " S S\	RL                  5      5       r'g)zValidate URL maps command.    )absolute_import)division)unicode_literalsN)base_classes)base)
exceptions)util)
properties)yaml_validator)
console_ioc                      SSSS.$ )NzValidate a URL map.z        Runs static validation for the UrlMap.
        In particular, the tests of the provided UrlMap will be run.
        Calling this method does NOT create or update the UrlMap.
        zf        A URL map can be validated by running:

          $ {command} --source=<path-to-file>
        )briefDESCRIPTIONEXAMPLES r       (lib/surface/compute/url_maps/validate.py_DetailedHelpr   !   s      
 r   c                     U [         R                  R                  :X  a  gU [         R                  R                  :X  a  gg)z3Returns the API version based on the release track.alphabetav1)r   ReleaseTrackALPHABETA)release_tracks    r   _GetApiVersionr   4   s3    d''---))...	r   c                 B    [         R                  " S[        U 5      SUS9$ )z!Returns the resource schema path.computeUrlMapfor_help)export_utilGetSchemaPathr   )r   r"   s     r   _GetSchemaPathr%   =   s%    		"	".8
M Mr   c                 p    SR                  U5      nU R                  S[        R                  " U5      SS9  g )Na  Path to a YAML file containing configuration export data.
        The YAML file must not contain any output-only fields. Alternatively,
        you may omit this flag to read from standard input. For a schema
        describing the export/import format, see: {}.
      z--sourceF)helprequired)formatadd_argumenttextwrapdedent)parserschema_path	help_texts      r   _AddSourceFlagr0   C   s>    
 &
	 
 	xy1E  Cr   c                 &    U R                  SSSS9  g )Nz--global
store_truezIf set, the URL map is global.)actionr'   r*   r-   s    r   _AddGlobalFlagr6   M   s    ,L  Nr   c                 $    U R                  SSS9  g )Nz--regionz"Region of the URL map to validate.)r'   r4   r5   s    r   _AddRegionFlagr8   R   s    j'KLr   c                 P    U R                  5       n[        U5        [        U5        g N)add_mutually_exclusive_groupr6   r8   )r-   scopes     r   _AddScopeFlagsr=   V   s     

-
-
/%r   c                 0    SnU R                  SSS/USS9  g)z!Add --load-balancing-scheme flag.a`    Specifies the load balancer type this validation request is for. Use
  `EXTERNAL_MANAGED` for global external Application Load Balancer. Use
  `EXTERNAL` for classic Application Load Balancer.

  Other load balancer types are not supported. For more information, refer to
  [Choosing a load balancer](https://cloud.google.com/load-balancing/docs/choosing-load-balancer/).

  If unspecified, the load balancing scheme will be inferred from the backend
  service resources this URL map references. If that can not be inferred (for
  example, this URL map only references backend buckets, or this URL map is
  for rewrites and redirects only and doesn't reference any backends),
  `EXTERNAL` will be used as the default type.

  If specified, the scheme must not conflict with the load balancing
  scheme of the backend service resources this URL map references.
  --load-balancing-schemeEXTERNALEXTERNAL_MANAGEDF)choicesr'   r(   Nr4   )r-   r/   s     r   _AddLoadBalancingSchemeFlagrC   \   s0    )" 	-.	  r   c           	      D   Uc<  U R                   R                  UUR                  U R                   R                  US9S9$ U R                   R                  R	                  U5      nU R                   R                  UUR                  U R                   R                  X$/S9S9$ )z>Construct (not send) and return the request for global UrlMap.resource)projecturlMapurlMapsValidateRequest)rF   loadBalancingSchemes)messagesComputeUrlMapsValidateRequestnameUrlMapsValidateRequest,LoadBalancingSchemesValueListEntryValuesEnum)clientrG   url_mapload_balancing_schemescheme_enums        r   _MakeGlobalRequestrT   v   s    "??88||%EE  F   9   //88eeK??88||%EE=  F  B 9 C Cr   c           	      |    U R                   R                  UUUR                  U R                   R                  US9S9$ )NrE   )rG   regionrH   regionUrlMapsValidateRequest)rK   #ComputeRegionUrlMapsValidateRequestrM   RegionUrlMapsValidateRequestrP   rG   rV   rQ   s       r   _MakeRegionalRequestr[      sF    		<	<\\#)??#O#O $P $	 
= 
 r   c                 `    U R                   R                  R                  [        XX#5      5      $ r:   )apitools_clienturlMapsValidaterT   )rP   rG   rQ   rR   s       r   _SendGlobalRequestr`      s-    				'	'	0	0'I
K Kr   c                 `    U R                   R                  R                  [        XX#5      5      $ r:   )r]   regionUrlMapsr_   r[   rZ   s       r   _SendRegionalRequestrc      s+    				-	-	6	66F<
> >r   c                   <    \ rS rSrSr\" 5       r\S 5       rS r	Sr
g)r_      z,Validates URL map configs from your project.c                 t    [        U[        U R                  5       SS95        [        U5        [	        U5        g )NTr!   )r0   r%   r   r=   rC   )clsr-   s     r   ArgsValidate.Args   s,    6>#*:*:*<tLM6'r   c                    [         R                  R                  R                  R	                  5       n[
        R                  " U R                  5       5      nUR                  nUR                  b(  UR                  (       a  [        R                  " SS5      e[        R                  " UR                  =(       d    SSS9n [         R"                  " UR$                  R&                  U[)        U R                  5       5      S9nUR                  b  [3        XBUR                  U5      $ [5        XBUUR                  5      $ ! [*        R,                   a$  n[.        R,                  " [1        U5      5      eSnAff = f)zRuns the command.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the .Args() method.

Returns:
  A response object returned by rpc call Validate.
Nr?   z;Cannot specify load balancing scheme for regional URL maps.-F)binary)message_typestreamr.   )r
   VALUEScorerG   	GetOrFailr   ComputeApiHolderr   rP   rV   rR   r   InvalidArgumentExceptionr   ReadFromFileOrStdinsourcer#   ImportrK   r    r%   r   ValidationErrorcompute_exceptionsstrrc   r`   )selfargsrG   holderrP   datarQ   es           r   RunValidate.Run   s,    $$,,668G**4+<+<+>?F]]F{{4#=#=//
#
GI I
 ))$++*<UKD7""--$T%6%6%89;g {{!&4;;HHfw"88: : )) 7..s1v667s   AD= =E5E00E5r   N)__name__
__module____qualname____firstlineno____doc__r   detailed_helpclassmethodrh   r   __static_attributes__r   r   r   r_   r_      s%     5/-( (
!:r   r_   )Fr:   )(r   
__future__r   r   r   r+   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computerx   !googlecloudsdk.command_lib.exportr	   r#   googlecloudsdk.corer
   r   googlecloudsdk.core.consoler   r   r   r%   r0   r6   r8   r=   rC   rT   r[   r`   rc   ReleaseTracksr   r   r   GACommandr_   r   r   r   <module>r      s    ! &  '  7 ( . O A * . 2&MCN
M4C$K
>
 D%%++T->->-C-C%%((*,:t|| ,:*,:r   