
                             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  G d	 d
e	j                        Zy)z5Surface to test an ip address against firewall rules.    )absolute_import)division)unicode_literals)appengine_firewall_api_client)base)firewall_rules_util)logc                   0    e Zd ZdZdddZed        Zd Zy)TestIpz-Display firewall rules that match a given IP.z{description}zs          To test an IP address against the firewall rule set, run:

              $ {command} 127.1.2.3
          )DESCRIPTIONEXAMPLESc                 |    | j                   j                  t        j                         | j	                  dd       y )Nipz5An IPv4 or IPv6 address to test against the firewall.)help)display_info	AddFormatr   LIST_FORMATadd_argument)parsers    )lib/surface/app/firewall_rules/test_ip.pyArgszTestIp.Args)   s7    
!!"5"A"AB
J  L    c                    t        j                  | j                               }|j                  |j                        }t        |      }|r\t        j                  j                  dj                  |d   j                               t        j                  j                  d       |S t        j                  j                  d       |S )Nz/The action `{0}` will apply to the IP address.
r   zMatching RuleszNo rules match the IP address.)
api_clientGetApiClientForTrackReleaseTrackListr   listr	   statusPrintformataction)selfargsclientresponseruless        r   Runz
TestIp.Run/   s    ,,T->->-@AF{{477#HNE	jjIveAhoo.0	jj'( L 
jj78Lr   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r(    r   r   r   r      s1    5 		- L L
r   r   N)r,   
__future__r   r   r   googlecloudsdk.api_lib.app.apir   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.appr   googlecloudsdk.corer	   Commandr   r/   r   r   <module>r6      s/    < &  ' V ( > # T\\  r   