
                            S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SrSS0rS rS r\R0                  \R2                  " \R4                  R6                  \R4                  R8                  \R4                  R:                  5       " S S\R<                  5      5       5       rg)zSwitches over a Cloud SQL instance to one of its replicas.

Switches over a Cloud SQL instance to one of its replicas. Currently only
supported on Cloud SQL for SQL Server and MySQL instances.
    )absolute_import)division)unicode_literalsN)api_util)
operations)validate)base)flags)log)
properties)
console_ioi  EXAMPLESz{        To switch over an instance to its replica called replica-instance:

          $ {command} replica-instance
        c                     [         R                  R                  U 5        U R                  S[        R
                  SS9  [        R                  " U 5        g)z>Declare flag and positional arguments for this command parser.replicazCloud SQL replica ID.)	completerhelpN)r	   
ASYNC_FLAGAddToParseradd_argumentr
   InstanceCompleterAddSwitchoverDbTimeoutparsers    'lib/surface/sql/instances/switchover.pyAddBaseArgsr   1   sE    //f%5229P   v&    c                 |   [         R                  " [         R                  5      nUR                  nUR                  n[
        R                  " U R                  5        UR                  R                  U R                  S[        R                  R                  R                  R                  0SS9n[        R                   R#                  [$        R&                  " 5       R)                  S5      S-   5        [*        R,                  " SSSS9  U R.                  nUb  [1        U R.                  5      S
-   nUR2                  R5                  UR7                  UR                  UR8                  US95      nUR                  R;                  SUR<                  UR                  S9nU R>                  (       a=  UR@                  RC                  URE                  UR                  URF                  S95      $ [@        RH                  RK                  X'S[L        5        [N        RP                  R#                  SRS                  US95        g	)a~  Switches over a Cloud SQL instance to one of its replicas.

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

Returns:
  A dict object representing the operations resource describing the
  switchover operation if the switchover was successful.

Raises:
  exceptions.OperationError: If the switchover operation is not supported for
  the instance.
projectzsql.instances)params
collectiona  Switching over to a replica leads to a short period of downtime and results in the primary and replica instances "switching" roles. Before switching over to the replica, you must verify that both the primary and replica instances are online. Otherwise, use a promote operation.z

 T)messagedefaultcancel_on_noNs)r   instance	dbTimeoutzsql.operations)	operationr   )r   r(   z#Switching over to Cloud SQL replicazSwitched over [{instance}].
)r&   )*r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr   ValidateInstanceNamer   resource_parserParser   VALUEScorer   	GetOrFailsysstderrwritetextwrapTextWrapperfillr   PromptContinue
db_timeoutstr	instances
SwitchoverSqlInstancesSwitchoverRequestr&   Createnameasync_r   GetSqlOperationsGetRequestr(   OperationsV1Beta4WaitForOperation%_SWITCHOVER_OPERATION_TIMEOUT_SECONDSr   statusformat)argsclientr+   r,   instance_refdb_timeout_strresultoperation_refs           r   RunBaseSwitchoverCommandrO   :   s    h::;&  *$$,
-''--
ll**//77AAB  . , **!!1 		 B4H??.)C/N**00&&((" 1 & ((//&++|7K7K 0 - 
[[  $$,,!))]5L5L 	- 	
  //!F+
 **%,,l,Cr   c                   2    \ rS rSrSr\rS r\S 5       r	Sr
g)r=      zwSwitches over a Cloud SQL instance to one of its replicas.

Switches over a Cloud SQL instance to one of its replicas.
c                     [        U5      $ )N)rO   )selfrI   s     r   RunSwitchover.Run   s    #D))r   c                     [        U 5        g)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.
N)r   r   s    r   ArgsSwitchover.Args   s     r    N)__name__
__module____qualname____firstlineno____doc__DETAILED_HELPdetailed_helprT   staticmethodrW   __static_attributes__rY   r   r   r=   r=      s'    

  -*  r   r=   ) r^   
__future__r   r   r   r3   r6   googlecloudsdk.api_lib.sqlr   r   r   googlecloudsdk.callioper	   googlecloudsdk.command_lib.sqlr
   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   rF   r_   r   rO   DefaultUniverseOnlyReleaseTracksReleaseTrackGABETAALPHACommandr=   rY   r   r   <module>rp      s    '  ' 
  / 1 / ( 0 # * 2 )- %  'GT $++00$2C2C2I2I  r   