
    C.                     l   d 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
 G d dej                        Z G d	 d
ej                        ZddZddZddZddZddZddej&                  j(                  dfdZddZddZddZddZd Zd dZddZddZddZddZddZ y)!z=Flags and helpers for the compute security policies commands.    )arg_parsers)
completers)flagsc                        e Zd Z fdZ xZS )GlobalSecurityPoliciesCompleterc                 2    t        t        | 
  dddd| y )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   z(GlobalSecurityPoliciesCompleter.__init__   s(    	
)49 -;     __name__
__module____qualname__r   __classcell__r   s   @r   r   r      s     r   r   c                        e Zd Z fdZ xZS )!RegionalSecurityPoliciesCompleterc                 2    t        t        | 
  dddd| y )Ncompute.regionSecurityPoliciesz6compute security-policies list --filter=region:* --urir
   r   )r   r   r   r   s     r   r   z*RegionalSecurityPoliciesCompleter.__init__#   s*    	
+T; 30 	r   r   r   s   @r   r   r       s     r   r   c                        e Zd Z fdZ xZS )SecurityPoliciesCompleterc                 D    t        t        | 
  ddt        t        gi| y )Nr   r   )r   r!   r   r   r   r   s     r   r   z"SecurityPoliciesCompleter.__init__-   s-    	
#T3 +-N
 	r   r   r   s   @r   r!   r!   +   s     r   r!   Fc                 @    t        j                  dt        |d| d      S )Nsecurity policysecurity policiesr	   )resource_name	completerpluralcustom_pluralrequiredglobal_collectioncompute_flagsResourceArgumentr!   r*   r(   s     r   SecurityPolicyArgumentr0   5   s'    		'	'%)'2
4 4r   c                 @    t        j                  dt        |d| d      S )Nr$   r%   r   )r&   r'   r(   r)   r*   regional_collectionr,   r/   s     r   SecurityPolicyRegionalArgumentr3   ?   s'    		'	'%)':
< <r   c           	      B    t        j                  dt        |d| dd      S )Nr$   r%   r	   r   )r&   r'   r(   r)   r*   r+   r2   r,   r/   s     r    SecurityPolicyMultiScopeArgumentr5   I   s*    		'	'%)'2:
< <r   c                 `    t        j                  ddt        d|ddj                  |             S )Nr$   --security-policyFr	   z2The security policy that will be set for this {0}.r&   namer'   r(   r*   r+   
short_helpr-   r.   r!   formatresourcer*   s     r   'SecurityPolicyArgumentForTargetResourcer?   T   s8    		'	'%)2FMM

 r   c                 `    t        j                  ddt        d|ddj                  |             S )Nr$   r7   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&   r9   r'   r(   r*   r2   r:   )r-   r.   r   r<   r=   s     r   /SecurityPolicyRegionalArgumentForTargetResourcerB   `   s7    		'	'%1:EF8

 
r   Nc                 n    t        j                  ddt        d|dd||xs dj                  |       |
      S )Nr$   r7   Fr	   r   rA   )
r&   r9   r'   r(   r*   r+   r2   region_hiddenr:   scope_flags_usager;   )r>   r*   rD   rE   short_help_texts        r   1SecurityPolicyMultiScopeArgumentForTargetResourcerG   n   sK     
	'	'%)2:! EEF8)
