
                             d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z
  G d d	e
j                        Zd
 Zd Zd Zd Zy)z?Declarative Request Hooks for Cloud SCC's Notification Configs.    )absolute_import)division)unicode_literalsN)util)
exceptionsc                       e Zd ZdZy)InvalidNotificationConfigErrorz)Exception raised for errors in the input.N)__name__
__module____qualname____doc__     Alib/googlecloudsdk/command_lib/scc/notifications/request_hooks.pyr	   r	      s    1r   r	   c                 x    ~ t        j                  |      }t        ||       t        |      |_        d|_        |S )z@Generate a notification config using organization and config id.N)r   GetParentFromNamedArguments!_ValidateMutexOnConfigIdAndParent_GetNotificationConfigNamenamefilter)refargsreqparents       r   UpdateNotificationReqHookr      s9    	++D1&#D&1'-#( $+	*r   c                 p   t        j                  d      }t        j                  d      }|j                  | j                        s&|j                  | j                        st	        d      |j                  | j                        r| j                  S t        j                  |       dz   | j                  z   S )z9Returns relative resource name for a notification config.zM(organizations|projects|folders)/.+/notificationConfigs/[a-zA-Z0-9-_]{1,128}$z[a-zA-Z0-9-_]{1,128}$zNotificationConfig must match either (organizations|projects|folders)/.+/notificationConfigs/[a-zA-Z0-9-_]{1,128})$ or [a-zA-Z0-9-_]{1,128}$.z/notificationConfigs/)recompilematchnotificationConfigIdr	   r   r   )r   resource_pattern
id_patterns      r   r   r   3   s    ZZU zz12*			

!)3)9)9

#
#*%
(	!" "
 D556$$$		)	)

%
&(,(A(A
B Br   c                 .    | j                  d      }|d   S )N/   )split)resource_nameparams_as_lists     r   _GetNotificationConfigIdr)   J   s     &&s+.		r   c                 V    d| j                   v r|t        d      y|t        d      y)zLValidates that only a full resource name or split arguments are provided.
  r$   NzOnly provide a full resource name (organizations/123/notificationConfigs/test-config) or an --(organization|folder|project) flag, not both.z{A corresponding parent by a --(organization|folder|project) flag must be provided if it is not included in notification ID.)r    r	   )r   r   s     r   r   r   O   sS     	D%%%*BC C 
 ~
(	@A A r   )r   
__future__r   r   r   r   googlecloudsdk.command_lib.sccr   googlecloudsdk.corer   core_exceptionsErrorr	   r   r   r)   r   r   r   r   <module>r0      sE    F &  ' 	 / =2_%:%: 2(B.
Ar   