
                             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  G d de
j                         Zy)z Command for spanner rows update.    )absolute_import)division)unicode_literals)database_sessions)	databases)arg_parsers)base)resource_args)
write_util)	resourcesc                   &    e Zd ZdZed        Zd Zy)Updatea  Update a row in a Cloud Spanner database.

  ## EXAMPLES

  To update a row with SingerId=1,SingName=abc in table Singers under
  my-database and my-instance, run:

    $ {command} --table=Singers --database=my-database --instance=my-instance --data=SingerId=1,SingerName=abc

    $ {command} --table=Singers --database=my-database --instance=my-instance --flags-file=path/to/file.yaml
  c                     t        j                  | dd       | j                  ddt        d       | j                  dddt	        j
                         d	
       y)zSee base class.zin which to update a rowFz--tableTzThe Cloud Spanner table name.)requiredtypehelpz--datazCOLUMN_NAME=VALUEzThe column names and values for the row being updated. For complicated input values, such as arrays, use the `--flags-file` flag. See $ gcloud topic flags-file for more information.)r   metavarr   r   N)r
   AddDatabaseResourceArgadd_argumentstrr   ArgDict)parsers    "lib/surface/spanner/rows/update.pyArgszUpdate.Args,   sj     ((1K).0
,	  .
 #  "D  E    c                 V   |j                   j                  j                         }t        j                  |      }t
        j                  j                  ||j                        }t        j                  ||j                        }t        j                  j                  ||      }t        j                  |      }t        j                   j#                  |j$                  d      }	 t        j&                  ||g      t        j(                  |       S # t        j(                  |       w xY w)z9This is what gets called when the user runs this command.z-spanner.projects.instances.databases.sessions)relative_name
collection)CONCEPTSdatabaseParser   GetDdlr   TableFromDdltableValidateArrayInputdatar   MutationFactoryr   Creater   REGISTRYParseRelativeNamenameCommitDelete)	selfargsdatabase_refddlr%   r'   mutationsession_namesessions	            r   Runz
Update.Run@   s     ==))//1L 

<
(C$$S$**5E((		:D 0077tDH %++L9L  22"''B 3 DG(%%gz:w'w's   %D D(N)__name__
__module____qualname____doc__staticmethodr   r6    r   r   r   r      s"    
 E E&(r   r   N)r:   
__future__r   r   r   googlecloudsdk.api_lib.spannerr   r   googlecloudsdk.callioper   r	   "googlecloudsdk.command_lib.spannerr
   r   googlecloudsdk.corer   Commandr   r<   r   r   <module>rC      s8    ' &  ' < 4 / ( < 9 )8(T\\ 8(r   