
                         x   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SKJr  \R*                  " \R,                  R.                  \R,                  R0                  \R,                  R2                  5       " S S\R4                  5      5       rg):Promotes Cloud SQL read replica to a stand-alone instance.    )absolute_import)division)unicode_literalsN)api_util)	instances)
operations)validate)base)flags)log)
properties)
console_ioc                   .    \ rS rSrSr\S 5       rS rSrg)PromoteReplica#   r   c                     [         R                  R                  U 5        U R                  S[        R
                  SS9  [        R                  " 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.
replicazCloud SQL read replica ID.)	completerhelpN)r   
ASYNC_FLAGAddToParseradd_argumentr   InstanceCompleterAddFailoverFlag)parsers    ,lib/surface/sql/instances/promote_replica.pyArgsPromoteReplica.Args(   sH     	OO'
)))  + 
&!    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UR                  R!                  UR#                  UR                  UR$                  S95      n[        R&                  R)                  UR*                  5      (       a  SnO3[        R&                  R-                  UR*                  5      (       a  SnOSnSnU(       a  SS	R/                  U5      -   n[0        R2                  R5                  [6        R8                  " 5       R;                  S
5      S-   5        U(       a  [0        R2                  R5                  U5        [<        R>                  " SSSS9  UR                  RA                  URC                  UR                  UR$                  URD                  S95      n	UR                  RG                  SU	RH                  UR                  S9n
URJ                  (       a=  URL                  R!                  URO                  U
R                  U
RP                  S95      $ [L        RR                  RU                  X:S5        [V        RX                  R5                  SR/                  US95        g)a'  Promotes Cloud SQL read replica to a stand-alone instance.

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

Returns:
  A dict object representing the operations resource describing the
  promote-replica operation if the promote-replica was successful.
projectzsql.instances)params
collection)r"   instancemysqlpostgresNzLearn more:
zRhttps://cloud.google.com/sql/docs/{}/replication/manage-replicas#promote-replica

a-  Promoting a read replica stops replication and converts the instance to a standalone primary instance with read and write capabilities. This can't be undone. To avoid loss of data, before promoting the replica, you should verify that the replica has applied all transactions received from the primary.z

 T)messagedefaultcancel_on_no)r"   r%   failoverzsql.operations)	operationr"   )r"   r-   zPromoting Cloud SQL replicazPromoted [{instance}].
)r%   )-r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr
   ValidateInstanceNamer   resource_parserParser   VALUEScorer"   	GetOrFailr   GetSqlInstancesGetRequestr%   InstancesV1Beta4IsMysqlDatabaseVersiondatabaseVersionIsPostgresDatabaseVersionformatsysstderrwritetextwrapTextWrapperfillr   PromptContinuer   !SqlInstancesPromoteReplicaRequestr,   Createnameasync_r	   SqlOperationsGetRequestr-   OperationsV1Beta4WaitForOperationr   status)selfargsclientr0   r1   instance_refinstance_resourcedatabase_type_fragmentpromote_replica_docs_linkresultoperation_refs              r   RunPromoteReplica.Run8   s     < <=F""J&&L!!$,,/))//:,,1199CCD" 0 $L
 #,,00++ ((<3H3H 	, 	JK !!88))+ +&		#	#	=	=))
+ 
+)  $ $

`6()*   JJX))+00	23
 6<< = !	jj01b$TJ!!0066 ((<3H3H]] 	7 	$%F **11FKK9M9M 2 OM {{""&&

.
.#++}7N7N / PQ Q   11*2OQ JJ/666MNr     N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   rW   __static_attributes__rY   r    r   r   r   #   s!     C" "MOr    r   )r^   
__future__r   r   r   r?   rB   googlecloudsdk.api_lib.sqlr   r   r	   r
   googlecloudsdk.callioper   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   ReleaseTracksReleaseTrackGABETAALPHACommandr   rY   r    r   <module>rm      s    A &  ' 
  / 0 1 / ( 0 # * 2 D%%(($*;*;*@*@%%++-`OT\\ `O-`Or    