
    
                     >   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&                  ej(                  j*                         G d
 dej,                                             Zddie_        y)z1Command for creating network policy associations.    )absolute_import)division)unicode_literals)ClassVar)base_classes)client)base)flagsc                   L    e Zd ZU dZeej                     ed<   ed        Z	d Z
y)CreatezCreate a new association between a network policy and a network.

  *{command}* is used to create network policy associations. A network policy is
  a set of rules that controls access to various resources.
  NETWORK_POLICY_ARGc                     t        j                  dd      | _        | j                  j                  |d       t        j                  |       |j
                  j                  t         j                         y )NTzcreate association for)required	operationcreate)operation_type)r
    NetworkPolicyAssociationArgumentr   AddArgumentAddArgsCreateAssociationdisplay_infoAddCacheUpdaterNetworkPoliciesCompleter)clsparsers     ;lib/surface/compute/network_policies/associations/create.pyArgszCreate.Args*   s^    "CC!9C &&vh&G	""6*
''(F(FG    c                    t        j                  | j                               }| j                  j	                  ||j
                        }t        j                  ||j                        }t        j                  d      j	                  ||j
                        }|j                  xs d|j                         z   }|j                         }|j                  j                  j                  ||      }|j                  ||j                         S )N)compute_clientz1The network to which the network policy attaches.znetwork-)attachmentTargetname)associationnetwork_policy)r   ComputeApiHolderReleaseTrackr   ResolveAsResource	resourcesr   NetworkPolicyr
   NetworkArgumentForOtherResourcer!   NameSelfLinkmessagesNetworkPolicyAssociationAddAssociationr#   )	selfargsholderrefnetwork_policy_clientnetwork_refr!   attachment_targetr"   s	            r   Runz
Create.Run3   s    **4+<+<+>?F

!
!
3
3D&:J:J
KC"00FMM 77;f../  997
[%5%5%77D#,,.--((AA* B K
 !//** 0  r   N)__name__
__module____qualname____doc__r   compute_flagsResourceArgument__annotations__classmethodr   r6    r   r   r   r      s3     }==>>H Hr   r   EXAMPLESaS      To associate a network policy with name ``my-region-policy'' in
    region ``region-a'' to network ``my-network'' with an association
    named ``my-association'', run:

      $ {command}
          --network-policy=my-policy
          --network-policy-region=region-a
          --network=my-network
          --name=my-association
    N)r:   
__future__r   r   r   typingr   googlecloudsdk.api_lib.computer   /googlecloudsdk.api_lib.compute.network_policiesr   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   r;   3googlecloudsdk.command_lib.compute.network_policiesHiddenUniverseCompatibleReleaseTracksr%   ALPHACreateCommandr   detailed_helpr?   r   r   <module>rN      s    8 &  '  7 B ( E E D%%++,)T ) -  )Z  
 r   