
    ^                     X   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r " S	 S
\	R                  5      rS>S jrS rS rS r S>S jr  S?S jrS rS r " S S\	R                  5      r S@S jr S>S jr S>S jrS?S jrSAS jrSAS jrSBS jrSCS jrSCS jr SCS jr!SCS  jr"SCS! jr#SCS" jr$S# r%SCS$ jr&SCS% jr'S?S& jr(SCS' jr)SBS( jr*S) r+S* r,S+ r-S, r.S- r/SCS. jr0SCS/ jr1SCS0 jr2SCS1 jr3S2 r4S3 r5S4 r6SCS5 jr7SCS6 jr8SCS7 jr9S8 r:SCS9 jr;SCS: jr<SCS; jr=SCS< jr>SCS= jr?g)DzEFlags and helpers for the compute network firewall policies commands.    )absolute_import)division)unicode_literals)arg_parsers)
completers)flagsz9    table(
      name:label=NAME,
      description
    )c                   (   ^  \ rS rSrU 4S jrSrU =r$ ) NetworkFirewallPoliciesCompleter    c                 4   > [         [        U ]
  " SSSS.UD6  g )Ncompute.networkFirewallPoliciesz,compute network-firewall-policies list --uri
collectionlist_command )superr
   __init__selfkwargs	__class__s     Ilib/googlecloudsdk/command_lib/compute/network_firewall_policies/flags.pyr   )NetworkFirewallPoliciesCompleter.__init__"   s(    	
