
    73                        S r SSKJr  SSKJr  SSKJr  SSKJr   " S S\R                  5      r
 " S S\R                  5      r " S	 S
\R                  5      rSS jrSS jrSS jrSS jrSS jrSS\R&                  R(                  S4S jrSS jrSS jrSS jrSS jrS rS S jrSS jrSS jrSS jrSS jrSS jr g)!z=Flags and helpers for the compute security policies commands.    )arg_parsers)
completers)flagsc                   (   ^  \ rS rSrU 4S jrSrU =r$ )GlobalSecurityPoliciesCompleter   c                 4   > [         [        U ]
  " SSSS.UD6  g )Ncompute.securityPoliciesz$compute security-policies list --uri
collectionlist_command )superr   __init__selfkwargs	__class__s     Alib/googlecloudsdk/command_lib/compute/security_policies/flags.pyr   (GlobalSecurityPoliciesCompleter.__init__   s(    	
)49 -;     r   __name__
__module____qualname____firstlineno__r   __static_attributes____classcell__r   s   @r   r   r      s     r   r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )!RegionalSecurityPoliciesCompleter    c                 4   > [         [        U ]
  " SSSS.UD6  g )Ncompute.regionSecurityPoliciesz6compute security-policies list --filter=region:* --urir   r   )r   r!   r   r   s     r   r   *RegionalSecurityPoliciesCompleter.__init__#   s*    	
+T; 30 	r   r   r   r   s   @r   r!   r!       s     r   r!   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )SecurityPoliciesCompleter+   c                 F   > [         [        U ]
  " SS[        [        /0UD6  g )Nr   r   )r   r'   r   r   r!   r   s     r   r   "SecurityPoliciesCompleter.__init__-   s-    	
#T3 +-N
 	r   r   r   r   s   @r   r'   r'   +   s     r   r'   Fc           	      <    [         R                  " S[        USU SS9$ )Nsecurity policysecurity policiesr
   )resource_name	completerpluralcustom_pluralrequiredglobal_collectioncompute_flagsResourceArgumentr'   r2   r0   s     r   SecurityPolicyArgumentr8   5   s'    		'	'%)'2
4 4r   c           	      <    [         R                  " S[        USU SS9$ )Nr,   r-   r$   )r.   r/   r0   r1   r2   regional_collectionr4   r7   s     r   SecurityPolicyRegionalArgumentr;   ?   s'    		'	'%)':
< <r   c           
      >    [         R                  " S[        USU SSS9$ )Nr,   r-   r
   r$   )r.   r/   r0   r1   r2   r3   r:   r4   r7   s     r    SecurityPolicyMultiScopeArgumentr=   I   s*    		'	'%)'2:
< <r   c                 \    [         R                  " SS[        SUSSR                  U 5      S9$ )Nr,   --security-policyFr
   z2The security policy that will be set for this {0}.r.   namer/   r0   r2   r3   
short_helpr5   r6   r'   formatresourcer2   s     r   'SecurityPolicyArgumentForTargetResourcerG   T   s8    		'	'%)2FMM

 r   c                 \    [         R                  " SS[        SUSSR                  U 5      S9$ )Nr,   r?   Fr$   xThe security policy that will be set for this {0}. To remove the policy from this {0} set the policy to an empty string.)r.   rA   r/   r0   r2   r:   rB   )r5   r6   r!   rD   rE   s     r   /SecurityPolicyRegionalArgumentForTargetResourcerJ   `   s7    		'	'%1:EF8

 
r   Nc                 t    [         R                  " SS[        SUSSUU=(       d    SR                  U 5      US9
$ )Nr,   r?   Fr
   r$   rI   )
r.   rA   r/   r0   r2   r3   r:   region_hiddenrB   scope_flags_usagerC   )rF   r2   rL   rM   short_help_texts        r   1SecurityPolicyMultiScopeArgumentForTargetResourcerO   n   sK     
	'	'%)2:! EEF8)
+ +r   c                 \    [         R                  " SS[        SUSSR                  U 5      S9$ )Nr,   z--edge-security-policyFr
   z}The edge security policy that will be set for this {0}. To remove the policy from this {0} set the policy to an empty string.r@   rC   rE   s     r   +EdgeSecurityPolicyArgumentForTargetResourcerQ      s7    		'	'%#)2IF8

 
