
                          z   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
lmZ ddlmZ d Zd Zd Zd Zd Zd Zd Z e
j4                  e
j6                  j8                  e
j6                  j:                  e
j6                  j<                         G d de
j>                               Z y)z3Command for removing a path matcher from a URL map.    )absolute_import)division)unicode_literals)encoding)base_classes)base)
exceptions)scope)flags)url_maps_utilsc                      ddddS )N%Remove a path matcher from a URL map.z
*{command}* is used to remove a path matcher from a URL
map. When a path matcher is removed, all host rules that
refer to the path matcher are also removed.
z
To remove the path matcher named ``MY-MATCHER'' from the URL map named
``MY-URL-MAP'', you can use this command:

  $ {command} MY-URL-MAP --path-matcher-name=MY-MATCHER
)briefDESCRIPTIONEXAMPLES r       3lib/surface/compute/url_maps/remove_path_matcher.py_DetailedHelpr       s     2

 r   c                     | j                   j                  d| j                  j                  |j	                         |j
                        fS )z6Returns the request for the existing URL map resource.Get)urlMapproject)apitools_clienturlMapsmessagesComputeUrlMapsGetRequestNamer   clienturl_map_refs     r   _GetGetRequestr"   2   sK    

 
 
(
(%
//
2
2 %%'1D1D 3 F
G Gr   c                     | j                   j                  d| j                  j                  |j	                         ||j
                        fS )NUpdate)r   urlMapResourcer   )r   r   r   ComputeUrlMapsUpdateRequestr   r   r    r!   replacements      r   _GetSetRequestr)   9   sL    

 
 
(
((
//
5
5 %%'(!)) 6 +
, ,r   c                    t        j                  |      }g }d}|j                  D ]/  }|j                  | j                  k(  rd}|j                  |       1 |s.t        j                  dj                  | j                              ||_        g }|j                  D ]-  }|j                  | j                  k7  s|j                  |       / ||_	        |S )z#Returns a modified URL map message.FTz.No path matcher with the name [{0}] was found.)r   CopyProtoMessagepathMatchersnamepath_matcher_nameappendcompute_exceptionsArgumentErrorformat	hostRulespathMatcher)argsexistingr(   new_path_matcherspath_matcher_foundpath_matchernew_host_rules	host_rules           r   _Modifyr<   A   s    ))(3+ ++lD222|,	 , 


*
*8??""	$% % /+ .%%i 6 66I& & )+	r   c                     | j                   j                  d| j                  j                  |j	                         |j
                  |j                        fS )zAReturns the request to get an existing regional URL map resource.r   )r   r   region)r   regionUrlMapsr   ComputeRegionUrlMapsGetRequestr   r   r>   r   s     r   _GetRegionalGetRequestrA   _   sR    

 
 
.
.
//
8
8 %%'!)) '' 9 )
* *r   c                     | j                   j                  d| j                  j                  |j	                         ||j
                  |j                        fS )zDReturns the request to update an existing regional URL map resource.r$   )r   r%   r   r>   )r   r?   r   !ComputeRegionUrlMapsUpdateRequestr   r   r>   r'   s      r   _GetRegionalSetRequestrD   h   sU    

 
 
.
.
//
;
; %%'(!)) ''	 < )
* *r   c                    |j                   }|j                  | |j                  t        j                  j
                        }t        j                  |      rt        ||      }nt        ||      }|j                  |g      d   }t        | |      }t        j                  |      rt        |||      }nt        |||      }|j                  |g      S )z=Issues requests necessary to remove path matcher on URL maps.)default_scoper   )r    ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALr   IsRegionalUrlMapRefrA   r"   MakeRequestsr<   rD   r)   )	r5   holderurl_map_argr    r!   get_requesturl_mapmodified_url_mapset_requests	            r   _RunrT   r   s    ==&--
FM,C,C,J,J . L+''4(=K 5K.q1'T7+''4(>NOK 6FGK			k]	++r   c                   8    e Zd ZdZ e       ZdZed        Zd Z	y)RemovePathMatcherr   Nc                     t        j                         | _        | j                  j                  |       |j	                  ddd       y )Nz--path-matcher-nameTz'The name of the path matcher to remove.)requiredhelp)r   UrlMapArgumentURL_MAP_ARGAddArgumentadd_argument)clsparsers     r   ArgszRemovePathMatcher.Args   s@    **,COOO'
6  8r   c                 v    t        j                  | j                               }t        ||| j                        S )N)r   ComputeApiHolderReleaseTrackrT   r[   )selfr5   rN   s      r   RunzRemovePathMatcher.Run   s0    **4+<+<+>?Ffd..//r   )
__name__
__module____qualname____doc__r   detailed_helpr[   classmethodr`   re   r   r   r   rV   rV      s*     ./-+8 80r   rV   N)!ri   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r0   r
   rI   +googlecloudsdk.command_lib.compute.url_mapsr   r   r   r"   r)   r<   rA   rD   rT   ReleaseTracksrc   ALPHABETAGAUpdateCommandrV   r   r   r   <module>rw      s     : &  ' % 7 ( O E = F$G,<**,, D%%++T->->-C-C%%((*0** 0*0r   