
    "                     F    S r S r      SS jr      SS jrS rS rg)	zBCommon command-agnostic utility functions for sql import commands.c                     Uc*  U R                   R                  R                  R                  $ U R                   R                  R                  R	                  UR                  5       5      $ )N)ImportContextBakImportOptionsValueBakTypeValueValuesEnumFULLlookup_by_nameupper)sql_messagesbak_types     -lib/googlecloudsdk/api_lib/sql/import_util.pyParseBakTyper      sY    ""88OOTT 
	#	#	9	9	P	P	_	_nn
     Nc                    U(       a  SnU(       d  U(       a$  U R                   R                  R                  UUS9nU R                  SUUU R                   R                  R                  UU R                   R                  UUUS9S9$ U R                  SUUU R                   R                  R                  UU R                   R                  US9S9$ )a  Generates the ImportContext for the given args, for importing from SQL.

Args:
  sql_messages: module, The messages module that should be used.
  uri: The URI of the bucket to import from; the output of the 'uri' arg.
  database: The database to import to; the output of the '--database' flag.
  user: The Postgres user to import as; the output of the '--user' flag.
  parallel: Whether to use parallel import or not; the output of the
    '--parallel' flag.
  threads: The number of threads to use; the output of the '--threads' flag.
    Only applicable for parallel import.
  clean: Clean (DROP) database objects before recreating them. Corresponds to
    the --clean flag on pg_restore. Only applies if --parallel is set.
    PostgreSQL only.
  if_exists: Include SQL statement (IF EXISTS) with each
    DROP statement produced by --clean; Corresponds to the --if-exists  flag
    on pg_restore. Only applies if --parallel is set. PostgreSQL only.

Returns:
  ImportContext, for use in InstancesImportRequest.importContext.
N)cleanifExistssql#importContext)parallelthreadspostgresImportOptions)kinduridatabasefileType
importUsersqlImportOptions)r   )r   SqlImportOptionsValuePostgresImportOptionsValueFileTypeValueValuesEnumSQL)	r	   r   r   userr   r   r   	if_existspostgres_import_optionss	            r   SqlImportContextr"      s    > "	

$
$
:
:%%  &   %% ++CCGG%33II"9 J 
 &   %% ++CCGG%33II J 
 & 	 	r   c
                     U R                  SU R                   R                  U=(       d    / UUUUU	S9UUU R                   R                  R                  US9$ )a7  Generates the ImportContext for the given args, for importing from CSV.

Args:
  sql_messages: module, The messages module that should be used.
  uri: The URI of the bucket to import from; the output of the 'uri' arg.
  database: The database to import into; the output of the '--database' flag.
  table: The table to import into; the output of the '--table' flag.
  columns: The CSV columns to import form; the output of the '--columns' flag.
  user: The Postgres user to import as; the output of the '--user' flag.
  quote: character in Hex. The quote character for CSV format; the output of
    the '--quote' flag.
  escape: character in Hex. The escape character for CSV format; the output of
    the '--escape' flag.
  fields_terminated_by: character in Hex. The fields delimiter character for
    CSV format; the output of the '--fields-terminated-by' flag.
  lines_terminated_by: character in Hex. The lines delimiter character for CSV
    format; the output of the '--lines-terminated-by' flag.

Returns:
  ImportContext, for use in InstancesImportRequest.importContext.
r   )columnstablequoteCharacterescapeCharacterfieldsTerminatedBylinesTerminatedBy)r   csvImportOptionsr   r   r   r   )r   CsvImportOptionsValuer   CSV)
r	   r   r   r%   r$   r   quoteescapefields_terminated_bylines_terminated_bys
             r   CsvImportContextr1   _   sn    > 
	#	##11GG-Ru 1/ H 1 ))AAEE 
$ 
 r   c                    SnU(       ab  U(       a[  U(       aT  U R                   R                  U R                   R                  R                  UUUS9S9nU(       a  XmR                  l        OU R                   R                  5       nU(       a  X}l        Xl        Xl        [        X
5      Ul	        Ub  UR                  S5      Ul        Xl        U R                  SUUU R                   R                  R                  US9$ )a`  Generates the ImportContext for the given args, for importing from BAK.

Args:
  sql_messages: module, The messages module that should be used.
  uri: The URI of the bucket to import from; the output of the `uri` arg.
  database: The database to import to; the output of the `--database` flag.
  cert_path: The certificate used for encrypted .bak; the output of the
    `--cert-path` flag.
  pvk_path: The private key used for encrypted .bak; the output of the
    `--pvk-path` flag.
  pvk_password: The private key password used for encrypted .bak; the output
    of the `--pvk-password` or `--prompt-for-pvk-password` flag.
  keep_encrypted: Whether or not to decrypt the imported encrypted BAK file.
  striped: Whether or not the import is striped.
  no_recovery: Whether the import executes with NORECOVERY keyword.
  recovery_only: Whether the import skip download and bring database online.
  bak_type: Type of the bak file.
  stop_at: Equivalent to SQL Server STOPAT keyword.
  stop_at_mark: Equivalent to SQL Server STOPATMARK keyword.

Returns:
  ImportContext, for use in InstancesImportRequest.importContext.
N)certPathpvkPathpvkPassword)encryptionOptionsz%Y-%m-%dT%H:%M:%S.%fZr   )r   r   r   r   bakImportOptions)r   r   EncryptionOptionsValuer6   keepEncryptedstriped
noRecoveryrecoveryOnlyr   bakTypestrftimestopAt
stopAtMarkr   BAK)r	   r   r   	cert_pathpvk_pathpvk_passwordkeep_encryptedr:   no_recoveryrecovery_onlyr
   stop_atstop_at_markbak_import_optionss                 r   BakImportContextrK      s    L 8%33II&44JJ		$ 
  

 J  ;I**8%33IIK!("-$1!+LC ' 0 01H I".		#	#
))AAEE) 
$ 
+ +r   c                     U R                   R                  UUUUS9nU R                  SU R                   R                  R                  US9$ )a}  Generates the ImportContext for the given args, for importing from TDE.

Args:
  sql_messages: module, The messages module that should be used.
  certificate: The certificate name; the output of the
    `--certificate` flag.
  cert_path: The certificate path in Google Cloud Storage; the output of the
    `--cert-path` flag.
  pvk_path: The private key path in Google Cloud Storage; the output of the
    `--pvk-path` flag.
  pvk_password: The password that encrypts the private key; the output
    of the `--pvk-password` or `--prompt-for-pvk-password` flag.

Returns:
  ImportContext, for use in InstancesImportRequest.importContext.
)namecertificatePathprivateKeyPathprivateKeyPasswordr   )r   r   tdeImportOptions)r   TdeImportOptionsValuer   TDE)r	   certificaterB   rC   rD   tde_import_optionss         r   TdeImportContextrV      sb    . $11GG%	 H ' 
	#	#))AAEE) 
$ 
+ +r   )NNFNFF)NNNNNN)__doc__r   r"   r1   rK   rV    r   r   <module>rY      sQ    I 	
@N " *.)-*ZC+L +r   