
    &                     2   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 r\R                   " \R"                  R$                  \R"                  R&                  \R"                  R(                  5       " S S	\R*                  5      5       rg
)z)Command for updating network attachments.    )encoding)base_classes)base)flags)scopec                      SSSS.$ )N2Update a Google Compute Engine network attachment.a"        *{command}* is used to update network attachments. You can update the
      following fields: description, subnets, producer-accept-list and
      producer-reject-list. If you update the producer-accept-list or
      producer-reject-list, the full new list should be specified.
      a        To update all the parameters with the new list, run:

        $ {command} NETWORK_ATTACHMENT_NAME --region=us-central1 --subnets=MY_SUBNET2 --description='default network attachment' --producer-accept-list=PROJECT5,PROJECT6 --producer-reject-list=PROJECT7,PROJECT8

      To update a network attachment to change only the subnet to MY_SUBNET3, run:

        $ {command} NETWORK_ATTACHMENT_NAME --region=us-central1 --subnets=MY_SUBNET3

      )briefDESCRIPTIONEXAMPLES r       1lib/surface/compute/network_attachments/update.py_DetailedHelpr      s    C
	

 r   c                   X    \ rS rSrSrSr\" 5       r\S 5       r	S r
S rS rS rS	 rS
rg)Update1   r	   Nc                 X   [         R                  " 5       U l        U R                  R                  USS9  [        R
                  " SS9U l        U R                  R                  U5        [         R                  " U5        [         R                  " U5        [         R                  " U5        g )Nupdate)operation_typeF)required)
r   NetworkAttachmentArgumentNETWORK_ATTACHMENT_ARGAddArgumentsubnetwork_flags&SubnetworkArgumentForNetworkAttachmentSUBNETWORK_ARGAddDescriptionAddProducerRejectListAddProducerAcceptList)clsparsers     r   ArgsUpdate.Args:   s    !&!@!@!BC**6(*K??O  ""6*	 	'	'r   c                     UR                   R                  " S0 UR                  5       D6nUR                  R                  nUR                  USU4/5      S   $ )z0Returns the existing NetworkAttachment resource.Getr   r   )messages#ComputeNetworkAttachmentsGetRequestAsDictapitools_clientnetworkAttachmentsMakeRequests)selfclientnetwork_attachment_refrequest
collections        r   _GetOldResourceUpdate._GetOldResourceG   sZ    ooAA 
 
'
'
)G ''::JUG <=>qAAr   c                    U R                   R                  UUR                  [        R                  R
                  [        R                  " UR                  5      S9nU Vs/ s H  oDR                  5       PM     nnU$ s  snf )z*Returns subnetwork urls from the argument.)default_scopescope_lister)
r   ResolveAsResource	resourcescompute_scope	ScopeEnumREGIONcompute_flagsGetDefaultScopeListerr.   SelfLink)r-   holderargssubnetwork_refssubnetwork_refsubnetworkss         r   _GetSubnetworksUpdate._GetSubnetworksO   s}    ));;#--44"88G	 < O 9H8Gn!   s   !A>c           	          UR                   R                  SUR                  R                  UR                  UR
                  UR                  5       US94$ )z3Returns a request to update the network attachment.Patch)projectregionnetworkAttachmentnetworkAttachmentResource)r*   r+   r'   %ComputeNetworkAttachmentsPatchRequestrH   rI   Name)r-   r.   r/   replacements       r   _GetPatchRequestUpdate._GetPatchRequest\   sX     	11==*22)00499;&1	 	> 	
	 	r   c                 L   [         R                  " U5      nSnUR                  S5      (       aH  [        U R	                  X5      5      nUR
                  b  U[        UR
                  5      :w  a  Xul        SnUR                  S5      (       a-  UR                  UR                  :w  a  UR                  Ul        SnUR                  S5      (       a[  [        UR                  5      nUR                  b  U[        UR                  5      :w  a   Xl        SnU(       d  UR                  S5        UR                  S5      (       a[  [        UR                  5      n	UR                  b  U	[        UR                  5      :w  a   Xl        SnU	(       d  UR                  S	5        U(       a  U$ g)
z'Returns the updated network attachment.FsubnetsNTdescriptionproducer_reject_listproducerRejectListsproducer_accept_listproducerAcceptLists)r   CopyProtoMessageIsSpecifiedsortedrD   rC   rS   rT   rU   appendrV   rW   )
r-   r?   r@   old_resourcecleared_fieldsrN   
is_updatednew_subnetworksnew_reject_listnew_accept_lists
             r   _ModifyUpdate._Modifyi   s|   ++L9KJ	""t33FABo		!	!	)_

"
"A . #2
&&			\55	5"&"2"2
.//t889o		)	)	1_

*
*I 6 +:'



 5
6.//t889o		)	)	1_

*
*I 6 +:'



 5
6r   c                    [         R                  " U R                  5       5      nUR                  nU R                  R                  XR                  [        R                  R                  S9nU R                  X45      n/ nU R                  X!XV5      nUc  U$ UR                  R                  U5         UR                  U R                  X4U5      /5      sSSS5        $ ! , (       d  f       g= f)z)Issue a network attachment PATCH request.)r5   N)r   ComputeApiHolderReleaseTrackr.   r   r7   r8   r9   r:   r;   r2   rb   r*   IncludeFieldsr,   rO   )r-   r@   r?   r.   r/   r\   r]   rN   s           r   Run
Update.Run   s    **4+<+<+>?F]]F!88JJm.E.E.L.L K  ''GLN,,v\JK				-	-n	=    M
N 
>	=	=s   2"C
C,r   )__name__
__module____qualname____firstlineno____doc__r   r   detailed_helpclassmethodr#   r2   rD   rO   rb   rh   __static_attributes__r   r   r   r   r   1   sA     ;/-
( 
(B*Xr   r   N)rn   apitools.base.pyr   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   r<   r   r9   6googlecloudsdk.command_lib.compute.network_attachments3googlecloudsdk.command_lib.compute.networks.subnetsr   r   ReleaseTracksrf   ALPHABETAGAUpdateCommandr   r   r   r   <module>r}      s    0 & 7 ( E E H Y, T..33T5F5F5I5IqT qqr   