
    )                        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   SS jr\
R(                  \
R*                  " \
R,                  R.                  5       " S S\
R0                  5      5       5       r\
R*                  " \
R,                  R4                  5       " S S\5      5       r\
R*                  " \
R,                  R8                  5       " S S\5      5       rg)z+Cloud Pub/Sub subscriptions update command.    )absolute_import)division)unicode_literals)subscriptions)
exceptions)base)flags)resource_args)util)labels_util)logc                     [         R                  " U S5        [        R                  " U SUS9  [        R
                  " U 5        [        R                  " U SS9  g)zAdds the arguments for this command.

Args:
  parser: the parser for the command.
  enable_push_to_cps: whether or not to enable Pubsub Export config flags
    support.
z
to update.T)	is_updateenable_push_to_cps)r   N)r
   AddSubscriptionResourceArgr	   AddSubscriptionSettingsFlagsr   AddUpdateLabelsFlagsAddMessageTransformsFlags)parserr   s     *lib/surface/pubsub/subscriptions/update.py_Argsr      sK     **6<@$$+
 ""6*!!&D9    c                   `    \ rS rSrSr\S 5       r\R                  " 5       SSS.S j5       r	Sr
g)	Update4   /Updates an existing Cloud Pub/Sub subscription.c                     [        U5        g Nr   clsr   s     r   ArgsUpdate.Args9   s	    	&Mr   Fr   enable_vertex_ai_smtc               l	  ^^)^* [         R                  " T5        [        R                  " 5       m)TR                  R
                  R                  5       m*[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n	[        TSS5      n
U(       a  [        TS	S5      OSn[        R                  " TT)R                  R                  R                  U)U*4S
 jS9nSn[        TSS5      nU(       a  U[        R                  :X  a  SnSnU(       a2  TR                  R                  R                  5       R                  5       n[        TSS5      nTR!                  S5      (       a  ["        R$                  " U5      n[        TSS5      nTR!                  S5      (       a  ["        R$                  " U5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      n[        TSS5      nTR!                  S5      (       a  ["        R$                  " U5      n[        TSS5      nSnU(       a  US   n[        TS S5      n [        TS!S5      n![        TS"S5      n"U(       a  [        TS#S5      OSn#U#(       a2  TR                  R&                  R                  5       R                  5       n#[        TS$S5      n$[        TS%S5      n%[        TS&S5      n&[        TS'S5      n' T)R(                  " T*40 S(TR*                  _S)["        R,                  " T5      _S*TR.                  _S+UR1                  5       _S,TR2                  _S-U_SU_SU_SU_SU_SU_SU_SU_S%U%_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_S U _S!U!_S"U"_SU	_SU
_S#U#_S$U$_S	U_S&U&_S'U'_S.U_6n([4        R6                  " T*R                  5       S/S09  U($ ! [        R8                   a@    [;        U4S1 jS2 5       5      (       d  e [4        R<                  R?                  S35        Sn( U($ f = f)4aX  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.
  enable_push_to_cps: Whether or not to enable Pubsub Export config flags
    support.
  enable_vertex_ai_smt: Whether to enable Vertex AI SMTs.

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

Raises:
  An HttpException if there was a problem calling the
  API subscriptions.Patch command.
dead_letter_topicNmax_delivery_attemptsclear_dead_letter_policyclear_retry_policyclear_bigquery_configclear_cloud_storage_configclear_push_no_wrapper_configclear_pubsub_export_configc                  :   > T R                  T5      R                  $ r   )Getlabels)clientsubscription_refs   r   <lambda>Update.Run.<locals>.<lambda>p   s    &**-=">"E"Er   )orig_labels_thunkFexpiration_periodTmin_retry_delaymax_retry_delaybigquery_tableuse_topic_schemause_table_schemawrite_metadatadrop_unknown_fieldsbigquery_service_account_emailcloud_storage_bucketcloud_storage_file_prefixcloud_storage_file_suffix"cloud_storage_file_datetime_formatcloud_storage_max_bytescloud_storage_max_durationcloud_storage_max_messagescloud_storage_output_formatr   cloud_storage_use_topic_schemacloud_storage_write_metadata#cloud_storage_service_account_emailpubsub_export_topicpubsub_export_topic_regionenable_exactly_once_deliverymessage_transforms_fileclear_message_transformsack_deadlinepush_configretain_acked_messagesr1   message_retention_durationno_expirationr%   subscription)kindc              3   F   >#    U  H  nTR                  U5      v   M     g 7fr   )IsSpecified).0argargss     r   	<genexpr>Update.Run.<locals>.<genexpr>   s&      Gc 

3

Gs   !)clear_labelsupdate_labelsremove_labelszNo update to perform.) r	   ValidateDeadLetterPolicyr   SubscriptionsClientCONCEPTSrU   Parsegetattrr   ProcessUpdateArgsLazymessagesSubscriptionLabelsValueNEVER_EXPIRATION_PERIOD_VALUEr'   RelativeNamerX   r   FormatDurationrK   PatchrP   ParsePushConfigrR   	GetOrNonerS   r   UpdatedResourceNoFieldsSpecifiedErroranystatusPrint)+selfr[   r   r%   r'   r(   r)   r*   r+   r,   r-   r.   labels_updaterT   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF    cloud_storage_output_format_listrG   rH   rI   rJ   rK   rL   rM   rN   rO   resultr2   r3   s+    `                                       @@r   Run
Update.Run=   s   6 
""4(..0F}}11779&94@#D*A4H&t-GN ';TB#D*A4H!(*D" $+,d$ 
  	2D9   55$$00EM M&94@	mII	I --99??ANNPd$5t<O)**++O<od$5t<O)**++O<oT#3T:Nt%7>t%7>T#3T:N!$(=tD%,.&" #4)?F '.I4 P '.I4 P)02D*& &d,EtL!(*D" ")*D" 455#'#6#6