+ +r   c                 `    t        j                  ddt        d|ddj                  |             S )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.r8   r;   r=   s     r   +EdgeSecurityPolicyArgumentForTargetResourcerI      s7    		'	'%#)2IF8

 
r   c           	      B    t        j                  ddt        d| dd      S )Nr$   r7   Fr	   .The security policy that this rule belongs to.r8   r,   r*   s    r   SecurityPolicyArgumentForRulesrM      s,    		'	'%)2A
C Cr   c                 x    t        j                  ddt        d| dddt         j                  j                  d
      S )	Nr$   r7   Fr	   r   TrK   )
r&   r9   r'   r(   r*   r+   r2   rD   rE   r:   )r-   r.   r!   ScopeFlagsUsageUSE_EXISTING_SCOPE_FLAGSrL   s    r   (SecurityPolicyMultiScopeArgumentForRulesrQ      sA    		'	'%)2:%55NNA

C 
Cr   c                 d    | j                  ddd|d       | j                  dddgd	 |d
d       y)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defaultr*   helpz%--layer7-ddos-defense-rule-visibilitySTANDARDPREMIUMc                 "    | j                         S Nupperxs    r   <lambda>z1AddCloudArmorAdaptiveProtection.<locals>.<lambda>   
    QWWYr   VISIBILITY_TYPEzJThe visibility type indicates whether the rules are opaque or transparent.)choicestyper*   metavarrV   add_argumentparserr*   s     r   AddCloudArmorAdaptiveProtectionri      sT    $   	-9%  r   c                     | j                  dt        d       | j                  dt        d       | j                  dt        d       | j                  dt        d	       y
)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)rc   rV   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)rf   floatint)rh   s    r   )AddCloudArmorAdaptiveProtectionAutoDeployrm      sx    8
V	  	 	>
\	  	 	E
c	  	 	8
P	  	r   c                 :   | j                  dg dd |d       | j                  dt        j                         dd	       | j                  d
ddgd |d       |r| j                  dg dd |d       | j                  dt        j                         dd	       y)z@Adds the cloud armor advanced options arguments to the argparse.z--json-parsing)DISABLEDrW   STANDARD_WITH_GRAPHQLc                 "    | j                         S rZ   r[   r]   s    r   r_   z$AddAdvancedOptions.<locals>.<lambda>   r`   r   zzThe JSON parsing behavior for this rule. Must be one of the following values: [DISABLED, STANDARD, STANDARD_WITH_GRAPHQL].rb   rc   r*   rV   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.
      )rc   rd   rV   z--log-levelNORMALVERBOSEc                 "    | j                         S rZ   r[   r]   s    r   r_   z$AddAdvancedOptions.<locals>.<lambda>   r`   r   z/The level of detail to display for WAF logging.z--request-body-inspection-size)8KB16KB32KB48KB64KBc                 "    | j                         S rZ   r[   r]   s    r   r_   z$AddAdvancedOptions.<locals>.<lambda>   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)rf   r   ArgList)rh   r*   enable_large_body_sizes      r   AddAdvancedOptionsr      s    ?;  = 	# 
	  
 	#<  > 
(7 4   	! &
	  r   c                 6    | j                  dg dd |d       y)FAdds the cloud armor DDoS protection config arguments to the argparse.z--network-ddos-protectionrW   ADVANCEDADVANCED_PREVIEWc                 "    | j                         S rZ   r[   r]   s    r   r_   z<AddDdosProtectionConfigWithAdvancedPreview.<locals>.<lambda>  r`   r   TThe DDoS protection level for network load balancing and instances with external IPsrr   Nre   rg   s     r   *AddDdosProtectionConfigWithAdvancedPreviewr     s&    !:  	r   c                 6    | j                  dg dd |d       y)r   z--ddos-protectionr   c                 "    | j                         S rZ   r[   r]   s    r   r_   z,AddDdosProtectionConfigOld.<locals>.<lambda>   r`   r   r   rr   Nre   rg   s     r   AddDdosProtectionConfigOldr     s&    :  	r   c                 6    | j                  dg dd |d       y)z@Adds the Cloud Armor Network DDoS adaptive protection arguments.z"--network-ddos-adaptive-protection)ro   ENABLEDPREVIEWc                 "    | j                         S rZ   r[   r]   s    r   r_   z2AddNetworkDdosAdaptiveProtection.<locals>.<lambda>.  r`   r   z]The DDoS adaptive protection level for network load balancing and instances with external IPsrr   Nre   rg   s     r    AddNetworkDdosAdaptiveProtectionr   )  s&    *0)  	r   c                 6    | j                  dt        |d       y)zGAdds the Cloud Armor Network DDoS impacted baseline threshold argument.z*--network-ddos-impacted-baseline-thresholdzTThreshold below which rules with collateral damage below this value will be deployed)rc   r*   rV   N)rf   rk   rg   s     r   'AddNetworkDdosImpactedBaselineThresholdr   7  s#    2$  r   c                 ,    | j                  d|d       y)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.
      )r*   rV   Nre   rg   s     r   AddRecaptchaOptionsr   D  s     %
  r   )TF)F)FF)!__doc__googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   compute_completersr   r-   googlecloudsdk.command_lib.utilListCommandCompleterr   r   MultiResourceCompleterr!   r0   r3   r5   r?   rB   rO   GENERATE_DEDICATED_SCOPE_FLAGSrG   rI   rM   rQ   ri   rm   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   