
                             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 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.    )absolute_import)division)unicode_literals)
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)SnapshotsClient1   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__4   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RelativeNamer0   Create)r'   snapshot_refsubscription_refr4   r5   
create_reqs         r   r;   SnapshotsClient.Create9   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.   !PubsubProjectsSnapshotsGetRequestr:   r0   Get)r'   r<   get_reqs      r   rD   SnapshotsClient.GetC   s>     mm==**, > .G==W%%r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zDeletes a Snapshot.rA   )r.   $PubsubProjectsSnapshotsDeleteRequestr:   r0   Delete)r'   r<   
delete_reqs      r   rI   SnapshotsClient.DeleteO   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	snapshotsrN   )
batch_sizefieldbatch_size_attribute)r.   "PubsubProjectsSnapshotsListRequestr:   r   YieldFromListr0   )r'   project_ref	page_sizelist_reqs       r   ListSnapshotsClient.ListU   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.
r4   )r7   z*Must specify at least one field to update.,)rB   
updateMask)updateSnapshotRequestr7   )r!   r.   Snapshotr:   r&   setattrr%   appendr   #PubsubProjectsSnapshotsPatchRequestUpdateSnapshotRequestjoinr0   Patch)r'   r<   r4   update_settingsrB   update_maskupdate_setting	patch_reqs           r   rd   SnapshotsClient.Patchh   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   )r0   r   r.   )NN)d   r   )r   r   r   r   r   r(   r;   rD   rI   rX   rd   r   r   r   r   r+   r+   1   s#    >3
,
&,<&*r   r+   )Fr   )r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r   Errorr   objectr!   r+   r   r   r   <module>rq      sU     1 &  ' ' , *A 
CZ-- CV S*f S*r   