
     "                        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S.r " S S\R0                  5      r\
R4                  \
R6                  " \
R8                  R:                  \
R8                  R<                  \
R8                  R>                  5       " S S\
R@                  5      5       5       r!S r"S r#S r$S r%g)z1Command for adding interconnects to a wire group.    )absolute_import)division)unicode_literals)base_classes)client)base)scope)flags)
exceptions)
propertiesz        *{command}* is used to add interconnects to a wire group.

        For an example, refer to the *EXAMPLES* section below.
        a:          To add an interconnect to a wire group, run:

          $ {command} example-wg               --cross-site-network=example-csn               --endpoint-label=endpoint-1               --interconnect-label=interconnect-1               --interconnect=example-interconnect               --vlan-tags=111
        )DESCRIPTIONEXAMPLESc                       \ rS rSrSrSrg)InvalidEndpointError4   z.Raised when the endpoint label does not exist. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       Alib/surface/compute/interconnects/wire_groups/add_interconnect.pyr   r   4   s    6r   r   c                   D    \ rS rSrSr\rSrSrSr	\
S 5       rS rS rSrg)AddInterconnect8   zpAdd interconnect to a Compute Engine wire group.

*{command}* adds interconnect to a Compute Engine wire group.
Nc                    [         R                  " 5       U l        U R                  R                  U5        [        R
                  " S5      U l        [        R                  " SS9U l	        U R                  R                  USS9  U R                  R                  U5        [        R                  " U5        [        R                  " U5        [        R                  " U5        g )Nz-The interconnect for the wire group endpoint.F)pluralupdate)operation_type)cross_site_network_flags(CrossSiteNetworkArgumentForOtherResourceCROSS_SITE_NETWORK_ARGAddArgumentinterconnect_flags$InterconnectArgumentForOtherResourceINTERCONNECT_ARGr
   WireGroupArgumentWIRE_GROUP_ARGAddEndpointLabelAddInterconnectLabelAddVlanTags)clsparsers     r   ArgsAddInterconnect.ArgsI   s     	!IIK  **62??;	
 
 00>C""6("C$$V,	6"	v&	fr   c                     g)Nzcompute.wireGroupsr   )selfs    r   
CollectionAddInterconnect.Collection[   s    r   c           	         [         R                  " U R                  5       5      nU R                  R	                  UUR
                  [        R                  R                  SUR                  0S9n[        R                  R                  R                  R                  5       nUR                  R                   U l        [        R$                  " UUUR                  UR                  UR
                  S9nUR&                  nUR(                  nUR*                  R-                  S5      nUR/                  5       R0                  n	U R2                  R	                  XR
                  5      n
[5        U	5      nXk;  a+  [7        SSR9                  UR;                  5       5      -   5      eX   R<                  n[?        U5      nUR                  R                   RA                  U
RC                  5       U Vs/ s H  n[E        U5      PM     snS9X'   [G        U R"                  U5      nU R"                  RI                  US9X'   [K        U R"                  U5      n	URM                  U	S	9$ s  snf )
a  Runs the add-interconnect command.

Modifies the existing endpoints and their interconnects. We need to break
down the endpoints and interconnects to make it easier to add or update the
interconnects. Since they are nested resources of a WireGroup, it can get
tricky to do modifications.

Args:
  args: Object containing CLI parameter values
Returns:
  Result of running the request.

Raises:
  InvalidEndpointError: If the endpoint does not exist.
crossSiteNetwork)default_scopeadditional_params)refprojectcross_site_networkcompute_client	resources,z5Not a valid endpoint. Found the following endpoints: z, )interconnectvlanTags)interconnects)	endpoints)'r   ComputeApiHolderReleaseTrackr*   ResolveAsResourcer>   compute_scope	ScopeEnumGLOBALr<   r   VALUEScorer;   	GetOrFailr   messages	_messages	WireGroupendpoint_labelinterconnect_label	vlan_tagssplitDescriberC   r(   _convert_endpoints_to_dictr   joinkeysrB   _convert_interconnects_to_dictWireGroupEndpointInterconnectSelfLinkint_build_interconnect_messagesWireGroupEndpoint_build_endpoint_messagesPatch)r3   argsholderr:   r;   
wire_grouprP   rQ   rR   rC   interconnect_refendpoints_maprB   interconnects_mapvlan_tags                  r   RunAddInterconnect.Run^   s0     **4+<+<+>?F



/
/#--44-t/F/FG	 0 C $$,,668G]]++DN!!22}}""J ((N00$$S)I##%//I,,>>  /y9M* 
AIIm((*+, 
 "1??M 7}E
 	<<)2244=>Ic(mI> 	= 	
 ) 1)M %)NN$D$D# %E %M! )GI    ?s   *I
)rN   )r   r   r   r   r   _DETAILED_HELPdetailed_helpr*   r$   r(   classmethodr0   r4   rg   r   r   r   r   r   r   8   s<    
 !-. " Or   r   c                     0 nU (       a  U R                   (       d  U$ U R                    H  nUR                  UR                  pCXAU'   M      U$ )zExtracts key value pairs from additionalProperties attribute.

Creates a dict to be able to pass them into the client.

Args:
  interconnects: the list of interconnect additionalProperties messages

Returns:
  dictionary containing key value pairs
additionalPropertieskeyvalue)rB   re   interconnect_propertyro   rp   s        r   rX   rX      sQ     	m@@,AA&**,A,G,G"c  B 
r   c                     0 nU (       a  U R                   (       d  U$ U R                    H  nUR                  UR                  pCXAU'   M      U$ )a  Extracts the key,value pairs from the additionalProperties attribute.

Creates a python dict to be able to pass them into the client.

Args:
  endpoints: the list of additionalProperties messages

Returns:
  Python dictionary containing the key value pairs.
rm   )rC   rd   endpoint_propertyro   rp   s        r   rU   rU      sO     -	)88$99"&&(9(?(?# : 
r   c                     / nUR                  5        H8  u  p4UR                  U R                  R                  R	                  UUS95        M:     U R                  R                  US9$ )a  Builds a WireGroupEndpoint.InterconnectsValue message.

Args:
  messages: the messages module
  interconnects_map: map of interconnects with label as the key and the
    interconnect message as the value

Returns:
  WireGroupEndpoint.InterconnectsValue message
ro   rp   rn   )itemsappendr]   InterconnectsValueAdditionalProperty)rM   re   interconnect_properties_listrQ   interconnect_messages        r   r\   r\      sy     "$4E4K4K4M0 ''""55HH"& 	I 	
 5N 
	#	#	6	67 
