
                             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
\R                  5      rg)z)Command for setting a backup target pool.    )absolute_import)division)unicode_literals)base_classes)base)
exceptions)flagsc                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)	SetBackup   a  Set a backup pool for a target pool.

*{command}* is used to set a backup target pool for a primary
target pool, which defines the fallback behavior of the primary
pool. If the ratio of the healthy instances in the primary pool
is at or below the specified ``--failover-ratio value'', then traffic
arriving at the load-balanced IP address will be directed to the
backup pool.

## EXAMPLES
To cause `TARGET-POOL` (in region `us-central1`) to fail over
to `BACKUP-POOL` when more than half of the `TARGET-POOL`
instances are unhealthy, run:

  $ {command} TARGET-POOL --backup-pool=BACKUP-POOL --failover-ratio=0.5 --region=us-central1

To remove `BACKUP-POOL` as a backup to `TARGET-POOL`, run:

  $ {command} TARGET-POOL --backup-pool='' --region=us-central1
Nc                 F   [         R                  " 5       U l        [         R                  " SS9U l        U R                  R                  USS9  UR                  SS9nUR                  SSS	S
9  UR                  S[         R                  SS9  UR                  S[        SS9  g )Nz" for which to set the backup pool.)help_suffixzset a backup pool for)operation_typeT)requiredz--no-backup-pool
store_truez/Unsets the backup pool. This disables failover.)actionhelpz--backup-poolz2Name of the target pool that will serve as backup.)	completerr   z--failover-ratioz^The new failover ratio value for the target pool. This must be a float in the range of [0, 1].)typer   )
r	   BackupPoolArgumentBACKUP_POOL_ARGTargetPoolArgumentTARGET_POOL_ARGAddArgumentadd_mutually_exclusive_groupadd_argumentTargetPoolsCompleterfloat)clsparserbackup_pool_groups      .lib/surface/compute/target_pools/set_backup.pyArgsSetBackup.Args7   s    224C228:C##6 $ 8 ;;T;J""<> # @ "",,A # C
 =  ?    c                    [         R                  " U R                  5       5      nUR                  nU R                  R                  UUR                  [        R                  " U5      S9nUR                  (       a_  UR                  Ul        U R                  R                  UUR                  5      nUR                  R                  UR                  5       S9nOUR                  R                  5       nUR                  (       a#  UR                   c  ["        R$                  " S5      eUR                   b6  UR                   S:  d  UR                   S:  a  ["        R$                  " S5      eUR                  R'                  UR)                  5       UUR                   UR                  UR*                  S9nUR-                  UR.                  R0                  SU4/5      $ )	z<Issues a request necessary for setting a backup target pool.)scope_lister)targetz?[--failover-ratio] must be provided when setting a backup pool.r      z?[--failover-ratio] must be a number between 0 and 1, inclusive.)
targetPooltargetReferencefailoverRatioregionprojectr   )r   ComputeApiHolderReleaseTrackclientr   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerbackup_poolr-   backup_pool_regionr   messagesTargetReferenceSelfLinkfailover_ratiocompute_exceptionsArgumentError"ComputeTargetPoolsSetBackupRequestNamer.   MakeRequestsapitools_clienttargetPools)selfargsholderr1   target_pool_refbackup_pool_reftarget_referencerequests           r"   RunSetBackup.RunN   s   **4+<+<+>?F]]F**<<"88@ = BO
  / 6 6d,,>>t?E?O?OQo88 ))+ 9 -  88:D//7,,
KM M &a4#6#6#:,,
KM M oo@@"'')())%%'' A )G !7!7!C!C!,g!7  8 9 9r%    )__name__
__module____qualname____firstlineno____doc__r   r   classmethodr#   rJ   __static_attributes__rL   r%   r"   r   r      s*    , //? ?,$9r%   r   N)rQ   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   r<   r	   r4   /googlecloudsdk.command_lib.compute.target_poolsSilentCommandr   rL   r%   r"   <module>rZ      s6    0 &  ' 7 ( O E AV9"" V9r%   