
    @                         S r SSKJr  SSKJr  SSKJr   " S S\5      r " S S\5      rS	 r	S
 r
S rS rS rS rS rS rS rS rS rS rS rS rS rS rg)z0Utility for updating Memorystore Redis clusters.    )encoding)cluster_util)utilc                       \ rS rSrSrSrg)Error   zExceptions for this module. N__name__
__module____qualname____firstlineno____doc____static_attributes__r	       <lib/googlecloudsdk/command_lib/redis/clusters_update_util.pyr   r      s    #r   r   c                       \ rS rSrSrSrg)InvalidTimeOfDayError   z&Error for passing invalid time of day.r	   Nr
   r	   r   r   r   r      s    .r   r   c                     UR                   nU(       a$  UR                  U 5      S:X  a  US-   U -   Ul         U$ Xl         U$ )Nr   ,)
updateMaskcount)fieldpatch_requestupdate_masks      r   AddFieldToUpdateMaskr      sK    ((+1$!,s!2U!:m 
  %	r   c                     [         R                  " U 5      n[        R                  " X5      nXBR                  l        [        SU5      nU$ )Nredis_configs)r   GetMessagesForResourcer   PackageClusterRedisConfigclusterredisConfigsr   )cluster_refredis_configs_dictr   messagesnew_redis_configss        r   AddNewRedisClusterConfigsr(   )   sF    ((5("<< (9$&F-	r   c                     UR                  S5      (       a'  UR                  UR                  l        [	        SU5      nU$ )z>Hook to add replica count to the redis cluster update request.replica_count)IsSpecifiedr*   r"   replicaCountr   unused_cluster_refargsr   s      r   UpdateReplicaCountr0   3   s9    	o&&)-););M&(-HM	r   c                 v    UR                  S5      (       d  UR                  S5      (       a  [        SU5      nU$ )zKHook to update maintenance window policy to the update mask of the request.maintenance_window_daymaintenance_window_hourmaintenance_windowr+   r   r-   s      r   UpdateMaintenanceWindowPolicyr6   ;   s;     /00			3	4	4()=}MM	r   c                 l    UR                  S5      (       a  SUR                  l        [        SU5      nU$ )z"Hook to remove maintenance policy.maintenance_window_anyNr4   )r+   r"   maintenancePolicyr   r-   s      r   UpdateMaintenanceWindowAnyr:   E   s5    	.//.2M+()=}MM	r   c                     UR                  S5      (       a'  UR                  UR                  l        [	        SU5      nU$ )zLHook to update simulate maintenance event to the update mask of the request.simulate_maintenance_event)r+   r<   r"   simulateMaintenanceEventr   r-   s      r   UpdateSimulateMaintenanceEventr>   M   sD    	233'' 2 )$mM 
r   c                     UR                  S5      (       a'  UR                  UR                  l        [	        SU5      nU$ )zKHook to update rotate server certificate to the update mask of the request.rotate_server_certificate)r+   r@   r"   rotateServerCertificater   r-   s      r   UpdateRotateServerCertificaterB   Y   sD    	122&& 1 )#]M 
r   c                     UR                  S5      (       a'  UR                  UR                  l        [	        SU5      nU$ )z<Hook to add shard count to the redis cluster update request.shard_count)r+   rD   r"   
shardCountr   r-   s      r   UpdateShardCountrF   e   s9    	m$$'+'7'7M$(FM	r   c                     UR                  S5      (       a'  UR                  UR                  l        [	        SU5      nU$ )zDHook to add maintenance version to the redis cluster update request.maintenance_version)r+   rH   r"   maintenanceVersionr   r-   s      r   UpdateMaintenanceVersionrJ   m   s;    	+,,/3/G/GM,()>NM	r   c                     UR                  S5      (       a'  UR                  UR                  l        [	        SU5      nU$ )zBHook to add delete protection to the redis cluster update request.deletion_protectiondeletion_protection_enabled)r+   rL   r"   deletionProtectionEnabledr   r-   s      r   UpdateDeletionProtectionrO   u   s?    	+,,6:6N6NM3(%}M 
r   c                    UR                  S5      (       ao  0 n[        UR                  SS5      (       a*  [        R                  " UR                  R
                  5      nUR                  UR                  5        [        XU5      nU$ )zAHook to update redis configs to the redis cluster update request.update_redis_configr#   N)	r+   getattrr"   r   MessageToDictr#   updaterQ   r(   )r$   r/   r   config_dicts       r   UpdateRedisConfigsrV      su    	+,,K}$$nd;;**=+@+@+M+MNkt//0--M 
r   c                 $   [        UR                  SS5      (       d  U$ UR                  S5      (       a[  [        R                  " UR                  R
                  5      nUR                   H  nUR                  US5        M     [        XU5      nU$ )zAHook to remove redis configs to the redis cluster update request.r#   Nremove_redis_config)	rR   r"   r+   r   rS   r#   rX   popr(   )r$   r/   r   rU   removed_keys        r   RemoveRedisConfigsr[      s    	&&	=	=	+,,(()>)>)K)KLK//ook4( 0--M 
r   c                    UR                  S5      (       dB  UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  [        SU5      nUR                  R                  (       ax  UR                  S5      (       d1  UR                  S5      (       d  SUR                  R                  l        UR                  S5      (       d  SUR                  R                  l        U$ )zCHook to add persistence config to the redis cluster update request.persistence_moderdb_snapshot_periodrdb_snapshot_start_timeaof_append_fsyncpersistence_configN)r+   r   r"   persistenceConfig	rdbConfig	aofConfigr-   s      r   UpdatePersistenceConfigre      s     )**			/	0	0			3	4	4			,	-	-()=}MM ,,1224;K;K!< < ;?m--7.//:>m--7	r   c                 J    UR                  S5      (       a  [        SU5      nU$ )z:Hook to add node type to the redis cluster update request.	node_typer5   r-   s      r   UpdateNodeTyperh      s%    	k""(mDM	r   c                     UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  [        SU5      nU$ )zHHook to add automated backup config to the redis cluster update request.automated_backup_ttlautomated_backup_start_timeautomated_backup_modeautomated_backup_configr5   r-   s      r   UpdateAutomatedBackupConfigrn      sQ     -..			7	8	8			1	2	2(!=M 
r   c                 4    U S:  d  U S:  a  [        S5      eU $ )Nr   r   z4A valid time of day must be specified (0, 23) hours.)r   )maintenance_window_start_times    r   $CheckMaintenanceWindowStartTimeFieldrq      s*    "Q&*G"*L
>  
'&r   N)r   apitools.base.pyr    googlecloudsdk.command_lib.redisr   r   	Exceptionr   r   r   r(   r0   r6   r:   r>   rB   rF   rJ   rO   rV   r[   re   rh   rn   rq   r	   r   r   <module>ru      s}    7 & 9 1$I $/E /		
0
'r   