$$  (/+T($ #''$DQ$G!%,.&" $+,d$  +23T+'
  	+T2  
--
+
+
1
1
3
@
@
B  ")*D" $+,d$  &d,EtL&t-GN5P||
*((* **40* !% : :	*
 ((** &*%D%D* &* .* .* !6* $<* 0* ** ** (D*  (!*" ,#*$ ,%*& ('*( 2)** *H+*, !6-*.  4/*0 %>1*2 %>3*4 .P5*6 #:7*8 &@9*: &@;*< 'B=*> *H?*@ (DA*B /RC*D &@E*F (DG*H 2I*J &@K*L &@M*N #:O*P $<Q*R  4S*fh 
*779OM //  G   		jj./f Ms   1C	Q AR32R3 N)__name__
__module____qualname____firstlineno____doc__classmethodr"   r    CatchHTTPErrorRaiseHTTPExceptionry   __static_attributes__r{   r   r   r   r   4   s@     8  ..0  y 1yr   r   c                   l   ^  \ rS rSrSr\S 5       r\R                  " 5       SS.U 4S jj5       r	Sr
U =r$ )
UpdateBeta   r   c                     [        USS9  g )NT)r   r   r    s     r   r"   UpdateBeta.Args   s    	r   Fr%   c               *   > [         [        U ]  USUS9$ )NTr$   )superr   ry   )ru   r[   r%   	__class__s      r   ry   UpdateBeta.Run  s%    T&1 '  r   r{   r|   r}   r~   r   r   r   r"   r   r   ry   r   __classcell__r   s   @r   r   r      s8    7  ..016  1r   r   c                   j   ^  \ rS rSrSr\U 4S j5       r\R                  " 5       U 4S j5       r	Sr
U =r$ )UpdateAlphai  r   c                 ,   > [         [        U ]  U5        g r   )r   r   r"   )r!   r   r   s     r   r"   UpdateAlpha.Args  s    	+s (r   c                 (   > [         [        U ]  USS9$ )NTr   )r   r   ry   )ru   r[   r   s     r   ry   UpdateAlpha.Run  s    d'4'HHr   r{   r   r   s   @r   r   r     s7    7) ) ..0I 1Ir   r   N)F)r   
__future__r   r   r   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.pubsubr	   r
   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   UniverseCompatibleReleaseTracksReleaseTrackGAUpdateCommandr   BETAr   ALPHAr   r{   r   r   <module>r      s    2 &  ' 7 2 ( 3 ; 2 < #
 :* D%%(()AT A * AH D%%**+  ,& D%%++,	I* 	I -	Ir   