
    i                     h   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ee_        y)z-Command for adding endpoints to a wire group.    )absolute_import)division)unicode_literals)base_classes)client)base)scope)flags)
propertiesz        *{command}* is used to add endpoints to a wire group.

        For an example, refer to the *EXAMPLES* section below.
        z        To add endpoint example-endpoint to wire group example-wire-group, run:

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

  *{command}* adds endpoint to a Compute Engine wire group.
  Nc                    t        j                         | _        | j                  j                  |       t	        j
                  d      | _        | j                  j                  |d       t	        j                  |       y )NF)pluralupdate)operation_type)cross_site_network_flags(CrossSiteNetworkArgumentForOtherResourceCROSS_SITE_NETWORK_ARGAddArgumentr
   WireGroupArgumentWIRE_GROUP_ARGAddEndpointLabel)clsparsers     =lib/surface/compute/interconnects/wire_groups/add_endpoint.pyArgszAddEndpoint.Args9   sh     	!IIK  **6200>C""6("C	6"    c                      y)Nzcompute.wireGroups )selfs    r   
CollectionzAddEndpoint.CollectionC   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*                  }t-        |      }|j                  j                   j/                         ||<   t1        | j"                  |      }|j3                  |      S )NcrossSiteNetwork)default_scopeadditional_params)refprojectcross_site_networkcompute_client	resources)	endpoints)r   ComputeApiHolderReleaseTrackr   ResolveAsResourcer,   compute_scope	ScopeEnumGLOBALr*   r   VALUEScorer)   	GetOrFailr   messages	_messages	WireGroupendpoint_labelDescriber-   convert_endpoints_to_dictWireGroupEndpoint_build_endpoint_messagesPatch)	r"   argsholderr(   r)   
wire_groupr:   r-   endpoints_maps	            r   RunzAddEndpoint.RunF   s4   **4+<+<+>?F



/
/#--44-t/F/FG	 0 C $$,,668G]]++DN!!22}}""J ((N##%//I-i8M$*MM$:$:$L$L$NM.!(GI   r   )
__name__
__module____qualname____doc__r   r   classmethodr   r#   rD   r!   r   r   r   r   .   s0    
 .# # r   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.
  )additionalPropertieskeyvalue)r-   rC   endpoint_propertyrL   rM   s        r   r<   r<   g   sS     -	)88$99"&&(9(?(?CM# : 
r   c                     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
  )rL   rM   )rK   )itemsappendr9   EndpointsValueAdditionalProperty)r7   rC   endpoint_properties_listr:   endpoints_messages        r   r>   r>   ~   sz      +8+>+>+@'n'##))<<# 	= 	
 ,A 
			*	*3 
+ 
 r   N)rH   
__future__r   r   r   googlecloudsdk.api_lib.computer   8googlecloudsdk.api_lib.compute.interconnects.wire_groupsr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r1   Dgooglecloudsdk.command_lib.compute.interconnects.cross_site_networksr
   r   <googlecloudsdk.command_lib.compute.interconnects.wire_groupsgooglecloudsdk.corer   DETAILED_HELPUniverseCompatibleReleaseTracksr/   ALPHABETAUpdateCommandr   r<   r>   detailed_helpr!   r   r   <module>re      s     4 &  ' 7 K ( E r N *  D%%++T->->-C-CD4$$$ 4 E 4n.8 * r   