r   c           
      >    [         R                  " SS[        SU SSS9$ )Nr,   r?   Fr
   .The security policy that this rule belongs to.r@   r4   r2   s    r   SecurityPolicyArgumentForRulesrU      s,    		'	'%)2A
C Cr   c                 t    [         R                  " SS[        SU SSS[         R                  R                  SS9
$ )	Nr,   r?   Fr
   r$   TrS   )
r.   rA   r/   r0   r2   r3   r:   rL   rM   rB   )r5   r6   r'   ScopeFlagsUsageUSE_EXISTING_SCOPE_FLAGSrT   s    r   (SecurityPolicyMultiScopeArgumentForRulesrY      sA    		'	'%)2:%55NNA

C 
Cr   c           	      X    U R                  SSSUSS9  U R                  SSS/S	 US
SS9  g)zCAdds the cloud armor adaptive protection arguments to the argparse.z--enable-layer7-ddos-defense
store_trueNzGWhether to enable Cloud Armor Layer 7 DDoS Defense Adaptive Protection.)actiondefaultr2   helpz%--layer7-ddos-defense-rule-visibilitySTANDARDPREMIUMc                 "    U R                  5       $ Nupperxs    r   <lambda>1AddCloudArmorAdaptiveProtection.<locals>.<lambda>   
    QWWYr   VISIBILITY_TYPEzJThe visibility type indicates whether the rules are opaque or transparent.)choicestyper2   metavarr^   add_argumentparserr2   s     r   AddCloudArmorAdaptiveProtectionrr      sT    $   	-9%  r   c                     U R                  S[        SS9  U R                  S[        SS9  U R                  S[        SS9  U R                  S[        S	S9  g
)zQAdds the cloud armor adaptive protection's auto-deploy arguments to the argparse.z0--layer7-ddos-defense-auto-deploy-load-thresholdzJLoad threshold above which Adaptive Protection's auto-deploy takes actionsrl   r^   z6--layer7-ddos-defense-auto-deploy-confidence-thresholdzPConfidence threshold above which Adaptive Protection's auto-deploy takes actionsz=--layer7-ddos-defense-auto-deploy-impacted-baseline-thresholdzWImpacted baseline threshold below which Adaptive Protection's auto-deploy takes actionsz0--layer7-ddos-defense-auto-deploy-expiration-seczDDuration over which Adaptive Protection's auto-deployed actions lastN)ro   floatint)rq   s    r   )AddCloudArmorAdaptiveProtectionAutoDeployrw      sx    8
V	  	 	>
\	  	 	E
c	  	 	8
P	  	r   c                 *   U R                  S/ SQS USS9  U R                  S[        R                  " 5       SSS	9  U R                  S
SS/S USS9  U(       a  U R                  S/ SQS USS9  U R                  S[        R                  " 5       SSS	9  g)z@Adds the cloud armor advanced options arguments to the argparse.z--json-parsing)DISABLEDr_   STANDARD_WITH_GRAPHQLc                 "    U R                  5       $ rb   rc   re   s    r   rg   $AddAdvancedOptions.<locals>.<lambda>   ri   r   zzThe JSON parsing behavior for this rule. Must be one of the following values: [DISABLED, STANDARD, STANDARD_WITH_GRAPHQL].rk   rl   r2   r^   z--json-custom-content-typesCONTENT_TYPEae        A comma-separated list of custom Content-Type header values to apply JSON
      parsing for preconfigured WAF rules. Only applicable when JSON parsing is
      enabled, like ``--json-parsing=STANDARD''. When configuring a Content-Type
      header value, only the type/subtype needs to be specified, and the
      parameters should be excluded.
      )rl   rm   r^   z--log-levelNORMALVERBOSEc                 "    U R                  5       $ rb   rc   re   s    r   rg   r|      ri   r   z/The level of detail to display for WAF logging.z--request-body-inspection-size)8KB16KB32KB48KB64KBc                 "    U R                  5       $ rb   rc   re   s    r   rg   r|      s
    qwwyr   z%Maximum request body inspection size.z--user-ip-request-headersUSER_IP_REQUEST_HEADERzt      A comma-separated list of request header names to use for resolving the
      caller's user IP address.
      N)ro   r   ArgList)rq   r2   enable_large_body_sizes      r   AddAdvancedOptionsr      s    ?;  = 	# 
	  
 	#<  > 
(7 4   	! &
	  r   c                 0    U R                  S/ SQS USS9  g)FAdds the cloud armor DDoS protection config arguments to the argparse.z--network-ddos-protectionr_   ADVANCEDADVANCED_PREVIEWc                 "    U R                  5       $ rb   rc   re   s    r   rg   <AddDdosProtectionConfigWithAdvancedPreview.<locals>.<lambda>  ri   r   TThe DDoS protection level for network load balancing and instances with external IPsr}   Nrn   rp   s     r   *AddDdosProtectionConfigWithAdvancedPreviewr     s&    !:  	r   c                 0    U R                  S/ SQS USS9  g)r   z--ddos-protectionr   c                 "    U R                  5       $ rb   rc   re   s    r   rg   ,AddDdosProtectionConfigOld.<locals>.<lambda>   ri   r   r   r}   Nrn   rp   s     r   AddDdosProtectionConfigOldr     s&    :  	r   c                 0    U R                  S/ SQS USS9  g)z@Adds the Cloud Armor Network DDoS adaptive protection arguments.z"--network-ddos-adaptive-protection)ry   ENABLEDPREVIEWc                 "    U R                  5       $ rb   rc   re   s    r   rg   2AddNetworkDdosAdaptiveProtection.<locals>.<lambda>.  ri   r   z]The DDoS adaptive protection level for network load balancing and instances with external IPsr}   Nrn   rp   s     r    AddNetworkDdosAdaptiveProtectionr   )  s&    *0)  	r   c                 n    U R                  US9nUR                  S[        SS9  UR                  SSSS9  g	)
