
    f                         S r SSKJr  SSKJr  SSKJr  SSK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 downloading a route policy from a Compute Engine router.    )absolute_import)division)unicode_literalsN)base_classes)base)
exceptions)flags)resource_printer)filesc                   >    \ rS rSrSrSr\S 5       rS rS r	S r
Srg)	DownloadRoutePolicy!   z5Download a route policy from a Compute Engine router.Nc                     [         R                  " 5       [        l        [        R                  R	                  USS9  UR                  SSSS9  UR                  SSSS9  UR                  S	S
S/SS9  g )Nexport)operation_typez--policy-nameTz%Name of the route policy to download.)requiredhelpz--file-namez<The name of the file to download the route policy config to.z--file-formatjsonyamlz(Format of the file passed to --file-name)choicesr   )r	   RouterArgumentr   
ROUTER_ARGAddArgumentadd_argument)clsparsers     4lib/surface/compute/routers/download_route_policy.pyArgsDownloadRoutePolicy.Args'   s    %*%9%9%;"""..vh.O
4  
 K  
  7      c                    [         R                  " U R                  5       5      nUR                  n[        R
                  R                  UUR                  [        R                  " U5      S9n[        R                  R                  UR                  5      (       a/  [        R                  " SR!                  UR                  5      5      eU R#                  X4UR$                  5      nU R'                  XQR                  UR(                  5        g)z?Downloads a route policy from a Router into the specified file.)scope_listerz[{0}] is a directoryN)r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerospathisdir	file_namer   BadFileExceptionformatGetRoutePolicypolicy_nameWriteToFilefile_format)selfargsholderr%   
router_refroute_policys         r   RunDownloadRoutePolicy.Run;   s    **4+<+<+>?F]]F$//AA"88@ B J 
ww}}T^^$$''
 
'
'
7  &&v4;K;KLL\>>43C3CDr    c                     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   $ )Nr0   policyr    )apitools_clientroutersmessages#ComputeRoutersGetRoutePolicyRequestAsDictMakeRequests)r4   r%   r7   r1   requests        r   r0   "DownloadRoutePolicy.GetRoutePolicyM   s`    &&;; 	
!	
*5	
G y)!,,r    c                     Uc  Sn[         R                  " U5       n[        R                  " UUUS9  S S S 5        g ! , (       d  f       g = f)Nr   )r'   print_formatout)r   
FileWriterr
   Print)r4   messager-   r3   export_files        r   r2   DownloadRoutePolicy.WriteToFileW   s@    k			)	$" 
%	$	$s	   <
A
r=   )__name__
__module____qualname____firstlineno____doc__r   classmethodr   r9   r0   r2   __static_attributes__r=   r    r   r   r   !   s,    =* &E$-r    r   zG  *{command}* downloads a route policy from a Compute Engine router.
  a            To download a route policy `my-export-policy` to a file `my-export-policy.yaml` from a router `my-router` in region `us-central1`, run:

            $ {command} my-router --region=us-central1 --policy-name=my-export-policy --file-name=my-export-policy.yaml"
  )DESCRIPTIONEXAMPLES)rR   
__future__r   r   r   r*   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer	   r(   *googlecloudsdk.command_lib.compute.routersgooglecloudsdk.core.resourcer
   googlecloudsdk.core.utilr   UniverseCompatibleDescribeCommandr   detailed_helpr=   r    r   <module>ra      si     K &  ' 	 7 ( . E < 9 * =$.. = =B		%  !r    