
                             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  \R                    " S
 S\R"                  5      5       rSSS.\l        g)zDCommand for adding an empty route policy to a Compute Engine router.    )absolute_import)division)unicode_literals)base_classes)base)
exceptions)flags)	arg_utilsc                   >    \ rS rSrSrSr\S 5       rS rS r	S r
Srg)	AddRoutePolicy   z5Add an empty route policy to a Compute Engine router.Nc                     [         R                  " 5       [        l        [        R                  R	                  USS9  UR                  SSSS9  UR                  S[        R                  SS	S
.SSS9  g )Nupdate)operation_typez--policy-namez Name of the route policy to add.T)helprequiredz--policy-typez%The route policy is an import policy.z%The route policy is an export policy.)IMPORTEXPORTz Type of the route policy to add.)typechoicesr   r   )r	   RouterArgumentr   
ROUTER_ARGAddArgumentadd_argumentr
   ChoiceToEnumName)clsparsers     /lib/surface/compute/routers/add_route_policy.pyArgsAddRoutePolicy.Args$   s|     % 4 4 6N))&)J
3  
 ''==
 4  	    c                    [         R                  " U R                  5       5      nUR                  n[        R
                  R                  UUR                  [        R                  " U5      S9nUR                  R                  UR                  UR                  R                  R                  U R                  UR                  5      5      S9nU R!                  X4UR                  5        UR"                  R$                  SUR                  R&                  " S0 UR)                  5       DSU0D64nUR+                  U/5      S   $ )zIssues the requests needed for adding an empty route policy to a Router.

Args:
  args: contains arguments passed to the command.

Returns:
  The result of patching the router adding the empty route policy.
)scope_lister)namer   UpdateRoutePolicyroutePolicyr    )r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListermessagesRoutePolicypolicy_nameTypeValueValuesEnumConvertRouteTypepolicy_typeRequireRoutePolicyDoesNotExistapitools_clientrouters&ComputeRoutersUpdateRoutePolicyRequestAsDictMakeRequests)selfargsholderr*   
router_refroute_policyrequests          r   RunAddRoutePolicy.Run8   s!    **4+<+<+>?F]]F**<<"88@ = J
 ??..__((<<!!$"2"23
 / L 	''D<L<LM&&>> 	
!	
/;	
G y)!,,r!   c                 V   UR                   R                  SUR                  R                  " S0 UR	                  5       DSU0D64n UR                  U/5        [        R                  " SSR                  U5      5      e! [         a  nSUR                  5       ;   a   S nAg e S nAff = f)NGetRoutePolicypolicyz?Could not fetch resource:
 - Invalid value for field 'policy': zpolicy-namez#A policy named '{0}' already existsr'   )r6   r7   r/   #ComputeRoutersGetRoutePolicyRequestr9   r:   	Exception__str__r   BadArgumentExceptionformat)r;   r*   r>   r1   r@   	exceptions         r   r5   -AddRoutePolicy.RequireRoutePolicyDoesNotExist[   s    &&;; 	
!	
*5	
G7)$ 
)
)<CCKP   
L ! 	s   A? ?
B(	B#"B##B(c                 "    US:X  a  gUS:X  a  gU$ )Nr   ROUTE_POLICY_TYPE_IMPORTr   ROUTE_POLICY_TYPE_EXPORTr'   )r;   
route_types     r   r3   AddRoutePolicy.ConvertRouteTypep   s    X'	x	'r!   r'   )__name__
__module____qualname____firstlineno____doc__r   classmethodr   rA   r5   r3   __static_attributes__r'   r!   r   r   r      s,    =* &!-F*r!   r   zO          *{command}* adds an empty route policy to a Compute Engine router.
  z          To add an import route policy `my-policy`  to a router `my-router` in region `us-central1`, run:

              $ {command} my-router --region=us-central1 --policy-name=my-policy --policy-type=IMPORT

          )DESCRIPTIONEXAMPLESN)rV   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer	   r-   *googlecloudsdk.command_lib.compute.routers$googlecloudsdk.command_lib.util.apisr
   UniverseCompatibleUpdateCommandr   detailed_helpr'   r!   r   <module>rd      se     K &  ' 7 ( . E < : WT'' W Wv	
  r!   