
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SS	K	Jr  SS
KJr  SSKJr  SSKJr  SSKJr  \R&                  " \R(                  R*                  \R(                  R,                  \R(                  R.                  5      \R0                  " SSSS9 " S S\R2                  5      5       5       rg)zExports data from a Cloud SQL instance.

Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as
a MySQL dump file.
    )absolute_import)division)unicode_literals)api_util)
operations)validate)arg_parsers)base)deprecation_utils)flags)log)
propertiesz205.0.0Fzgcloud sql export sql)remove_versionremovealt_commandc                   .    \ rS rSrSr\S 5       rS rSrg)Export&   zExports data from a Cloud SQL instance.

Exports data from a Cloud SQL instance to a Google Cloud Storage
bucket as a MySQL dump file.
c           	      6   [         R                  R                  U 5        U R                  S[        R
                  SS9  U R                  SSS9  [        R                  " U [        R                  5        U R                  SS[        R                  " S	S
9SSSS9  g)zArgs is called by calliope to gather arguments for this command.

Args:
  parser: An argparse parser that you can use to add arguments that go
      on the command line after this command. Positional arguments are
      allowed.
instancezCloud SQL instance ID.)	completerhelpurizThe path to the file in Google Cloud Storage where the export will be stored. The URI is in the form gs://bucketName/fileName. If the file already exists, the operation fails. If the filename ends with .gz, the contents are compressed.)r   z--tablez-t   )
min_lengthTABLEFzTables to export from the specified database. If you specify tables, specify one and only one database. For Postgres instances, only one table can be exported at a time.)typemetavarrequiredr   N)
r
   
ASYNC_FLAGAddToParseradd_argumentr   InstanceCompleterAddDatabaseList&DEFAULT_DATABASE_LIST_EXPORT_HELP_TEXTr	   ArgList)parsers    #lib/surface/sql/instances/export.pyArgsExport.Args1   s     	OO'
))%  ' 6  7 
&%"N"NO
  A.4  5    c                    [         R                  " [         R                  5      nUR                  nUR                  n[
        R                  " UR                  5        UR                  R                  UR                  S[        R                  R                  R                  R                  0SS9nUR                  UR                  UR                  UR!                  UR#                  SUR$                  UR&                  =(       d    / UR"                  R(                  R*                  UR"                  R-                  UR.                  =(       d    / S9S9S9S9nUR0                  R3                  U5      nUR                  R5                  S	UR6                  UR                  S
9nUR8                  (       a=  UR:                  R=                  UR?                  UR                  UR@                  S95      $ [:        RB                  RE                  X8S5        [F        RH                  RK                  SRM                  XQR$                  S95        g)a  Exports data from a Cloud SQL instance.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
      with.

Returns:
  A dict object representing the operations resource describing the export
  operation if the export was successful.
projectzsql.instances)params
collectionzsql#exportContext)tables)kindr   	databasesfileTypesqlExportOptions)exportContext)r   r-   instancesExportRequestzsql.operations)	operationr-   )r-   r7   zExporting Cloud SQL instancez%Exported [{instance}] to [{bucket}].
)r   bucketN)'r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr   ValidateInstanceNamer   resource_parserParser   VALUEScorer-   	GetOrFailSqlInstancesExportRequestInstancesExportRequestExportContextr   databaseFileTypeValueValuesEnumSQLSqlExportOptionsValuetable	instancesr   Createnameasync_r   GetSqlOperationsGetRequestr7   OperationsV1Beta4WaitForOperationr   statuswriteformat)	selfargsclientr;   r<   instance_refexport_requestresult_operationoperation_refs	            r(   Run
Export.RunP   s     < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L ";;&&$$+BB&44(HH---2%33KKOO ..DD#zz/R E 2 5   C 	  < N "++22>B**11"''$$ 2 &M
 {{""&&

.
.#++}7N7N / PQ Q   11#AC JJ=DDhh E 0 1 r+    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr)   r]   __static_attributes__r_   r+   r(   r   r   &   s     
 5 5<7r+   r   N)rd   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r   googlecloudsdk.callioper	   r
   googlecloudsdk.command_libr   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   ReleaseTracksReleaseTrackGABETAALPHADeprecateCommandAtVersionCommandr   r_   r+   r(   <module>rt      s    '  ' / 1 / / ( 8 0 # * D%%(($*;*;*@*@%%++-,,U8OQ]T\\ ]Q-]r+   