
                            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lmZ ddlmZ  ej(                  ej*                  j,                         G d dej.                               Z ej(                  ej*                  j2                         G d de             Z ej(                  ej*                  j6                         G d de             Zddie_        y)z,Command for updating Compute Engine routers.    )absolute_import)division)unicode_literals)base_classes)routers_utils)poller)waiter)base)flags)router_utils)log)	resourcesc                   @    e Zd ZdZdZed        Zed        Zd Zd Z	y)UpdateUpdate a Compute Engine router.Nc                 X   t        j                         | _        | j                  j                  |d       t        j
                  j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |d       y )Nupdate)operation_typerouter)r   RouterArgument
ROUTER_ARGAddArgumentr
   
ASYNC_FLAGAddToParserAddKeepaliveIntervalArgAddBgpIdentifierRangeArg	AddAsnArg AddUpdateCustomAdvertisementArgsclsparsers     %lib/surface/compute/routers/update.py_ArgszUpdate._Args&   ss    ))+CNNNvh?OO'	!!&)	""6*	OOF	**68<    c                 &    | j                  |       y )N)r#   r   s     r"   ArgszUpdate.Args0   s    IIfr$   c           	      6   t        j                  |       t        j                  | j	                               }|j
                  j                  }|j
                  j                  j                  }| j                  j                  ||j                        }|j                  }|j                   |di |j                               }|j                  xs |j!                         |_        |j                  j"                  }|j$                  !t'        |j                  d|j$                         |j(                  !t'        |j                  d|j(                         |j*                  !t'        |j                  d|j*                         t        j,                  |      rt        j.                  ||j                   |      \  }	}
}t        j0                  ||j                   ||	       |	|
|d}|j3                         D ]  \  }}|	t'        |j                  ||       ! t        j4                  |      rt        j6                  ||j                   |j                         |j8                  rPt;        j<                  |j                   |j8                        }|j                  j>                  jA                  |       |jB                  rXt;        j<                  |j                   |jB                        }t        jD                  ||j                   |j                  |	       |jF                  rFt;        jH                  ||jF                  
      }|j                  jJ                  jA                  |       |jL                  r7t        jN                  ||j                   |j                  |jL                         g }|j                  j>                  s|jQ                  d       |j                  jJ                  s|jQ                  d       |j
                  j                  jS                  |      5  |jT                  }|jW                   ||jX                  |jZ                  |j]                         |            }d d d        t        j^                  ja                  jb                  d|jX                  |jZ                  d      }|jd                  r8tg        jh                  |djk                  |j]                               dd       |S |j                  ja                  |j]                         d|jX                  |jZ                  d      }tm        jn                  ||      }tq        jr                  ||djk                  |j]                                     S # 1 sw Y   xY w)NkeepaliveIntervalidentifierRangeasn)messagesresource_classargs)r+   r,   existing_modenew_mode)advertiseModeadvertisedGroupsadvertisedIpRanges)r+   r,   resource)r,   groups)r+   r,   r3   r4   )r+   	ip_ranges)r+   r,   r3   r5   zbgp.advertisedGroupszbgp.advertisedIpRanges)projectregionr   routerResourcezcompute.regionOperations)r6   r7   )
collectionparamszrouter [{0}]Tz[Run the [gcloud compute operations describe] command to check the status of this operation.)kindis_asyncdetailszcompute.routerszUpdating router [{0}] ):r   CheckIncompatibleFlagsOrRaiser   ComputeApiHolderReleaseTrackclientr+   apitools_clientroutersr   ResolveAsResourcer   ComputeRoutersGetRequestGetAsDictbgp	RouterBgpr0   keepalive_intervalsetattrbgp_identifier_ranger*   HasReplaceAdvertisementFlagsParseAdvertisementsPromptIfSwitchToDefaultModeitems HasIncrementalAdvertisementFlagsValidateCustomModeadd_advertisement_groupsr   ParseGroupsr1   extendremove_advertisement_groupsRemoveGroupsFromAdvertisementsadd_advertisement_rangesParseIpRangesr2   remove_advertisement_ranges RemoveIpRangesFromAdvertisementsappendIncludeFieldsComputeRoutersPatchRequestPatchr6   r7   NameREGISTRYParsenameasync_r   UpdatedResourceformatr   Pollerr	   WaitFor)selfr-   holderr+   service
router_refrequest_typereplacementr.   moder4   rangesattrsattrvaluegroups_to_addgroups_to_removeip_ranges_to_addcleared_fieldsresultoperation_reftarget_router_refoperation_pollers                          r"   _RunzUpdate._Run4   s   ..t4**4+<+<+>?F}}%%Hmm++33G2249I9IJJ44L++lAZ->->-@ABK!oo=););)=KOOO11M*koo2D4K4KL  ,koo0$2K2KLxxkooudhh/006)==H,>,>TdFF ..!++%	  $ &e +$
+//4
/ ' 44T:%%!++?? 
	&	&%11#--00
 	((//>		)	)(44#--33
 	33#-- __#		
 
	&	&(66)F)F
 	**112BC		)	)55#-- __66		
 N??++23??--45		&	&	4	4^	D88l}}
 ((&&__&(	f 
E &&,,-!)) ''
 - M {{	
$$Z__%677 m((..$!)) ''
 /  }}W.?@>>&&z'89 U 
E	Ds   (A
VVc                 $    | j                  |      S )zSee base.UpdateCommand.)r}   )rj   r-   s     r"   Runz
Update.Run   s    99T?r$   )
__name__
__module____qualname____doc__r   classmethodr#   r&   r}   r   r>   r$   r"   r   r       s<    '*= =  M^r$   r   c                       e Zd ZdZy)
UpdateBetar   Nr   r   r   r   r>   r$   r"   r   r          'r$   r   c                       e Zd ZdZy)UpdateAlphar   Nr   r>   r$   r"   r   r      r   r$   r   DESCRIPTIONzH
        *{command}* is used to update a Compute Engine router.
        N)r   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr	   googlecloudsdk.callioper
   *googlecloudsdk.command_lib.compute.routersr   r   googlecloudsdk.corer   r   ReleaseTracksrA   GAUpdateCommandr   BETAr   ALPHAr   detailed_helpr>   r$   r"   <module>r      s    3 &  ' 7 8 < . ( < C # ) D%%(()dT d *dN D%%**+  , D%%++,*  -   r$   