
    p                        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
 r " S S\5      r\R.                  \R0                  " \R2                  R4                  5       " S S\R6                  5      5       5       r\R0                  " \R2                  R:                  5       " S S\5      5       r\R0                  " \R2                  R>                  5       " S S\5      5       r g)z)Command for creating service attachments.    )absolute_import)division)unicode_literals)base_classes)base)flags)scope)service_attachments_utilsc                      SSSS.$ )N2Create a Google Compute Engine service attachment.a        *{command}* is used to create service attachments. A service producer
      creates service attachments to make a service available to consumers.
      Service consumers use Private Service Connect endpoints to privately
      forward traffic to the service attachment.
      a        If there is an already-created internal load balancer (ILB) with the name
      MY_ILB in region us-central1 and there is an already-created Private
      Service Connect subnets MY_SUBNET1 and MY_SUBNET2, create a service
      attachment pointing to the ILB by running:

        $ {command} SERVICE_ATTACHMENT_NAME --region=us-central1 --producer-forwarding-rule=MY_ILB --connection-preference=ACCEPT_AUTOMATIC --nat-subnets=MY_SUBNET1,MY_SUBNET2

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

        $ {command} SERVICE_ATTACHMENT_NAME --region=us-central1 --producer-forwarding-rule=MY_ILB --connection-preference=ACCEPT_AUTOMATIC --nat-subnets=MY_SUBNET1,MY_SUBNET2 --description='default service attachment'

      )briefDESCRIPTIONEXAMPLES r       1lib/surface/compute/service_attachments/create.py_DetailedHelpr      s     ?


 r   c                   @    \ rS rSrSrSrSrSrS r\	S 5       r
