
    \                        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 e
j$                   e
j&                  e
j(                  j*                         G d de
j,                                      Ze
j$                   e
j&                  e
j(                  j0                  e
j(                  j2                         G d de                    Zddde_        y)z(Command for creating target TCP proxies.    )absolute_import)division)unicode_literals)base_classes)target_proxies_utils)utils)base)scope)flagsc                   @    e Zd ZdZdZdZed        Zd Zd Z	d Z
d Zy)CreatezCreate a target TCP proxy.Nc                    t        j                  |       t        j                  d      | _        | j                  j                  |       t        j                  d      | _        | j                  j                  |d       t        j                  |       |j                  dd       |j                  j                  t        j                         y )NT)allow_regionalcreate)operation_typez--descriptionz:An optional, textual description for the target TCP proxy.)help)r   AddProxyHeaderRelatedCreateArgsbackend_service_flags'BackendServiceArgumentForTargetTcpProxyBACKEND_SERVICE_ARGAddArgumentr   TargetTcpProxyArgumentTARGET_TCP_PROXY_ARGAddProxyBindadd_argumentdisplay_infoAddCacheUpdaterTargetTcpProxiesCompleter)clsparsers     0lib/surface/compute/target_tcp_proxies/create.pyArgszCreate.Args'   s    88@ 	EE	
 
 ''/$;;4PC(((I	v
I  K ''(G(GH    c                 f   t        j                  | j                               }|j                  s0|j                  s$t        |dd       |_        t        |dd       |_        | j                  j                  ||j                  t        j                  j                        }| j                  j                  ||j                  t        j                  j                        }|j                  j                  }|j                  r&|j                   j#                  |j                        }n |j                   j"                  j$                  }|j!                  |j&                  |j)                         ||j+                               }|j,                  |j,                  |_        | j1                  |||      S )Nregionglobal)default_scope)descriptionnameproxyHeaderservice)r   ComputeApiHolderReleaseTrackbackend_service_regionglobal_backend_servicegetattrr   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALr   clientmessagesproxy_headerTargetTcpProxyProxyHeaderValueValuesEnumNONEr(   NameSelfLink
proxy_bind	proxyBind_MakeRequest)selfargsholderbackend_service_reftarget_tcp_proxy_refr7   r8   target_tcp_proxys           r!   Runz
Create.Run<   sz   **4+<+<+>?F''4+F+F$+D(D$Ad!$+D(D$Ad!22DDfm.E.E.L.L E N  44FFfm.E.E.L.L G N }}%%H,,GG


l --HHMMl..$$!&&( #,,.	 / 0 "#'?? 13CVLLr#   c                 t    |j                         dk(  r| j                  |||      S | j                  |||      S )Nzcompute.regionTargetTcpProxies)
Collection_MakeRegionalRequest_MakeGlobalRequest)rA   rE   rF   rC   s       r!   r@   zCreate._MakeRequest\   sL    &&(,LL&&';=M'-/ /""#79I#)+ +r#   c                 4   |j                   j                  }|j                   j                  }|j                  |j                  ||j
                        }g }|j                   j                  |j                  d|fg|      }|rt        j                  |       |S )N)projecttargetTcpProxyr%   Insert)
r6   apitools_clientr7   *ComputeRegionTargetTcpProxiesInsertRequestrM   r%   MakeRequestsregionTargetTcpProxiesr   RaiseToolException	rA   rE   rF   rC   r6   r7   requesterrorsr2   s	            r!   rJ   zCreate._MakeRegionalRequestc   s    ]]**F}}%%HAA$,,'#** B ,G
 F**

'
'7	;<fFI v&r#   c                    |j                   j                  }|j                   j                  }|j                  |j                  |      }g }|j                   j                  |j                  d|fg|      }|rt        j                  |       |S )N)rM   rN   rO   )	r6   rP   r7   $ComputeTargetTcpProxiesInsertRequestrM   rR   targetTcpProxiesr   rT   rU   s	            r!   rK   zCreate._MakeGlobalRequestt   s    ]]**F}}%%H;;$,,=M < OG F**

!
!8W	56@I v&r#   )__name__
__module____qualname____doc__r   r   classmethodr"   rG   r@   rJ   rK    r#   r!   r   r      s=     #I I(M@+"r#   r   c                       e Zd Zy)CreateAlphaBetaN)r[   r\   r]   r`   r#   r!   rb   rb      s     r#   rb   zCreate a target TCP proxya8  
        *{command}* is used to create target TCP proxies. A target
        TCP proxy is referenced by one or more forwarding rules which
        define which packets the proxy is responsible for routing. The
        target TCP proxy points to a backend service which handle the
        actual requests.
        )briefDESCRIPTIONN)r^   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   r3   3googlecloudsdk.command_lib.compute.backend_servicesr   r   5googlecloudsdk.command_lib.compute.target_tcp_proxiesUniverseCompatibleReleaseTracksr-   GACreateCommandr   ALPHABETArb   detailed_helpr`   r#   r!   <module>rr      s    / &  ' 7 ? 0 ( E$ G D%%(()_T _ * _D D%%++T->->-C-CDf  E  	$		 r#   