
    m                         S r SSKJr  SSKJr  SSKJr  SS jrSS jr " S S	\R                  5      r
 " S
 S\5      r " S S\5      rg)z*Utilities for Cloud Pub/Sub Snapshots API.    )
list_pager)apis)
exceptionsc                 .    [         R                  " SSU S9$ )Npubsubv1no_http)r   GetClientInstancer	   s    .lib/googlecloudsdk/api_lib/pubsub/snapshots.pyr   r      s    			$	@@    Nc                 @    U =(       d
    [        5       n U R                  $ N)r   MESSAGES_MODULE)clients    r   GetMessagesModuler      s    (&(&			r   c                       \ rS rSrSrSrg)NoFieldsSpecifiedError"   z:Error when no fields were specified for a Patch operation. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r   "   s    Br   r   c                       \ rS rSrSrS rSrg)_SnapshotUpdateSetting&   z-Data container class for updating a snapshot.c                     Xl         X l        g r   
field_namevalue)selfr"   r#   s      r   __init___SnapshotUpdateSetting.__init__)   s     OJr   r!   N)r   r   r   r   r   r%   r   r   r   r   r   r   &   s
    5r   r   c                   L    \ rS rSrSrSS jrSS jrS rS rSS jr	SS	 jr
S
rg)SnapshotsClient.   z6Client for snapshots service in the Cloud Pub/Sub API.Nc                     U=(       d
    [        5       U l        U=(       d    [        U5      U l        U R                  R                  U l        g r   )r   r   r   messagesprojects_snapshots_service)r$   r   r+   s      r   r%   SnapshotsClient.__init__1   s5    /-/DK9 1& 9DMKK22DMr   c                     U R                   R                  U R                   R                  UR                  5       UUS9UR                  5       S9nU R                  R                  U5      $ )zCreates a Snapshot.)subscriptionlabelstags)createSnapshotRequestname)r+   $PubsubProjectsSnapshotsCreateRequestCreateSnapshotRequestRelativeNamer-   Create)r$   snapshot_refsubscription_refr1   r2   
create_reqs         r   r8   SnapshotsClient.Create6   sk    CC"mmAA)668 B  &&( D *J ==
++r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zGets a Snapshot.

Args:
  snapshot_ref (Resource): Resource reference to the Snapshot to get.
Returns:
  Snapshot: The snapshot.
snapshot)r+   !PubsubProjectsSnapshotsGetRequestr7   r-   Get)r$   r9   get_reqs      r   rA   SnapshotsClient.Get@   s>     mm==**, > .G==W%%r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zDeletes a Snapshot.r>   )r+   $PubsubProjectsSnapshotsDeleteRequestr7   r-   Delete)r$   r9   
delete_reqs      r   rF   SnapshotsClient.DeleteL   s=    CC**, D .J==
++r   c                     U R                   R                  UR                  5       US9n[        R                  " U R
                  X2SSS9$ )a%  Lists Snapshots for a given project.

Args:
  project_ref (Resource): Resource reference to Project to list
    Snapshots from.
  page_size (int): the number of entries in each batch (affects requests
    made, but not the yielded results).
Returns:
  A generator of Snapshots in the Project.
)projectpageSize	snapshotsrK   )
batch_sizefieldbatch_size_attribute)r+   "PubsubProjectsSnapshotsListRequestr7   r   YieldFromListr-   )r$   project_ref	page_sizelist_reqs       r   ListSnapshotsClient.ListR   sP     }}??((* @ H ##x
< <r   c                    [        SU5      /nU R                  R                  UR                  5       S9n/ nU HM  nUR                  c  M  [        XFR                  UR                  5        UR                  UR                  5        MO     U(       d  [        S5      eU R                  R                  U R                  R                  USR                  U5      S9UR                  5       S9nU R                  R                  U5      $ )a  Updates a Snapshot.

Args:
  snapshot_ref (Resource): Resource reference for the snapshot to be
    updated.
  labels (LabelsValue): The Cloud labels for the snapshot.
Returns:
  Snapshot: The updated snapshot.
Raises:
  NoFieldsSpecifiedError: if no fields were specified.
r1   )r4   z*Must specify at least one field to update.,)r?   
updateMask)updateSnapshotRequestr4   )r   r+   Snapshotr7   r#   setattrr"   appendr   #PubsubProjectsSnapshotsPatchRequestUpdateSnapshotRequestjoinr-   Patch)r$   r9   r1   update_settingsr?   update_maskupdate_setting	patch_reqs           r   ra   SnapshotsClient.Patche   s     .h?@O}}%%&&( & *HK)				)33^5I5IJ>445 * "#OPPAA"mmAAxx, B . &&(	 B *I ==y))r   )r-   r   r+   )NN)d   r   )r   r   r   r   r   r%   r8   rA   rF   rU   ra   r   r   r   r   r(   r(   .   s#    >3
,
&,<&*r   r(   )Fr   )r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r   Errorr   objectr   r(   r   r   r   <module>rm      sN     1 ( , *A 
CZ-- CV S*f S*r   