
    
                         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 import 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)Importz;import Cloud Firestore documents from Google Cloud Storage.EXAMPLESa            To import all collection groups from `mybucket/my/path`, run:

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

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

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

          To import all collection groups from certain namespace, run:

            $ {command} gs://mybucket/my/path --namespace-ids='specific namespace id'
      c                     t        j                  |        t        j                  |        t        j                  |        | j	                  dd       t
        j                  j                  |        y)z Register flags for this command.INPUT_URI_PREFIXz
        Location of the import files.

        This location is the 'output_uri_prefix' field of a previous export,
        and can be found via the '{parent_command} operations describe' command.
        )helpN)r
   AddCollectionIdsFlagAddNamespaceIdsFlagAddDatabaseIdFlagadd_argumentr	   
ASYNC_FLAGAddToParser)parsers    lib/surface/firestore/import.pyArgszImport.Args1   s]     
v&	f%	F#
   	OO'    c                    t         j                  j                  j                  j	                  d      }t
        j                  j                  |j                  d      }t        j                  ||j                  |j                         j                  d      |j                  |j                        }|j                   st#        j$                  |       |S )NT)required)allow_empty_object/)namespace_idscollection_ids)r   VALUEScoreprojectGetr   ObjectReferenceFromUrlr   r   r   databaseToUrlrstripr    r!   async_r   WaitForOperation)selfargsr$   
object_refresponses        r   Runz
Import.RunA   s    $$,,00$0?G--55$ 6 8J ""!!#&((**,H ;;!!(+Or   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r1    r   r   r   r      s/    C 
-" ( (r   r   N)r5   
__future__r   r   r    googlecloudsdk.api_lib.firestorer   r   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper	   $googlecloudsdk.command_lib.firestorer
   googlecloudsdk.corer   Commandr   r8   r   r   <module>r@      s5    + &  ' 9 7 7 ( 6 *3T\\ 3r   