
    U                         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	r	Sr
S	r\R                  qS
 rS rS rS rS rg)z*Utilities for `gcloud app firewall-rules`.    )absolute_import)division)unicode_literals)
exceptions)	resourcesNizS
  table(
    priority:sort=1,
    action,
    source_range,
    description
  )
  c                      [         R                  R                  SU 5        [
        $ ! [         R                   a<    [         R                  R	                  5       q[
        R                  SU 5         [
        $ f = f)N	appengine)r   REGISTRYGetCollectionInfoInvalidCollectionExceptionCloneregistryRegisterApiByName)versions    9lib/googlecloudsdk/command_lib/app/firewall_rules_util.pyGetRegistryr   (   sd    5((g> 
/ 
	-	- 5!!'')H{G4	/5s    ( AA87A8c                     [        U R                  5       5      R                  [        R                  " [        U5      5      SU R                  0SS9nU$ )zCreates a resource path given a firewall rule priority.

Args:
  client: AppengineFirewallApiClient, the API client for this release track.
  priority: str, the priority of the rule.

Returns:
  The resource for the rule.

appsIdz$appengine.apps.firewall.ingressRules)params
collection)r   
ApiVersionParsesix	text_typeParsePriorityproject)clientpriorityress      r   ParseFirewallRuler    2   sN     	F%%'(..	mmM(+,'7 	/ 	9# 
*    c                     U S:X  a  [         n  [        U 5      nUS::  d
  U[         :  a*  [        R                  " SSR	                  [         5      5      eU$ ! [
         a    [        R                  " SS5      ef = f)z"Converts a priority to an integer.defaultr   r   z-Priority must be between 1 and {0} inclusive.z1Priority should be an integer value or `default`.)DEFAULT_RULE_PRIORITYintr   InvalidArgumentExceptionformat
ValueError)r   priority_ints     r   r   r   D   s    $H	Ix=LqL+@@//
ELL#%& & 	 I

-
-GI IIs   AA "A7c                 d    U(       d  gU R                   R                  UR                  5       5      $ )aA  Converts an action string to the corresponding enum value.

Options are: 'allow' or 'deny', otherwise None will be returned.

Args:
  messages: apitools.base.protorpclite.messages, the proto messages class for
    this API version for firewall.
  action: str, the action as a string
Returns:
  ActionValueValuesEnum type
N)FirewallRuleActionValueValuesEnumupper)messagesactions     r   ParseActionr0   U   s'     
				4	4V\\^	DDr!   c                  4    [         R                  " / SQS5      e)N)z--actionz--source-rangez--descriptionzCPlease specify at least one attribute to the firewall-rules update.)r   MinimumArgumentException r!   r   RaiseMinArgumentr4   f   s    ++ -J	L Lr!   )__doc__
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.corer   r   r$   LIST_FORMATr
   r   r   r    r   r0   r4   r3   r!   r   <module>r:      sT    1 &  ' . ) 
 "  $I"E"Lr!   