zGAdds the Cloud Armor Network DDoS impacted baseline threshold argument.rT   z*--network-ddos-impacted-baseline-thresholda        DDoS Protection for Network Load Balancers (and VMs with public IPs)
      builds DDoS mitigations that minimize collateral damage. It quantifies
      this as the fraction of a non-abuse baseline that's inadvertently blocked.
      Rules whose collateral damage exceeds ddosImpactedBaselineThreshold will
      not be deployed. Using a lower value will prioritize keeping collateral
      damage low, possibly at the cost of its effectiveness in rate limiting
      some or all of the attack. It should typically be unset, so Advanced DDoS
      (and Adaptive Protection) uses the best mitigation it can find. Setting
      the threshold is advised if there are logs for false positive detections
      with high collateral damage, and will cause Advanced DDoS to attempt to
      find a less aggressive rule that satisfies the constraint. If a suitable
      rule cannot be found, the system falls back to either no mitigation for
      smaller attacks or broader network throttles for larger ones.
      rt   z0--clear-network-ddos-impacted-baseline-thresholdr[   zZIf provided, clears the Network DDoS impacted baseline threshold from the security policy.)r\   r^   N)add_mutually_exclusive_groupro   ru   )rq   r2   !impacted_baseline_threshold_groups      r   'AddNetworkDdosImpactedBaselineThresholdr   7  s\    &,&I&I 'J '# $002
 1 & $008( 1 r   c                 &    U R                  SUSS9  g)zAAdds the cloud armor reCAPTCHA options arguments to the argparse.z--recaptcha-redirect-site-keyz      The reCAPTCHA site key to be used for rules using the ``redirect'' action
      and the ``google-recaptcha'' redirect type under the security policy.
      )r2   r^   Nrn   rp   s     r   AddRecaptchaOptionsr   W  s     %
  r   )TF)F)FF)!__doc__googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   compute_completersr   r5   googlecloudsdk.command_lib.utilListCommandCompleterr   r!   MultiResourceCompleterr'   r8   r;   r=   rG   rJ   rW   GENERATE_DEDICATED_SCOPE_FLAGSrO   rQ   rU   rY   rr   rw   r   r   r   r   r   r   r   r   r   <module>r      s    D / O E 6&8&M&M (:(O(O 
 A A 4<<	  #33##+0CC&	8.b@r   