
                         p    S r SSKrSSKJr  SSKJr  SSKJr  SrSrSr	S	r
 " S
 S\5      r " S S\5      rg)z"Cloud Backup and DR API utilities.    N)apis)waiter)	resourcesbackupdrv1z;ResponseError: code={status_code}, message={status_message}zMRun [backup-dr operations describe {}] to check the status of this operation.c                   t    \ rS rSrSr\4S jr\S 5       r\S 5       r	S r
S\R                  " SS	94S
 jrSrg)BackupDrClientBase%   z1Base class for Backup and DR API client wrappers.c                     [         R                  " SU5      U l        [         R                  " SU5      U l        S U l        U R                  R                  U l        g )Nr   )	r   GetClientInstance_clientGetMessagesModule	_messagesserviceclientprojects_locations_operationsoperations_service)selfapi_versions     +lib/googlecloudsdk/api_lib/backupdr/util.py__init__BackupDrClientBase.__init__(   sC    ))*kBDL++JDDNDL"kkGGD    c                     U R                   $ N)r   r   s    r   r   BackupDrClientBase.client.   s    <<r   c                     U R                   $ r   )r   r   s    r   messagesBackupDrClientBase.messages2   s    >>r   c                 n    UR                   c  g[        R                  R                  UR                   SS9$ )zKConverts an Operation to a Resource that can be used with `waiter.WaitFor`.Nonez&backupdr.projects.locations.operations)
collection)namer   REGISTRYParseRelativeName)r   	operations     r   GetOperationRef"BackupDrClientBase.GetOperationRef6   s7    ~~//#K 0  r   Ti  )secondsc                     U(       a,  [         R                  " U R                  U R                  5      nO [         R                  " U R                  5      n[         R
                  " XQX$R                  S-  S9$ )ao  Waits for an operation to complete.

Polls the Backup and DR Operation service until the operation completes,
fails, or
max_wait_seconds elapses.

Args:
  operation_ref: a Resource created by GetOperationRef describing the
    operation.
  message: the message to display to the user while they wait.
  has_result: if True, the function will return the target of the operation
    when it completes. If False, nothing will be returned (useful for Delete
    operations)
  max_wait: The time to wait for the operation to succeed before returning.

Returns:
  if has_result = True, a Backup and DR entity.
  Otherwise, None.
i  )max_wait_ms)r   CloudOperationPollerr   r   CloudOperationPollerNoResourcesWaitForr*   )r   operation_refmessage
has_resultmax_waitpollers         r   WaitForOperation#BackupDrClientBase.WaitForOperation>   s_    4 **
,,//f 55d6M6MNf>>w4D4Dt4K r   )r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__DEFAULT_API_VERSIONr   propertyr   r   r(   datetime	timedeltar5   __static_attributes__ r   r   r	   r	   %   sS    9!4 H     !!$/#r   r	   c                   H   ^  \ rS rSrSrU 4S jrU 4S jrSU 4S jjrSrU =r	$ )RestrictedDictd   zNRestricted dict only allows specific keys, useful in creating a config object.c                 2   > [         TU ]  " U0 UD6  Xl        g r   )superr   allowed_keys)r   rG   argskwargs	__class__s       r   r   RestrictedDict.__init__g   s    	Gd%f%$r   c                    > XR                   ;  a+  [        SU SSR                  U R                   5       S35      e[        TU ]  X5        g )Nz	The Key 'z' is not one of  [z, ])rG   KeyErrorjoinrF   __setitem__)r   keyvaluerJ   s      r   rP   RestrictedDict.__setitem__k   sN    
###cU,TYYt7H7H-I,J!
L  
G#r   c                 *  > U(       az  [        U[        5      (       a  UR                  5       OUn[        U5      [        U R                  5      -
  nU(       a+  [        SU SSR                  U R                  5       S35      e[        TU ]   " U40 UD6  g )Nz	The Keys z are not part of  [,rM   )	
isinstancedictkeyssetrG   rN   rO   rF   update)r   otherrI   
other_keysinvalid_keysrJ   s        r   rZ   RestrictedDict.updater   s    #-eT#:#:5::<j_s4+<+<'==l	~ &$++,-Q0
 	
 
GN5#F#r   )rG   r   )
r7   r8   r9   r:   r;   r   rP   rZ   r@   __classcell__)rJ   s   @r   rC   rC   d   s    V%$$ $r   rC   )r;   r>   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.corer   DEFAULT_API_NAMEr<   HTTP_ERROR_FORMATASYNC_OPERATION_MESSAGEobjectr	   rW   rC   rA   r   r   <module>rf      sR    )  , . )   B 
. < <~$T $r   