
                         t   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ddZe
j*                   e
j,                  e
j.                  j0                  e
j.                  j2                         G d de
j4                                      Zd Zd Zd Zd Zee_         y)z1Command for adding interconnects to a wire group.    )absolute_import)division)unicode_literals)base_classes)client)base)scope)flags)
propertiesz        *{command}* is used to remove interconnects from a wire group endpoint.

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

          $ {command} example-wire-group --project=example-project --cross-site-network=example-cross-site-network --endpoint-label=example-endpoint --interconnect-label=example-interconnect
        )DESCRIPTIONEXAMPLESc                   4    e Zd ZdZdZdZed        Zd Zd Z	y)RemoveInterconnectziRemove interconnect from a wire group.

  *{command}* removes interconnect from a wire group endpoint.
  Nc                 0   t        j                         | _        | j                  j                  |       t	        j
                  d      | _        | j                  j                  |d       t	        j                  |       t	        j                  |       y )NF)pluralupdate)operation_type)	cross_site_network_flags(CrossSiteNetworkArgumentForOtherResourceCROSS_SITE_NETWORK_ARGAddArgumentr
   WireGroupArgumentWIRE_GROUP_ARGAddEndpointLabelAddInterconnectLabel)clsparsers     Dlib/surface/compute/interconnects/wire_groups/remove_interconnect.pyArgszRemoveInterconnect.Args9   sv     	!IIK  **6200>C""6("C	6"	v&    c                      y)Nzcompute.wireGroups )selfs    r   
CollectionzRemoveInterconnect.CollectionD   s    r    c                    t        j                  | j                               }| j                  j	                  ||j
                  t        j                  j                  d|j                  i      }t        j                  j                  j                  j                         }|j                  j                   | _        t        j$                  |||j                  |j                  |j
                        }|j&                  }|j(                  }|j+                         j,                  }t/        |      }	||	vrt1        d      S ||	v rV|	|   j2                  }
t5        |
      }||v r||= t7        | j"                  |      }
| j"                  j9                  |
      |	|<   t;        | j"                  |	      }|j=                  |      S )a  Runs the remove-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.

    crossSiteNetwork)default_scopeadditional_params)refprojectcross_site_networkcompute_client	resourceszEndpoint not found.)interconnects)	endpoints)r   ComputeApiHolderReleaseTrackr   ResolveAsResourcer-   compute_scope	ScopeEnumGLOBALr+   r   VALUEScorer*   	GetOrFailr   messages	_messages	WireGroupendpoint_labelinterconnect_labelDescriber/   _convert_endpoints_to_dictAttributeErrorr.   _convert_interconnects_to_dict_build_interconnect_messagesWireGroupEndpoint_build_endpoint_messagesPatch)r#   argsholderr)   r*   
wire_groupr<   r=   r/   endpoints_mapr.   interconnects_maps               r   RunzRemoveInterconnect.RunG   s    **4+<+<+>?F



/
/#--44-t/F/FG	 0 C $$,,668G]]++DN!!22}}""J ((N00##%//I /y9M]*122&#N3AAm 9G 
0	001 3
..+m '+nn&F&F% 'G 'mN# )GI   r    )
__name__
__module____qualname____doc__r   r   classmethodr   r$   rK   r"   r    r   r   r   .   s1    
 .' ' Br    r   c                     i }| r| j                   s|S | j                   D ]  }|j                  |j                  }}|||<   ! |S )a  Extracts 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)r.   rJ   interconnect_propertyrT   rU   s        r   rA   rA      sV     	m@@,AA&**,A,G,GC"c  B 
r    c                     i }| r| j                   s|S | j                   D ]  }|j                  |j                  }}|||<   ! |S )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.
  rR   )r/   rI   endpoint_propertyrT   rU   s        r   r?   r?      sS     -	)88$99"&&(9(?(?CM# : 
r    c                     |syg }|j                         D ];  \  }}|j                  | j                  j                  j	                  ||             = | j                  j                  |      S )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
  NrT   rU   rS   )itemsappendrC   InterconnectsValueAdditionalProperty)r9   rJ   interconnect_properties_listr=   interconnect_messages        r   rB   rB      s     
!#4E4K4K4M0/ ''""55HH"& 	I 	
 5N 
	#	#	6	67 
7 
 r    c                     |syg }|j                         D ];  \  }}|j                  | j                  j                  j	                  ||             = | j                  j                  |      S )ac  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
  NrZ   r[   )r\   r]   r;   EndpointsValuer_   )r9   rI   endpoint_properties_listr<   endpoints_messages        r   rD   rD      s     
-:-@-@-B)~(##))<<# 	= 	
 .C 
			*	*3 
+ 
 r    N)!rO   
__future__r   r   r   googlecloudsdk.api_lib.computer   8googlecloudsdk.api_lib.compute.interconnects.wire_groupsr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r3   Dgooglecloudsdk.command_lib.compute.interconnects.cross_site_networksr
   r   <googlecloudsdk.command_lib.compute.interconnects.wire_groupsgooglecloudsdk.corer   DETAILED_HELPUniverseCompatibleReleaseTracksr1   ALPHABETAUpdateCommandr   rA   r?   rB   rD   detailed_helpr"   r    r   <module>ru      s     8 &  ' 7 K ( E r N *  D%%++T->->-C-CDY++ Y E Yx..:> $1   r    