
    D                          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Jr   " S S\5      r " S S\5      r " S S\5      rg)zJCommands for interacting with the Cloud NetApp Files Backups API resource.    )absolute_import)division)unicode_literals)
list_pager)	constants)util)waiter)base)log)	resourcesc                       \ rS rSrSr\R                  R                  4S jr\	S 5       r
\	S 5       rS rS r     SS	 jrSS
 jrS rS rS rS r  SS jrSrg)BackupsClient   zFWrapper for working with Backups in the Cloud NetApp Files API Client.c                    U[         R                  R                  :X  a  [        5       U l        g U[         R                  R
                  :X  a  [        5       U l        g [        SR                  [        R                  U   5      5      e)Nz [{}] is not a valid API version.)r
   ReleaseTrackBETABetaBackupsAdapter_adapterGABackupsAdapter
ValueErrorformatnetapp_utilVERSION_MAP)selfrelease_tracks     Alib/googlecloudsdk/api_lib/netapp/backup_vaults/backups/client.py__init__BackupsClient.__init__!   sg    ))...(*dm	$++..	.$&dm9@@

!
!-
02 3 3    c                 .    U R                   R                  $ N)r   clientr   s    r   r#   BackupsClient.client*   s    ==r    c                 .    U R                   R                  $ r"   )r   messagesr$   s    r   r'   BackupsClient.messages.   s    ==!!!r    c                     [         R                  " [         R                  " U R                  R                  5      USR                  UR                  5       5      5      $ )zWaits on the long-running operation until the done field is True.

Args:
  operation_ref: The operation reference.

Returns:
  The 'response' field of the Operation.

Raises:
  waiter.OperationError: If the operation contains an error.
zWaiting for [{0}] to finish)r	   WaitForCloudOperationPollerNoResourcesr#   projects_locations_operationsr   Name)r   operation_refs     r   WaitForOperationBackupsClient.WaitForOperation2   sL     >>..KK55	
 	%,,]-?-?-AB r    c                 v   U R                   R                  UR                  5       R                  5       UR	                  5       US9nU R
                  R                  R                  U5      nU(       a  U$ [        R                  R                  UR                  [        R                  S9nU R                  U5      $ )zCreate a Cloud NetApp Backup.)parentbackupIdbackup
collection)r'   7NetappProjectsLocationsBackupVaultsBackupsCreateRequestParentRelativeNamer-   r#   'projects_locations_backupVaults_backupsCreater   REGISTRYParseRelativeNamenamer   OPERATIONS_COLLECTIONr/   )r   
backup_refasync_r4   request	create_opr.   s          r   CreateBackupBackupsClient.CreateBackupF   s     	MM$$&335__& 	N 	
  CCJJI &&889#B#B 9 M   //r    Nc                 v    U R                   R                  5       nXl        X&l        X6l        XFl        XVl        U$ )a  Parses the command line arguments for Create Backup into a message.

Args:
  name: The name of the Backup.
  source_snapshot: The Source Snapshot of the Backup.
  source_volume: The Source Volume of the Backup.
  description: The description of the Backup.
  labels: The parsed labels value.