*D: 4C     r   __name__
__module____qualname____firstlineno__r   __static_attributes____classcell__r   s   @r   r
   r
            r   r
   Nc                 `    [         R                  " SS[        UU SSR                  U5      SSS9	$ )NFIREWALL_POLICYfirewall policyzfirewall policiesz+name of the network firewall policy to {0}.r   %compute.regionNetworkFirewallPolicies)	nameresource_name	completerpluralrequiredcustom_plural
short_helpglobal_collectionregional_collection)compute_flagsResourceArgumentr
   formatr,   r+   	operations      r   NetworkFirewallPolicyArgumentr6   *   s@    		'	'%0'>EE
 :A
 r   c                 $    U R                  SSS9  g)z8Adds the arguments for network firewall policy creation.--descriptionAAn optional, textual description for the network firewall policy.helpNadd_argumentparsers    r   #AddArgNetworkFirewallPolicyCreationr@   :       N  r   c                 2    U R                  SSSS/U-   SS9  g)zAdds policy type argument.z--policy-typeF
VPC_POLICYRDMA_ROCE_POLICYzNetwork firewall policy type.r,   choicesr;   Nr<   )r?   additional_choicess     r   AddPolicyTyperH   B   s-    /03EE*	  r   c                 $    U R                  SSS9  g)z/Adds the arguments  for firewall policy update.r8   r9   r:   Nr<   r>   s    r   "AddArgsUpdateNetworkFirewallPolicyrJ   L   rA   r   c           
      T    [         R                  " SSUU SR                  U5      SSS9$ )N--firewall-policyr&   z1Firewall policy ID with which to {0} association.r   r'   r(   r)   r+   r,   r.   r/   r0   r1   r2   r3   r4   s      r   (NetworkFirewallPolicyAssociationArgumentrO   T   s<     
	'	'%DKK
 :A

 
r   c                     U R                  SSS9  U R                  SSSS9  U(       a  U R                  SS	SS
S9  U nU(       a"  U R                  SS	S9nUR                  SS	SSS9  UR                  SSS	S	SS9  g)z+Adds the arguments of association creation.--nameName of the association.r:   	--networkTz:Name of the network with which the association is created.r,   r;   
--priorityFPriority of the association.r,   hiddenr;   )mutexr,   z"--associated-policy-to-be-replacedz9Name of an already associated firewall policy to replace.z--replace-association-on-target
store_truezBy default, if you attempt to insert an association to a network that is already associated with a firewall policy the method will fail. If this is set, the existing association will be deleted at the same time that the new association is created.)actiondefaultr,   r;   N)r=   	add_group)r?   support_priority(support_associated_policy_to_be_replacedgroups       r   AddArgsCreateAssociationra   d   s     	h%?@G   
+	   %-4%8E	,H	   '$  r   c                 H    U R                  SSSS9  U R                  SSSS9  g)z)Adds the arguments of association update.rQ   TrR   rT   rU   rV   Nr<   r>   s    r   AddArgsUpdateAssociationrc      s3    h4NOT(F  r   c                 &    U R                  SSSS9  g)z+Adds the arguments of association deletion.rQ   Tz"Name of the association to delete.rT   Nr<   r>   s    r   AddArgsDeleteAssociationre      s    $H  r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )NetworksCompleter   c                 4   > [         [        U ]
  " SSSS.UD6  g )Ncompute.networkszcompute networks list --urir   r   )r   rg   r   r   s     r   r   NetworksCompleter.__init__   s(    	
T+ %2 r   r   r   r"   s   @r   rg   rg      r#   r   rg   c                 @    [         R                  " SS[        SUSU US9$ )NrS   networkFrj   )r(   r)   r*   r+   r,   r/   r.   detailed_help)r1   r2   rg   )r.   r,   rn   s      r   NetworkArgumentForOtherResourcero      s/     
	'	'!*!	
 	r   c           
      T    [         R                  " SSUU SR                  U5      SSS9$ )NrL   r&   *Firewall policy ID with which to {0} rule.r   r'   rM   rN   r4   s      r   !NetworkFirewallPolicyRuleArgumentrr      s7     
	'	'%=DDYO9A
 r   c           	      R    [         R                  " SSUU SR                  U5      SS9$ )NrL   r&   rq   r   )r(   r)   r+   r,   r.   r/   rN   r4   s      r   0NetworkFirewallPolicyPacketMirroringRuleArgumentrt      s4     
	'	'%=DDYO9
 r   c           
      6    [         R                  " SSUU SSSS9$ )N--source-firewall-policyr&   z5Source Firewall policy NAME with which to clone rule.r   r'   rM   )r1   r2   )r,   r+   s     r   $NetworkSrcFirewallPolicyRuleArgumentrw      s*    		'	'%%H9A
 r   c                 0    U R                  S/ SQS USS9  g))Adds the action argument to the argparse.--action)allowdeny	goto_nextapply_security_profile_groupc                 "    U R                  5       $ Nlowerxs    r   <lambda>AddAction.<locals>.<lambda>   
    QWWYr   :Action to take if the request matches the match condition.rF   typer,   r;   Nr<   r?   r,   s     r   	AddActionr      s$    LG  r   c                 0    U R                  S/ SQS USS9  g)ry   rz   )mirrordo_not_mirrorr}   c                 "    U R                  5       $ r   r   r   s    r   r   *AddPacketMirroringAction.<locals>.<lambda>   r   r   r   r   Nr<   r   s     r   AddPacketMirroringActionr      s$    6G  r   c                 B    U R                  SSR                  U5      S9  g)z0Adds the rule priority argument to the argparse.priorityz8Priority of the rule to be {}. Valid in [0, 2147483547].r:   Nr=   r3   r?   r5   s     r   AddRulePriorityr      s)    ELL
  r   c                 P    U R                  S[        R                  " 5       USSS9  g)zAdds the source IP ranges.z--src-ip-rangesSRC_IP_RANGEa\  A list of IP address blocks that are allowed to make inbound connections that match the firewall rule to the instances on the network. The IP address blocks must be specified in CIDR format: http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing.Either --src-ip-ranges or --src-secure-tags must be specified for INGRESS traffic. If both --src-ip-ranges and --src-secure-tags are specified, the rule matches if either the range of the source matches --src-ip-ranges or the secure tag of the source matches --src-secure-tags.Multiple IP address blocks can be specified if they are separated by commas.r   r,   metavarr;   Nr=   r   ArgListr   s     r   AddSrcIpRangesr     s/     
  r   c                 P    U R                  S[        R                  " 5       USSS9  g)zAdds the destination IP ranges.z--dest-ip-rangesDEST_IP_RANGEz.Destination IP ranges to match for this rule. r   Nr   r   s     r   AddDestIpRangesr     s-     ;  r   c                 P    U R                  S[        R                  " 5       USSS9  g)zAdds the layer4 configs.z--layer4-configsLAYER4_CONFIGzPA list of destination protocols and ports to which the firewall rule will apply.r   Nr   r   s     r   AddLayer4Configsr   %  s/       	r   c                 ,    U R                  SUSS/SS9  g)z?Adds the direction of the traffic to which the rule is applied.z--directionINGRESSEGRESSzZDirection of the traffic the rule is applied. The default is to apply on incoming traffic.rE   Nr<   r   s     r   AddDirectionr   3  s(    (#(  r   c                 D    U R                  SU[        R                  SS9  g)z"Adds the option to enable logging.z--enable-loggingzSUse this flag to enable logging of connections that allowed or denied by this rule.r,   r[   r;   Nr=   r   StoreTrueFalseActionr   s     r   AddEnableLoggingr   @  s)    --!  r   c                 D    U R                  SU[        R                  SS9  g)z$Adds the option to disable the rule.z
--disabledzJUse this flag to disable the rule. Disabled rules will not affect traffic.r   Nr   r   s     r   AddDisabledr   M  s)    --  r   c                 (    U R                  SSSSS9  g)z'Adds the --global-firewall-policy flag.z--global-firewall-policyTrZ   z9Use this flag to indicate that firewall policy is global.r   Nr<   r>   s    r   AddGlobalFirewallPolicyr   Z  s#     	 F	  r   c                 P    U R                  S[        R                  " 5       SUSS9  g)z.Adds the target service accounts for the rule.z--target-service-accountsTARGET_SERVICE_ACCOUNTSz-List of target service accounts for the rule.r   r   r,   r;   Nr   r   s     r   AddTargetServiceAccountsr   i  s-    ! ':  r   c                 &    U R                  SUSS9  g)z"Adds the description of this rule.r8   z.An optional, textual description for the rule.rT   Nr<   r   s     r   AddDescriptionr   t  s    ;  r   c                 l    SnU(       a  US-  nU R                  S[        R                  " 5       SUUS9  g)z'Adds a  source secure tag to this rule.a  A list of instance secure tags indicating the set of instances on the network to which the rule applies if all other fields match. Either --src-ip-ranges or --src-secure-tags must be specified for ingress traffic. If both --src-ip-ranges and --src-secure-tags are specified, an inbound connection is allowed if either the range of the source matches --src-ip-ranges or the tag of the source matches --src-secure-tags. Secure Tags can be assigned to instances during instance creation.zD Secure tags cannot be specified if source network type is INTERNET.z--src-secure-tagsSOURCE_SECURE_TAGSr   Nr   )r?   r,   support_network_scopes	help_texts       r   AddSrcSecureTagsr   }  sK      NI 	 "  r   c                 P    U R                  S[        R                  " 5       SUSS9  g)z&Adds a target secure tag to this rule.z--target-secure-tagsTARGET_SECURE_TAGSzdAn optional, list of target secure tags with a name of the format tagValues/ or full namespaced namer   Nr   r   s     r   AddTargetSecureTagsr     s/     "6  	r   c                 B    U R                  SSR                  U5      S9  g)z;Adds the new firewall policy rule priority to the argparse.z--new-priorityz6New priority for the rule to {}. Valid in [0, 65535]. r:   Nr   r   s     r   AddNewPriorityr     s)    
B
I
I  r   c                 &    U R                  SSSS9  g)z:Adds the argument for network firewall policy clone rules.rv   TzBName of the source network firewall policy to copy the rules from.rT   Nr<   r>   s    r   AddArgsCloneRulesr     s     O  r   c                 P    U R                  S[        R                  " 5       SSSS9  g)z)Adds a source address group to this rule.z--src-address-groupsSOURCE_ADDRESS_GROUPSFz\Source address groups to match for this rule. Can only be specified if DIRECTION is ingress.r   Nr   r>   s    r   AddSrcAddressGroupsr     s/     %;  	r   c                 P    U R                  S[        R                  " 5       SSSS9  g)z.Adds a destination address group to this rule.z--dest-address-groupsDEST_ADDRESS_GROUPSFzaDestination address groups to match for this rule. Can only be specified if DIRECTION is engress.r   Nr   r>   s    r   AddDestAddressGroupsr     s/     #;  	r   c                 P    U R                  S[        R                  " 5       SSSS9  g)zAdds source fqdns to this rule.z--src-fqdnsSOURCE_FQDNSFzUSource FQDNs to match for this rule. Can only be specified if DIRECTION is `ingress`.r   Nr   r>   s    r   AddSrcFqdnsr     s/     =  	r   c                 P    U R                  S[        R                  " 5       SSSS9  g)z$Adds destination fqdns to this rule.z--dest-fqdns
DEST_FQDNSFzYDestination FQDNs to match for this rule. Can only be specified if DIRECTION is `egress`.r   Nr   r>   s    r   AddDestFqdnsr     s/     <  	r   c                 l    SnU(       a  US-  nU R                  S[        R                  " 5       SSUS9  g)z'Adds a source region code to this rule.z[Source Region Code to match for this rule. Can only be specified if DIRECTION is `ingress`.z\ Cannot be specified when the source network type is NON_INTERNET, VPC_NETWORK or INTRA_VPC.z--src-region-codesSOURCE_REGION_CODESFr   Nr   r?   r   r   s      r   AddSrcRegionCodesr     sM    !  	;I 	 #  r   c                 l    SnU(       a  US-  nU R                  S[        R                  " 5       SSUS9  g)z,Adds a destination region code to this rule.z_Destination Region Code to match for this rule. Can only be specified if DIRECTION is `egress`.zB Cannot be specified when the source network type is NON_INTERNET.z--dest-region-codesDEST_REGION_CODESFr   Nr   r   s      r   AddDestRegionCodesr     sK       LI 	 !  r   c                 f    SnU(       a  SnU R                  S[        R                  " 5       SSUS9  g)z8Adds source threat intelligence list names to this rule.zSource Threat Intelligence lists to match for this rule. Can only be specified if DIRECTION is `ingress`. The available lists can be found here: https://cloud.google.com/vpc/docs/firewall-policies-rule-details#threat-intelligence-fw-policy.aL  Source Threat Intelligence lists to match for this rule. Can only be specified if DIRECTION is `ingress`. Cannot be specified when the source network type is NON_INTERNET, VPC_NETWORK or INTRA_VPC. The available lists can be found here: https://cloud.google.com/vpc/docs/firewall-policies-rule-details#threat-intelligence-fw-policy.z--src-threat-intelligence SOURCE_THREAT_INTELLIGENCE_LISTSFr   Nr   r   s      r   AddSrcThreatIntelligencer     sJ    h  	j  	! 0  r   c                 f    SnU(       a  SnU R                  S[        R                  " 5       SSUS9  g)z=Adds destination threat intelligence list names to this rule.zDestination Threat Intelligence lists to match for this rule. Can only be specified if DIRECTION is `egress`. The available lists can be found here: https://cloud.google.com/vpc/docs/firewall-policies-rule-details#threat-intelligence-fw-policy.a2  Destination Threat Intelligence lists to match for this rule. Can only be specified if DIRECTION is `egress`. Cannot be specified when source network type is NON_INTERNET. The available lists can be found here: https://cloud.google.com/vpc/docs/firewall-policies-rule-details#threat-intelligence-fw-policy.z--dest-threat-intelligenceDEST_THREAT_INTELLIGENCE_LISTSFr   Nr   r   s      r   AddDestThreatIntelligencer   4  sJ    h  	j  	" .  r   c                 (    U R                  SSSSS9  g))Adds security profile group to this rule.--security-profile-groupSECURITY_PROFILE_GROUPFzMA security profile group to be used with apply_security_profile_group action.r   r,   r;   Nr<   r>   s    r   AddSecurityProfileGroupr   M  s#     &2  r   c                 (    U R                  SSSSS9  g)r   r   r   Fz7A security profile group to be used with mirror action.r   Nr<   r>   s    r    AddMirroringSecurityProfileGroupr   Z  s!     &D	  r   c                 D    U R                  SS[        R                  SS9  g)z6Adds the option to turn on TLS decryption on the rule.z--tls-inspectFzUse this flag to indicate whether TLS traffic should be inspected using the TLS inspection policy when the security profile group is applied. Default: no TLS inspection.r   Nr   r>   s    r   AddTlsInspectr   d  s)    --4  	r   c                 (    U R                  SUSSS9  g)z'Adds source network scope to this rule.z--src-network-scopeTaE  Deprecated. Use --src-network-type instead. Use this flag to indicate that the rule should match internet, non-internet traffic or traffic coming from the network specified by --src-network. It applies to ingress rules. Valid values are INTERNET, NON_INTERNET, VPC_NETWORKS and INTRA_VPC. Use empty string to clear the field.rW   Nr<   r   s     r   AddSrcNetworkScoper   r  s#    (  r   c                 &    U R                  SUSS9  g)z&Adds source network type to this rule.z--src-network-type  Use this flag to indicate that the rule should match internet, non-internet traffic or traffic coming from the network specified by --src-networks. It applies to ingress rules. Valid values are INTERNET, NON_INTERNET, VPC_NETWORKS and INTRA_VPC. Use empty string to clear the field.rT   Nr<   r   s     r   AddSrcNetworkTyper     s     (	  
r   c                 &    U R                  SUSS9  g)z)Adds source network context to this rule.z--src-network-contextr   rT   Nr<   r   s     r   AddSrcNetworkContextr     s     (	  
r   c                 P    U R                  S[        R                  " 5       SSSS9  g)z+Adds source network urls list to this rule.z--src-networksSRC_NETWORKSFzThe source VPC networks to  match for this rule.  It can only be specified when --src-network-type is VPC_NETWORKS. It applies to  ingress rules. It accepts full or partial URLs.r   Nr   r>   s    r   AddSrcNetworksr     s/     =  
r   c                 (    U R                  SUSSS9  g)z,Adds destination network scope to this rule.z--dest-network-scopeTa  Deprecated. Use --dest-network-type instead. Use this flag to indicate that the rule should match internet or non-internet traffic. It applies to destination traffic for egress rules. Valid values are INTERNET and NON_INTERNET. Use empty string to clear the field.rW   Nr<   r   s     r   AddDestNetworkScoper     s#    .  r   c                 &    U R                  SUSS9  g)z+Adds destination network type to this rule.z--dest-network-typeUse this flag to indicate that the rule should match internet or non-internet traffic. It applies to destination traffic for egress rules. Valid values are INTERNET and NON_INTERNET. Use empty string to clear the field.rT   Nr<   r   s     r   AddDestNetworkTyper     s     .	  	r   c                 &    U R                  SUSS9  g)z.Adds destination network context to this rule.z--dest-network-contextr   rT   Nr<   r   s     r   AddDestNetworkContextr     s     .	  	r   c                 ,    U R                  SUSS/SS9  g)zAdds target type to this rule.z--target-type	INSTANCESINTERNAL_MANAGED_LBzTarget type of the rule. By default a rule applies to VM instances (target-type = INSTANCES). Use INTERNAL_MANAGED_LB value to apply the rule to load balancers.rE   Nr<   r   s     r   AddTargetTyper     s)    12)  	r   c                 P    U R                  SU[        R                  " 5       SSS9  g)z*Adds target forwarding rules to this rule.z--target-forwarding-rulesTARGET_FORWARDING_RULESa(  A list of forwarding rules to which this rule applies. This field allows you to control which load balancers get this rule. If not specified, the rule applies to all load balancers. This field is only applicable when --target-type is INTERNAL_MANAGED_LB. It accepts full or partial resource URLs.)r,   r   r   r;   Nr   r   s     r   AddTargetForwardingRulesr     s/    ! '4  r   )FFN)FF)TN)Tr   )F)@__doc__
__future__r   r   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   compute_completersr   r1   DEFAULT_LIST_FORMATListCommandCompleterr
   r6   r@   rH   rJ   rO   ra   rc   re   rg   ro   rr   rt   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r     sX   L &  ' / O E	 '9'N'N   -1$ -2,^*??  .2  -1 -1
	.


4	(&62
" r   