
    t                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  Sr
\R                  " S	5      r\R                  " S
5      r\R                  " S5      rS rS rS rS rS rS rS rS rS rS rS rS rS rS rg)zGDeclarative Request Hooks for Security Health Analytics custom modules.    )absolute_import)division)unicode_literalsN)InvalidSCCInputError)CleanUpUserInputz /securityHealthAnalyticsSettingsz([0-9]{1,20})$z^[0-9]{1,19}$z^organizations/[0-9]{1,19}$c                 x    A [        U5      Ul        UR                  S;  a  [        SUR                  -  5      eU$ )z2Creates a Security Health Analytics custom module.)enableddisabledzYInvalid custom module enablement state: %s. Enablement state must be enabled or disabled.)_ValidateAndGetParentparentenablement_stater   refargsreqs      Flib/googlecloudsdk/command_lib/scc/custom_modules/sha/request_hooks.py0CreateSecurityHealthAnalyticsCustomModuleReqHookr       sG    	$T*#*	"99
	 "&"7"7	89 9 
*    c                 z    A [        U5      nUb  [        U5      nUS-   U-   Ul        U$ [        U5      nXRl        U$ )z2Deletes a Security Health Analytics custom module./customModules/r   _ValidateAndGetCustomModuleIdname+_ValidateAndGetCustomModuleFullResourceNamer   r   r   r   custom_module_idcustom_modules         r   0DeleteSecurityHealthAnalyticsCustomModuleReqHookr   +   Q    	 &&4T:)),<<CH 
* @EMH	*r   c                 z    A [        U5      nUb  [        U5      nUS-   U-   Ul        U$ [        U5      nXRl        U$ )z/Gets a Security Health Analytics custom module.r   r   r   s         r   -GetSecurityHealthAnalyticsCustomModuleReqHookr!   8   r   r   c                 z    A [        U5      nUb  [        U5      nUS-   U-   Ul        U$ [        U5      nXRl        U$ )z:Gets an effective Security Health Analytics custom module.z/effectiveCustomModules/)r   r   r   4_ValidateAndGetEffectiveCustomModuleFullResourceNamer   s         r   6GetEffectiveSecurityHealthAnalyticsCustomModuleReqHookr$   E   sQ    	 &&4T:225EECH 
* INMH	*r   c                 (    A [        U5      Ul        U$ )z/Lists Security Health Analytics custom modules.r   r   r   s      r   /ListSecurityHealthAnalyticsCustomModulesReqHookr'   R       	$T*#*	*r   c                 (    A [        U5      Ul        U$ )z:Lists descendant Security Health Analytics custom modules.r&   r   s      r   9ListDescendantSecurityHealthAnalyticsCustomModulesReqHookr*   Y   r(   r   c                 (    A [        U5      Ul        U$ )z9Lists effective Security Health Analytics custom modules.r&   r   s      r   8ListEffectiveSecurityHealthAnalyticsCustomModulesReqHookr,   `   r(   r   c                     A [        U5      nSnUR                  nUb  [        U5      nUS-   U-   nO[        U5      nXBl        UR
                  b  XER
                  l        U$ )z/Test a Security Health Analytics custom module. r   )r   .testSecurityHealthAnalyticsCustomModuleRequestr   r   r   #securityHealthAnalyticsCustomModule)r   r   r   r   custom_module_nametest_reqr   s          r   /TestSecurityHealthAnalyticsCustomModulesReqHookr3   g   sp    	 &&??(4T:"336FFDTJ(22>8J005	*r   c                 (    A [        U5      Ul        U$ )z4Simulates a Security Health Analytics custom module.r&   r   s      r   3SimulateSecurityHealthAnalyticsCustomModulesReqHookr5   x   r(   r   c                     A [        U5      nUb  [        U5      nUS-   U-   Ul        O[        U5      nXRl        [	        UR
                  5      Ul        UR                  S;  a  [        SUR                  -  5      eU$ )z2Updates a Security Health Analytics custom module.r   )r	   r
   	inheritedzdInvalid custom module enablement state: %s. Enablement state must be enabled, disabled or inherited.)r   r   r   r   r   
updateMaskr   r   r   s         r   0UpdateSecurityHealthAnalyticsCustomModuleReqHookr9      s    	 &&4T:)),<<CH?EMH#CNN3#.	"FF
	+-1-B-B	CD D 
*r   c                     U R                   n[        R                  U5      (       d  [        S[        R                  -  5      eU$ )zValidates customModuleId.z1Custom module id does not match the pattern '%s'.)r   _SHA_CUSTOM_MODULE_ID_PATTERNmatchr   pattern)r   r   s     r   r   r      sF    ''	&	,	,-=	>	>
;%--	./ / r   c                     U R                   n[        R                  " S[        R                  -  5      nUR                  U5      (       d  [        S5      eU$ )z+Validates custom module full resource name.zT(organizations|projects|folders)/.*/securityHealthAnalyticsSettings/customModules/%stCustom module must match the full resource name, or `--organization=`, `--folder=` or `--project=` must be provided.r   recompiler;   r=   r<   r   r   r   resource_patterns      r   r   r      s]    $$-ZZ6>>?@ 
			.	.
	9: : 
r   c                     U R                   n[        R                  " S[        R                  -  5      nUR                  U5      (       d  [        S5      eU$ )z5Validates effective custom module full resource name.z](organizations|projects|folders)/.*/securityHealthAnalyticsSettings/effectiveCustomModules/%sr?   r@   rC   s      r   r#   r#      sX    $$-ZZe%--. 
			.	.
~  
r   c                    U R                   b  SU R                   ;   aS  [        R                  U R                   5      (       d  [        S[        R                  -  5      eU R                   [
        -   $ [        R                  U R                   5      (       d  [        S[        R                  -  5      eSU R                   -   [
        -   $ U R                  bz  SU R                  ;   aT  [        R                  " S5      nUR                  U R                  5      (       d  [        S5      eU R                  [
        -   $ SU R                  -   [
        -   $ U R                  bz  SU R                  ;   aT  [        R                  " S	5      nUR                  U R                  5      (       d  [        S
5      eU R                  [
        -   $ SU R                  -   [
        -   $ g)zValidates parent.N/zFWhen providing a full resource path, it must include the pattern '%s'.z-Organization does not match the pattern '%s'.zorganizations/z^folders/.*$zPWhen providing a full resource path, it must include the pattern '^folders/.*$'.zfolders/z^projects/.*$zQWhen providing a full resource path, it must include the pattern '^projects/.*$'.z	projects/)organization_ORGANIZATION_NAME_PATTERNr<   r   r=   _PARENT_SUFFIX_ORGANIZATION_ID_PATTERNfolderrA   rB   project)r   r=   s     r   r   r      s   	"
d'--d.?.?@@"0889: 	:   >11%++D,=,=>>";$,,-. 	.  $"3"33nDD	[[
dkk

>*g]]4;;''" 	 {{^++$++%66	\\
dll

?+g]]4<<(("  	  ||n,,4<<'.88 r   )__doc__
__future__r   r   r   rA   %googlecloudsdk.command_lib.scc.errorsr   $googlecloudsdk.command_lib.scc.hooksr   rJ   rB   r;   rK   rI   r   r   r!   r$   r'   r*   r,   r3   r5   r9   r   r   r#   r    r   r   <module>rS      s    N &  ' 	 F A3 "

+; < ::o6 ZZ(EF 


"$	
(9r   