
                         p    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Z	dZ
d	Zd
ZdZd Zd Zd Zd Zy)z=Common utility functions for Cloud Filestore backup commands.    )absolute_import)division)unicode_literals)util)
propertiesz%projects/{}/locations/{}/instances/{}z#projects/{}/locations/{}/backups/{}zprojects/{}/locations/{}v1
v1p1alpha1c                     ~ |j                   |_        t        j                  j                  j
                  j                  d      }|j                  }t        j                  ||      |_
        |S )zUPython hook for yaml commands to supply the backup create request with proper values.Trequired)backupbackupIdr   VALUEScoreprojectGetregionPARENT_TEMPLATEformatparentrefargsreqr   locations        8lib/googlecloudsdk/command_lib/filestore/backups/util.pyFormatBackupCreateRequestr       sW    	#,""**...='[[(%%gx8#*	*    c                     ~ t         j                  j                  j                  j	                  d      }|j
                  }t        j                  |||j                        |_	        |S )zTPython hook for yaml commands to supply backup access requests with the proper name.Tr   )
r   r   r   r   r   r   BACKUP_NAME_TEMPLATEr   r   namer   s        r   FormatBackupAccessRequestr"   *   sR    	""**...='[[(!(((DKKH#(	*r   c                 <   ~ t         j                  j                  j                  j	                  d      }t        j                  |      }|t        k(  r<t        j                  ||j                  |j                        |j                  _        |S |j                  :t        j                  ||j                  |j                        |j                  _        |j                  :t        j                  ||j                  |j                        |j                  _        |S )zBPython hook for yaml commands to process the source instance name.Tr   )r   r   r   r   r   r   GetApiVersionFromArgsALPHA_API_VERSIONINSTANCE_NAME_TEMPLATEr   instance_zoneinstancer   sourceInstanceinstance_location)r   r   r   r   api_versions        r   AddInstanceNameToRequestr,   3   s    	""**...='**40+%% 6 = =##T]]!4CJJJ	# 6 = =##T]]!4CJJ	' 6 = =''!8CJJ	*r   c                    ~ |j                   |j                  |S t        j                  j                  j
                  j                  d      }t        j                  ||j                  |j                         |j                  _
        |S )z@Python hook for yaml commands to process the source backup name.Tr   )source_backupsource_backup_regionr   r   r   r   r   r    r   restoreInstanceRequestsourceBackup)r   r   r   r   s       r   AddBackupNameToRequestr2   G   sw    		4#<#<#DJ""**...=',@,G,Gt(($*<*<->#)	*r   N)__doc__
__future__r   r   r   $googlecloudsdk.command_lib.filestorer   googlecloudsdk.corer   r&   r    r   V1_API_VERSIONr%   r   r"   r,   r2    r   r   <module>r9      sJ    D &  ' 5 *@ < ,  (r   