
    0                        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 r\R4                  " \R6                  R8                  \R6                  R:                  \R6                  R<                  5       " S S\R>                  5      5       r g)z,Command for adding a host rule to a URL map.    )absolute_import)division)unicode_literals)encoding)base_classes)arg_parsers)base)scope)flags)url_maps_utilsc                      SSSS.$ )N7Add a rule to a URL map to map hosts to a path matcher.a  
*{command}* is used to add a mapping of hosts to a path
matcher in a URL map. The mapping will match the host
component of HTTP requests to path matchers which in turn map
the request to a backend service. Before adding a host rule,
at least one path matcher must exist in the URL map to take
care of the path component of the requests.
`gcloud compute url-maps add-path-matcher` or
`gcloud compute url-maps edit` can be used to add path matchers.
z
To create a host rule mapping the ```*-foo.example.com``` and
```example.com``` hosts to the ```www``` path matcher, run:

  $ {command} MY-URL-MAP --hosts='*-foo.example.com,example.com' --path-matcher-name=www
)briefDESCRIPTIONEXAMPLES r       -lib/surface/compute/url_maps/add_host_rule.py_DetailedHelpr       s     D	
 r   c                     U R                  SSS9  U R                  S[        R                  " SS9SSS	S
9  U R                  SSSS9  g)z%Add command line flags to the parser.z--descriptionz3An optional, textual description for the host rule.)helpz--hosts   )
min_lengthHOSTTaL        The set of hosts to match requests against. Each host must be
      a fully qualified domain name (FQDN) with the exception that
      the host can begin with a ``*'' or ``*-''. ``*'' acts as a
      glob and will match any string of atoms to the left where an
      atom is separated by dots (``.'') or dashes (``-'').
      )typemetavarrequiredr   z--path-matcher-namez      The name of the path matcher to use if a request matches this
      host rule. The path matcher must already exist in the URL map
      (see `gcloud compute url-maps add-path-matcher`).
      )r   r   N)add_argumentr   ArgList)parsers    r   _Argsr!   9   so     	@  B 	!,
   	
  r   c                     U R                   R                  SU R                  R                  UR	                  5       UR
                  S94$ )z6Returns the request for the existing URL map resource.Get)urlMapproject)apitools_clienturlMapsmessagesComputeUrlMapsGetRequestNamer%   clienturl_map_refs     r   _GetGetRequestr.   W   sK    

 
 
(
(%
//
2
2 %%'1D1D 3 F
G Gr   c                     U R                   R                  SU R                  R                  UR	                  5       UUR
                  S94$ )NUpdate)r$   urlMapResourcer%   )r&   r'   r(   ComputeUrlMapsUpdateRequestr*   r%   r,   r-   replacements      r   _GetSetRequestr5   ^   sL    

 
 
(
((
//
5
5 %%'(!)) 6 +
, ,r   c                     [         R                  " U5      nU R                  R                  UR                  [        UR                  5      UR                  S9nUR                  R                  U5        U$ )z#Returns a modified URL map message.)descriptionhostspathMatcher)
r   CopyProtoMessager(   HostRuler7   sortedr8   path_matcher_name	hostRulesappend)r,   argsexistingr4   new_host_rules        r   _ModifyrC   f   se    ))(3+//**""4::(( + *-
 }-	r   c                     U R                   R                  SU R                  R                  UR	                  5       UR
                  UR                  S94$ )zAReturns the request to get an existing regional URL map resource.r#   )r$   r%   region)r&   regionUrlMapsr(   ComputeRegionUrlMapsGetRequestr*   r%   rE   r+   s     r   _GetRegionalGetRequestrH   t   sR    

 
 
.
.
//
8
8 %%'!)) '' 9 )
* *r   c           	          U R                   R                  SU R                  R                  UR	                  5       UUR
                  UR                  S94$ )zDReturns the request to update an existing regional URL map resource.r0   )r$   r1   r%   rE   )r&   rF   r(   !ComputeRegionUrlMapsUpdateRequestr*   r%   rE   r3   s      r   _GetRegionalSetRequestrK   }   sU    

 
 
.
.
//
;
; %%'(!)) ''	 < )
* *r   c                    UR                   nUR                  XR                  [        R                  R
                  S9n[        R                  " U5      (       a  [        X45      nO[        X45      nUR                  U/5      S   n[        X0U5      n[        R                  " U5      (       a  [        X4U5      nO[        X4U5      nUR                  U/5      $ ):Issues requests necessary to add host rule to the Url Map.)default_scoper   )r,   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALr   IsRegionalUrlMapRefrH   r.   MakeRequestsrC   rK   r5   )	r@   holderurl_map_argr,   r-   get_requestold_url_mapmodified_url_mapset_requests	            r   _Runr\      s     ==&--
M,C,C,J,J . L+''44(=K 5K##[M215+V;7''44(>NOK 6FGK			k]	++r   c                   @    \ rS rSrSr\" 5       rSr\S 5       r	S r
Srg)AddHostRule   r   Nc                     [         R                  " 5       U l        U R                  R                  U5        [	        U5        g )N)r   UrlMapArgumentURL_MAP_ARGAddArgumentr!   )clsr    s     r   ArgsAddHostRule.Args   s+    **,COOO'	&Mr   c                 v    [         R                  " U R                  5       5      n[        XU R                  5      $ )rM   )r   ComputeApiHolderReleaseTrackr\   rb   )selfr@   rV   s      r   RunAddHostRule.Run   s.    **4+<+<+>?Fd..//r   r   )__name__
__module____qualname____firstlineno____doc__r   detailed_helprb   classmethodre   rk   __static_attributes__r   r   r   r^   r^      s+     @/-+ 
0r   r^   N)!rq   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r	   "googlecloudsdk.command_lib.computer
   rQ   +googlecloudsdk.command_lib.compute.url_mapsr   r   r   r!   r.   r5   rC   rH   rK   r\   ReleaseTracksri   ALPHABETAGAUpdateCommandr^   r   r   r   <module>r      s     3 &  ' % 7 / ( E = F2<G,**,6 D%%++T->->-C-C%%((*0$$$ 0*0r   