
                            d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddZ ej(                  ej*                  j,                         G d dej.                               Z ej(                  ej*                  j2                  ej*                  j4                         G d de             Zy)z(Cloud Pub/Sub subscriptions ack command.    )absolute_import)division)unicode_literals)
exceptions)subscriptions)base)flags)resource_args)util)log)
propertiesc                 >   t        j                         }| j                  j                  j	                         }|sj|j                  ||      }t        j                  j                  dj                  dj                  |                   |r|j                         |di fS |i fS d}i }	 |j                  ||      }t        j                   ||      \  }	}
t        j                  j                  dj                  dj                  |
                   |	r=t        j                  j                  dj                  dj                  |	                   |r|j                         |d}||fS # t        j                  $ r}t        j                  |      }Y d}~d}~ww xY w)zAcks one or more messages.z2Acked the messages with the following ackIds: [{}],)subscriptionIdackIdsNz:Failed to ack the messages with the following ackIds: [{}])r   SubscriptionsClientCONCEPTSsubscriptionParseAckr   statusPrintformatjoinRelativeNameapi_ex	HttpErrorr   HandleExactlyOnceDeliveryError'ParseExactlyOnceAckIdsAndFailureReasons)argsack_idslegacy_outputcapture_failuresclientsubscription_refresultack_ids_and_failure_reasonserrorfailed_ack_idssuccessfully_processed_ack_idss              'lib/surface/pubsub/subscriptions/ack.py_Runr,       s   ,,.&]]//557	ZZ!12FJJ<CCHHW	  ,99; 
 
 RZ& "MZZ!12F 483_3_!74,0.0 **GNN	hh-.0 1JJDKKHH^$	&' *779F 
,	,,% 
		 M"&"E"Ee"LMs   *E* *F=FFc                   .    e Zd ZdZddiZed        Zd Zy)r   @Acknowledges one or more messages on the specified subscription.DESCRIPTIONa            Acknowledges one or more messages as having been successfully received.
          If a delivered message is not acknowledged within the Subscription's
          ack deadline, Cloud Pub/Sub will attempt to deliver it again.

          To automatically acknowledge messages when pulling from a Subscription,
          you can use the `--auto-ack` flag on `gcloud pubsub subscriptions pull`.
      c                 \    t        j                  | d       t        j                  | d       y )Nto ACK messages on.acknowledge.r
   AddSubscriptionResourceArgr	   AddAckIdFlagparsers    r+   ArgszAck.Args[   s#    ,,V5JK	v~.    c                 D    t        ||j                  d      \  }}|r|S |S )NT)r#   )r,   r!   )selfr    r&   r'   s       r+   RunzAck.Run`   s+    *.dllT+3'F'"((Mr9   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr8   r<    r9   r+   r   r   K   s/    H 

- / /r9   r   c                   &    e Zd ZdZed        Zd Zy)AckBetar.   c                 `    t        j                  | d       t        j                  | dd       y )Nr1   r2   T)add_deprecatedr3   r6   s    r+   r8   zAckBeta.Argsl   s%    ,,V5JK	v~dCr9   c                     t        j                  |      }t        j                  j                  j
                  j                         }t        ||d|      \  }}|r|S |S )NT)r#   r"   )r	   ParseAckIdsArgsr   VALUESpubsubr"   GetBoolr,   )r;   r    r!   r"   r&   r'   s         r+   r<   zAckBeta.Runq   sZ    ##D)G%%,,::BBDM*.gM+K'F'"((Mr9   N)r=   r>   r?   r@   rB   r8   r<   rC   r9   r+   rE   rE   h   s    HD Dr9   rE   N)FF)r@   
__future__r   r   r   apitools.base.pyr   r   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.pubsubr	   r
   r   googlecloudsdk.corer   r   r,   ReleaseTracksReleaseTrackGACommandr   BETAALPHArE   rC   r9   r+   <module>rY      s    / &  ' 1 7 ( 3 ; 2 # *(-V D%%(()$,,  *8 D%%**D,=,=,C,CDc  Er9   