
    d                    :   S 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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  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r# " S S\$5      r%S r&S)S jr'S r(S r)S r*S r+S  r,S! r-\R\                  \R^                  " \R`                  Rb                  5       " S" S#\Rd                  5      5       5       r3\R\                  \R^                  " \R`                  Rh                  5       " S$ S%\Rd                  5      5       5       r5\R\                  \R^                  " \R`                  Rl                  5       " S& S'\Rd                  5      5       5       r7    S*S( jr8g)+-Updates the settings of a Cloud SQL instance.    )absolute_import)annotations)division)unicode_literalsN)Optional)messages)encoding)api_util)
exceptions)	instances)
operations)validate)arg_parsers)base)flags)labels_util)log)
properties)
console_ioi  im  c                      \ rS rSrSrS rSrg)_Result/   zRun() method result object.c                    Xl         X l        g Nnewold)selfr   r   s      "lib/surface/sql/instances/patch.py__init___Result.__init__2   s    HH    r   N)__name__
__module____qualname____firstlineno____doc__r!   __static_attributes__ r#   r    r   r   /   s
    #r#   r   c           
        SnSU ;   =(       a    U R                   SLn[        U R                  SLU R                  SLU R                  SLU R
                  SLU R                  SLU R                  SLU R                  SL/5      n[        U R                  U R                  SLUU/5      (       a  SnGO[        U R                  U R                  /5      (       a  Sn[        R                  R                  U5      (       a  SnO&[        R                  R!                  U5      (       a  SnSR#                  U5      nU R                  bQ  [        SU R                  ;   S	U R                  ;   /5      (       a%  [$        R&                  " S
R#                  U5      5        SR#                  U5      nO([        U R(                  U R*                  /5      (       a  SnSU ;   a7  U R,                  b*  Sn[$        R&                  " S5        U(       a	  US-   U-   nOUnU(       a2  [.        R0                  " U5      (       d  [2        R4                  " S5      egg)zFPrint and confirm warning indicating the effect of applying the patch.N#insights_config_query_string_lengthzWARNING: This patch modifies a value that requires your instance to be restarted. Submitting this patch will immediately restart your instance if it's running.mysqlpostgres	sqlserverz*https://cloud.google.com/sql/docs/{}/flagssync_binloginnodb_flush_log_at_trx_commitzfChanging innodb_flush_log_at_trx_commit or sync_binlog may cause data loss. Check {} for more details.zWARNING: This patch modifies database flag values, which may require your instance to be restarted. Check the list of supported flags - {} - to see if your instance will be restarted when this patch is submitted.zWARNING: This patch modifies the zone your instance is set to run in, which may require it to be moved. Submitting this patch will restart your instance if it is running in a different zone.	time_zonezjWARNING: This patch modifies the time zone for your instance which may cause inconsistencies in your data.zaThis patch modifies the time zone for your instance which may cause inconsistencies in your data.
zcanceled by the user.)r,   anyactive_directory_domainclear_active_directory"clear_active_directory_dns_serversactive_directory_dns_servers#active_directory_secret_manager_key$active_directory_organizational_unitactive_directory_modetierenable_database_replicationdatabase_flagsclear_database_flagsr   InstancesV1Beta4IsPostgresDatabaseVersionIsSqlServerDatabaseVersionformatr   warningfollow_gae_appgce_zoner2   r   PromptContinuer   CancelledError)argsdatabase_versioncontinue_msginsights_query_length_changedactive_directory_config_changeddatabase_type_fragmentflag_docs_urltime_zone_warning_msgs           r    _PrintAndConfirmWarningMessagerQ   7   sP   , ,t3 ?

2
2$
>  
 %(
""$.
!!-
--T9
''t3
..d:
//t;
  ,) %! 	
ii
&&d2%#	
  OL D!:!:;<<$  ::;KLL)		"	"	=	=>N	O	O*@GG M&3,,,(D,?,??0 , , 
kk%vm4	 }-	  D/002  DT^^7	/  KK	) !D(+@@l*l*33LAA

#
#$;
<< B\r#   c                   U(       a  U O[         R                  " U 5      nUR                  5        H  nUR                  S:X  a	  SUl        M  [        U[        R                  5      (       d  M=  [        X#R                  5      nUc  MW  [        U[        5      (       a3  [        X#R                  U Vs/ s H  n[        US5      PM     sn5        M  [        X#R                  [        US5      5        M     U$ s  snf )z+Remove the kind field from a proto message.kindNT)copydeepcopy
all_fieldsnamerS   
isinstancer	   MessageFieldgetattrlistsetattrWithoutKind)messageinlineresultfieldvalueitems         r    r]   r]      s    7$--"8&  "ezzVfk	E800	1	1fjj)e		eT""
&**7<=ut;tT*u=? &**k%&>
? # 
- >s   0C5c                   / nU R                   (       a  UR                  S5        U R                  (       a  UR                  S5        U R                  (       a  UR                  S5        U R                  (       a  UR                  S5        U R
                  (       a  UR                  S5        U R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S	5        U R                  S
5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        U R                  (       a  UR                  S5        U R                  (       a  UR                  S5        [        R                  R                  S5        [        R                  R                  [        R                  " [        U5      US9S-   5        [        XR                   5        U$ )z5Clear fields according to args and confirm with user.z"settings.authorizedGaeApplicationsz+settings.ipConfiguration.authorizedNetworkszsettings.databaseFlagszsettings.denyMaintenancePeriodsz!settings.passwordValidationPolicyclear_allowed_psc_projectsz:settings.ipConfiguration.pscConfig.allowedConsumerProjectsclear_psc_auto_connectionsz5settings.ipConfiguration.pscConfig.pscAutoConnections&clear_custom_subject_alternative_namesz6settings.ipConfiguration.customSubjectAlternativeNamesclear_connection_pool_flagsz#settings.connectionPoolConfig.flags clear_psc_network_attachment_uriz7settings.ipConfiguration.pscConfig.networkAttachmentUriclear_unc_mappingszsettings.uncMappingsz)settings.activeDirectoryConfig.dnsServerszsettings.activeDirectoryConfigz=The following message will be used for the patch API method.
)include_fieldsr3   )clear_gae_appsappendclear_authorized_networksr?   remove_deny_maintenance_periodclear_password_policyIsKnownAndSpecifiedr7   r6   r   statuswriter
   MessageToJsonr]   rQ   databaseVersion)rI   patch_instanceoriginal_instancecleared_fieldss       r    _GetConfirmedClearedFieldsry      s   .	>?	##GH	23	((;<	=>	:;;D 
:;;? 
FGG@ 
;<<?@	@AAA 
23301	,,EF	  :;**F **
n
%n 	 !'H'HI	r#   c                   [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [        R
                  R                  U 5        U R                  5       n[         R                  " USS9  UR                  SSSSS9  U R                  5       n[         R                  " USS9  UR                  SSSS	S9  [         R                  " U 5        U R                  5       nUR                  5       n[         R                  " U5        [         R                  " USS
9  [         R                  " U5        [         R                   " U5        UR                  SSSSS9  U R                  5       n[         R"                  " U5        UR                  SSSSS9  [         R$                  " U 5        U R                  SSSS9  [         R&                  " U SS9  U R                  S[(        R*                  SS9  U R                  SSSS9  U R                  S[         R,                  SS9  [         R.                  " U 5        U R                  SSSS9  [         R0                  " U 5        [         R2                  " U 5        [         R4                  " U 5        [         R6                  " U 5        [         R8                  " U 5        U R                  SSSS9  [         R:                  " U SS9  [         R<                  " U 5        [         R>                  " U SS9  [         R@                  " U SS9  [         RB                  " U 5        [         RD                  " U 5        [         RF                  " U 5        [         RH                  " U 5        [         RJ                  " U 5        [         RL                  " U 5        [         RN                  " U 5        [         RP                  " U 5        [         RR                  " U 5        U R                  SS SS!S"/S#S$9  [         RT                  " U 5        U R                  S%[(        R*                  S&S9  [         RV                  " U 5        [         RX                  " U 5        [         RZ                  " U 5        [         R\                  " U SS'9  [         R^                  " U 5        [         R`                  " U 5        [         Rb                  " U 5        [         Rd                  " U 5        [         Rf                  " U 5        [         Rh                  " U 5        [         Rj                  " U 5        [         Rl                  " U 5        [         Rn                  " U SS9  [         Rp                  " U 5        [         Rr                  " U 5        [         Rt                  " U 5        [         Rv                  " U 5        U R                  5       n[         Rx                  " U5        [         Rz                  " U5        U R                  5       n[         R|                  " U5        [         R~                  " U5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U SS9  U R                  5       n[         R                  " U5        [         R                  " U5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        U R                  5       n	[         R                  " U	5        [         R                  " U	5        U R                  5       n
[         R                  " U
5        [         R                  " U
5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        g())z'Adds base args and flags to the parser.T)updatez--clear-gae-appsF
store_truezMSpecified to clear the list of App Engine apps that can access this instance.)requiredactionhelpz--clear-authorized-networkszPClear the list of external networks that are allowed to connect to the instance.)allow_emptyz--no-backupz-Specified if daily backup should be disabled.z--clear-database-flagszRClear the database flags set on the instance. WARNING: Instance will be restarted.z--diffz,Show what changed as a result of the update.)r~   r   )show_negated_in_helpz--enable-database-replicationzoEnable database replication. Applicable only for read replica instance(s). WARNING: Instance will be restarted.z--follow-gae-appzFirst Generation instances only. The App Engine app this instance should follow. It must be in the same region as the instance. WARNING: Instance may be restarted.)r}   r   instancezCloud SQL instance ID.)	completerr   z--maintenance-window-anyz.Removes the user-specified maintenance window.z --remove-deny-maintenance-periodz3Removes the user-specified deny maintenance period.z--pricing-planz-pPER_USEPACKAGEzDFirst Generation instances only. The pricing plan for this instance.)r}   choicesr   z--require-sslzEmysqld should default to 'REQUIRE X509' for users connecting over IP.)is_patchN)br   AddActivationPolicyAddActiveDirectoryDomainAddAssignIpr   
ASYNC_FLAGAddToParseradd_mutually_exclusive_groupAddAuthorizedGAEAppsadd_argumentAddAuthorizedNetworksAddAvailabilityType	add_groupAddBackupStartTimeAddBackupLocationAddRetainedBackupsCountAddRetainedTransactionLogDaysAddDatabaseFlagsAddCPUAddEnableBinLogr   StoreTrueFalseActionInstanceCompleterAddMaintenanceReleaseChannelAddMaintenanceWindowDayAddMaintenanceWindowHour!AddDenyMaintenancePeriodStartDateAddDenyMaintenancePeriodEndDateAddDenyMaintenancePeriodTime%AddInsightsConfigQueryInsightsEnabled"AddInsightsConfigQueryStringLength&AddInsightsConfigRecordApplicationTags$AddInsightsConfigRecordClientAddress$AddInsightsConfigQueryPlansPerMinute	AddMemoryAddPasswordPolicyMinLengthAddPasswordPolicyComplexityAddPasswordPolicyReuseInterval*AddPasswordPolicyDisallowUsernameSubstring'AddPasswordPolicyPasswordChangeInterval%AddPasswordPolicyEnablePasswordPolicy$AddPasswordPolicyClearPasswordPolicyAddReplicationAddStorageAutoIncreaseAddStorageSizeAddStorageTypeAddTier
AddEditionAddEnablePointInTimeRecovery
AddNetworkAddMaintenanceVersionAddSqlServerAuditAddSqlServerTimeZoneAddDeletionProtectionAddConnectorEnforcementAddEnableGooglePrivatePathAddThreadsPerCoreAddEnableDataCacheAddEnableAutoUpgrade!AddRecreateReplicasOnPrimaryCrashAddAllowedPscProjectsAddClearAllowedPscProjects AddCustomSubjectAlternativeNames%AddClearCustomSubjectAlternativeNames
AddSslModeAddEnableGoogleMLIntegrationAddEnableDataplexIntegration AddUpgradeSqlNetworkArchitectureAddForceSqlNetworkArchitectureAddSimulateMaintenanceEvent&AddSwitchTransactionLogsToCloudStorageAddFailoverDrReplicaNameAddClearFailoverDrReplicaName(AddIncludeReplicasForMajorVersionUpgradeAddRetainBackupsOnDeleteAddStorageProvisionedIopsAddStorageProvisionedThroughputAddEnablePrivateServiceConnectAddPSCNetworkAttachmentUriAddClearPSCNetworkAttachmentUriAddInstanceTypeAddNodeCountAddActiveDirectoryMode"AddActiveDirectorySecretManagerKey$AddActiveDirectoryOrganizationalUnitAddActiveDirectoryDNSServersClearActiveDirectoryDNSServersAddClearActiveDirectoryAddFinalBackupAddFinalbackupRetentionDaysAddEnableConnectionPoolingAddConnectionPoolFlagsAddClearConnectionPoolFlagsAddPscAutoConnectionsAddClearPscAutoConnectionsAddServerCaModeAddServerCaPoolAddReadPoolAutoScaleConfig)parsergae_apps_groupnetworks_groupbackups_groupbackups_enabled_groupdatabase_flags_grouppsc_update_groupip_update_custom_sans_grouppsc_na_uri_update_groupconnection_pool_flags_group!psc_update_auto_connections_groups              r    AddBaseArgsr      s=    F#  (F//f%668.^D9	   668.nT:#	  ! F#557-'11301/TB 56%%&;<:	  <  <<>-.##3	 $ 5 ,,v9  ; T:%--@  B
 	@  B 	''#  % $$V, ;  = '  ())&1''/$$V,(@  B --f4P**62..4),,V$O,,V4//&""6*##F+&&v.226://7--f5,,V4
)$   v--  
 v&vv--&6$$V,6f%&!V$f%'""6E&!6"V$))&188:./""#34 & C C E(()DE--.IJ6$$V,$$V,((0&&v.##F+..v6  (%%f-008  (!!&)''/&&vDI"??A""#:;''(?@Vv&**62,,V4$$V,&&v.'v##F+""6* & C C E:;##$?@&,&I&I&K#?@""#DE""6*r#   c                *   [         R                  " U 5        [         R                  " U 5        [        R                  " U SS9  [         R
                  " U 5        [         R                  " U 5        U R                  SS9n[         R                  " U5        [         R                  " U5        [         R                  " U 5        [         R                  " U 5        [         R                  " U SS9  [         R                  " U SS9  [         R                  " U SS9  g)z'Adds beta args and flags to the parser.T)enable_clear)hiddenN)r   AddInstanceResizeLimitAddAllocatedIpRangeNamer   AddUpdateLabelsFlags&AddReplicationLagMaxSecondsForRecreateAddReconcilePsaNetworkingr   AddUncMappingsAddClearUncMappingsAddDataApiAccess AddServerCertificateRotationModeAddPerformanceCaptureConfigAddSqlServerEntraIdAddClearEntraIdConfig)r   unc_mappings_groups     r    AddBetaArgsr  w  s    v&'""6=..v6!!&)::$:G)*./ ((0##F48F40fT2r#   c                    g)z(Adds alpha args and flags to the parser.Nr*   )unused_parsers    r    AddAlphaArgsr    s    r#   c                    U [         R                  R                  :H  =(       d    U [         R                  R                  :H  $ )z3Returns true if the release track is beta or newer.)r   ReleaseTrackBETAALPHA)release_tracks    r    IsBetaOrNewerr    s6     t((--- 2	$++11	1r#   c           	        U R                   (       a  U R                  S5      (       d  SU l        [        R                  " [        R
                  5      nUR                  nUR                  n[        R                  " U R                  5        [        R                  " U 5        UR                  R                  U R                  S[        R                  R                   R"                  R$                  0SS9nU R                  S5      (       a]  U R'                  5        HI  nUS:X  a  M  US:X  a  M  U R)                  U5      R*                  (       a  M5  [,        R.                  " S5      e   U R                  S	5      (       aX  U R                  S
5      (       a  [,        R.                  " S5      eU R                  S5      (       a  [,        R.                  " S5      eU R1                  S5      (       a,  U R1                  S5      (       a  [,        R.                  " S5      eU R2                  (       a  [4        R6                  R9                  5         UR:                  R=                  UR?                  UR"                  UR                  S95      nU R1                  S5      (       a@  UR@                  RB                  RE                  S5      (       d  [,        R.                  " S5      eU R                  S5      (       d,  U R                  S5      (       d  U R                  S5      (       a  URF                  nU(       al  [I        U5      n	U	(       aZ  [J        RL                  RO                  5       n
X-
  n[P        URR                  s=::  a
  [T        :  a  O  O[V        RX                  " S5        [[        U5      (       a  U R                  S5      (       a  UR\                  R^                  (       a%  UR\                  R^                  R`                  (       d  [,        R.                  " S5      eU R'                  5        HI  nUS:X  a  M  US:X  a  M  U R)                  U5      R*                  (       a  M5  [,        R.                  " S5      e   [b        R6                  Re                  UU UUS9nUR"                  Ul        UR                  Ul!        [g        XU5      nU Rh                  (       a  URk                  S5        U R1                  S5      (       a  URk                  S5        URm                  U5         UR:                  Ro                  URq                  UUR"                  UR                  S95      nS S S 5        UR                  Rs                  S!WRB                  UR"                  S"9nU Rt                  (       a=  URv                  R=                  URy                  UR"                  URz                  S#95      $ [v        R|                  R                  X?S$5        [V        R                  " U5        UR:                  R=                  UR?                  UR"                  UR                  S95      n[        UU5      $ ! , (       d  f       GN= f)%a  Updates settings of a Cloud SQL instance using the patch api method.

Args:
  args: argparse.Namespace, The arguments that this command was invoked with.
  release_track: base.ReleaseTrack, the release track that this was run under.

Returns:
  A dict object representing the operations resource describing the patch
  operation if the patch was successful.
Raises:
  CancelledError: The user chose not to continue.
rC   zdiff(old, new)projectzsql.instances)params
collectionsimulate_maintenance_eventr   zc`--simulate-maintenance-event` cannot be specified with other arguments excluding gCloud wide flags	no_backupenable_bin_logzD`--enable-bin-log` cannot be specified when --no-backup is specifiedenable_point_in_time_recoveryzS`--enable-point-in-time-recovery` cannot be specified when --no-backup is specifiedfailover_dr_replica_nameclear_failover_dr_replica_namezc`--failover-dr-replica-name` cannot be specified when --clear-failover-dr-replica-name is specified)r  r   performance_capture_configMYSQLzE`--performance-capture-config` is only supported for MySQL instances."deny_maintenance_period_start_date deny_maintenance_period_end_datedeny_maintenance_period_timea.  Your instance has NOT undergone maintenance for at least 9 months. It is highly recommended to perform it soon. While you can still set a deny maintenance period now, please be aware that once your instance is on a maintenance version that is at least 12 months old, you will no longer be able to set a deny period. Maintenance is crucial for important updates, security patches, and bug fixes, and skipping them can leave your instance vulnerable. You can learn more about how to perform maintenance here: https://cloud.google.com/sql/docs/mysql/maintenancereconcile_psa_networkingz_argument --reconcile-psa-networking can be used only with instances that have a private networkzhargument --reconcile-psa-networking cannot be specified with other arguments excluding gcloud wide flags)originalr  zsettings.maintenanceWindowreplicationCluster)databaseInstancer  r   Nzsql.operations)	operationr  )r  r   zPatching Cloud SQL instance)BdiffIsSpecifiedrC   common_api_util	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr   ValidateInstanceNamer   ValidateInstanceLocationresource_parserParser   VALUEScorer  	GetOrFailGetSpecifiedArgsDictGetFlagArgument	is_globalr   ArgumentErrorrq   authorized_networksr   r@   *PrintAndConfirmAuthorizedNetworksOverwriter   GetSqlInstancesGetRequestru   rW   
startswithmaintenanceVersion _ParseDateFromMaintenanceVersiondatetimedatetoday_NINE_MONTHS_IN_DAYSdays_TWELVE_MONTHS_IN_DAYSr   rD   r  settingsipConfigurationprivateNetworkcommand_utilConstructPatchInstanceFromArgsry   maintenance_window_anyrm   IncludeFieldsPatchSqlInstancesPatchRequestCreateasync_r   SqlOperationsGetRequestr   OperationsV1Beta4WaitForOperationUpdatedResourcer   )rI   r  clientr&  r'  instance_refkeyoriginal_instance_resourcemaintenance_versionmaintenance_dater<  deltarv   rx   result_operationoperation_refchanged_instance_resources                    r    RunBasePatchCommandrY    s    
YYt''11"DK$$_%H%HI&  *$$,
.
##D)''--
mm**//77AAB  . ", 
"  ((*	
		,	,!!#&000&&5
 	
 + 
k""())$$  
		9	:	:$$%& & 
899 @AA$$:; ; 
HHJ)3377))&&1F1F * H I 
" &66;;FFwOO

"
"O 
 ;<<			<	=	=			8	9	94GG9:MN	##%(5::F0FF
++	E =!!d&6&6 ' ' '//??)22BBQQ$$)  ((*	
		*	*!!#&000&&5
 	
 +  00OO
)!	 P #.
 (//.$--.-d.HJ. 
  67	>??.//!++11--+ ((!** 	. 	,- 0 ((// %%"" 0 $-
 
[[  $$,,!))]5L5L 	- 	NO O //
0MO l#(2266))&&1F1F * HI 
*,F	GG3 0/s   ?Y
Y-c                  .    \ rS rSrSrS r\S 5       rSrg)rG  iA  r   c                4    [        XR                  5       5      $ r   rY  r  r   rI   s     r    Run	Patch.RunF      t%6%6%899r#   c                n    [        U 5        [        R                  " U SS9  [        R                  " U SS9  g)@Args is called by calliope to gather arguments for this command.lPreferred Compute Engine zone (e.g. us-central1-a, us-central1-b, etc.). WARNING: Instance may be restarted.	help_textF)support_default_versionN)r   r   AddZoneAddDatabaseVersionr   s    r    Args
Patch.ArgsI  s4     	MMOQ 
VUCr#   r*   N	r$   r%   r&   r'   r(   r^  staticmethodrj  r)   r*   r#   r    rG  rG  A  s"     6: D Dr#   rG  c                  .    \ rS rSrSrS r\S 5       rSrg)	PatchBetaiT  r   c                4    [        XR                  5       5      $ r   r\  r]  s     r    r^  PatchBeta.RunY  r`  r#   c                    [        U 5        [        R                  " U SS9  [        U 5        [        R                  " U SSS9  grb  rc  rd  F)restrict_choicesrf  N)r   r   rg  r  rh  ri  s    r    rj  PatchBeta.Args\  sC     	MMOQ 	 %'r#   r*   Nrl  r*   r#   r    ro  ro  T  s      6: ' 'r#   ro  c                  .    \ rS rSrSrS r\S 5       rSrg)
PatchAlphaik  r   c                4    [        XR                  5       5      $ r   r\  r]  s     r    r^  PatchAlpha.Runp  r`  r#   c                    [        U 5        [        R                  " U SS9  [        U 5        [	        U 5        [        R
                  " U SSS9  grs  )r   r   rg  r  r  rh  ri  s    r    rj  PatchAlpha.Argss  sK     	MMOQ 	 %'r#   r*   Nrl  r*   r#   r    rw  rw  k  s      6: ' 'r#   rw  c                ^   U R                  SS5      R                  S5       Hw  nUR                  S5      (       d  M  USS n[        U5      S:X  d  M1  UR	                  5       (       d  MH   [
        R
                  R                  US5      R                  5       s  $    g! [         a     M  f = f)zParses the date from a maintenance version string.

Args:
  maintenance_version: The maintenance version string in a format like
    'MYSQL_5_7_44.R20240915.01_02'.

Returns:
  A datetime.date object if a valid date is found, otherwise None.
_.R   N   z%Y%m%d)	replacesplitr7  lenisdigitr:  strptimer;  
ValueError)rS  partmaybe_date_strs      r    r9  r9    s     "))#s399#>dsABxn	^		!n&<&<&>&>	""++NHEJJL
L ? 
  	
	s   +-B
B,+B,)F)rS  strreturnzOptional[datetime.date])9r(   
__future__r   r   r   r   rT   r:  typingr   apitools.base.protorpcliter	   apitools.base.pyr
   googlecloudsdk.api_lib.sqlr   r#  r   r   r   r   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.sqlr   rC  $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   r=  r?  objectr   rQ   r]   ry   r   r  r  r  rY  DefaultUniverseOnlyReleaseTracksr  GAUpdateCommandrG  r	  ro  r
  rw  r9  r*   r#   r    <module>r     s   4 & "  '    / % B 1 < 1 / / ( 0 D < # * 2   f K=\"3lh+V3"
iHX D%%(()DD D * D" D%%**+'"" ' , '* D%%++,'## ' - ',r#   