
    n                        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  SSKJr  SSKrSSS.r\
R*                  \
R,                  " \
R.                  R0                  \
R.                  R2                  \
R.                  R4                  5       " S S\
R6                  5      5       5       rg)z%Import firewall policy rules command.    )absolute_import)division)unicode_literals)base_classes)client)base)firewall_policies_utils)flags)util)
console_ioNzI        Imports Firewall Policy rules configuration from a file.
        z        Firewall Policy rules can be imported by running:

          $ {command} FIREWALL_POLICY --source=<path-to-file>
            --organization=<organization>
        )DESCRIPTIONEXAMPLESc                   Z    \ rS rSrSrSr\r\S 5       r	\S	S j5       r
\S 5       rS rSrg)
Import*   zImport Compute Engine organization firewall policy rules.

Imports organization firewall policy rules configuration from a file.
Nc                     U R                  5       [        R                   R                  :X  a  gU R                  5       [        R                   R                  :X  a  gg)z3Returns the API version based on the release track.alphabetav1)ReleaseTrackr   ALPHABETA)clss    5lib/surface/compute/firewall_policies/import_rules.pyGetApiVersionImport.GetApiVersion7   sG     T..444				t0055	5    c                 L    [         R                  " SU R                  5       SUS9$ )z!Returns the resource schema path.computeFirewallPolicyfor_help)export_utilGetSchemaPathr   )r   r"   s     r   r$   Import.GetSchemaPath@   s,     $$	 r   c                     [         R                  " SSS9U l        U R                  R                  USS9  UR	                  SSS9  [
        R                  " XR                  SS	95        g )
NTzimports rules to)required	operationzexport-rules)operation_typez--organizationzuOrganization in which the organization firewall policy rules import to. Must be set if FIREWALL_POLICY is short name.)helpr!   )r
   FirewallPolicyArgumentFIREWALL_POLICY_ARGAddArgumentadd_argumentr#   AddImportFlagsr$   )r   parsers     r   ArgsImport.ArgsJ   sp    #::!3C ''~'N
H   v'8'8$'8'GHr   c           	      p   [         R                  " U R                  5       5      nU R                  R	                  XR
                  SS9n[        R                  " UUR                  UR
                  [        R                  " U R                  5       5      R                  5       S9n[        R                  " UR                  =(       d    SSS9n[        R                  " UR                  R                   R"                  UU R%                  5       S9n[&        R(                  " UUR+                  5       UR,                  S9nUR/                  USS9S	   n[        R0                  " S
SS9  UR                  R                   R#                  UR2                  UR4                  UR6                  S9n	UR9                  USU	S9$ )NF)with_project)refcompute_client	resourcesversion-)binary)message_typestreamschema_path)organization)fp_idonly_generate_requestr   z*Firewall Policy rules will be overwritten.T)messagecancel_on_no)fingerprintrulespacketMirroringRules)r?   r@   firewall_policy)r   ComputeApiHolderr   r,   ResolveAsResourcer7   r   OrgFirewallPolicysix	text_typelowerr   ReadFromFileOrStdinsourcer#   r   messagesr    r$   r	   GetFirewallPolicyIdNamer>   DescribePromptContinuerC   rD   rE   Update)
selfargsholderfirewall_policy_reforg_firewall_policydatafirewall_policy_rulesr?   existing_firewall_policyrF   s
             r   Run
Import.RunY   s   **4+<+<+>?F22DDU E  !22}}""d//1288:	 ))$++*<UKD'..]]++::&&( $77  "&&E  3;;5  <   	 <4 mm,,;;,88#))2GG < O %%#' &  r    )F)__name__
__module____qualname____firstlineno____doc__NETWORK_FIREWALL_POLICY_ARGDETAILED_HELPdetailed_helpclassmethodr   r$   r1   r]   __static_attributes__r_   r   r   r   r   *   sU    

 !%-    I I,r   r   )rd   
__future__r   r   r   googlecloudsdk.api_lib.computer   0googlecloudsdk.api_lib.compute.firewall_policiesr   googlecloudsdk.callioper   4googlecloudsdk.command_lib.compute.firewall_policiesr	   r
   !googlecloudsdk.command_lib.exportr   r#   googlecloudsdk.core.consoler   rJ   rf   DefaultUniverseOnlyReleaseTracksr   r   r   GACommandr   r_   r   r   <module>ru      s    , &  ' 7 C ( X F A 2 
	
 T..33T5F5F5I5IWT\\ W Wr   