
                            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 e	j*                  e	j,                  j.                  e	j,                  j0                         G d de	j2                               Z e	j*                  e	j,                  j6                         G d de             Zy)z)Command for creating target HTTP proxies.    )absolute_import)division)unicode_literals)base_classes)target_proxies_utils)base)scope)flags)target_http_proxies_utilsc                      ddddS )NCreate a target HTTP proxy.a        *{command}* is used to create 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.
      a        If there is an already-created URL map with the name URL_MAP, create a
      global target HTTP proxy pointing to this map by running:

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

      Create a regional target HTTP proxy by running:

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

      To create a proxy with a textual description, run:

        $ {command} PROXY_NAME --url-map=URL_MAP --description="default proxy"
      )briefDESCRIPTIONEXAMPLES r       1lib/surface/compute/target_http_proxies/create.py_DetailedHelpr      s    ,


 r   c                 (   | j                   j                  t        j                         | j	                  dd       | j                   j                  t        j                         |rt        j                  | d       t        j                  |        y)z=Add the target http proxies comamnd line flags to the parser.z--descriptionz;An optional, textual description for the target HTTP proxy.)helpFN)
display_info	AddFormatr
   DEFAULT_LIST_FORMATadd_argumentAddCacheUpdaterTargetHttpProxiesCompleterAddProxyBindr   AddHttpKeepAliveTimeoutSec)parsertraffic_director_securitys     r   _Argsr!   :   sr     9 9:H   	%%e&F&FG	vu%11&9r   c                    |j                   }|r\| j                  rP|j                  j                  | j                  |j                         |j                         | j                        }nD|j                  j                  | j                  |j                         |j                               }| j                  d      r| j                  |_	        t        j                  |      rI|j                  j                  |j                  |j                  |      }|j                  j                   }n=|j                  j#                  |j                  |      }|j                  j$                  }|j'                  |d|fg      S ))Issue a Target HTTP Proxy Insert request.)descriptionnameurlMap	proxyBind)r$   r%   r&   http_keep_alive_timeout_sec)projectregiontargetHttpProxy)r)   r+   Insert)client
proxy_bindmessagesTargetHttpProxyr$   NameSelfLinkIsSpecifiedr(   httpKeepAliveTimeoutSecr   IsRegionalTargetHttpProxiesRef+ComputeRegionTargetHttpProxiesInsertRequestr)   r*   apitools_clientregionTargetHttpProxies%ComputeTargetHttpProxiesInsertRequesttargetHttpProxiesMakeRequests)	argsholderurl_map_reftarget_http_proxy_refr    r-   target_http_proxyrequest
collections	            r   _RunrC   H   s^    ==&4??77$$"'')##%//	 8  77$$"'')##% 8  
34040P0P-== ooII%--$++) J G
 ''??JooCC%--?P D G ''99J			z8W=>	??r   c                   @    e Zd ZdZdZdZdZ e       Ze	d        Z
d Zy)Creater   FNc                    t        j                         | _        | j                  j                  |d       t	        j
                         | _        | j                  j                  |       t        || j                         y )Ncreate)operation_type)	r
   TargetHttpProxyArgumentTARGET_HTTP_PROXY_ARGAddArgumenturl_map_flagsUrlMapArgumentForTargetProxyURL_MAP_ARGr!   _traffic_director_security)clsr   s     r   ArgszCreate.Args{   s^     % = = ?C))&)J#@@BCOOO'	&#001r   c                 R   t        j                  | j                               }| j                  j	                  ||j
                  t        j                  j                        }t        j                  || j                  ||j
                        }t        ||||| j                        S )r#   )default_scope)r   ComputeApiHolderReleaseTrackrJ   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALr   ResolveTargetHttpProxyUrlMaprN   rC   rO   )selfr<   r=   r?   r>   s        r   Runz
Create.Run   s    **4+<+<+>?F 66HHfm.E.E.L.L I  ,HHd 5v7G7GK '' r   )__name__
__module____qualname____doc__rO   rN   rJ   r   detailed_helpclassmethodrQ   r]   r   r   r   rE   rE   q   s4    #$+/-2 2r   rE   c                       e Zd ZdZy)CreateAlphaTN)r^   r_   r`   rO   r   r   r   re   re      s    #r   re   N)ra   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   rX   6googlecloudsdk.command_lib.compute.target_http_proxiesr
   r   +googlecloudsdk.command_lib.compute.url_mapsrL   r   r!   rC   ReleaseTracksrU   BETAGACreateCommandrE   ALPHAre   r   r   r   <module>rq      s    0 &  ' 7 ? ( E H \ N8:&@R D%%**D,=,=,@,@A T   B F D%%++,$& $ -$r   