
                            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KJr  \R(                  \R*                  " \R,                  R.                  \R,                  R0                  5       " S S\R2                  5      5       5       r\R*                  " \R,                  R6                  5       " S S\5      5       rg)z'Cloud Pub/Sub snapshots create command.    )absolute_import)division)unicode_literals)
exceptions)	snapshots)base)flags)util)labels_util)logc                   .    \ rS rSrSr\S 5       rS rSrg)Create    ,Creates one or more Cloud Pub/Sub snapshots.c                     U R                  SSSS9  U R                  SSSS9  U R                  S	S
SS9  [        R                  " U 5        [        R                  " U 5        g)z!Registers flags for this command.snapshot+z%One or more snapshot names to create.)nargshelpz--subscriptionTa  The subscription whose backlog the snapshot retains.  Specifically, the created snapshot is guaranteed to retain a) The existing backlog on the subscription, i.e., the set of messages in the subscription that are unacknowledged upon the successful completion of the create snapshot request, b) Any messages published to the subscription's topic following the successful creation of the snapshot.)requiredr   z--subscription-project z~The name of the project the provided subscription belongs to. If not set, it defaults to the currently selected cloud project.)defaultr   N)add_argumentr   AddCreateLabelsFlagsr	   AddTagsFlag)parsers    &lib/surface/pubsub/snapshots/create.pyArgsCreate.Args%   s~     #$K  M 6  	8     " $$V,	f    c           	   #     #    [         R                  " 5       n[        R                  " UR                  UR
                  5      n[        R                  " XR                  R                  R                  5      n[        R                  " XR                  R                  R                  5      n/ nUR                   Hg  n[        R                  " U5      n UR!                  XXES9n	[        R8                  " U	5      n	[*        R,                  " UR/                  5       SS9  U	v   Mi     U(       a  [        R:                  " US5      eg! ["        R$                   a  n
[&        R(                  " U
5      n[*        R,                  " UR/                  5       S[        R0                  " UR2                  R4                  5      S9  UR7                  U5         Sn
A
GM  Sn
A
ff = f7f)a  This is what gets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Yields:
  A serialized object (dict) describing the results of the operation.
  This description fits the Resource described in the ResourceRegistry under
  'pubsub.projects.snapshots'.

Raises:
  util.RequestFailedError: if any of the requests to the API failed.
)labelstagsr   )kindfailedN)r$   create)r   SnapshotsClientr
   ParseSubscriptionsubscriptionsubscription_projectr   ParseCreateArgsmessagesCreateSnapshotRequestLabelsValuer	   GetTagsMessage	TagsValuer   ParseSnapshotr   api_ex	HttpErrorr   HttpExceptionr   CreatedResourceRelativeNameCreateFailureErrorMessagepayloadstatus_messageappendSnapshotDisplayDictRequestsFailedError)selfargsclientsubscription_refr"   r#   r%   snapshot_namesnapshot_refresulterrorexcs               r   Run
Create.RunA   s     &&(F--d.?.?.2.G.GI ((oo33??AF oo33==D F''6l6  
 ''/f	,335JGl' '* $$VX66   &&u-%%'11#++2L2LM	

 	m$s2   CGE#A GGA3G
GGG N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   rF   __static_attributes__rH   r    r   r   r       s     5 627r    r   c                   6   ^  \ rS rSrSr\U 4S j5       rSrU =r$ )CreateAlphav   r   c                 4   > [         [        [        ]  U 5        g )N)superrQ   r   )r   	__class__s    r   r   CreateAlpha.Argsz   s    	+{(0r    rH   )	rI   rJ   rK   rL   rM   rN   r   rO   __classcell__)rU   s   @r   rQ   rQ   v   s    41 1r    rQ   N)rM   
__future__r   r   r   apitools.base.pyr   r2   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   !googlecloudsdk.command_lib.pubsubr	   r
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   DefaultUniverseOnlyReleaseTracksReleaseTrackGABETACreateCommandr   ALPHArQ   rH   r    r   <module>rg      s    . &  ' 1 3 2 ( 3 2 < # D%%(($*;*;*@*@AQ7T Q7 B Q7h D%%++,1& 1 -1r    