
                            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S
KJr  SSKJr  SS
KJ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 updating target HTTP proxies.    )absolute_import)division)unicode_literals)encoding)base_classes)target_proxies_utils)base)
exceptions)flags)scope)target_http_proxies_utilsc                      SSSS.$ )NUpdate a target HTTP proxy.a        *{command}* is used to change the URL map of existing target
      HTTP proxies. A target HTTP proxy is referenced by one or more
      forwarding rules which specify the network traffic that the proxy
      is responsible for routing. The target HTTP proxy points to a URL
      map that defines the rules for routing the requests. The URL map's
      job is to map URLs to backend services which handle the actual
      requests.
      aC        If there is an already-created URL map with the name URL_MAP, update a
      global target HTTP proxy pointing to this map by running:

        $ {command} PROXY_NAME --url-map=URL_MAP

      Update a regional target HTTP proxy by running:

        $ {command} PROXY_NAME --url-map=URL_MAP --region=REGION_NAME
      )briefDESCRIPTIONEXAMPLES r       1lib/surface/compute/target_http_proxies/update.py_DetailedHelpr   !   s    ,
	

 r   c           	      >   UR                   nUR                  U UR                  [        R                  R
                  [        R                  " U5      S9n[        R                  " XXQR                  5      n[        R                  " U5      (       a  SnU R                  S5      (       a  SnOU R                  S5      (       a  SnUb  [        R                  " US5      eUR                  R                  UR                   UR"                  UR%                  5       UR                  R'                  UR)                  5       S9S	9nUR*                  R,                  n	UR/                  U	S
U4/5      n
U
$ [1        XE5      n[2        R4                  " U5      n/ nU R6                  (       a  UR)                  5       Ul        U R                  S5      (       a  U R:                  Ul        O.U R                  S5      (       a  SUl        UR?                  S5        X:w  a  [A        XEX5      $ g)z8Issues requests necessary to update Target HTTP Proxies.)default_scopescope_listerNhttp_keep_alive_timeout_secz--http-keep-alive-timeout-sec!clear_http_keep_alive_timeout_secz#--clear-http-keep-alive-timeout-seczIhttp keep alive timeout is not patchable for regional target HTTP proxies)urlMap)projectregiontargetHttpProxyurlMapReference	SetUrlMaphttpKeepAliveTimeoutSec)!clientResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALcompute_flagsGetDefaultScopeListerr   ResolveTargetHttpProxyUrlMapIsRegionalTargetHttpProxiesRefIsSpecifiedr
   InvalidArgumentExceptionmessages.ComputeRegionTargetHttpProxiesSetUrlMapRequestr   r   NameUrlMapReferenceSelfLinkapitools_clientregionTargetHttpProxiesMakeRequests_GetGlobalTargetHttpProxyr   CopyProtoMessageurl_mapr   r   r"   append_PatchGlobalTargetHttpProxy)argsholdertarget_http_proxy_argurl_map_argr#   	proxy_refurl_map_refinvalid_argrequest
collectionresold_resourcenew_resourcecleared_fieldss                 r   _RunrI   :   s   ==&#55
!++22 66v>	 6 ) *FF
$4$4+ ==iHHK5663k			=	>	>9k//
  ooLL!!!(77'') 8 
	 M G ''??J



KAB
CCJ,V?L,,\:LN||'002l566-1-M-Ml*			=	>	>-1l*56#(
\  $r   c           	          / nUR                  U R                  R                  SU R                  R	                  UR
                  UR                  5       S945        U R                  U5      nUS   $ )z'Retrieves the Global target HTTP proxy.Get)r   r   r   )r:   r4   targetHttpProxiesr/   "ComputeTargetHttpProxiesGetRequestr   r1   r6   )r#   r@   requestsrE   s       r   r7   r7   u   sp     (
//..oo88##Y^^5E 9   	H%#	Q-r   c           
      F   / nUR                  U R                  R                  SU R                  R	                  UR
                  UR                  5       US945        U R                  R                  U5         U R                  U5      sSSS5        $ ! , (       d  f       g= f)z%Patches the Global target HTTP proxy.Patch)r   r   targetHttpProxyResourceN)	r:   r4   rL   r/   $ComputeTargetHttpProxiesPatchRequestr   r1   IncludeFieldsr6   )r#   r@   rG   rH   rN   s        r   r;   r;      s     (
//..oo::###..*". ;   ++N;x( <;;s   7B
B c                   D    \ rS rSrSrSrSr\" 5       r\	S 5       r
S rSrg)Update   r   Nc                 N   [         R                  " 5       U l        U R                  R                  USS9  [        R
                  " 5       U l        U R                  R                  U5        UR                  5       n[        R                  " U5        [        R                  " U5        g )Nupdate)operation_type)r   TargetHttpProxyArgumentTARGET_HTTP_PROXY_ARGAddArgumenturl_map_flagsUrlMapArgumentForTargetProxyURL_MAP_ARGadd_mutually_exclusive_groupr   AddHttpKeepAliveTimeoutSecAddClearHttpKeepAliveTimeoutSec)clsparsergroups      r   ArgsUpdate.Args   sx     % = = ?C))&)J#@@BCOOO'//1E33E:88?r   c                     [         R                  " U R                  5       5      n[        UUU R                  U R
                  5      $ )N)r   ComputeApiHolderReleaseTrackrI   r[   r_   )selfr<   r=   s      r   Run
Update.Run   s@    **4+<+<+>?F""	 r   r   )__name__
__module____qualname____firstlineno____doc__r[   r_   r   detailed_helpclassmethodrf   rl   __static_attributes__r   r   r   rU   rU      s2     $+/-@ @r   rU   N)!rr   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper	   r
   "googlecloudsdk.command_lib.computer   r)   r   r&   6googlecloudsdk.command_lib.compute.target_http_proxiesr   +googlecloudsdk.command_lib.compute.url_mapsr]   r   rI   r7   r;   ReleaseTracksrj   ALPHABETAGAUpdateCommandrU   r   r   r   <module>r      s    0 &  ' % 7 ? ( . E E H \ N28v )$ T..33T5F5F5I5IT r   