
                            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 dd
lmZ ddlmZ dddZej,                   ej.                  ej0                  j2                  ej0                  j4                  ej0                  j6                         G d dej8                                      Zy)z-Import network firewall policy rules command.    )absolute_import)division)unicode_literals)base_classes)client)region_client)base)flags)util)
console_iozI        Imports Firewall Policy rules configuration from a file.
        z        Firewall Policy rules can be imported by running:

          $ {command} FIREWALL_POLICY --source=<path-to-file> --global
        )DESCRIPTIONEXAMPLESc                   P    e Zd ZdZdZeZed        Zedd       Z	ed        Z
d Zy)Importz}Import a Compute Engine network firewall policy rules.

  Imports network firewall policy rules configuration from a file.
  Nc                     | j                         t        j                   j                  k(  ry| j                         t        j                   j                  k(  ryy)z3Returns the API version based on the release track.alphabetav1)ReleaseTrackr	   ALPHABETA)clss    =lib/surface/compute/network_firewall_policies/import_rules.pyGetApiVersionzImport.GetApiVersion7   sG     T..444				t0055	5    c                 P    t        j                  d| j                         d|      S )z!Returns the resource schema path.computeFirewallPolicyfor_help)export_utilGetSchemaPathr   )r   r    s     r   r"   zImport.GetSchemaPath@   s,     $$	 r   c                     t        j                  dd      | _        | j                  j                  |d       t	        j
                  || j                  d             y )NTzimport rules to)required	operationzimport-rules)operation_typer   )r
   NetworkFirewallPolicyArgumentNETWORK_FIREWALL_POLICY_ARGAddArgumentr!   AddImportFlagsr"   )r   parsers     r   ArgszImport.ArgsJ   s[    &+&I&I!2'C# ##//~ 0  vs'8'8$'8'GHr   c                 >   t        j                  | j                               }| j                  j	                  ||j
                  t        j                  t                    }t        j                  ||j                        }t        |d      r!t        j                  ||j                        }t        j                  |j                  xs dd      }t!        j"                  |j                  j$                  j&                  || j)                               }|j+                  d      d	   }t        j,                  d
d       |j                  j$                  j'                  |j.                  |j0                  |j2                        }|j5                  |d      S )N)scope_lister)compute_clientregion-F)binary)message_typestreamschema_path)only_generate_requestr   z*Firewall Policy rules will be overwritten.T)messagecancel_on_no)fingerprintrulespacketMirroringRules)firewall_policyr6   )r   ComputeApiHolderr   r(   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerr   NetworkFirewallPolicyhasattrr   RegionNetworkFirewallPolicyr   ReadFromFileOrStdinsourcer!   r   messagesr   r"   DescribePromptContinuer9   r:   r;   Update)	selfargsholderfirewall_policy_refnetwork_firewall_policy_clientdatafirewall_policy_rulesexisting_firewall_policyr<   s	            r   Runz
Import.RunT   s{   **4+<+<+>?F::LL"88@ M 
 &,%A%AFMM&" "H-

3
3!&-- % ))$++*<UKD'..]]++::&&(  >FF#  G   	 <4 mm,,;;,88#))2GG < O
 *00'u 1  r   )F)__name__
__module____qualname____doc__r(   DETAILED_HELPdetailed_helpclassmethodr   r"   r,   rS    r   r   r   r   *   sU    

 !%-    I I(r   r   N)rW   
__future__r   r   r   googlecloudsdk.api_lib.computer   8googlecloudsdk.api_lib.compute.network_firewall_policiesr   r   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   r@   <googlecloudsdk.command_lib.compute.network_firewall_policies!googlecloudsdk.command_lib.exportr   r!   googlecloudsdk.core.consoler   rX   DefaultUniverseOnlyReleaseTracksr   r   r   GACommandr   r[   r   r   <module>rh      s    4 &  ' 7 K R ( E N A 2		 T..33T5F5F5I5INT\\ N Nr   