7 
 r   c                     / nUR                  5        H8  u  p4UR                  U R                  R                  R	                  UUS95        M:     U R                  R                  US9$ )aQ  Builds a WireGroup.EndpointValue message.

This is so we can re-assign them to the additionalProperties attribute on
the WireGroup.EndpointsValue message.

Args:
  messages: the messages module
  endpoints_map: map of endpoints with label as the key and the
    endpoint message as the value

Returns:
  WireGroup.EndpointsValue message
ru   rv   )rw   rx   rO   EndpointsValuerz   )rM   rd   endpoint_properties_listrP   endpoints_messages        r   r^   r^      sw      -:-@-@-B)~##))<<# 	= 	
 .C 
			*	*3 
+ 
 r   N)&r   
__future__r   r   r   googlecloudsdk.api_lib.computer   8googlecloudsdk.api_lib.compute.interconnects.wire_groupsr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   rG   0googlecloudsdk.command_lib.compute.interconnectsr
   r&   Dgooglecloudsdk.command_lib.compute.interconnects.cross_site_networksr"   <googlecloudsdk.command_lib.compute.interconnects.wire_groupsgooglecloudsdk.corer   r   ri   Errorr   UniverseCompatibleReleaseTracksrE   ALPHABETAGAUpdateCommandr   rX   rU   r\   r^   r   r   r   <module>r      s     8 &  ' 7 K ( E X r N * *
	&7:++ 7 T..33T5F5F5I5Iqd(( q qh..4r   