
    #                         S r SSKrSSKrSSKJr  SSKJr  S
S jr " S S\R                  5      r
 " S S	\R                  5      rg)zXSpanner migration library functions and utilities for the spanner-migration-tool binary.    N)binary_operations)
exceptionsc                     [         R                  " [        R                  5      nU (       a  UR	                  U 5        U(       a  U H  nUR                  U5        M     U$ )z6Return an env dict to be passed on command invocation.)copydeepcopyosenvironupdatepop)
extra_varsexclude_varsenvks       ;lib/googlecloudsdk/command_lib/spanner/migration_backend.pyGetEnvArgsForCommandr      s@    bjj!#JJz	ggaj 	*    c                       \ rS rSrSrSrg)SpannerMigrationException#   zIBase Exception for any errors raised by gcloud spanner migration surface. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r   #   s    Qr   r   c                      ^  \ rS rSrSrU 4S jr       SS jr          SS jr          SS jr    SS jr	       SS jr
      SS	 jrS
 rSrU =r$ )SpannerMigrationWrapper'   z=Binary operation wrapper for spanner-migration-tool commands.c                 4   > [         [        U ]
  " SSSS.UD6  g )Nzspanner-migration-toolT)binaryinstall_if_missingr   )superr   __init__)selfkwargs	__class__s     r   r$    SpannerMigrationWrapper.__init__*   s(    	
!41 L'DLDJLr   c	                    A	S/n
U(       a  U
R                  SU/5        U(       a  U
R                  SU/5        U(       a  U
R                  SU/5        U(       a  U
R                  SU/5        U(       a  U
R                  SU/5        U(       a  U
R                  S5        U(       a  U
R                  SU/5        U(       a  U
R                  S	U/5        U
$ )
z#"Parse args for the schema command.schema--source--prefix--source-profile--target--target-profile	--dry-run--log-level	--projectextendappend)r%   sourceprefixsource_profiletargettarget_profiledry_run	log_levelprojectr&   	exec_argss              r   _ParseSchemaArgs(SpannerMigrationWrapper._ParseSchemaArgs.   s     	
I
F+,
F+,*N;<
F+,*N;<{#y12W-.r   c                 v   AS/nU(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  S5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  S	U/5        U	(       a  UR                  S
5        U
(       a  UR                  SU
/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U$ )z!"Parse args for the data command.datar+   z	--sessionr,   --skip-foreign-keysr-   r.   r/   --write-limitr0   r1   r2   --dataflow-templater3   )r%   r6   sessionr7   skip_foreign_keysr8   r9   r:   write_limitr;   r<   r=   dataflow_templater&   r>   s                  r   _ParseDataArgs&SpannerMigrationWrapper._ParseDataArgsM   s    	I
F+,W-.
F+,,-*N;<
F+,*N;<56{#y12W-.-/@ABr   c                 B   AS/nU(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  S5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  S	5        U	(       a  UR                  S
U	/5        U
(       a  UR                  SU
/5        U(       a  UR                  SU/5        U$ )z,"Parse args for the schema-and-data command.schema-and-datar+   r,   rC   r-   r.   r/   rD   r0   r1   r2   rE   r3   )r%   r6   r7   rG   r8   r9   r:   rH   r;   r<   r=   rI   r&   r>   s                 r   _ParseSchemaAndDataArgs/SpannerMigrationWrapper._ParseSchemaAndDataArgsx   s    	"#I
F+,
F+,,-*N;<
F+,*N;<56{#y12W-.-/@ABr   c                     AS/nU(       a  UR                  S5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U$ )zParse args for the web command.webz--openz--portr1   rE   )r5   r4   )r%   	open_flagportr<   rI   r&   r>   s          r   _ParseWebArgs%SpannerMigrationWrapper._ParseWebArgs   si     	Ix $'(y12-/@ABr   c	                    A	S/n
U(       a  U
R                  SU/5        U(       a  U
R                  SU/5        U(       a  U
R                  SU/5        U(       a  U
R                  S5        U(       a  U
R                  S5        U(       a  U
R                  S5        U(       a  U
R                  S5        U(       a  U
R                  S	5        U
$ )
z$"Parse args for the cleanup command.cleanupz--jobIdz--dataShardIdsr/   z--datastreamz
--dataflowz--pubsubz--monitoringr1   r3   )r%   job_iddata_shard_idsr:   
datastreamdataflowpub_sub
monitoringr<   r&   r>   s              r   ParseCleanupArgs(SpannerMigrationWrapper.ParseCleanupArgs   s     	I	6*+(.9:*N;<~&|$z"~&}%r   c                    AS/nU(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U(       a  UR                  SU/5        U	(       a  UR                  S	U	/5        U(       a  UR                  S
U/5        U
(       a  UR                  SU
/5        U$ )z#"Parse args for the import command.importz
--instancez
--databasez--table-namez--source-uriz--source-formatz--schema-uriz--csv-line-delimiterz--csv-field-delimiterr2   z--database-dialect)r4   )r%   instancedatabase
source_urisource_format
table_namer=   
schema_uricsv_line_delimitercsv_field_delimiterdatabase_dialectr&   r>   s                r   ParseImportArgs'SpannerMigrationWrapper.ParseImportArgs   s     	
Ih/0h/0
34
34)=9:
34.0BCD/1DEFW-.,.>?@r   c                 l   US:X  a  U R                   " S0 UD6$ US:X  a  U R                  " S0 UD6$ US:X  a  U R                  " S0 UD6$ US:X  a  U R                  " S0 UD6$ US:X  a  U R                  " S0 UD6$ US:X  a  U R
                  " S0 UD6$ [        R                  " SR                  U5      5      e)	z-Call the parser corresponding to the command.r*   rB   rM   rQ   rW   ra   z1Invalid Operation [{}] for spanner-migration-toolr   )	r?   rJ   rN   rT   r^   rk   r   InvalidOperationForBinaryformat)r%   commandr&   s      r   _ParseArgsForCommand,SpannerMigrationWrapper._ParseArgsForCommand   s    ("",V,,	F	  *6**	%	%))3F33	E	)&))	I	"",V,,	H	!!+F++77
=
D
DW
MO Or   r   )NNNNFNN)
NFNNNNFNNN)FNNN)NNFFFFN)NNNNNN)r   r   r   r   r   r$   r?   rJ   rN   rT   r^   rk   rq   r   __classcell__)r'   s   @r   r   r   '   s    EL #&*"&*$!%#D !',$( $(!%"#!'+)Z &*05-1%)-1*.&+(,&*04&R $"&*	* '+&*"' %$"'!%H "&"!%)-*.'+#JO Or   r   )NN)r   r   r   &googlecloudsdk.command_lib.util.anthosr   googlecloudsdk.corer   c_exceptr   Errorr   StreamingBinaryBackedOperationr   r   r   r   <module>ry      sE    _  	 D 6R R`O/NN `Or   