
    @
                     j    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S	 rS
\S\4S jrg)z0Common validation methods for some SQL commands.    )absolute_import)division)unicode_literalsN)validate)arg_parsersc                      ^^ SmSmUU4S jn U $ )zReturns a function that validates an instance name using predefined rules.

Returns:
  function: str -> str, usable as an argparse type
z^[a-z][a-z0-9-:.]*zVmust be composed of lowercase letters, numbers, and hyphens; must start with a letter.c                    > [         R                  " TS-   U 5      (       d&  [        R                  " SR	                  U T5      5      e[
        R                  " U 5        U $ )N$zBad value [{0}]: {1})rematchr   ArgumentTypeErrorformatapi_validateValidateInstanceName)valuedescriptionpatterns    .lib/googlecloudsdk/command_lib/sql/validate.pyParse*InstanceNameRegexpValidator.<locals>.Parse'   sN    88GcM5))))
 
'
'{
;= =%%e,L     )r   r   r   s    @@r   InstanceNameRegexpValidatorr      s     "'-+ 
,r   c                 <     [        U 5        g! [         a     gf = f)a  Checks if the backup request is project level.

Project level requests will have backup_id in string format whearas they will
be integer values for instance level backup requests.

Args:
  backup_id: The id of the requested backup.

Returns:
  True if is a project level backup request.
FT)int
ValueError	backup_ids    r   IsProjectLevelBackupRequestr   1   s'    	N  
 s    
r   returnc                     U =(       a    SU ;   $ )a  Checks if the backup request is a backupdr backup by checking if the backup id contains /backupVaults.

A backupdr backup will have the backup in the format of
projects/{project}/locations/{location}/backupVaults/{backup_vault}/dataSources/{data_source}/backups/{backup}.

Args:
  backup_id: The id of the requested backup.

Returns:
  True if the request is a backupdr backup request.
z/backupVaultsr   r   s    r   IsBackupDrBackupRequestr"   E   s     
	3)33r   )__doc__
__future__r   r   r   r   googlecloudsdk.api_lib.sqlr   r   googlecloudsdk.callioper   r   r   strboolr"   r   r   r   <module>r)      s9    7 &  ' 	 ? /.(4s 4t 4r   