
    <                     P    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 r	S r
g	)
z1Utilities for reCAPTCHA Firewall Policy Commands.    )absolute_import)division)unicode_literals)apis)
exceptionsc                     [         R                  " SS5      nU R                  S5      n/ nU H  nUR                  [	        XA5      5        M     U$ )Nrecaptchaenterprisev1,)r   GetMessagesModulesplitappendParseAction)actionsmessagesactions_listaction_messagesactions        Blib/googlecloudsdk/command_lib/recaptcha/firewall_policies_util.pyParseFirewallActionsr      sK    ##$94@(s#,/f;v89 	    c                    UR                  5       nU R                  S5      nUS   S;   a8  [        U5      S:  a)  [        R                  " SSR                  US   5      5      eUS   S:X  a&  [        U5      S:w  a  [        R                  " SS	5      eUS   S
:X  a&  [        U5      S:w  a  [        R                  " SS5      eUS   S:X  a  UR                  5       Ul        U$ US   S:X  a  UR                  5       Ul	        U$ US   S:X  a  UR                  5       Ul        U$ US   S:X  a+  UR                  5       Ul        US   UR                  l        U$ US   S
:X  a@  UR                  5       Ul        US   US   sUR                   l        UR                   l        U$ [        R                  " SSR                  U 5      5      e)a  Parses a string action into a FirewallAction and returns it.

Actions are parsed to be one of AllowAction, BlockAction, RedirectAction,
SubstituteAction or SetHeaderAction.

Args:
  action: The action string to parse.
  messages: The message module in which FirewallAction is found in the cloud
    API.

Returns:
  An instance of FirewallAction containing the action represented in the given
  string.

Raises:
  BadArgumentException: A parsing error occurred.
=r   >   allowblockredirect   z	--actionsz)Action {0} has > 0 arguments, expected 0.
substitute   zVSubstituteAction requires exactly one argument for path, in the form substitute=$PATH.
set_header   zlSetHeaderAction requires exactly two arguments for header key and value, in the form set_header=$KEY=$VALUE.r   r   r   z5Action string {0} cannot be parsed as FirewallAction.).GoogleCloudRecaptchaenterpriseV1FirewallActionr   lenr   BadArgumentExceptionformat9GoogleCloudRecaptchaenterpriseV1FirewallActionAllowActionr   9GoogleCloudRecaptchaenterpriseV1FirewallActionBlockActionr   <GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectActionr   >GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteActionr   path=GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction	setHeaderkeyvalue)r   r   parsed_actionaction_piecess       r   r   r   "   s   $ IIK-,,s#- 1  "=1A5

)
)3::=;KLN N 1%#m*<*A

)
)`  1%#m*<*A

)
)v  1 "\\ M* 
' Q7""\\ M$ 
! Q:%%bb M 
 Q<''ff  M$1!$4M! 
 Q<'&dd MAN	B! ?M!8!8!> 
 
)
)?FFvNP Pr   N)__doc__
__future__r   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   r    r   r   <module>r6      s#    8 &  ' , .=r   