
    G                     r    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
\5      rg)z"Network endpoint group api client.    )absolute_import)division)unicode_literals)utils)poller)waiter)	arg_utilsc                       \ rS rSrSrS r                  SS jrS rS rS r	S	 r
S
 rS rS rS rS rS rS rS rSS jrS rS rSrg)NetworkEndpointGroupsClient   z:Client for network endpoint groups service in the GCE API.c                    Xl         X l        X0l        U R                   R                  R                  U l        [        U R                   R                  S5      (       a%  U R                   R                  R                  U l        [        U R                   R                  S5      (       a&  U R                   R                  R                  U l
        g g )NglobalNetworkEndpointGroupsregionNetworkEndpointGroups)clientmessages	resourcesapitools_clientnetworkEndpointGroups_zonal_servicehasattrr   _global_servicer   _region_service)selfr   r   r   s       =lib/googlecloudsdk/api_lib/compute/network_endpoint_groups.py__init__$NetworkEndpointGroupsClient.__init__   s     KMN++55KKDt{{**,IJJ
++
%
%
A
A  t{{**,IJJ
++
%
%
A
A  K    Nc                 >
   [        US5      n[        US5      nSnU R                  U5      nU=(       a    U R                  U5      nU(       aS  U(       d  U(       d  U(       d  U(       a7  U R                  R	                  USUR
                  0SS9nUR                  5       nSnU(       a  U(       d  U(       d  U(       al  U(       a  UR                  nO [        R                  " UR                  5      nU R                  R	                  UUR
                  US.SS9nUR                  5       nSnU(       d  U(       d  U	(       a  U R                  R                  UUU	S	9nSnU
(       d  U(       d  U(       d  U(       a  U R                  R                  UUUS
9nSn U(       d  U(       a  U R                  R                  XS9n Sn!U(       d  U(       d  U(       d  U(       a  U R                  R                  UUUUS9n!U R                  R                   R"                  n"U(       Ga  U!(       aF  U R                  R!                  UR%                  5       [&        R(                  " UU"5      UUUUUU U!S9	n#GOU(       a  [&        R(                  " UU"5      U"R*                  :X  a  U(       a]  U R                  R-                  US9n$U R                  R!                  UR%                  5       [&        R(                  " UU"5      UU$UUUS9n#GOU R                  R!                  UR%                  5       [&        R(                  " UU"5      UUUUS9n#OU(       aA  U R                  R!                  UR%                  5       [&        R(                  " UU"5      UUUS9n#OU R                  R!                  UR%                  5       [&        R(                  " UU"5      UUUUUU S9n#O@U R                  R!                  UR%                  5       [&        R(                  " UU"5      UUUS9n#U(       a[  U R                  R/                  U#UR
                  UR                  S9n%U R0                  R3                  U R4                  SU%4/5      S   $ U(       a[  U R                  R7                  U#UR
                  UR                  S9n%U R0                  R3                  U R8                  SU%4/5      S   $ U R                  R;                  U#UR
                  S9n%U R0                  R3                  U R<                  SU%4/5      S   $ )z!Creates a network endpoint group.zoneregionNprojectzcompute.networks
collection)r!   r    zcompute.subnetworks)servicetagurlMask)r$   versionr&   )functionr&   )platformresourcer'   r&   )	namenetworkEndpointTypedefaultPortnetwork
subnetworkcloudRun	appEnginecloudFunctionserverlessDeployment)producerPort)r+   r,   r-   pscDatar.   r/   pscTargetService)r+   r,   r-   r.   r/   r6   )r+   r,   r-   r.   r/   )r+   r,   r-   r.   r/   r0   r1   r2   )networkEndpointGroupr!   r   Insertr   )r7   r!   r    )r7   r!   )r   _IsInternetNeg_IsPortMappingNegr   Parser!   SelfLinkr    	api_utilsZoneNameToRegionNamer   r   NetworkEndpointGroupCloudRunNetworkEndpointGroupAppEngine!NetworkEndpointGroupCloudFunction(NetworkEndpointGroupServerlessDeploymentNetworkEndpointGroup"NetworkEndpointTypeValueValuesEnumNamer	   ChoiceToEnumPRIVATE_SERVICE_CONNECTNetworkEndpointGroupPscData)ComputeNetworkEndpointGroupsInsertRequestr   MakeRequestsr   /ComputeRegionNetworkEndpointGroupsInsertRequestr   /ComputeGlobalNetworkEndpointGroupsInsertRequestr   )&r   neg_refnetwork_endpoint_typedefault_portproducer_portr.   subnetcloud_run_servicecloud_run_tagcloud_run_url_maskapp_engine_appapp_engine_serviceapp_engine_versionapp_engine_url_maskcloud_function_namecloud_function_url_maskserverless_deployment_platformserverless_deployment_resourceserverless_deployment_versionserverless_deployment_url_maskpsc_target_serviceis_zonalis_regionalnetwork_uriis_internet_negis_port_mapping_negnetwork_ref
subnet_urir    
subnet_ref	cloud_run
app_enginecloud_functionserverless_deploymentendpoint_type_enumnetwork_endpoint_grouppsc_datarequests&                                         r   Create"NetworkEndpointGroupsClient.Create.   s   0 w'H'8,KK ))*?@O% $*@*@+ &/=PNN((
Iw/<N ) k  ((*kJ815H	//=>>''
oo
8* ( j
 &&(jIM-?--<<#$ = i
 J==>>$$% ? j
 N5}}FF& G n !&)() --
@
@5534	 A   	**MM   
!%!C!C ) 6 6%'9! %! (!6 "D "
 $$%:<NO778 ]]>>( ? ( $(==#E#E<<>"+"8"8');# '!#1 $F 
$
  $(==#E#E<<>"+"8"8');# '!#1 $F 	$
  !%!C!C ) 6 6%'9! %! "D "
 "&!C!C ) 6 6%'9! %! ( "D "
  $}}AA||~'44#%7 #  B   GG5//|| H g
 [[%%73
4	  
MM5// N g
 [[%%  (G4
5	  MM5w N g [[%%  (G4
5	 r   c           
         U R                   R                  nU R                   R                  nU" UR                  5       UR                  UR
                  U" U R                  U5      S9S9nU R                  R                  U5      $ )z=Attaches network endpoints to a zonal network endpoint group.networkEndpoints)r7   r!   r   +networkEndpointGroupsAttachEndpointsRequest)	r   9ComputeNetworkEndpointGroupsAttachNetworkEndpointsRequest+NetworkEndpointGroupsAttachEndpointsRequestrE   r!   r   _GetEndpointMessageListr   AttachNetworkEndpointsr   rM   	endpointsrequest_classnested_request_classro   s         r   _AttachZonalEndpoints1NetworkEndpointGroupsClient._AttachZonalEndpoints   |     	OO  	AA  $\\^\\4H!99)D5
	G 55g>>r   c                 H    U H  nSU;   d  M  [        U5      S:X  d  M    g   g)z;Checks if endpoint list has an endpoint with instance only.instance   TF)len)r   r{   arg_endpoints      r   _HasAnyInstanceOnlyEndpoint7NetworkEndpointGroupsClient._HasAnyInstanceOnlyEndpoint  s(    !	|	#L(9Q(> " r   c           
         U R                   R                  nU R                   R                  nU" UR                  5       UR                  UR
                  U" U R                  U5      S9S9nU R                  R                  U5      $ )z?Detaches network endpoints from a zonal network endpoint group.rs   )r7   r!   r   +networkEndpointGroupsDetachEndpointsRequest)	r   9ComputeNetworkEndpointGroupsDetachNetworkEndpointsRequest+NetworkEndpointGroupsDetachEndpointsRequestrE   r!   r   rx   r   DetachNetworkEndpointsrz   s         r   _DetachZonalEndpoints1NetworkEndpointGroupsClient._DetachZonalEndpoints  r   r   c           
         U R                   R                  nU R                   R                  nU" UR                  5       UR                  UR
                  U" U R                  U5      S9S9nU R                  R                  U5      $ )z@Attaches network endpoints to a regional network endpoint group.rs   )r7   r!   r    1regionNetworkEndpointGroupsAttachEndpointsRequest)	r   ?ComputeRegionNetworkEndpointGroupsAttachNetworkEndpointsRequest1RegionNetworkEndpointGroupsAttachEndpointsRequestrE   r!   r    rx   r   ry   rz   s         r   _AttachRegionalEndpoints4NetworkEndpointGroupsClient._AttachRegionalEndpoints(  |     	UU  	GG  $\\^~~:N!99)D;
	G 66w??r   c           
         U R                   R                  nU R                   R                  nU" UR                  5       UR                  UR
                  U" U R                  U5      S9S9nU R                  R                  U5      $ )zBDetaches network endpoints from a regional network endpoint group.rs   )r7   r!   r    1regionNetworkEndpointGroupsDetachEndpointsRequest)	r   ?ComputeRegionNetworkEndpointGroupsDetachNetworkEndpointsRequest1RegionNetworkEndpointGroupsDetachEndpointsRequestrE   r!   r    rx   r   r   rz   s         r   _DetachRegionalEndpoints4NetworkEndpointGroupsClient._DetachRegionalEndpoints:  r   r   c           	          U R                   R                  nU R                   R                  nU" UR                  5       UR                  U" U R                  U5      S9S9nU R                  R                  U5      $ )z>Attaches network endpoints to a global network endpoint group.rs   )r7   r!   1globalNetworkEndpointGroupsAttachEndpointsRequest)r   ?ComputeGlobalNetworkEndpointGroupsAttachNetworkEndpointsRequest1GlobalNetworkEndpointGroupsAttachEndpointsRequestrE   r!   rx   r   ry   rz   s         r   _AttachGlobalEndpoints2NetworkEndpointGroupsClient._AttachGlobalEndpointsL  u     	UU  	GG  $\\^:N!99)D;
G 66w??r   c           	          U R                   R                  nU R                   R                  nU" UR                  5       UR                  U" U R                  U5      S9S9nU R                  R                  U5      $ )z@Detaches network endpoints from a global network endpoint group.rs   )r7   r!   1globalNetworkEndpointGroupsDetachEndpointsRequest)r   ?ComputeGlobalNetworkEndpointGroupsDetachNetworkEndpointsRequest1GlobalNetworkEndpointGroupsDetachEndpointsRequestrE   r!   rx   r   r   rz   s         r   _DetachGlobalEndpoints2NetworkEndpointGroupsClient._DetachGlobalEndpoints]  r   r   c                    / nU H  nU R                   R                  5       nSU;   a  UR                  S5      Ul        SU;   a  UR                  S5      Ul        SU;   a  UR                  S5      Ul        SU;   a  UR                  S5      Ul        SU;   a  UR                  S5      Ul        SU;   a  UR                  S5      Ul        UR                  U5        M     U$ )z=Convert endpoints to a list which can be passed in a request.r   ipipv6portfqdnzclient-destination-port)
r   NetworkEndpointgetr   	ipAddressipv6Addressr   r   clientDestinationPortappend)r   r{   output_listr   message_endpoints        r   rx   3NetworkEndpointGroupsClient._GetEndpointMessageListn  s    K!668	|	#$0$4$4Z$@!		%1%5%5d%;"	<	'3'7'7'?$	<	 , 0 0 8	<	 , 0 0 8	"l	21=1A1A%2
. )*! "$ r   c                 J    U R                   R                  UR                  SS9$ )Nzcompute.zoneOperationsr"   r   r;   selfLinkr   	operations     r   _GetOperationsRef-NetworkEndpointGroupsClient._GetOperationsRef  s*    >>'?    r   c                 J    U R                   R                  UR                  SS9$ )Nzcompute.regionOperationsr"   r   r   s     r   _GetRegionalOperationsRef5NetworkEndpointGroupsClient._GetRegionalOperationsRef  *    >>'A    r   c                 J    U R                   R                  UR                  SS9$ )Nzcompute.globalOperationsr"   r   r   s     r   _GetGlobalOperationsRef3NetworkEndpointGroupsClient._GetGlobalOperationsRef  r   r   c                 @    U(       a  [         R                  " XU5      $ g N)r   WaitFor)r   operation_polleroperation_refmessages       r   _WaitForResult*NetworkEndpointGroupsClient._WaitForResult  s    ^^,WEEr   c           	         SnSnSn[        US5      (       as  [        R                  " U R                  5      nU(       a"  U R	                  X5      nU R                  U5      nU(       a"  U R                  X5      nU R                  U5      nO[        US5      (       as  [        R                  " U R                  5      nU(       a"  U R                  X5      nU R                  U5      nU(       a"  U R                  X5      nU R                  U5      nOr[        R                  " U R                  5      nU(       a"  U R                  X5      nU R                  U5      nU(       a"  U R                  X5      nU R                  U5      nUR                  5       nSn	U R!                  UUSR#                  U(       a  [%        U5      OSU5      5      =(       d    U	n	U(       a(  U R'                  U5      (       a  SR#                  U5      n
O$SR#                  U(       a  [%        U5      OSU5      n
U R!                  UUU
5      =(       d    U	n	U	$ )z)Updates a Compute Network Endpoint Group.Nr   r    z!Attaching {0} endpoints to [{1}].r   zDetaching endpoints from [{0}].z#Detaching {0} endpoints from [{1}].)r   r   Pollerr   r~   r   r   r   r   r   r   r   r   r   r   rE   r   formatr   r   )r   rM   add_endpointsremove_endpointsattach_endpoints_refdetach_endpoints_refr   r   neg_nameresultremove_endpoints_error_messages              r   Update"NetworkEndpointGroupsClient.Update  s   wt':':;	..wF	#55i@	..wI	#55i@	(	#	#t';';<	11'I	#==iH	11'L	#==iHt';';<	//G	#;;IF	//J	#;;IF||~HF /66&3M"H	
 	   D<<=MNN'H'O'O
($
 0
6
6'7c"#Q % 	 *	
 	
   Mr   c                     U R                   R                  R                  n[        R                  " X5      nUUR
                  UR                  1;   $ r   )r   rC   rD   r	   rF   INTERNET_FQDN_PORTINTERNET_IP_PORTr   rN   rl   endpoint_type_enum_values       r   r9   *NetworkEndpointGroupsClient._IsInternetNeg  sV    **MM   )55  $--++(  r   c                     U R                   R                  R                  n[        R                  " X5      nX2R
                  :H  $ )z7Checks if the NEG in the request is a Port Mapping NEG.)r   rC   rD   r	   rF   GCE_VM_IP_PORTMAPr   s       r   r:   -NetworkEndpointGroupsClient._IsPortMappingNeg  sC     	**MM   )55  $'K'KKKr   )r   r   r   r   r   r   )NNNNNNNFNNNNNNNNNN)NN)__name__
__module____qualname____firstlineno____doc__r   rp   r~   r   r   r   r   r   r   rx   r   r   r   r   r   r9   r:   __static_attributes__ r   r   r   r      s    B( "%)%)$(%)+M^?$?$@$@$@"@".



@D
Lr   r   N)r   
__future__r   r   r   googlecloudsdk.api_lib.computer   r=   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr   $googlecloudsdk.command_lib.util.apisr	   objectr   r   r   r   <module>r      s/    ) &  ' = < . :XL& XLr   