
                             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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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)z"Flag utilities for `gcloud redis`.    )absolute_import)division)unicode_literals)encoding)redis)arg_parsers)base)labels_util)
console_ioN)zmaxmemory-policyznotify-keyspace-eventstimeout)activedefragzlfu-decay-timezlfu-log-factorzmaxmemory-gb)zstream-node-max-byteszstream-node-max-entries)zmaxmemory-clientszlazyfree-lazy-evictionzlazyfree-lazy-expirezlazyfree-lazy-user-delzlazyfree-lazy-user-flushc                 f    U R                  5       R                  n[        R                  " U5      nU$ N)GetCollectionInfoapi_versionr   Client)resource_refr   clients      ,lib/googlecloudsdk/command_lib/redis/util.pyGetClientForResourcer   .   s)    ..0<<+<<$&	-    c                 f    U R                  5       R                  n[        R                  " U5      nU$ r   )r   r   r   Messages)r   r   messagess      r   GetMessagesForResourcer   4   s)    ..0<<+^^K((	/r   c                      [         [        -   [        -   [        -   n U  Vs0 s H  o[        R
                  _M     sn$ s  snf r   )VALID_REDIS_3_2_CONFIG_KEYSVALID_REDIS_4_0_CONFIG_KEYSVALID_REDIS_5_0_CONFIG_KEYSVALID_REDIS_7_0_CONFIG_KEYSsix	text_type)valid_redis_config_keysks     r   InstanceRedisConfigArgDictSpecr%   :   sD    !$??!"$?@  %<	<$;qS]]
$;	<<	<s   =c                 F    [         R                  " [        5       S9" U 5      $ )N)spec)r   ArgDictr%   values    r   InstanceRedisConfigArgTyper+   A   s    			"@"B	CE	JJr   c                 p    [         R                  " [        R                  [        R                  S9" U 5      $ )N)key_type
value_type)r   r(   r
   KEY_FORMAT_VALIDATORVALUE_FORMAT_VALIDATORr)   s    r   InstanceLabelsArgTyper1   E   s1    			//33
5 
 r   c                  *    [        5       [        5       /$ r   )InstanceUpdateRedisConfigFlagInstanceRemoveRedisConfigFlag r   r   !AdditionalInstanceUpdateArgumentsr6   L   s    #%#%
 r   c                      [         R                  " SS9n U R                  [        R                  " 5       5        U R                  [        R
                  " S5      5        [        R                  " S5      U /$ )NT)mutex )r	   ArgumentGroupAddArgumentr
   GetClearLabelsFlagGetRemoveLabelsFlagGetUpdateLabelsFlag)remove_groups    r   InstanceUpdateLabelsFlagsr@   S   sX    ##$/,;99;<;::2>?

)
)"
-|	<<r   c                     [         R                  " SS[        [        R                  SR                  SR                  [        5      SR                  [        5      SR                  [        5      SR                  [        5      5      S9$ )Nz--update-redis-configz	KEY=VALUEa        A list of Redis config KEY=VALUE pairs to update according to
      http://cloud.google.com/memorystore/docs/reference/redis-configs. If a config parameter is already set,
      its value is modified; otherwise a new Redis config parameter is added.
      Currently, the only supported parameters are:

      Redis version 3.2 and newer: {}.

      Redis version 4.0 and newer: {}.

      Redis version 5.0 and newer: {}.

      Redis version 7.0 and newer: {}.
      z, metavartypeactionhelp)r	   Argumentr+   r   UpdateActionformatjoinr   r   r   r    r5   r   r   r3   r3   Z   sj    	%%%	
 &
))/
0
))/
0
))/
0
))/
0	
 r   c                  t    [         R                  " SS[        R                  " 5       [        R                  SS9$ )Nz--remove-redis-configKEYzv      A list of Redis config parameters to remove. Removing a non-existent
      config parameter is silently ignored.rB   )r	   rG   r   ArgListrH   r5   r   r   r4   r4   s   s3    	 %%/
0 0r   c                 T    [         R                  " XR                  R                  SS9$ )NT)
sort_items)r   DictToAdditionalPropertyMessageInstanceRedisConfigsValue)configr   s     r   PackageInstanceRedisConfigrT   ~   s(    		1	111d
D Dr   c                 @    U (       a  [         R                  " SSSS9  U $ )zEAdds prompt that describes lack of security provided by AUTH feature.zAUTH prevents accidental access to the instance by requiring an AUTH string (automatically generated for you). AUTH credentials are not confidential when transmitted or intended to protect against malicious actors.zDo you want to proceed?T)messageprompt_stringcancel_on_no)r   PromptContinue)auth_enableds    r   WarnOnAuthEnabledr[      s(    
 0 
r   c                 .    UR                   S-   Ul         U$ )Nz/certificateAuthority)name)
unused_refunused_argsreqs      r   (UpdateGetCertificateAuthorityRequestPathra      s    XX//#(	*r   )!__doc__
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_libr   googlecloudsdk.callioper   r	   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.core.consoler   r!   r   r   r   r    r   r   r%   r+   r1   r6   r@   r3   r4   rT   r[   ra   r5   r   r   <module>ri      s    ) &  ' % ( / ( < 2 
* A :  =K=20D
"r   