
    d                         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dlm	Z	 ddl
mZ dd	lmZ dd
lmZ  G d dej                         Zy)z$The gcloud firestore export command.    )absolute_import)division)unicode_literals)importexport)
operations)storage_util)base)flags)
propertiesc                   .    e Zd ZdZddiZed        Zd Zy)Exportz9export Cloud Firestore documents to Google Cloud Storage.EXAMPLESa            To export all collection groups to `mybucket` in objects prefixed with `my/path`, run:

            $ {command} gs://mybucket/my/path

          To export a specific set of collections groups asynchronously, run:

            $ {command} gs://mybucket/my/path --collection-ids='specific collection group1','specific collection group2' --async

          To export all collection groups from certain namespace, run:

            $ {command} gs://mybucket/my/path --namespace-ids='specific namespace id'

          To export from a snapshot at '2023-05-26T10:20:00.00Z', run:

            $ {command} gs://mybucket/my/path --snapshot-time='2023-05-26T10:20:00.00Z'
      c                    t        j                  |       t        j                  |       t        j                  |       t        j                  |       |j                  dd       t        j                  j                  |       y)z Register flags for this command.OUTPUT_URI_PREFIXa:  
        Location where the export files will be stored. Must be a valid
        Google Cloud Storage bucket with an optional path prefix.

        For example:

          $ {command} gs://mybucket/my/path

        Will place the export in the `mybucket` bucket in objects prefixed with
        `my/path`.
        )helpN)	r
   AddCollectionIdsFlagAddNamespaceIdsFlagAddSnapshotTimeFlagAddDatabaseIdFlagadd_argumentr	   
ASYNC_FLAGAddToParser)clsparsers     lib/surface/firestore/export.pyArgszExport.Args2   sk     
v&	f%	f%	F#

   	OO'    c                    t         j                  j                  j                  j	                  d      }t
        j                  j                  |j                  d      }t        j                  ||j                  |j                         j                  d      |j                  |j                  |j                         }|j"                  st%        j&                  |       |S )NT)required)allow_empty_object/)namespace_idscollection_idssnapshot_time)r   VALUEScoreprojectGetr   ObjectReferenceFromUrlr   r   r   databaseToUrlrstripr"   r#   r$   async_r   WaitForOperation)selfargsr'   
object_refresponses        r   Runz
Export.RunI   s    $$,,00$0?G--554 6 J ""!!#&((**((H ;;!!(+Or   N)__name__
__module____qualname____doc__detailed_helpclassmethodr   r4    r   r   r   r      s-    A  
 -$ ( (,r   r   N)r8   
__future__r   r   r    googlecloudsdk.api_lib.firestorer   r   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper	   $googlecloudsdk.command_lib.firestorer
   googlecloudsdk.corer   Commandr   r;   r   r   <module>rC      s5    + &  ' 9 7 7 ( 6 *?T\\ ?r   