
    #                         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 " S S\5      rg)zRCommands for interacting with the Cloud NetApp Files Volume Snapshot 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S jrS rSrg)SnapshotsClient   zHWrapper for working with Snapshots in the Cloud NetApp Files API Client.c                 l   U[         R                  R                  :X  a  [        5       U l        g 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ALPHAAlphaSnapshotsAdapter_adapterBETABetaSnapshotsAdapterGASnapshotsAdapter
ValueErrorformatnetapp_api_utilVERSION_MAP)selfrelease_tracks     =lib/googlecloudsdk/api_lib/netapp/volumes/snapshots/client.py__init__SnapshotsClient.__init__!   s    ))///+-dm	$++00	0*,dm	$++..	.&(dm9@@

%
%m
46 7 7    c                 .    U R                   R                  $ N)r   clientr   s    r   r%   SnapshotsClient.client,   s    ==r"   c                 .    U R                   R                  $ r$   )r   messagesr&   s    r   r)   SnapshotsClient.messages0   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.

Raises:
  waiter.OperationError: if the operation contains an error.

Returns:
  the 'response' field of the Operation.
zWaiting for [{0}] to finish)r	   WaitForCloudOperationPollerNoResourcesr%   projects_locations_operationsr   Name)r   operation_refs     r   WaitForOperation SnapshotsClient.WaitForOperation4   sL     >>..KK55	
 	%,,]-?-?-AB r"   c                 <   U R                   R                  X!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 Volume Snapshot.)parent
snapshotIdsnapshot
collection)r)   4NetappProjectsLocationsVolumesSnapshotsCreateRequestr/   r%   $projects_locations_volumes_snapshotsCreater   REGISTRYParseRelativeNamenamer   OPERATIONS_COLLECTIONr1   )r   snapshot_ref
volume_refasync_configrequest	create_opr0   s           r   CreateSnapshotSnapshotsClient.CreateSnapshotH   s     	JJ*;*;*= 	K 	
 
 @@GGPI&&889#B#B 9 M   //r"   Nc                 ^    U R                   R                  5       nXl        X$l        X4l        U$ )a3  Parses the command line arguments for Create Snapshot into a config.

Args:
  name: the name of the Snapshot.
  description: the description of the Snapshot.
  labels: the parsed labels value.

Returns:
  the configuration that will be used as the request body for creating a
  Cloud NetApp Files Snapshot.
)r)   Snapshotr>   descriptionlabels)r   r>   rJ   rK   r6   s        r   ParseSnapshotConfig#SnapshotsClient.ParseSnapshotConfigW   s+     }}%%'HM&OOr"   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$ )aa  Make API calls to List active Cloud NetApp Volume Snapshots.

Args:
  volume_ref: The parent Volume to list NetApp Volume Snapshots.
  limit: The number of Cloud NetApp Volume Snapshots 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 Volume Snapshots.
)r4   zLocation {} may be unreachable.pageSize)fieldlimitbatch_size_attribute)r)   2NetappProjectsLocationsVolumesSnapshotsListRequestr%   r:   Listunreachabler   warningr   r   YieldFromListr   SNAPSHOT_RESOURCE)r   rA   rQ   rD   responselocations         r   ListSnapshotsSnapshotsClient.ListSnapshotsi   s     mmNN O G {{??DDWMH((	kk3::8DE )##88))' r"   c                 r    U R                   R                  UR                  5       S9nU R                  X#5      $ )z1Deletes an existing Cloud NetApp Volume Snapshot.r>   )r)   4NetappProjectsLocationsVolumesSnapshotsDeleteRequestRelativeName_DeleteSnapshot)r   r@   rB   rD   s       r   DeleteSnapshotSnapshotsClient.DeleteSnapshot   s@     	JJ**, 	K 	
 
 00r"   c                     U R                   R                  R                  U5      nU(       a  U$ [        R                  R                  UR                  [        R                  S9nU R                  U5      $ )Nr7   )
r%   r:   Deleter   r<   r=   r>   r   r?   r1   )r   rB   rD   	delete_opr0   s        r   ra   SnapshotsClient._DeleteSnapshot   sa    @@GGPI&&889#B#B 9 DM  //r"   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )z&Get Cloud NetApp Snapshot information.r^   )r)   1NetappProjectsLocationsVolumesSnapshotsGetRequestr`   r%   r:   Get)r   r@   rD   s      r   GetSnapshotSnapshotsClient.GetSnapshot   sC    mmMM&&( N *G;;;;??HHr"   c                 8    U R                   R                  UUUS9$ )zParses updates into a snapshot config.

Args:
  snapshot_config: The snapshot config to update.
  description: str, a new description, if any.
  labels: LabelsValue message, the new labels value, if any.

Returns:
  The snapshot message.
rJ   rK   )r   ParseUpdatedSnapshotConfigr   snapshot_configrJ   rK   s       r   ro   *SnapshotsClient.ParseUpdatedSnapshotConfig   s)     ==33 4  r"   c                     U R                   R                  XU5      nU(       a  U$ [        R                  R	                  UR
                  [        R                  S9nU R                  U5      $ )a9  Updates a Cloud NetApp Snapshot.

