
    ,                        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
 jr\R                   \R"                  " \R$                  R&                  5       " S S\R(                  5      5       5       r\R"                  " \R$                  R,                  5       " S S\5      5       r\R"                  " \R$                  R0                  5       " S S\5      5       rg)z+Cloud Pub/Sub subscriptions update command.    )subscriptions)
exceptions)base)flags)resource_args)util)labels_util)logc                     [         R                  " U S5        [        R                  " U SU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.
  enable_bigtable_config: whether or not to enable Bigtable export config
    flags.
z
to update.T)	is_updateenable_push_to_cpsenable_bigtable_config)r   N)r   AddSubscriptionResourceArgr   AddSubscriptionSettingsFlagsr	   AddUpdateLabelsFlagsAddMessageTransformsFlags)parserr   r   s      *lib/surface/pubsub/subscriptions/update.py_Argsr      sN     **6<@$$+3	 ""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)	Update5   /Updates an existing Cloud Pub/Sub subscription.c                     [        U5        g Nr   clsr   s     r   ArgsUpdate.Args:   s	    	&Mr   Fr   enable_vertex_ai_smtc               
  ^^.^/ [         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[        TS
S5      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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.                  _S0UR1                  5       _S1TR2                  _S2U_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)_S
U_S+U+_S,U,_S3U_6n-[4        R6                  " T/R                  5       S4S59  U-$ ! [        R8                   a@    [;        U4S6 jS7 5       5      (       d  e [4        R<                  R?                  S85        Sn- U-$ f = f)9aX  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_configclear_bigtable_configc                  :   > T R                  T5      R                  $ r   )Getlabels)clientsubscription_refs   r   <lambda>Update.Run.<locals>.<lambda>r   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bigtable_tablebigtable_app_profile_idbigtable_service_account_emailbigtable_write_metadataenable_exactly_once_deliverymessage_transforms_fileclear_message_transformsack_deadlinepush_configretain_acked_messagesr0   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CONCEPTSrX   Parsegetattrr	   ProcessUpdateArgsLazymessagesSubscriptionLabelsValueNEVER_EXPIRATION_PERIOD_VALUEr%   RelativeNamer[   r   FormatDurationrJ   PatchrS   ParsePushConfigrU   	GetOrNonerV   r
   UpdatedResourceNoFieldsSpecifiedErroranystatusPrint)0selfr^   r   r#   r%   r&   r'   r(   r)   r*   r+   r,   r-   labels_updaterW   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE    cloud_storage_output_format_listrF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   resultr1   r2   s0    `                                            @@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 
 $D*A4H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" T#3T:N%d,EtL%,.&" &d,EtL#*,d$  &d,EtL&t-GN: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 *HS/T #:U/V !6W/X #:Y/Z $<[/\  4]/fr 
*779OM //  G   		jj./f Ms   2CR/ /ATT N)__name__
__module____qualname____firstlineno____doc__classmethodr    r    CatchHTTPErrorRaiseHTTPExceptionr|   __static_attributes__r~   r   r   r   r   5   s@     8  ..0  F 1F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$ )
UpdateBetai  r   c                     [        USSS9  g )NT)r   r   r   r   s     r   r    UpdateBeta.Args  s    	#r   Fr#   c               *   > [         [        U ]  USUS9$ )NTr"   )superr   r|   )rx   r^   r#   	__class__s      r   r|   UpdateBeta.Run  s%    T&1 '  r   r~   r   r   r   r   r   r   r    r   r   r|   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   r|   )rx   r^   r   s     r   r|   UpdateAlpha.Run%  s    d'4'HHr   r~   r   r   s   @r   r   r     s7    7) ) ..0I 1Ir   r   N)FF)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 8 2 ( 3 ; 2 < #
  :2 D%%(()NT N * Nb D%%**+  ,( D%%++,	I* 	I -	Ir   