
                            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lZdZdZej*                   G d dej,                  ej.                               Zddde_        y)z@Command for listing the rules of organization firewall policies.    )absolute_import)division)unicode_literals)base_classes)firewalls_utils)lister)client)base)firewall_policies_utils)flags)logNzTo show all fields of the firewall, please show in JSON format: --format=json
To show more fields in table format, please see the examples in --help.
z  table(
    priority,
    direction,
    action,
    match.srcIpRanges.list():label=SRC_RANGES,
    match.destIpRanges.list():label=DEST_RANGES,
    match.layer4Configs.map().org_firewall_rule().list():label=PORT_RANGES
  )c                   0    e Zd ZdZdZed        Zd Zd Zy)	ListRuleszList the rules of a Compute Engine organization firewall policy.

  *{command}* is used to list the rules of an organization firewall policy.
  Nc                    t        j                  dd      | _        | j                  j                  |d       |j	                  dd       |j
                  j                  t               t        j                  |       y )	NTzlist rules for)required	operationget)operation_typez--organizationzmOrganization which the organization firewall policy belongs to. Must be set if FIREWALL_POLICY is short name.)help)
r   FirewallPolicyArgumentFIREWALL_POLICY_ARGAddArgumentadd_argumentdisplay_info	AddFormatDEFAULT_LIST_FORMATr   AddBaseListerArgs)clsparsers     3lib/surface/compute/firewall_policies/list_rules.pyArgszListRules.Args:   su    #::!13C''u'E
>  @ !!"56
V$    c           	      6   t        j                  | j                               }| j                  j	                  ||j
                  d      }t        j                  ||j                  |j
                  t        j                  | j                               j                               }t        j                  ||j                         |j                        }|j                  |d      }|sy t!        j"                  |j                  |d   j$                        S )NF)with_project)refcompute_client	resourcesversion)organization)fp_idonly_generate_requestr   )r   ComputeApiHolderReleaseTrackr   ResolveAsResourcer'   r	   OrgFirewallPolicysix	text_typelowerr   GetFirewallPolicyIdNamer)   Describer   SortFirewallPolicyRulesrules)selfargsholderr%   org_firewall_policyr*   responses          r    RunzListRules.RunF   s    **4+<+<+>?F

"
"
4
4fU 5 4C 22}}""d//1288:	<
 $77SXXZd6G6GIE"++5 , 2H226==3;A;3D3DF Fr"   c                 R    ~t         j                  j                  dt        z          y )N
)r   statusPrintLIST_NOTICE)r8   resources_were_displayeds     r    EpilogzListRules.EpilogX   s     JJTK'(r"   )	__name__
__module____qualname____doc__r   classmethodr!   r=   rD    r"   r    r   r   /   s,    
 	% 	%F$)r"   r   a      To list the rules of an organization firewall policy with ID
    ``123456789", run:

      $ {command} 123456789

    To list all the fields of the rules of an organization firewall policy with
    ID ``123456789", run:

      $ {command} 123456789 --format="table(
        priority,
        action,
        direction,
        match.srcIpRanges.list():label=SRC_RANGES,
        match.destIpRanges.list():label=DEST_RANGES,
        match.layer4Configs.map().org_firewall_rule().list():label=PORT_RANGES,
        targetServiceAccounts.list():label=TARGET_SVC_ACCT,
        targetResources:label=TARGET_RESOURCES,
        ruleTupleCount,
        enableLogging,
        description)"
        a      To list rules of a firewall policy, the user must have the following
    permission: *`compute.firewallPolicies.get`.

    To find predefined roles that contain those permissions, see the [Compute
    Engine IAM roles](https://cloud.google.com/compute/docs/access/iam).
    )EXAMPLESzIAM PERMISSIONS)rH   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   0googlecloudsdk.api_lib.compute.firewall_policiesr	   googlecloudsdk.callioper
   4googlecloudsdk.command_lib.compute.firewall_policiesr   r   googlecloudsdk.corer   r0   rB   r   DefaultUniverseOnlyDescribeCommandListCommandr   detailed_helprJ   r"   r    <module>rV      s    G &  ' 7 : 1 C ( X F # 

  ()$$d&6&6 () ()Z	,1	 r"   