
                         ^   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	 ddl
mZ dd	l
mZ dd
lmZ e	j                    e	j"                  e	j$                  j&                  e	j$                  j(                  e	j$                  j*                         G d de	j,                                      Zy)z/The gcloud Firestore databases restore command.    )absolute_import)division)unicode_literalsN)	databases)base)flags)util)
propertiesc                   ,    e Zd ZdZed        Zd Zd Zy)RestoreFirestoreAPIa8  Restores a Cloud Firestore database from a backup.

  ## EXAMPLES

  To restore a database from a backup.

      $ {command}
      --source-backup=projects/PROJECT_ID/locations/LOCATION_ID/backups/BACKUP_ID
      --destination-database=DATABASE_ID

  To restore a database from a backup with tags.

      $ {command}
      --source-backup=projects/PROJECT_ID/locations/LOCATION_ID/backups/BACKUP_ID
      --destination-database=DATABASE_ID
      --tags=key1=value1,key2=value2

  To restore to a CMEK-enabled database.

      $ {command}
      --source-backup=projects/PROJECT_ID/locations/LOCATION_ID/backups/BACKUP_ID
      --destination-database=DATABASE_ID
      --encryption-type=customer-managed-encryption
      --kms-key-name=projects/PROJECT_ID/locations/LOCATION_ID/keyRings/KEY_RING_ID/cryptoKeys/CRYPTO_KEY_ID
  c           	          |j                  ddt        dt        j                  d             t	        j
                  |dd       t	        j                  |d       t	        j                  |d       y )	Nz--source-backupSOURCE_BACKUPTa              The source backup to restore from.

            For example, to restore from backup `cf9f748a-7980-4703-b1a1-d1ffff591db0` in us-east1:

            $ {command} --source-backup=projects/PROJECT_ID/locations/us-east1/backups/cf9f748a-7980-4703-b1a1-d1ffff591db0
            )metavartyperequiredhelprestorebackupdatabase)add_argumentstrtextwrapdedentr   AddDestinationDatabaseAddEncryptionConfigGroupAddTags)clsparsers     *lib/surface/firestore/databases/restore.pyArgszRestoreFirestoreAPI.Args=   sd    
__     
  H=	""684	MM&*%    c                     t         j                  j                  j                  j	                  d      }t        j                  ||j                  |j                  | j                  |      |j                        S )NT)r   )r
   VALUEScoreprojectGetr   RestoreDatabasesource_backupdestination_databaseEncryptionConfigtags)selfargsr%   s      r   RunzRestoreFirestoreAPI.RunP   sd    $$,,00$0?G$$!!d#		 r!   c                 ,    t        j                  |      S )N)utilsExtractEncryptionConfig)r,   r-   s     r   r*   z$RestoreFirestoreAPI.EncryptionConfigZ   s    ((..r!   N)__name__
__module____qualname____doc__classmethodr    r.   r*    r!   r   r   r      s%    
4 & &$/r!   r   )r5   
__future__r   r   r   r    googlecloudsdk.api_lib.firestorer   googlecloudsdk.callioper   $googlecloudsdk.command_lib.firestorer   r	   r0   googlecloudsdk.corer
   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHABETAGACommandr   r7   r!   r   <module>rD      s    6 &  '  6 ( 6 > * T..33T5F5F5I5I9/$,, 9/ 9/r!   