S rSrg)CreateHelper;   z,Helper class to create a service attachment.Nc                     Xl         g N_holder)selfholders     r   __init__CreateHelper.__init__B   s    Lr   c                 8   [         R                  " 5       U l        U R                  R                  USS9  [        R
                  " 5       U l        [        R                  " 5       U l	        U R                  R                  U5        UR                  R                  [         R                  5        UR                  R                  [         R                  5        [         R                  " U5        [         R                   " U5        [         R"                  " USS9  [         R$                  " U5        [         R&                  " U5        [         R(                  " U5        [         R*                  " U5        [         R,                  " U5        [         R.                  " U5        g)ztCreate a Google Compute Engine service attachment.

Args:
  parser: the parser that parses the input from the user.
create)operation_typeF)	is_updateN)r   ServiceAttachmentArgumentSERVICE_ATTACHMENT_ARGAddArgumentforwarding_rule_flags*ForwardingRuleArgumentForServiceAttachmentPRODUCER_FORWARDING_RULE_ARGsubnetwork_flags&SubnetworkArgumentForServiceAttachmentNAT_SUBNETWORK_ARGdisplay_info	AddFormatDEFAULT_LIST_FORMATAddCacheUpdaterServiceAttachmentsCompleterAddDescription-AddTargetServiceAndProducerForwardingRuleArgsAddConnectionPreferenceAddEnableProxyProtocolForCreate AddReconcileConnectionsForCreateAddConsumerRejectListAddConsumerAcceptListOldAddDomainNamesAddPropagatedConnectionLimitclsparsers     r   ArgsCreateHelper.ArgsE   s"    "'!@!@!BC**6(*KHHJ $ 	??A  &&v.
!!%";";<
''(I(IJ	 	77?	!!&E:	))&1	**62	'	""6*	 	&&v.r   c           
         U R                   R                  nU R                  R                  UU R                   R                  [
        R                  R                  S9nU R                  R                  UU R                   R                  [
        R                  R                  S9nUR                  =n(       a  UnSnO'U(       a   UR                  5       nUR                  5       nU R                  R                  UU R                   R                  [
        R                  R                  [        R                  " U5      S9nU V	s/ s H  n	U	R                  5       PM     n
n	[        R                  " XR                   5      nUR"                  nUR                   R%                  UR&                  UR)                  5       U
UUWWS9nUR+                  S5      (       a  UR,                  Ul        UR+                  S5      (       a&  [        R0                  " XR                   5      nXl        UR+                  S5      (       a  UR4                  Ul        UR+                  S5      (       a  UR8                  Ul        UR+                  S	5      (       a  UR<                  Ul        UR                   RA                  URB                  URD                  US
9nURF                  RH                  nURK                  USU4/5      $ s  sn	f )z*Issue a service attachment INSERT request.)default_scopeN)r@   scope_lister)descriptionname
natSubnetsconnectionPreferenceenableProxyProtocolproducerForwardingRuletargetServiceconsumer_reject_listconsumer_accept_listdomain_namesreconcile_connectionspropagated_connection_limit)projectregionserviceAttachmentInsert)&r   clientr$   ResolveAsResource	resourcescompute_scope	ScopeEnumREGIONr(   target_serviceSelfLinkr+   compute_flagsGetDefaultScopeListerr
   GetConnectionPreferencemessagesenable_proxy_protocolServiceAttachmentrB   NameIsSpecifiedrI   consumerRejectListsGetConsumerAcceptListconsumerAcceptListsrK   domainNamesrL   reconcileConnectionsrM   propagatedConnectionLimit&ComputeServiceAttachmentsInsertRequestrN   rO   apitools_clientserviceAttachmentsMakeRequests)r   argsrR   service_attachment_refproducer_forwarding_rule_reftarget_service_argsrX   producer_forwarding_rulenat_subnetwork_refsnat_subnetwork_refnat_subnetworksconnection_preferencer^   service_attachmentaccept_listrequest
collections                    r   RunCreateHelper.Runc   s   \\  F!88JJ#--44 K  	));;LL""'1188 	< 	
 ! #1111*n!%	%!=!F!F!H3<<>n11CC#--44"88@	 D  #6"5 	##%"5   6MMoo 66::$$#((*"217$ ;  .///3/H/H,.//-CC
!k/:,'''+'8'8$/00040J0J-566

*
* 2 ooDD&..%,,, E .G ''::JXw ?@AAMs   K5r   )__name__
__module____qualname____firstlineno____doc__r$   r(   r+   r   classmethodr=   ry   __static_attributes__r   r   r   r   r   ;   s7    4!% / /:ABr   r   c                   <    \ rS rSrSr\" 5       r\S 5       rS r	Sr
g)Create   r   c                 .    [         R                  U5        g r   )r   r=   r:   s     r   r=   Create.Args   s    fr   c                 ~    [         R                  " U R                  5       5      n[        U5      R	                  U5      $ r   )r   ComputeApiHolderReleaseTrackr   ry   )r   rl   r   s      r   ry   
Create.Run   s1    **4+<+<+>?F##D))r   r   N)r{   r|   r}   r~   r   r   detailed_helpr   r=   ry   r   r   r   r   r   r      s%    
 ;/- *r   r   c                   &    \ rS rSrSr\" 5       rSrg)
CreateBeta   r   r   Nr{   r|   r}   r~   r   r   r   r   r   r   r   r   r           ;/-r   r   c                   &    \ rS rSrSr\" 5       rSrg)CreateAlpha   r   r   Nr   r   r   r   r   r      r   r   r   N)!r   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   rZ   r	   rU   3googlecloudsdk.command_lib.compute.forwarding_rulesr&   3googlecloudsdk.command_lib.compute.networks.subnetsr)   6googlecloudsdk.command_lib.compute.service_attachmentsr
   r   objectr   UniverseCompatibleReleaseTracksr   GACreateCommandr   BETAr   ALPHAr   r   r   r   <module>r      s    0 &  ' 7 ( E E ^ Y H \8iB6 iBX *T * * " "" "& ""r   