
                         ,   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ dd	lmZ dd
lmZ ej                    ej"                  ej$                  j&                         G d dej(                                      Zej                    ej"                  ej$                  j,                         G d de                    Zej                    ej"                  ej$                  j0                         G d de                    Zddie_        y)z:Command for creating network firewall policy associations.    )absolute_import)division)unicode_literals)base_classes)!firewall_policy_association_utils)client)region_client)base)flagsc                   2    e Zd ZdZdZdZdZed        Zd Z	y)CreateCreate a new association between a firewall policy and a network.

  *{command}* is used to create network firewall policy associations. A
  network firewall policy is a set of rules that controls access to various
  resources.
  NFc                    t        j                  dd      | _        | j                  j                  |d       t        j                  || j
                  | j                         |j                  j                  t         j                         y )NTcreate)required	operation)operation_type)
r   (NetworkFirewallPolicyAssociationArgumentNETWORK_FIREWALL_POLICY_ARGAddArgumentAddArgsCreateAssociation_support_priority)_support_associated_policy_to_be_replaceddisplay_infoAddCacheUpdater NetworkFirewallPoliciesCompleter)clsparsers     Dlib/surface/compute/network_firewall_policies/associations/create.pyArgszCreate.Args*   sy     	66X	/ # ##//x/P	""55
 ''(N(NO    c                    t        j                  | j                               }| j                  j	                  ||j
                        }t        j                  ||j                        }t        |d      r!t        j                  ||j                        }t        j                  d      j	                  ||j
                        }d }|j                  d      r|j                  }nd|j                         z   }|j!                         }d }| j"                  r0|j                  d      rt%        j&                  |j(                        }d }	| j*                  r|j                  d      r|j,                  }	d}
|j.                  rd	}
d }| j"                  r+|)|j                  j0                  j3                  |||
      }n'|j                  j0                  j3                  ||      }|j5                  ||j6                  |
|	| j*                  d      S )N)compute_clientregionz2The network to which the firewall policy attaches.nameznetwork-priority associated_policy_to_be_replacedFT)attachmentTargetr%   r&   )r(   r%   )associationfirewall_policyreplace_existing_associationr'   (support_associated_policy_to_be_replacedonly_generate_request)r   ComputeApiHolderReleaseTrackr   ResolveAsResource	resourcesr   NetworkFirewallPolicyhasattrr	   RegionNetworkFirewallPolicyr   NetworkArgumentForOtherResourceIsSpecifiedr%   NameSelfLinkr   association_utilsConvertPriorityToIntr&   r   r'   replace_association_on_targetmessagesFirewallPolicyAssociationAddAssociationr*   )selfargsholderrefnetwork_firewall_policynetwork_refr%   attachment_targetr&   r'   r+   r)   s               r   Runz
Create.Run7   s   **4+<+<+>?F

*
*
<
<f C %::FMM+sH - I I
fmm!- 77<>>O>O&""?$  DYYd+**,,d#,,.H$"2"2:">"77Fh'+$55$:J:J*; *.)N)N&#( ))%)"K("6MM**DD,4( E k MM**DD,4 E k #11,,%A)I151_1_# 2  r!   )
__name__
__module____qualname____doc__NEWORK_FIREWALL_POLICY_ARGr   r   classmethodr    rF    r!   r   r   r      s4      $.3+
P 
P6r!   r   c                       e Zd ZdZdZdZy)
CreateBetar   FNrG   rH   rI   rJ   r   r   rM   r!   r   rO   rO   p   s     .3+r!   rO   c                       e Zd ZdZdZdZy)CreateAlphar   TNrP   rM   r!   r   rR   rR   ~   s     .2+r!   rR   EXAMPLESa      To associate a global network firewall policy with name ``my-policy''
    to network ``my-network'' with an association named ``my-association'', run:

      $ {command}
          --firewall-policy=my-policy
          --network=my-network
          --name=my-association
          --global-firewall-policy

    To associate a network firewall policy with name ``my-region-policy'' in
    region ``region-a''
    to network ``my-network'' with an association named ``my-association'', run:

      $ {command}
          --firewall-policy=my-policy
          --network=my-network
          --name=my-association
          --firewall-policy-region=region-a
    N)rJ   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r9   8googlecloudsdk.api_lib.compute.network_firewall_policiesr   r	   googlecloudsdk.callioper
   <googlecloudsdk.command_lib.compute.network_firewall_policiesr   UniverseCompatibleReleaseTracksr/   GACreateCommandr   BETArO   ALPHArR   detailed_helprM   r!   r   <module>r`      s
   A &  ' 7 a K R ( N D%%(()NT N * Nb D%%**+	4 	4 , 	4 D%%++,	3& 	3 - 	3 	 r!   