
    >                     <   S r SSKJr  SSKJr  SSKJ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rSrSr\\S.r\R.                  " \R0                  R2                  5      \R4                   " S S\R6                  5      5       5       rg)HPerforms pre-checks for a major version upgrade of a Cloud SQL instance.    )absolute_import)division)unicode_literalsN)
exceptions)api_util)validate)base)flags)
propertieszZ
    *{command}* performs pre-checks for a major version upgrade of a Cloud SQL instance.
z
    To perform pre-checks before upgrading to a target version:

      $ {command} test-instance --target-database-version=POSTGRES_15
)DESCRIPTIONEXAMPLESc                   2    \ rS rSrSr\r\S 5       rS r	Sr
g)PreCheckMajorVersionUpgrade1   r   c                     [         R                  R                  U 5        U R                  S[        R
                  SS9  U R                  SSSS9  g )NinstancezCloud SQL instance ID.)	completerhelpz--target-database-versionTz(Target database version for the upgrade.)requiredr   )r
   
ASYNC_FLAGAddToParseradd_argumentr   InstanceCompleter)parsers    <lib/surface/sql/instances/pre_check_major_version_upgrade.pyArgs PreCheckMajorVersionUpgrade.Args8   sT    OO'
))%  
 #7      c           
      J   [         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"                  R%                  5       5      nUR-                  UR                  UR                  UR/                  UR                  US9S9S9nUR0                  R3                  U5      nUR                  R5                  S	UR6                  UR                  S
9n	UR8                  (       a=  UR:                  R=                  UR?                  U	R                  U	R@                  S95      $  UR:                  R=                  UR?                  U	R                  U	R@                  S95      n
U
RB                  URD                  RF                  RH                  :X  a  O[J        RL                  " S5        M  [O        U
SS 5      nU(       a  [O        US/ 5      O/ n/ nU H  nURP                  nURS                  S5      (       a  US S nURU                  5       RU                  S5      nSU;  d  MQ  URW                  UURX                  R6                  URZ                  S.5        M     []        S5        U(       a  []        S5        O[]        S5        UR                  UR                  U(       a  [_        UR`                  5      OUR"                  R%                  5       USS.$ ! [&         a    [(        R*                  " SS5      ef = f! [b        Rd                   a  nURf                  [h        Rj                  Rl                  Rn                  :X  a3  [(        Rp                  " SRs                  URu                  5       5      5      e[(        Rp                  " U5      eS nAff = f)Nprojectzsql.instances)params
collectionztarget-database-versionz6Missing or Invalid parameter: Target database version.)targetDatabaseVersion)"preCheckMajorVersionUpgradeContext)r   r!   +instancesPreCheckMajorVersionUpgradeRequestzsql.operations)	operationr!   )r!   r'      r%   preCheckResponsez"]"zpre-upgrade check failed)messagemessage_typeactions_requiredz2Performing pre-check on Cloud SQL instance....donezFPlease check the output in the PreCheckResults field for more details.zNo issues or warnings detected during pre-check. We recommend that you perform MVU on a cloned instance before applying them to a production instance.	COMPLETED)NameProjectTargetDatabaseVersionPreCheckResultsStatuszFThere's no instance found at {} or you're not authorized to access it.);r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr	   ValidateInstanceNamer   resource_parserParser   VALUEScorer!   	GetOrFail"PreCheckMajorVersionUpgradeContext$TargetDatabaseVersionValueValuesEnumtarget_database_versionupper	TypeErrorr   InvalidArgumentException.SqlInstancesPreCheckMajorVersionUpgradeRequest+InstancesPreCheckMajorVersionUpgradeRequest	instancesr   Createnameasync_
operationsGetSqlOperationsGetRequestr'   status	OperationStatusValueValuesEnumDONEtimesleepgetattrr,   endswithstripappendmessageTypeactionsRequiredprintstrr$   apitools_exceptions	HttpErrorstatus_codesixmoveshttp_client	FORBIDDENHttpExceptionformatRelativeName)selfargsclientr7   r8   instance_reftarget_version_enumrequestresult_operationoperation_refopcontextprecheck_responsesformatted_responsesrespraw_messageclean_messageerrors                     r   RunPreCheckMajorVersionUpgrade.RunF   s    < <=F""J&&L!!$--0))//:,,1199CCD" 0 Lf,
*MMrr((..0
 KK==&&

B
B1=1`1`(; 2a 2 C 	 L 	g 


:
:7
C  ,,33
$))&& 4 m 
$$((00%--9P9P 1 
 	
 ""&&00%--'11 1 
 99..DDIII


1  @$Gg6=''-r
22  $$ll %%#CR(+#))+11#6%]:

$
$&"..33"&"6"6&  % @A	E	

 	$	
 ''!))  '//0//5570
 
_  
11%D
 	

v (( ,			cii33==	=&& &!:!:!<=
 	
 $$U++,s:   23M) %CN <C9N 9B/N )"NN P""A;PP" N)__name__
__module____qualname____firstlineno____doc__DETAILED_HELPdetailed_helpstaticmethodr   rv   __static_attributes__rx   r   r   r   r   1   s%     Q- r,r   r   )r}   
__future__r   r   r   rR   apitools.base.pyr   r\   googlecloudsdk.api_lib.sqlr   r	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   six.moves.http_clientr_   r   r   r~   ReleaseTracksReleaseTrackGAUniverseCompatibleCommandr   rx   r   r   <module>r      s     O &  '  > / / ( . 0 *   D%%(()E,$,, E,  *E,r   