Args:
  snapshot_ref: the reference to the Snapshot.
  snapshot_config: Snapshot config, the updated snapshot.
  update_mask: str, a comma-separated list of updated fields.
  async_: bool, if False, wait for the operation to complete.

Returns:
  an Operation or Volume message.
r7   )	r   UpdateSnapshotr   r<   r=   r>   r   r?   r1   )r   r@   rq   update_maskrB   	update_opr0   s          r   rt   SnapshotsClient.UpdateSnapshot   sb     ,,\-8:I&&889#B#B 9 DM  //r"   )r   )NNNr$   NN)__name__
__module____qualname____firstlineno____doc__r
   r   r   r    propertyr%   r)   r1   rF   rL   r[   rb   ra   rk   ro   rt   __static_attributes__ r"   r   r   r      sw    P#'#4#4#:#: 	7     " "(0$210I .2(,&0r"   r   c                   2    \ rS rSrSrS rS r  SS jrSrg)	r      z9Adapter for the Cloud NetApp Files API Snapshot resource.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    SnapshotsAdapter.__init__   sN    **--D!33((DK $55((DMr"   c                     U R                   R                  UUR                  5       US9nU R                  R                  R                  U5      nU$ )z3Send a Patch request for the Cloud NetApp Snapshot.)r6   r>   
updateMask)r)   3NetappProjectsLocationsVolumesSnapshotsPatchRequestr`   r%   r:   Patch)r   r@   rq   ru   update_requestrv   s         r   rt   SnapshotsAdapter.UpdateSnapshot   sX     	II$**," 	J 	$ 
 @@FFIr"   Nc                 *    Ub  X!l         Ub  X1l        U$ )z:Parse update information into an updated Snapshot message.rn   rp   s       r   ro   +SnapshotsAdapter.ParseUpdatedSnapshotConfig   s"    
 $/!%r"   r%   r)   r   rx   )	ry   rz   r{   r|   r}   r    rt   ro   r   r   r"   r   r   r      s    A	 .2(,	r"   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r      z>Adapter for the Beta Cloud NetApp Files API Snapshot resource.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    BetaSnapshotsAdapter.__init__   s]    	
.0**//D!33((DK $55((DMr"   r   ry   rz   r{   r|   r}   r    r   __classcell__r   s   @r   r   r      s    F r"   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )r      z?Adapter for the Alpha Cloud NetApp Files API Snapshot resource.c                    > [         [        U ]  5         [        R                  R
                  U l        [        R                  " U R                  S9U l	        [        R                  " U R                  S9U l        g r   )r   r   r    r
   r   r   r   r   r   r%   r   r)   r   s    r   r    AlphaSnapshotsAdapter.__init__   s]    	
/1**00D!33((DK $55((DMr"   r   r   r   s   @r   r   r      s    G 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"   r   <module>r      s_    Y &  ' ' 3 A . ( # )`0f `0F v  F+ 0 r"   