
                            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 ddlmZ ddlmZ e	j"                   e	j$                  e	j&                  j(                         G d de	j*                                      Z e	j$                  e	j&                  j.                         G d de             Z e	j$                  e	j&                  j2                         G d de             Zy)z?Imports data into an AlloyDB cluster from Google Cloud Storage.    )absolute_import)division)unicode_literals)api_util)cluster_operations)base)cluster_helper)flags)log)
properties)	resourcesc                   6    e Zd ZdZdddZed        Zd Zd Zy)	Importz>Import data into an AlloyDB cluster from Google Cloud Storage.z{description}z        To import data into a cluster, run:

          $ {command} my-cluster --region=us-central1 --database=my-database --gcs-uri=gs://my-bucket/source-file-path --sql --user=my-user"
        )DESCRIPTIONEXAMPLESc                 @   t         j                  j                  |        t        j                  |        t        j
                  |        t        j                  | d       t        j                  |        t        j                  |        t        j                  |        y)zySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    FN)
r   
ASYNC_FLAGAddToParserr
   	AddRegion
AddClusterAddDatabaseAddSourceURIAddImportUserAddImportOptions)parsers    &lib/surface/alloydb/clusters/import.pyArgszImport.Args0   sj     	OO'	OOF	V	fe$	v		6"    c                 0    t        j                  |||      S )N)r	   ConstructImportRequestFromArgs)selfalloydb_messagescluster_refargss       r   r    z%Import.ConstructImportRequestFromArgs?   s    88+t r   c                    t        j                  | j                               }|j                  }|j                  }|j
                  j                  dt        j                  j                  j                  j                  |j                  |j                        }| j                  |||      }|j                  j!                  |      }t"        j$                  j'                  |j(                  d      }|j*                  s&t-        j.                  |d| j                         d       t0        j2                  j5                  dj7                  |j9                                      |S )zConstructs and sends request.

    Args:
      args: argparse.Namespace, An object that contains the values for the
        arguments specified in the .Args() method.

    Returns:
      ProcessHttpResponse of the request made.
    z#alloydb.projects.locations.clusters)
projectsIdlocationsId
clustersIdz%alloydb.projects.locations.operations)
collectionzImporting data from clusterFzOperation ID: {})r   AlloyDBClientReleaseTrackalloydb_clientr"   resource_parserCreater   VALUEScoreproject	GetOrFailregionclusterr    projects_locations_clustersr   r   REGISTRYParseRelativeNamenameasync_r   Awaitr   statusPrintformatName)	r!   r$   clientr,   r"   r#   reqopop_refs	            r   Runz
Import.RunD   s&    ##D$5$5$78F**N..((//-$$))11;;KK<<	 0 K 
-
-+tC 
	3	3	:	:3	?B11
C 2 F ;;
/1B1B1De JJ'..v{{}=>Ir   N)	__name__
__module____qualname____doc__detailed_helpstaticmethodr   r    rC    r   r   r   r   "   s7     G %- # #
 r   r   c                       e Zd ZdZy)ImportAlpha<Import data to an AlloyDB cluster from Google Cloud Storage.NrD   rE   rF   rG   rJ   r   r   rL   rL   g       Dr   rL   c                       e Zd ZdZy)
ImportBetarM   NrN   rJ   r   r   rQ   rQ   l   rO   r   rQ   N)rG   
__future__r   r   r   googlecloudsdk.api_lib.alloydbr   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.alloydbr	   r
   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr+   GASilentCommandr   ALPHArL   BETArQ   rJ   r   r   <module>r]      s    F &  ' 3 = ( = 4 # * ) D%%(()@T @ * @F D%%++,E& E -E D%%**+E E ,Er   