
                             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 dd
lmZ ddlmZ  G d de
j                         Zy)z)Command for spanner databases ddl update.    )absolute_import)division)unicode_literalsN)database_operations)	databases)base)flags)resource_args)logc                   N    e Zd ZdZd ej
                  d      iZed        Zd Z	y)Updatez,Update the DDL for a Cloud Spanner database.EXAMPLESz        To add a column to a table in the given Cloud Spanner database, run:

          $ {command} my-database-id --instance=my-instance-id
              --ddl='ALTER TABLE test_table ADD COLUMN a INT64'
        c                 L   t        j                  | d       t        j                  d      j	                  |        t        j
                  d      j	                  |        t        j                  d      j	                  |        t        j                  j	                  |        y)zSee base class.zof which the ddl to updatezSemi-colon separated DDL (data definition language) statements to run inside the database. If a statement fails, all subsequent statements in the batch are automatically cancelled.)	help_texta&  Path of a file containing semi-colon separated DDL (data definition language) statements to run inside the database. If a statement fails, all subsequent statements in the batch are automatically cancelled. If --ddl_file is set, --ddl is ignored. One line comments starting with -- are ignored.zPath of a file that contains a protobuf-serialized google.protobuf.FileDescriptorSet message. To generate it, install and run `protoc` with --include_imports and --descriptor_set_out.N)	r
   AddDatabaseResourceArgr	   DdlAddToParserDdlFileProtoDescriptorsFiler   
ASYNC_FLAG)parsers    +lib/surface/spanner/databases/ddl/update.pyArgszUpdate.Args,   s     ((1MN	II E  {6"	MM:;
 <G;v;N	I k&OO'    c                 t   t        j                  |j                  j                  j	                         t        j                  |      t        j                  |            }|j                  r8t        j                  j                  dj                  |j                              S t        j                  |d      S )zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    z,Schema update in progress. Operation name={}zSchema updating)r   	UpdateDdlCONCEPTSdatabaseParser	   SplitDdlIntoStatementsGetProtoDescriptorsasync_r   statusPrintformatnamer   Await)selfargsops      r   Runz
Update.RunB   s     
		T]]3399;"99$?"66t<
>B {{ZZ
8
?
?
HJ J$$R):;;r   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r+    r   r   r   r      s=    4 
(//  - ( (*<r   r   )r/   
__future__r   r   r   r0   googlecloudsdk.api_lib.spannerr   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.spannerr	   r
   googlecloudsdk.corer   UpdateCommandr   r4   r   r   <module>r;      s:    0 &  '  > 4 ( 4 < #3<T 3<r   