
                         x   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 ddlmZ dddZej*                   ej,                  ej.                  j0                  ej.                  j2                  ej.                  j4                         G d dej6                                      Zy)zDCreate command to create a new resource of Custom Intercept profile.    )absolute_import)division)unicode_literals)intercept_api)base)sp_flags) endpoint_group_association_flags)labels_util)
exceptions)logzE

          Create a new Custom Intercept Security Profile.

        aO  
          To create a Custom Intercept Security Profile named `intercept-profile` linked to a Intercept Endpoint Group (q.v.), run:

              $ {command} intercept-profile --description="An Intercept Profile"                 --intercept-endpoint-group=projects/my-project/locations/global/interceptEndpointGroups/my-mep

        )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)Createz&Create a new Custom Intercept Profile.c                 f   t        j                  || j                                t        j                  |       t        j
                  j                  |       t        j
                  j                  |d       t        j                  |       t        j                  | j                         |       y )NF)r   AddSecurityProfileResourceReleaseTrackAddProfileDescriptionr   
ASYNC_FLAGAddToParser
SetDefaultr
   AddCreateLabelsFlagsintercept_flags!AddInterceptEndpointGroupResource)clsparsers     Ilib/surface/network_security/security_profiles/custom_intercept/create.pyArgszCreate.Args6   sy    ''0@0@0BC""6*OO'OOvu-$$V,55F    c                 N   t        j                  | j                               }|j                  j                  j                         }|j                  }t        j                  ||j                  j                  j                        }|j                  }|j                  j                  j                         }|j                  dk7  r"t        j                   d|j                  z        |j#                  |j%                         |j'                         j)                         |||j)                               }|r.|j*                  }	t,        j.                  j1                  d|	       |S |j3                  |j5                  |      dj7                  |j)                               d      S )Nglobalz0Only `global` location is supported, but got: %s)sp_idparentdescriptionlabelsintercept_endpoint_groupz9Check for operation completion status using operation ID:z/Waiting for security-profile [{}] to be createdT)operation_refmessage
has_result)r   Clientr   CONCEPTSsecurity_profileParser$   r
   ParseCreateArgsmessagesSecurityProfileLabelsValueasync_r&   locationcore_exceptionsErrorCreateCustomInterceptProfileNameParentRelativeNamenamer   statusPrintWaitForOperationGetOperationsRefformat)
selfargsclientr,   r$   r%   is_asyncr&   responseoperation_ids
             r   Runz
Create.RunA   sq   !!$"3"3"56F}}55;;=""K((foo--99F {{H#}}EEKKM}} !!
<t}}
L  22##%&&(557!9!F!F!H 3 H ]]l	jj
E
 o ""--h7AHH))+
  #  r   N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpclassmethodr   rF    r   r   r   r   -   s#    
 /- 'r   r   N)rJ   
__future__r   r   r   9googlecloudsdk.api_lib.network_security.security_profilesr   googlecloudsdk.callioper   +googlecloudsdk.command_lib.network_securityr   5googlecloudsdk.command_lib.network_security.interceptr	   r   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.corer   r4   r   rK   DefaultUniverseOnlyReleaseTracksr   ALPHABETAGACreateCommandr   rN   r   r   <module>r\      s    K &  ' S ( @ u < = #
  T..33T5F5F5I5I7T 7 7r   