
                         J   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	 Z ej$                  ej&                  j(                  ej&                  j*                  ej&                  j,                         G d
 dej.                               Zy)z)Command for creating network attachments.    )absolute_import)division)unicode_literals)base_classes)base)flags)scopec                     | j                   dk(  r |j                  j                  j                  S | j                   dk(  r |j                  j                  j                  S y)z4Get connection preference of the network attachment.ACCEPT_AUTOMATICACCEPT_MANUALN)connection_preferenceNetworkAttachment#ConnectionPreferenceValueValuesEnumr   r   )argsmessagess     1lib/surface/compute/network_attachments/create.pyGetConnectionPreferencer      sR    	#55%%IIZZZ	?2%%IIWWW	    c                   :    e Zd ZdZddddZdZdZed        Zd Z	y)Createz2Create a Google Compute Engine network attachment.a
        *{command}* is used to create network attachments. A service consumer
      creates network attachments and makes it available to producers.
      Service producers then use a multi-NIC VM to form a bi-directional,
      non-NAT'd communication channel.
      a  
        $ {command} NETWORK_ATTACHMENT_NAME --region=us-central1 --subnets=MY_SUBNET --connection-preference=ACCEPT_MANUAL --producer-accept-list=PROJECT1,PROJECT2 --producer-reject-list=PROJECT3,PROJECT4

      To create a network attachment with a textual description, run:

        $ {command} NETWORK_ATTACHMENT_NAME --region=us-central1 --subnets=MY_SUBNET --connection-preference=ACCEPT_MANUAL --producer-accept-list=PROJECT1,PROJECT2 --producer-reject-list=PROJECT3,PROJECT4 --description='default network attachment'

      )briefDESCRIPTIONEXAMPLESNc                 $   t        j                         | _        | j                  j                  |d       t	        j
                         | _        | j                  j                  |       |j                  j                  t         j                         |j                  j                  t         j                         t        j                  |       t        j                  |       t        j                  |       t        j                  |       y)zCreate a Google Compute Engine network attachment.

    Args:
      parser: the parser that parses the input from the user.
    create)operation_typeN)r   NetworkAttachmentArgumentNETWORK_ATTACHMENT_ARGAddArgumentsubnetwork_flags&SubnetworkArgumentForNetworkAttachmentSUBNETWORK_ARGdisplay_info	AddFormatDEFAULT_LIST_FORMATAddCacheUpdaterNetworkAttachmentsCompleterAddDescriptionAddConnectionPreferenceAddProducerRejectListAddProducerAcceptList)clsparsers     r   ArgszCreate.ArgsC   s     "'!@!@!BC**6(*K)PP C""6*
!!%";";<
''(I(IJ	 	!!&)	'	'r   c                    t        j                  | j                               }|j                  }| j                  j                  ||j                  t        j                  j                        }| j                  j                  ||j                  t        j                  j                  t        j                  |            }|D cg c]  }|j                          }}|j                  j                  |j                   |j#                         t%        ||j                        |      }|j'                  d      r|j(                  |_        |j'                  d      r|j,                  |_        |j                  j1                  |j2                  |j4                  |      }	|j6                  j8                  }
|j;                  |
d|	fg      S c c}w )z*Issue a network attachment INSERT request.)default_scope)r0   scope_lister)descriptionnameconnectionPreferencesubnetworksproducer_reject_listproducer_accept_list)projectregionnetworkAttachmentInsert)r   ComputeApiHolderReleaseTrackclientr   ResolveAsResource	resourcescompute_scope	ScopeEnumREGIONr"   compute_flagsGetDefaultScopeListerSelfLinkr   r   r2   Namer   IsSpecifiedr6   producerRejectListsr7   producerAcceptLists&ComputeNetworkAttachmentsInsertRequestr8   r9   apitools_clientnetworkAttachmentsMakeRequests)selfr   holderr>   network_attachment_refsubnetwork_refssubnetwork_refr5   network_attachmentrequest
collections              r   Runz
Create.RunX   s   **4+<+<+>?F]]F!88JJfm.E.E.L.L K N));;#--44"88@	 < BO 9H8Gn!    ::$$#((*4T6??K	 ; ! .//3/H/H,.//3/H/H,ooDD&..%,,, E .G ''::JXw ?@AA)s   G)
__name__
__module____qualname____doc__detailed_helpr   r"   classmethodr.   rW    r   r   r   r   '   sC     ; D

-&  .( ((Br   r   N)r[   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   rD   r	   rA   6googlecloudsdk.command_lib.compute.network_attachments3googlecloudsdk.command_lib.compute.networks.subnetsr    r   ReleaseTracksr=   ALPHABETAGACreateCommandr   r^   r   r   <module>rj      s    0 &  ' 7 ( E E H Y T..33T5F5F5I5IMBT MBMBr   