
                             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
ZdZ ej$                  ej&                  j(                         G d dej*                               Zy)z:Command to update a Distributed Cloud Edge Network router.    )absolute_import)division)unicode_literals)routers)base)resource_args)flags)loga%  Update a Distributed Cloud Edge Network router.

Note that `update` operations are not thread-safe, meaning that if more than one
user is updating a router at a time, there can be race conditions. Please ensure
that at most one `update` operation is being applied to a given router at a
time.
a      To add a northbound route advertisement for destination range 8.8.0.0/16 for Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:

        $ {command} my-router --add-advertisement-ranges=8.8.0.0/16 --location=us-central1 --zone=us-central1-edge-den1

    To remove a northbound route advertisement for destination range 8.8.0.0/16 for Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:

        $ {command} my-router --remove-advertisement-ranges=8.8.0.0/16 --location=us-central1 --zone=us-central1-edge-den1

    To replace the set of route advertisements with just 8.8.0.0/16 and 1.1.0.0/16, in Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:

        $ {command} my-router --set-advertisement-ranges=8.8.0.0/16,1.1.0.0/16 --location=us-central1 --zone=us-central1-edge-den1
   c                   6    e Zd ZdZeedZed        Zd Z	d Z
y)UpdatezyUpdate a Distributed Cloud Edge Network router.

  *{command}* is used update a Distributed Cloud Edge Network router.
  )DESCRIPTIONEXAMPLESc                     t        j                  | dd       t        j                  |        t        j
                  j                  |        y )Nzto be updatedT)r   AddRouterResourceArgrouters_flagsAddUpdateArgsr   
ASYNC_FLAGAddToParser)parsers    3lib/surface/edge_cloud/networking/routers/update.pyArgszUpdate.Args;   s4    &&vE'OO'    c                    t        j                  | j                               }|j                  j                  j                         }| j                  |      sy |j                  ||      }t        |dd      }|s8|j                  |      }t        j                  |j                         d       |S t        j                  j                  dj                  |j                         |j                                y )Nasync_FzOperation was successful.)detailsz$Updating [{0}] with operation [{1}].)r   RoutersClientReleaseTrackCONCEPTSrouterParsehas_routes_argChangeAdvertisementsgetattrWaitForOperationr
   UpdatedResourceRelativeNamestatusPrintformatname)selfargsrouters_client
router_refupdate_req_opr   responses          r   Runz
Update.RunA   s    **4+<+<+>?N%%++-Jt$"77
DIMT8U+F00?h	

!
!
#-HJoJJ;BB!=#5#57 8r   c                     |j                   |j                  |j                  g}t        d |      }t	        d |D              }|dk(  ry|dk(  ryt        d      )Nc              3       K   | ]  }d   yw)   N ).0_s     r   	<genexpr>z(Update.has_routes_arg.<locals>.<genexpr>[   s     +(Qq(s   r   Fr4   TzwInvalid argument: Expected at most one of add_advertisement_ranges remove_advertisement_ranges set_advertisement_ranges)add_advertisement_rangesremove_advertisement_rangesset_advertisement_rangesfiltersum
ValueError)r+   r,   relevant_argsfilterednumber_founds        r   r!   zUpdate.has_routes_argT   sl    %%((%%M
 dM*H+(++Lqq
	?@ @r   N)__name__
__module____qualname____doc__r   r   detailed_helpstaticmethodr   r1   r!   r5   r   r   r   r   2   s0    
 #.8D-( (
8&@r   r   N)rE   
__future__r   r   r   4googlecloudsdk.api_lib.edge_cloud.networking.routersr   googlecloudsdk.callioper   0googlecloudsdk.command_lib.edge_cloud.networkingr   8googlecloudsdk.command_lib.edge_cloud.networking.routersr	   r   googlecloudsdk.corer
   r   r   ReleaseTracksr   ALPHAUpdateCommandr   r5   r   r   <module>rQ      sn    A &  ' H ( J [ # D%%++,0@T 0@ -0@r   