
    *                        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	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Jr  SSKJr  SSKJr   " S S\5      r\
R2                  \
R4                  " \
R6                  R8                  5       " S S\
R:                  5      5       5       r\
R2                  \
R4                  " \
R6                  R>                  5       " S S\
R:                  5      5       5       r \
R2                  \
R4                  " \
R6                  RB                  5       " S S\
R:                  5      5       5       r"g)z-Command for updating security policies rules.    )absolute_import)division)unicode_literals)base_classes)client)base)
exceptions)scope)flags)security_policies_utils)
properties)	resourcesc                   @    \ rS rSrSr\  SS j5       r\S 5       rSrg)UpdateHelper!   <  Update a Compute Engine security policy rule.

*{command}* is used to update security policy rules.

## EXAMPLES

To update the description and IP ranges of a rule at priority
1000, run:

  $ {command} 1000 \
     --security-policy=my-policy \
     --description="block 1.2.3.4/32" \
     --src-ip-ranges=1.2.3.4/32
c                 b   [         R                  " S5      U l        U R                  R                  USSS9  [         R                  " US5        [
        R                  " 5       U l        U R                  R                  U5        [         R                  " USS9  [         R                  " USUS9  [         R                  " U5        [         R                  " USS9  [         R                  " U5        [         R                  " UUS	9  [         R                  " U5        [         R                  " U5        g
)z,Generates the flagset for an Update command.updatePRIORITY)operation_typecust_metavarF)required)r   support_fairshareT)
for_updatesupport_rpc_statusN)r   PriorityArgumentNAME_ARGAddArgumentAddRegionFlagsecurity_policy_flags(SecurityPolicyMultiScopeArgumentForRulesSECURITY_POLICY_ARGAddMatcherAndNetworkMatcher	AddActionAddDescription
AddPreviewAddRedirectOptionsAddRateLimitOptionsAddRequestHeadersToAddAddRecaptchaOptions)clsparserr   r   s       5lib/surface/compute/security_policies/rules/update.pyArgsUpdateHelper.Args1   s     **84CLLLxj  B	)FFH  ''/	%%fu=	OO+- 
 	V-	V$	- 
  (	f%    c                 J   UR                   UR                  UR                  UR                  SLUR                  UR
                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                   UR"                  UR$                  UR&                  UR(                  UR*                  UR,                  UR.                  UR0                  UR2                  /n/ SQnU(       a:  UR5                  UR6                  UR8                  /5        UR5                  SS/5        [;        U Vs/ s H&  obR=                  USS R?                  SS5      5      PM(     sn5      (       d  [@        RB                  " US5      e[D        RF                  " U5      nURH                  (       Ga  U RJ                  RM                  UURN                  [P        RR                  RT                  S	9n[W        US
S5      bj  URN                  RY                  URZ                  S[\        R^                  R`                  Rb                  Rd                  URf                  URH                  S.S9n	OURN                  RY                  URZ                  S[\        R^                  R`                  Rb                  Rd                  URH                  S.S9n	O` URN                  RY                  URZ                  S[\        R^                  R`                  Rb                  Rd                  [W        US
S5      S.S9n	[l        Rn                  " XRl                  S9n
[p        Rr                  " URl                  U5      n[p        Rt                  " URl                  X#5      nUR                  n[p        Rv                  " URl                  U5      n[p        Rx                  " URl                  U5      nUS   nUS   nUR=                  S5      (       a!  UR                  S;  a  UR{                  S5        UR=                  S5      (       a"  UR                  S;  a  UR{                  S5        O7UR=                  S5      (       a!  UR$                  S;  a  UR{                  S5        SR}                  U5      nU
R                  UR                  UR                  UUUR                  UR                   UR                  UUUU(       a  US9$ SS9$ s  snf ! [N        Rh                  [N        Rj                  4 aW    URN                  RY                  URZ                  SS[\        R^                  R`                  Rb                  Rd                  0S9n	 GNDf = f)z7Validates arguments and patches a security policy rule.N)z--descriptionz--src-ip-rangesz--expressionz--actionz	--previewz--network-user-defined-fieldsz--network-src-ip-rangesz--network-dest-ip-rangesz--network-ip-protocolsz--network-src-portsz--network-dest-portsz--network-src-region-codesz--redirect-typez--redirect-targetz--request-headers-to-addz--rate-limit-threshold-countz#--rate-limit-threshold-interval-secz--conform-actionz--exceed-actionz--enforce-on-keyz--enforce-on-key-namez--ban-threshold-countz--ban-threshold-interval-secz--ban-duration-secz--recaptcha_action_site_keysz--recaptcha_session_site_keysz--exceed-action-rpc-status-codez"--exceed-action-rpc-status-message   -_z'At least one property must be modified.)default_scoperegionz!compute.regionSecurityPolicyRules)projectr7   securityPolicy)
collectionparamszcompute.securityPolicyRules)r8   r9   )r8   r7   r8   )compute_clientr      action)redirectredirect_options)throttlezrate-based-ban	fairsharerate_limit_optionsexceed_actionz*rate_limit_options.exceed_redirect_options,)src_ip_ranges
expressionexpression_optionsnetwork_matcherr>   descriptionpreviewr@   rC   request_headers_to_addupdate_mask)ArJ   rF   r>   rK   network_user_defined_fieldsnetwork_src_ip_rangesnetwork_dest_ip_rangesnetwork_ip_protocolsnetwork_src_portsnetwork_dest_portsnetwork_src_region_codesnetwork_src_asnsredirect_typeredirect_targetrL   rate_limit_threshold_count!rate_limit_threshold_interval_secconform_actionrD   enforce_on_keyenforce_on_key_nameban_threshold_countban_threshold_interval_secban_duration_secrecaptcha_action_site_keysrecaptcha_session_site_keysextendexceed_action_rpc_status_code exceed_action_rpc_status_messageanyIsSpecifiedreplacer	   MinimumArgumentExceptionr   ComputeApiHoldersecurity_policyr#   ResolveAsResourcer   compute_scope	ScopeEnumGLOBALgetattrParsenamer   VALUEScorer8   	GetOrFailr7   RequiredFieldOmittedException WrongResourceCollectionExceptionr   SecurityPolicyRuler   CreateRedirectOptionsCreateRateLimitOptionsCreateExpressionOptionsCreateNetworkMatcherappendjoinPatchrG   )r,   release_trackargsr   modified_fieldsmin_argsfieldholdersecurity_policy_refrefsecurity_policy_ruler@   rC   rL   rH   resultrI   rM   update_mask_strs                      r.   RunUpdateHelper.RunP   s$    	D ((""##!!%%##''..    ''''((5O8H8 

,
,

/
/ 	 oo
+
. 	 DLMH5		%)++C5	6HMO O//
=? ? **=9F33EE



%//66 F 8 
$h	5	A$$II:%,,1199CC-44"&"6"6 %  $$II4%,,1199CC"&"6"6 % 

$$II:%,,1199CC!$$7 % 
& "44MM+ /DDt 1GGt "880HHt %99tF QiO)K!!dkk&E+,!!dkk : '
 -.			/	*	*t/A/A J 0 EFhh{+O%%((??-'{{$$)-5'6O &   =A &  o 	NN 
1
1

4
4 

 $$II4:,,1199CC % 
	

s   1-T">AT' 'A7V"!V" N)FF)	__name__
__module____qualname____firstlineno____doc__classmethodr/   r   __static_attributes__r   r1   r.   r   r   !   s9      	& &< l lr1   r   c                   :    \ rS rSrSrSrSrSr\S 5       r	S r
Srg)UpdateGA   r   NFc                 @    [         R                  UU R                  S9  g )Nr   r   r/   _support_rpc_statusr,   r-   s     r.   r/   UpdateGA.Args  s!    22  r1   c                 `    [         R                  U R                  5       UU R                  5      $ Nr   r   ReleaseTrackr   selfr   s     r.   r   UpdateGA.Run  -       r1   r   )r   r   r   r   r   r#   r   r   r   r/   r   r   r   r1   r.   r   r      s1     ( r1   r   c                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)
UpdateBetai&  r   NFc                 B    [         R                  USU R                  S9  g NT)r   r   r   r   s     r.   r/   UpdateBeta.Args<  $    22  r1   c                 `    [         R                  U R                  5       UU R                  5      $ r   r   r   s     r.   r   UpdateBeta.RunD  r   r1   r   r   r   r   r   r   r#   r   r   r/   r   r   r   r1   r.   r   r   &  s,      r1   r   c                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)UpdateAlphaiL  r   NTc                 B    [         R                  USU R                  S9  g r   r   r   s     r.   r/   UpdateAlpha.Argsb  r   r1   c                 `    [         R                  U R                  5       UU R                  5      $ r   r   r   s     r.   r   UpdateAlpha.Runj  r   r1   r   r   r   r1   r.   r   r   L  s,      r1   r   N)#r   
__future__r   r   r   googlecloudsdk.api_lib.computer   0googlecloudsdk.api_lib.compute.security_policiesr   googlecloudsdk.callioper   r	   "googlecloudsdk.command_lib.computer
   rl   4googlecloudsdk.command_lib.compute.security_policiesr   r!   r   :googlecloudsdk.command_lib.compute.security_policies.rulesgooglecloudsdk.corer   r   objectr   UniverseCompatibleReleaseTracksr   GAUpdateCommandr   BETAr   ALPHAr   r   r1   r.   <module>r      s   4 &  ' 7 C ( . E _ X L * )\6 \~ D%%(()!t!! ! * !H D%%**+!## ! , !H D%%++,!$$$ ! - !r1   