
                            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dZej$                  j&                  ej$                  j(                  fZdZej.                   ej0                  ej$                  j&                  ej$                  j(                  ej$                  j2                         G d dej4                                      Zee_        y)zBCreate command to create a new resource of security profile group.    )absolute_import)division)unicode_literals)spg_api)base)	spg_flags)labels_util)
exceptions)logzN

          Create a new Security Profile Group with the given name.

        a  
          To create a Security Profile Group with the name `my-security-profile-group`, with a threat prevention profile using `--threat-prevention-profile` flag and optional description as `optional description`, run:

              $ {command} my-security-profile-group --organization=1234 --location=global --threat-prevention-profile=`organizations/1234/locations/global/securityProfiles/my-security-profile` --description='optional description'

        )DESCRIPTIONEXAMPLES))threat-prevention-profilecustom-mirroring-profile)r   custom-intercept-profile)url-filtering-profiler   )r   r   )r   r   c                   ,    e Zd ZdZed        Zd Zd Zy)CreateProfileGroupz$Create a new Security Profile Group.c                    t        j                  || j                                t        j                  |       |j	                  d      }| j                         t
        v r(t        j                  || j                         d|d       t        j                  || j                         d|ddg       t        j                  || j                         d	|d       t        j                  || j                         d
|d       t        j                  |       t        j                  j                  |       t        j                  j                  |d       y )NT)requiredr   F)groupr   r   zsecurity-profile)r   r   arg_aliasesr   r   )r   AddSecurityProfileGroupResourceReleaseTrackAddProfileGroupDescription	add_group_URL_FILTERING_SUPPORTEDAddSecurityProfileResourcer	   AddCreateLabelsFlagsr   
ASYNC_FLAGAddToParser
SetDefault)clsparserrequired_groups      >lib/surface/network_security/security_profile_groups/create.pyArgszCreateProfileGroup.Args>   s(   --fc6F6F6HI((0%%t%4N
55**





! ((#'( ((" ((" $$V,OO'OOvu-    c                 p   t        j                  | j                               }| j                  |       |j                  j
                  j                         }|j                  j                  j                         }t        |j                  d      r$|j                  j                  j                         nd }t        |j                  d      r$|j                  j                  j                         nd }t        |j                  d      r$|j                  j                  j                         nd }|j                  }|j                  }	t        j                  ||j                   j"                  j$                        }
|j&                  dk7  r"t)        j*                  d|j&                  z        |j-                  |j/                         |j1                         |j3                         j/                         |||j/                         nd ||j/                         nd ||j/                         nd ||j/                         nd |
	      }|	r.|j4                  }t6        j8                  j;                  d|       |S |j=                  |j?                  |      djA                  |j/                               d	
      S )Nurl_filtering_profilecustom_mirroring_profilecustom_intercept_profileglobalz0Only `global` location is supported, but got: %s)	security_profile_group_namesecurity_profile_group_idparentdescriptionthreat_prevention_profiler)   r*   r+   labelsz9Check for operation completion status using operation ID:z5Waiting for security-profile-group [{}] to be createdT)operation_refmessage
has_result)!r   Clientr   ValidateCompatibleProfilesCONCEPTSsecurity_profile_groupParser1   hasattrr)   r*   r+   r0   async_r	   ParseCreateArgsmessagesSecurityProfileGroupLabelsValuelocationsIdcore_exceptionsErrorCreateSecurityProfileGroupRelativeNameNameParentnamer   statusPrintWaitForOperationGetOperationsRefformat)selfargsclientr9   r1   r)   r*   r+   r0   is_asyncr2   responseoperation_ids                r%   RunzCreateProfileGroup.Runf   su   ^^D--/0F##D)!]]AAGGI $ G G M M O 4=="9: 	++113  4=="<= 	..446  4=="<= 	..446  ""K{{H((foo22>>F ))X5!!
<"../ 
 00$:$G$G$I"8"="="?%,,.;;=$0 #<"H"H"J , 4@@B#/ ":!F!F!H#/ ":!F!F!H# 1 H* ]]l	jj
E
 o ""--h7GNN"//1
  #  r'   c                 d   ddddd}|j                   j                  j                         d|d<   t        |j                   d      r)|j                   j                  j                         d|d<   t        |j                   d      r)|j                   j
                  j                         d|d<   t        |j                   d	      r)|j                   j                  j                         d|d
<   t        D ]:  }||d      s||d      st        j                  ddj                  |      z         y )NF)r   r   r   r   Tr   r)   r   r*   r   r+   r   r      zHOnly one of the following profiles can be specified at the same time: %sz, )r8   r1   r:   r;   r)   r*   r+   _INCOMPATIBLE_PAIRSrB   rC   join)rN   rO   profilespairs       r%   r7   z-CreateProfileGroup.ValidateCompatibleProfiles   s   %*!&$)$)	H }}..446B.2h*+67MM//557C*.h&'9:MM2288:F-1h)*9:MM2288:F-1h)*#	$q'	xQ0##iio
 	
 $r'   N)__name__
__module____qualname____doc__classmethodr&   rT   r7    r'   r%   r   r   7   s&    
 -%. %.NER
r'   r   N)r^   
__future__r   r   r   ?googlecloudsdk.api_lib.network_security.security_profile_groupsr   googlecloudsdk.callioper   +googlecloudsdk.command_lib.network_securityr   $googlecloudsdk.command_lib.util.argsr	   googlecloudsdk.corer
   rB   r   _DETAILED_HELPr   ALPHABETAr   rW   DefaultUniverseOnlyReleaseTracksGACreateCommandr   detailed_helpr`   r'   r%   <module>ro      s    I &  ' S ( A < = #
 	T..33   T..33T5F5F5I5IS
++ S
 S
l $2   r'   