
                         n   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\
R0                  " \
R2                  R4                  \
R2                  R6                  \
R2                  R8                  5       " S S\
R:                  5      5       rg)z0Command for removing a host rule from a URL map.    )absolute_import)division)unicode_literals)encoding)base_classes)base)
exceptions)scope)flags)url_maps_utilsc                      SSSS.$ )N"Remove a host rule from a URL map.z
*{command}* is used to remove a host rule from a URL map. When
a host rule is removed, its path matcher is only removed if
it is not referenced by any other host rules and
`--delete-orphaned-path-matcher` is provided.
z
To remove a host rule that contains the host `example.com`
from the URL map named `MY-URL-MAP`, you can use this
command:

  $ {command} MY-URL-MAP --host=example.com
)briefDESCRIPTIONEXAMPLES r       0lib/surface/compute/url_maps/remove_host_rule.py_DetailedHelpr       s     /
 r   c                 r   [         R                  " U5      (       aI  U R                  R                  SU R                  R                  UR                  5       UR                  S94$ U R                  R                  SU R                  R                  UR                  5       UR                  UR                  S94$ )z6Returns the request for the existing URL map resource.Get)urlMapproject)r   r   region)r   IsGlobalUrlMapRefapitools_clienturlMapsmessagesComputeUrlMapsGetRequestNamer   regionUrlMapsComputeRegionUrlMapsGetRequestr   )clienturl_map_refs     r   _GetGetRequestr%   4   s    %%k22""**EOO44"'');3F3F 5 HI I ""00%OO::"'')#++")) ; +, ,r   c           	      v   [         R                  " U5      (       aJ  U R                  R                  SU R                  R                  UR                  5       UUR                  S94$ U R                  R                  SU R                  R                  UR                  5       UUR                  UR                  S94$ )NUpdate)r   urlMapResourcer   )r   r(   r   r   )r   r   r   r   r   ComputeUrlMapsUpdateRequestr    r   r!   !ComputeRegionUrlMapsUpdateRequestr   )r#   r$   replacements      r   _GetSetRequestr,   B   s    %%k22""**HOO77"'')*#++ 8 -. . ""00(OO=="'')*#++"))	 > +, ,r   c                    [         R                  " U5      nSn/ nUR                   H<  nU R                  UR                  ;   a  UR
                  nM+  UR                  U5        M>     U(       d/  [        R                  " SR                  U R                  5      5      eXBl        SnUR                   H  nUR
                  U:X  d  M  Sn  O   U(       dv  U R                  (       a6  UR                   Vs/ s H  nUR                  U:w  d  M  UPM     snUl        U$ [        R                  " SR                  WR
                  5      5      eU$ s  snf )z#Returns a modified URL map message.Nz%No host rule contains the host [{0}].FTzThis operation will orphan the path matcher [{0}]. To delete the orphan path matcher, rerun this command with [--delete-orphaned-path-matcher] or use [gcloud compute url-maps edit] to modify the URL map by hand.)r   CopyProtoMessage	hostRuleshosthostspathMatcherappendcompute_exceptionsArgumentErrorformatdelete_orphaned_path_matcherpathMatchersname)argsexistingr+   path_matcher_to_removenew_host_rules	host_rule#path_matcher_is_used_by_other_rulespath_matchers           r   _ModifyrA   R   sA   ))(3+.%%iyyIOO#(44I&	 & 
 

*
*/66tyyAC C )(-%((i 66,0) )
 
-((+3+@+@"+@<"88 +@"k 
 ,,: ;A&##;%	& & 
"s   2E
Ec                    UR                   nUR                  XR                  [        R                  R
                  S9n[        X45      nUR                  U/5      n[        XS   5      nUR                  [        X4U5      /5      $ )z:Issues requests necessary to remove host rule on URL maps.)default_scoper   )
r#   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALr%   MakeRequestsrA   r,   )r:   holderurl_map_argr#   r$   get_requestobjects
new_objects           r   _RunrO   {   s}    ==&--
M,C,C,J,J . L+v3+.'tQZ(*			nV*MN	OOr   c                   @    \ rS rSrSr\" 5       rSr\S 5       r	S r
Srg)RemoveHostRule   r   Nc                     [         R                  " 5       U l        U R                  R                  U5        UR	                  SSSS9  UR	                  SSSSS	9  g )
Nz--hostTz,One of the hosts in the host rule to remove.)requiredhelpz--delete-orphaned-path-matcher
store_trueFzIf provided and a path matcher is orphaned as a result of this command, the command removes the orphaned path matcher instead of failing.)actiondefaultrU   )r   UrlMapArgumentURL_MAP_ARGAddArgumentadd_argument)clsparsers     r   ArgsRemoveHostRule.Args   sc    **,COOO'
;  = (	  r   c                 v    [         R                  " U R                  5       5      n[        XU R                  5      $ )N)r   ComputeApiHolderReleaseTrackrO   rZ   )selfr:   rJ   s      r   RunRemoveHostRule.Run   s.    **4+<+<+>?Fd..//r   r   )__name__
__module____qualname____firstlineno____doc__r   detailed_helprZ   classmethodr_   re   __static_attributes__r   r   r   rQ   rQ      s*     +/-+ 0r   rQ   N)rk   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r4   r
   rF   +googlecloudsdk.command_lib.compute.url_mapsr   r   r   r%   r,   rA   rO   ReleaseTracksrc   ALPHABETAGAUpdateCommandrQ   r   r   r   <module>rz      s     7 &  ' % 7 ( O E = F(,, &R	P D%%++T->->-C-C%%((*0T'' 0*0r   