
    F                        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 ddlmZ ddlmZ ddlZdZdZeedZ ej0                  ej2                  j4                  ej2                  j6                  ej2                  j8                         G d dej:                               Zy)%Reencrypts a Cloud SQL CMEK instance.    )absolute_import)division)unicode_literals)
exceptions)api_util)
operations)validate)base)flags)log)
properties)
console_ioNzJ    Reencrypt a Cloud SQL CMEK instance with the primary key version.
    zk    To reencrypt a Cloud SQL CMEK instance with the primary key version:

    $ {command} instance-foo
    )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)	Reencryptr   c                     t         j                  j                  |        | j                  dt        j
                  d       y)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helpN)r   
ASYNC_FLAGAddToParseradd_argumentr   InstanceCompleter)parsers    &lib/surface/sql/instances/reencrypt.pyArgszReencrypt.Args8   s8     	OO'
))%      c                    t        j                  t         j                        }|j                  }|j                  }d}t        j                  |j                         |j                  j                  |j                  dt        j                  j                  j                  j                  id      }t        j                   d      sy	 |j"                  j%                  |j'                  |j                  |j                              }|j                  j)                  d|j*                  |j                        }|j,                  r@|j.                  j1                  |j3                  |j                  |j4                  	            S t.        j6                  j9                  ||d
       y# t:        j<                  $ r+ t?        j@                  dtC        jD                  |              w xY w)a#  Reencrypts a Cloud SQL CMEK instance.

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

    Returns:
      A dict object representing the operations resource describing the
      reencrypt operation if the reencryption was successful.
    Nprojectzsql.instances)params
collectionzyWARNING: Reencryption will restart your instance if the primary key version is different from the instance's key version.)r   r!   zsql.operations)	operationr!   )r!   r$   zReencrypting Cloud SQL instancezoperation : %s)#r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr
   ValidateInstanceNamer   resource_parserParser   VALUEScorer!   	GetOrFailr   PromptContinue	instancesr   SqlInstancesReencryptRequestCreatenameasync_r	   GetSqlOperationsGetRequestr$   OperationsV1Beta4WaitForOperationr   	HttpErrorr   debugsix	text_type)selfargsclientr'   r(   operation_refinstance_refresults           r   RunzReencrypt.RunG   s     < <=F""J&&LM!!$--0))//:,,1199CCD" 0 L $$	A ##--

3
3#,,l6J6J 4 f ,,33
fkk<;O;O 4 m 
$$((00%--9P9P 1 
 	
 ""33
m%F  	ii #--">?s   
B=F* !F* *>G(N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr   rC    r   r   r   r   0   s#     .- 4r   r   )rG   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.sqlr   r	   r
   googlecloudsdk.callioper   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   r;   r   EXAMPLES_GArH   ReleaseTracksReleaseTrackALPHABETAGACommandr   rK   r   r   <module>rZ      s    , &  ' ' / 1 / ( 0 # * 2 
  T..33T5F5F5I5IH HHr   