Returns:
  The configuration that will be used ass the request body for creating a
  Cloud NetApp Backup.
)r'   Backupr>   sourceSnapshotsourceVolumedescriptionlabels)r   r>   source_snapshotsource_volumerJ   rK   r4   s          r   ParseBackupBackupsClient.ParseBackupY   s7    * ]]!!#FK+'$MMr    c                 b   U R                   R                  US9nU R                  R                  R	                  U5      nUR
                   H(  n[        R                  " SR                  U5      5        M*     [        R                  " U R                  R                  U[        R                  USS9$ )aG  Make API calls to List Cloud NetApp Backups.

Args:
  backupvault_ref: The parsed Backup Vault of the listed NetApp Backups.
  limit: The number of Cloud NetApp Backups to limit the results to.
    This limit is passed to the server and the server does the limiting.

Returns:
  Generator that yields the Cloud NetApp Backups.
)r2   zLocation {} may be unreachable.pageSize)fieldlimitbatch_size_attribute)r'   5NetappProjectsLocationsBackupVaultsBackupsListRequestr#   r:   Listunreachabler   warningr   r   YieldFromListr   BACKUP_RESOURCE)r   backupvault_refrS   rB   responselocations         r   ListBackupsBackupsClient.ListBackupsv   s     	KK" 	L 	
  {{BBGGPH((	kk3::8DE )##;;''' r    c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )z$Get Cloud NetApp Backup information.r>   )r'   4NetappProjectsLocationsBackupVaultsBackupsGetRequestr9   r#   r:   Get)r   r@   rB   s      r   	GetBackupBackupsClient.GetBackup   sJ     	JJ((* 	K 	
 
 ;;>>BB7KKr    c                 r    U R                   R                  UR                  5       S9nU R                  X#5      $ )z(Deletes an existing Cloud NetApp Backup.ra   )r'   7NetappProjectsLocationsBackupVaultsBackupsDeleteRequestr9   _DeleteBackup)r   r@   rA   rB   s       r   DeleteBackupBackupsClient.DeleteBackup   s@     	MM((* 	N 	
 
 f..r    c                     U R                   R                  R                  U5      nU(       a  U$ [        R                  R                  UR                  [        R                  S9nU R                  U5      $ )Nr5   )
r#   r:   Deleter   r<   r=   r>   r   r?   r/   )r   rA   rB   	delete_opr.   s        r   rh   BackupsClient._DeleteBackup   sg    CCJJI &&889#B#B 9 M   //r    c                     U R                   R                  XU5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )a   Updates a Backup.

Args:
  backup_ref: The reference to the Backup.
  backup: Backup message, the updated Backup.
  update_mask: str, a comma-separated list of updated fields.
  async_: bool, if False, wait for the operation to complete.

Returns:
  an Operation or Backup Vault message.
r5   )	r   UpdateBackupr   r<   r=   r>   r   r?   r/   )r   r@   r4   update_maskrA   	update_opr.   s          r   rp   BackupsClient.UpdateBackup   se     **KI &&889#B#B 9 M   //r    c                 8    U R                   R                  UUUS9$ )zParses updates into a Backup.rJ   rK   )r   ParseUpdatedBackupr   r4   rJ   rK   s       r   rv    BackupsClient.ParseUpdatedBackup   s)     ==++ ,  r    )r   )NNNNNr"   NN)__name__
__module____qualname____firstlineno____doc__r
   r   r   r   propertyr#   r'   r/   rD   rN   r^   rd   ri   rh   rp   rv   __static_attributes__ r    r   r   r      s    N#'#4#4#9#9 3     " "(0* :8L/	006 	r    r   c                   2    \ rS rSrSrS r  SS jrS rSrg)	r      z6Adapter for the GA Cloud NetApp Files API for Backups.c                     [         R                  R                  U l        [        R
                  " U R                  S9U l        [        R                  " U R                  S9U l        g N)r   )	r
   r   r   r   r   GetClientInstancer#   GetMessagesModuler'   r$   s    r   r   BackupsAdapter.__init__   sN    **--D//((DK  11((DMr    Nc                 *    Ub  X!l         Ub  X1l        U$ )z!Parses updates into a new Backup.ru   rw   s       r   rv   !BackupsAdapter.ParseUpdatedBackup   s      &mMr    c                     U R                   R                  UUR                  5       US9nU R                  R                  R                  U5      nU$ )z1Send a Patch request for the Cloud NetApp Backup.)r4   r>   
updateMask)r'   6NetappProjectsLocationsBackupVaultsBackupsPatchRequestr9   r#   r:   Patch)r   r@   r4   rq   update_requestrr   s         r   rp   BackupsAdapter.UpdateBackup   sX     	LL((*" 	M 	$ 
 CCIIIr    r#   r'   r   ry   )	rz   r{   r|   r}   r~   r   rv   rp   r   r   r    r   r   r      s    > 		r    r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r      z8Adapter for the Beta Cloud NetApp Files API for Backups.c                    > [         [        U ]  5         [        R                  R
                  U l        [        R                  " U R                  S9U l	        [        R                  " U R                  S9U l        g r   )superr   r   r
   r   r   r   r   r   r#   r   r'   )r   	__class__s    r   r   BetaBackupsAdapter.__init__   s]    	
d,.**//D//((DK  11((DMr    r   )rz   r{   r|   r}   r~   r   r   __classcell__)r   s   @r   r   r      s    @ r    r   N)r~   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.netappr   r   r   googlecloudsdk.api_lib.utilr	   googlecloudsdk.callioper
   googlecloudsdk.corer   r   objectr   r   r   r   r    r   <module>r      sQ    Q &  ' ' 3 = . ( # )tF tn"V "J r    