
    D                         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 e	j                   G d
 de	j                                Zd Zddde_        y)zDCommand for updating a route policy term of a Compute Engine router.    )absolute_import)division)unicode_literals)base_classes)arg_parsers)base)flags)route_policy_utilsc                   *    e Zd ZdZdZed        Zd Zy)UpdateRoutePolicyTermzEUpdates a term of an existing route policy of a Comute Engine router.Nc           	      x   t        j                         t        _        t        j                  j	                  |d       |j                  ddd       |j                  dddt        j                  d	d
             |j                  ddd       |j                  dddt        j                  d      d       y )Nupdate)operation_typez--policy-namez=Name of the route policy to which the term should be updated.T)helprequiredz
--priorityz$Order of the term within the policy.r   i)lower_boundupper_bound)r   r   typez--matchz$CEL expression for matching a route.z	--actionszRSemicolon separated CEL expressions for the actions to take when the rule matches.;)custom_delim_charACTION)r   r   r   metavar)	r	   RouterArgumentr   
ROUTER_ARGAddArgumentadd_argumentr   
BoundedIntArgList)clsparsers     7lib/surface/compute/routers/update_route_policy_term.pyArgszUpdateRoutePolicyTerm.Args"   s    ',';';'=$$$00x 1  P  
 7##zJ	   7  
 e  37      c                    t        j                  | j                               }|j                  }|j                  j                  }|j                  j
                  j                  }t        j                  j                  ||j                  t        j                  |            }|j                   |j                  di |j                         d|j                   i      j"                  }t%        j&                  ||j(                        }t+        |||       |d |j,                  di |j                         d|if}	|j/                  |	g      d   S )N)scope_listerpolicyPatchRoutePolicyroutePolicyr    )r   ComputeApiHolderReleaseTrackclientmessagesapitools_clientroutersr   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerGetRoutePolicy#ComputeRoutersGetRoutePolicyRequestAsDictpolicy_nameresourcer
   FindPolicyTermOrRaisepriority_UpdatePolicyTermMessage%ComputeRoutersPatchRoutePolicyRequestMakeRequests)
selfargsholderr,   r-   service
router_refroute_policytermrequests
             r!   RunzUpdateRoutePolicyTerm.Run@   s=   **4+<+<+>?F]]F}}%%Hmm++33G&11CC"88@ D J
 ))444 	
!	
*.*:*:	
 h	  33L$--PDT8T2666 	
!	
$	
G y)!,,r#   )__name__
__module____qualname____doc__r   classmethodr"   rF   r)   r#   r!   r   r      s!    M* :-r#   r   c                     |j                  |j                        | _        |j                  D cg c]  }|j                  |       c}| _        y c c}w )N)
expression)Exprmatchactions)rD   r-   r?   cel_expressions       r!   r;   r;   _   sM    }}

}3$* !LL(. mm~m.($, s   Az>        *{command}* updates a term of a route policy.
        a          To update a term with priority 128 with match `destination == '192.168.0.0/24'` and actions `med.set(12345);asPath.prependSequence([1, 2])` of a route policy `example-policy-name` of a router `example-router` in region `router-region`, run:

          $ {command} example-router --region=router-region --policy-name=example-policy-name --priority=128 --match="destination == '192.168.0.0/24'" --actions="med.set(12345);asPath.prependSequence([1, 2])"

        )DESCRIPTIONEXAMPLESN)rJ   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer	   r2   *googlecloudsdk.command_lib.compute.routersr
   UniverseCompatibleUpdateCommandr   r;   detailed_helpr)   r#   r!   <module>r\      sh    K &  ' 7 / ( E < I ?-D.. ?- ?-D'  #r#   