
                         \   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  e
j$                  e
j&                  j(                  e
j&                  j*                  e
j&                  j,                         G d de
j.                               Zy)Restarts a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)
operations)validate)base)flags)log)
properties)
console_ioc                   &    e Zd ZdZed        Zd Zy)Restartr   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/restart.pyArgszRestart.Args$   s8     	OO'
))%  '    c                    t        j                  t         j                        }|j                  }|j                  }t        j                  |j                         |j                  j                  |j                  dt        j                  j                  j                  j                  id      }t        j                   ddd       |j"                  j%                  |j'                  |j                  |j                              }|j                  j)                  d|j*                  |j                  	      }|j,                  r@|j.                  j1                  |j3                  |j                  |j4                  
            S t.        j6                  j9                  ||d       t:        j<                  j?                  djA                  |             y)a  Restarts a Cloud SQL instance.

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

    Returns:
      A dict object representing the operations resource describing the restart
      operation if the restart was successful.
    projectzsql.instances)params
collectionzThe instance will shut down and start up again immediately if its activation policy is "always." If "on demand," the instance will start up again when a new connection request is made.T)messagedefaultcancel_on_no)r   r   zsql.operations)	operationr   )r   r$   zRestarting Cloud SQL instancezRestarted [{resource}].
)resourceN)!r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr	   ValidateInstanceNamer   resource_parserParser   VALUEScorer   	GetOrFailr   PromptContinue	instancesr   SqlInstancesRestartRequestCreatenameasync_r   GetSqlOperationsGetRequestr$   OperationsV1Beta4WaitForOperationr   statuswriteformat)selfargsclientr(   r)   instance_refresult_operationoperation_refs           r   RunzRestart.Run3   s     < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L
 @  "++33// ((<3H3H 	0 	JK **11"''$$ 2 &M
 {{""&&

.
.#++}7N7N / PQ Q   11M#BD JJ0777NOr   N)__name__
__module____qualname____doc__staticmethodr   rC    r   r   r   r      s     '' '-Pr   r   N)rG   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   ReleaseTracksReleaseTrackGABETAALPHACommandr   rI   r   r   <module>rV      s    % &  ' / 1 / ( 0 # * 2 D%%(($*;*;*@*@%%++-?Pdll ?P-?Pr   