
                             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  G d
 dej                        Zy)zCCommand to import files into a Cloud Composer environment's bucket.    )absolute_import)division)unicode_literalsN)base)flags)resource_args)storage_utilc                   *    e Zd ZdZdZed        Zd Zy)Importak  Import data from local storage or Cloud Storage into an environment.

  If the SOURCE is a directory, it and its contents are imported recursively.
  Colliding files in the environment's Cloud Storage bucket will be
  overwritten. If a file exists in the bucket but is not present in the SOURCE,
  it is not removed.

  ## EXAMPLES
  Suppose the '/foo' directory in the local filesystem has the following
  structure:

    foo
    |
    +-- subdir1
    |   |
    |   +-- file1.txt
    |   +-- file2.txt
    |
    +-- subdir2
    |   |
    |   +-- file3.txt
    |   +-- file4.txt

  And the environment `myenv`'s Cloud Storage bucket has the following
  structure:

    gs://the-bucket
    |
    +-- data
    |   |
    |   +-- foo
    |   |   |
    |   |   +-- subdir1
    |   |   |   |
    |   |   |   +-- bar.txt

  The following command:

    {command} myenv --source=/foo

  would result in the following structure in `myenv`'s Cloud Storage bucket:

    gs://the-bucket
    |
    +-- data
    |   |
    |   +-- foo
    |   |   |
    |   |   +-- subdir1
    |   |   |   |
    |   |   |   +-- bar.txt
    |   |   |   +-- file1.txt
    |   |   |   +-- file2.txt
    |   |   |
    |   |   +-- subdir2
    |   |   |   |
    |   |   |   +-- file3.txt
    |   |   |   +-- file4.txt

  If instead we had run

    {command} myenv --source=/foo --destination=bar

  the resulting bucket structure would be the following:

    gs://the-bucket
    |
    +-- data
    |   |
    |   +-- foo
    |   |   |
    |   |   +-- subdir1
    |   |   |   |
    |   |   |   +-- bar.txt
    |   |
    |   +-- bar
    |   |   |
    |   |   +-- foo
    |   |   |   |
    |   |   |   +-- subdir1
    |   |   |   |   |
    |   |   |   |   +-- file1.txt
    |   |   |   |   +-- file2.txt
    |   |   |   |
    |   |   |   +-- subdir2
    |   |   |   |   |
    |   |   |   |   +-- file3.txt
    |   |   |   |   +-- file4.txt
  datac                     t        j                  | dd       t        j                  | t        j
                         t        j                  | t        j
                         y )Nz/into whose Cloud Storage bucket to import data.F)
positional)r   AddEnvironmentResourceArgr   AddImportSourceFlagr   SUBDIR_BASEAddImportDestinationFlag)parsers    8lib/surface/composer/environments/storage/data/import.pyArgszImport.Argsz   sG    ++A 
ff&8&89	""66+=+=>    c                    t        j                  |j                  d       |j                  j                  j                         }t        j                  }|j                  r=t        j                  ||j                  j                  t        j                              }t        j                  |d      }t        j                  ||j                  || j                               S )Nz--source )release_track)r	   WarnIfWildcardIsPresentsourceCONCEPTSenvironmentParser   r   destination	posixpathjoinstripsepReleaseTrack)selfargsenv_ref
gcs_subdirs       r   Runz
Import.Run   s    ((jAmm''--/G##J>>*"&"2"2"8"8"GIj
B/Jj8I8I8KM Mr   N)__name__
__module____qualname____doc__r   staticmethodr   r)    r   r   r   r      s(    Xt +? ?	Mr   r   )r-   
__future__r   r   r   r    googlecloudsdk.callioper   #googlecloudsdk.command_lib.composerr   r   r	   Commandr   r/   r   r   <module>r4      s7    J &  '  ( 5 = <nMT\\ nMr   