ó
    €Ïö  ã                   ó¶   • S r SSKJr  SSKJr   " S S\R
                  5      r " S S\R
                  5      r " S S	\R
                  5      rS
 r	S r
S rS rg)zAUtility for Memorystore Redis clusters Cross Cluster Replication.é    )Úutil)Ú
exceptionsc                   ó   • \ rS rSrSrSrg)ÚDetachNotSupportedExceptioné   z+Exception for when detach is not supported.© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú9lib/googlecloudsdk/command_lib/redis/clusters_ccr_util.pyr   r      s   † Ü3r   r   c                   ó   • \ rS rSrSrSrg)ÚSwitchoverNotSupportedExceptioné   z/Exception for when switchover is not supported.r   Nr	   r   r   r   r   r      s   † Ü7r   r   c                   ó   • \ rS rSrSrSrg)Ú&DetachSecondariesNotSupportedExceptioné   z7Exception for when detach-secondaries is not supported.r   Nr	   r   r   r   r   r      s   † Ü?r   r   c                 óª   • [         R                  " U 5      n[         R                  " U 5      nUR                  R	                  UR                  US95      $ )N)Úname)r   ÚGetClientForResourceÚGetMessagesForResourceÚprojects_locations_clustersÚGetÚ(RedisProjectsLocationsClustersGetRequest)Úcluster_refÚcluster_nameÚclientÚmessagess       r   Ú_GetClusterr#   !   sL   € Ü×$Ò$ [Ó1€&Ü×(Ò(¨Ó5€(Ø	×	+Ñ	+×	/Ñ	/Ø×7Ñ7¸\Ð7ÐJó
ð r   c                 óô  • A[        XR                  5      n[        R                  " U 5      nUR                  b8  UR                  R
                  UR                  R                  R                  :w  a$  [        SR                  UR                  5      5      eUR                  UR                  R                  R                  S9/nUR                  R                  R                   HG  nUR                  UR                  :w  d  M  UR!                  UR                  UR                  S95        MI     UR                  UR                  R                  R"                  US9nSUl        UR'                  US9Ul        U$ )z8Hook to trigger the switchover to the secondary cluster.zTCluster {} is not a secondary cluster. Please run switchover on a secondary cluster.)Úcluster)ÚclusterRoleÚsecondaryClustersÚ cross_cluster_replication_config©ÚcrossClusterReplicationConfig)r#   r   r   r   r*   r&   ÚCrossClusterReplicationConfigÚClusterRoleValueValuesEnumÚ	SECONDARYr   ÚformatÚRemoteClusterÚprimaryClusterr%   Ú
membershipr'   ÚappendÚPRIMARYÚ
updateMaskÚCluster)r   ÚargsÚpatch_requestr%   r"   Únew_secondary_clustersÚcurr_sec_clusterÚnew_ccr_configs           r   Ú
Switchoverr;   )   sg  € à
Ü˜×%7Ñ%7Ó8€'Ü×(Ò(¨Ó5€(à×+Ñ+Ñ3Ø	×	.Ñ	.×	:Ñ	:à
×
0Ñ
0×
KÑ
K×
UÑ
Uó
ô
 *ð	ß$™f W§\¡\Ó2óð ð ×ÑØ×7Ñ7×FÑF×NÑNð ð ðÐð ×,Ñ,×7Ñ7×IÔIð ð ×Ñ 7§<¡<Õ/Ø×#Ñ#Ø
×
 Ñ
 Ð)9×)AÑ)AÐ
 Ð
Böñ Jð ×9Ñ9Ø×8Ñ8×SÑS×[Ñ[Ø.ð :ð €.ð
 @€-ÔØ"×*Ñ*Ø$2ð +ð €-Ôð 
Ðr   c                 óÀ  • A[        XR                  5      n[        R                  " U 5      nUR                  b8  UR                  R
                  UR                  R                  R                  :w  a$  [        SR                  UR                  5      5      eUR                  UR                  R                  R                  S9nSUl        UR                  US9Ul        U$ )z>Hook to detach the secondary cluster from the primary cluster.zPCluster {} is not a secondary cluster. Please run detach on a secondary cluster.)r&   r(   r)   )r#   r   r   r   r*   r&   r+   r,   r-   r   r.   ÚNONEr4   r5   r%   )r   r6   r7   r%   r"   r:   s         r   ÚDetachr>   V   sÖ   € à
Ü˜×%7Ñ%7Ó8€'Ü×(Ò(¨Ó5€(à×+Ñ+Ñ3Ø	×	.Ñ	.×	:Ñ	:à
×
0Ñ
0×
KÑ
K×
UÑ
Uó
ô
 &ð	ß$™f W§\¡\Ó2óð ð
 ×9Ñ9Ø×8Ñ8×SÑS×XÑXð :ð €.ð @€-ÔØ"×*Ñ*Ø$2ð +ð €-Ôð 
Ðr   c                 óÐ  • [        XR                  5      n[        R                  " U 5      nUR                  b8  UR                  R
                  UR                  R                  R                  :w  a$  [        SR                  UR                  5      5      eUR                  R                  n/ nU H0  nUR                  UR                  ;  d  M  UR                  U5        M2     UR                  5       nU(       d&  UR                  R                  R                  Ul        O+UR                  R                  R                  Ul        Xhl        SUl        UR#                  US9Ul        U$ )zEHook to detach the given secondary clusters from the primary cluster.zXCluster {} is not a primary cluster. Please run detach-secondaries on a primary cluster.r(   r)   )r#   r   r   r   r*   r&   r+   r,   r3   r   r.   r'   r%   Úclusters_to_detachr2   r=   r4   r5   )	r   r6   r7   r%   r"   Úcurrent_secondary_clustersr8   Úsecondary_clusterr:   s	            r   ÚDetachSecondariesrC   r   sG  € ä˜×%7Ñ%7Ó8€'Ü×(Ò(¨Ó5€(à×+Ñ+Ñ3Ø	×	.Ñ	.×	:Ñ	:à
×
0Ñ
0×
KÑ
K×
SÑ
Só
ô
 1ð	ß$™f W§\¡\Ó2óð ð ×+Ñ+×=Ñ=ð ð ÐÛ5ÐØ× Ñ ¨×(?Ñ(?Õ?Ø×#Ñ#Ð$5Ö6ñ 6ð ×9Ñ9Ó;€.Þ	à×.Ñ.×IÑI×NÑNð Õð
 	×.Ñ.×IÑI×QÑQð Ôð (>Ô$à?€-ÔØ"×*Ñ*Ø$2ð +ð €-Ôð 
Ðr   N)r   Ú googlecloudsdk.command_lib.redisr   Úgooglecloudsdk.corer   ÚErrorr   r   r   r#   r;   r>   rC   r   r   r   Ú<module>rG      s^   ðñ Hå 1Ý *ô4 *×"2Ñ"2ô 4ô8 j×&6Ñ&6ô 8ô@¨Z×-=Ñ-=ô @òò*òZó8'r   