
    8                     6   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KJr  SS0rSSSSS.rSrS rS rSS.S jr\R6                  \R8                  " \R:                  R<                  5       " S S\R>                  5      5       5       r \R8                  " \R:                  RB                  5       " S S\ 5      5       r"\R8                  " \R:                  RF                  5       " S S\"5      5       r$g )!z$Cloud Pub/Sub topics update command.    )absolute_import)division)unicode_literals)topics)base)resource_args)flags)util)labels_util)
exceptions)logEXAMPLESaS            To update existing labels on a Cloud Pub/Sub topic, run:

              $ {command} mytopic --update-labels=KEY1=VAL1,KEY2=VAL2

          To clear all labels on a Cloud Pub/Sub topic, run:

              $ {command} mytopic --clear-labels

          To remove an existing label on a Cloud Pub/Sub topic, run:

              $ {command} mytopic --remove-labels=KEY1,KEY2

          To enable customer-managed encryption for a Cloud Pub/Sub topic by protecting message data with a Cloud KMS CryptoKey, run:

              $ {command} mytopic --topic-encryption-key=projects/PROJECT_ID/locations/KMS_LOCATION/keyRings/KEYRING/cryptoKeys/KEY

          To enable or update retention on a Cloud Pub/Sub topic, run:

              $ {command} mytopic --message-retention-duration=MESSAGE_RETENTION_DURATION

          To disable retention on a Cloud Pub/Sub topic, run:

              $ {command} mytopic --clear-message-retention-duration

          To update a Cloud Pub/Sub topic's message storage policy, run:

              $ {command} mytopic --message-storage-policy-allowed-regions=some-cloud-region1,some-cloud-region2

          To recompute a Cloud Pub/Sub topic's message storage policy based on your organization's "Resource Location Restriction" policy, run:

              $ {command} mytopic --recompute-message-storage-policy

          To enforce both at-rest and in-transit guarantees for messages published to the topic, run:

              $ {command} mytopic --message-storage-policy-allowed-regions=some-cloud-region1,some-cloud-region2 --message-storage-policy-enforce-in-transit
          z--topic-encryption-keyz--topic-encryption-key-keyringz--topic-encryption-key-locationz--topic-encryption-key-project)zkms-keyzkms-keyringzkms-locationzkms-projectad  
The specified Cloud KMS key should have purpose set to "ENCRYPT_DECRYPT".
The service account,
"service-${CONSUMER_PROJECT_NUMBER}@gcp-sa-pubsub.iam.gserviceaccount.com"
requires the IAM cryptoKeyEncrypterDecrypter role for the given Cloud KMS key.
CONSUMER_PROJECT_NUMBER is the project number of the project that is the parent
of the topic being updatedc                    U R                   R                  R                  5       nU(       a  UR                  5       $ S H?  nU R	                  UR                  SS5      5      (       d  M+  [        R                  " S5      e   g)zParses the KMS key resource name from args.

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

Returns:
  The KMS CryptoKey resource name for the key specified in args, or None.
)ztopic-encryption-keyztopic-encryption-key-projectztopic-encryption-key-locationztopic-encryption-key-keyring-_z/--topic-encryption-key was not fully specified.N)CONCEPTSkms_keyParseRelativeNameIsSpecifiedreplacecore_exceptionsError)argskms_refkeywords      #lib/surface/pubsub/topics/update.py_GetKmsKeyNameFromArgsr   U   ss     MM!!'')'!!g S122!!
;  
    c           	         [         R                  " U S5        [        R                  " U 5        [         R                  " U [
        R                  " S[        [        S9/5        [        R                  " U SS9  [        R                  " U SS9  [        R                  " U SS9  [        R                  " U SS9  [        R                  " U SS9  g)!Registers flags for this command.z
to update.topic)flag_overridespermission_infoT)	is_updateN)r   AddTopicResourceArgr   AddUpdateLabelsFlagsAddResourceArgskms_resource_argsGetKmsKeyPresentationSpec_KMS_FLAG_OVERRIDES_KMS_PERMISSION_INFOr	   AddTopicMessageRetentionFlags!AddTopicMessageStoragePolicyFlagsAddSchemaSettingsFlagsAddIngestionDatasourceFlagsAddMessageTransformsFlagsparsers    r   _Argsr4   r   s     ##FL9""6*

5
502	 %%f=))&DAv6## !!&D9r   Fenable_vertex_ai_smtc         
      :  ^ ^,^- [         R                  " 5       m,T R                  R                  R	                  5       m-[        T SS5      nU(       a  [        R                  " U5      n[        T SS5      n[        R                  " T T,R                  R                  R                  U,U-4S jS9n[        T SS5      nU(       a2  T R                  R                  R	                  5       R                  5       n[        T SS5      nSnU(       a  US   n[        T S	S5      n[        T S
S5      n	S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SnU(       a  US   n[        T SS5      nU(       a   UR                  S5      R!                  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 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"                  " T-UR%                  5       ['        T 5      UUT R(                  T R*                  U40 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
[,        R.                  " T-R                  5       S-S.9  U
$ ! [         R0                   aB    / S/Qn+[3        U 4S0 jU+ 5       5      (       d  e [,        R4                  R7                  S15         U
$ f = f)2a  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_vertex_ai_smt: Whether to enable Vertex AI SMTs.

Returns:
  A serialized object (dict) describing the results of the operation.

Raises:
  An HttpException if there was a problem calling the
  API topics.Patch command.
message_retention_durationN clear_message_retention_durationc                  :   > T R                  T5      R                  $ N)Getlabels)client	topic_refs   r   <lambda>_Run.<locals>.<lambda>   s    

9 5 < <r   )orig_labels_thunkschemamessage_encodingr   first_revision_idlast_revision_idclear_schema_settings)message_storage_policy_enforce_in_transitkinesis_ingestion_stream_arnkinesis_ingestion_consumer_arnkinesis_ingestion_role_arn!kinesis_ingestion_service_accountcloud_storage_ingestion_bucket$cloud_storage_ingestion_input_format&cloud_storage_ingestion_text_delimiterzutf-8zunicode-escape2cloud_storage_ingestion_minimum_object_create_time"cloud_storage_ingestion_match_glob)azure_event_hubs_ingestion_resource_group$azure_event_hubs_ingestion_namespace$azure_event_hubs_ingestion_event_hub$azure_event_hubs_ingestion_client_id$azure_event_hubs_ingestion_tenant_id*azure_event_hubs_ingestion_subscription_id*azure_event_hubs_ingestion_service_accountaws_msk_ingestion_cluster_arnaws_msk_ingestion_topicaws_msk_ingestion_aws_role_arn!aws_msk_ingestion_service_account*confluent_cloud_ingestion_bootstrap_server$confluent_cloud_ingestion_cluster_idconfluent_cloud_ingestion_topic*confluent_cloud_ingestion_identity_pool_id)confluent_cloud_ingestion_service_accountingestion_log_severity$clear_ingestion_data_source_settingsmessage_transforms_fileclear_message_transformsr6   r"   )kind)clear_labelsupdate_labelsremove_labels recompute_message_storage_policy&message_storage_policy_allowed_regionsc              3   F   >#    U  H  nTR                  U5      v   M     g 7fr;   )r   ).0argr   s     r   	<genexpr>_Run.<locals>.<genexpr>N  s     ;
t$$
s   !zNo update to perform.)r   TopicsClientr   r"   r   getattrr
   FormatDurationr   ProcessUpdateArgsLazymessagesTopicLabelsValuerC   r   encodedecodePatch	GetOrNoner   rj   rk   r   UpdatedResourceNoFieldsSpecifiedErroranystatusPrint).r   r6   r8   r9   labels_updaterC   message_encoding_listrD   rE   rF   resultrG   rH   rI   rJ   rK   rL   rM   )cloud_storage_ingestion_input_format_listrN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   
operationsr>   r?   s.   `                                           @@r   _Runr      s     &mm!!''))&t-I4P!%!4!45O!P%,
.&" 33
oo''<- 44(&]]!!'')668F!$(:DA,Q/d$7>T#5t<&!$(?F.5
7/+ ")
*D" $+
,d$   't-I4P&-
/'# $+
,d$  /6
2D/+ *.&.1!4 ) ,3
4d,( , 	/55g>EE	
 +
 8?
@$84 (/
0$($ /6
7/+ *1
2D*& *1
2D*& *1
2D*& *1
2D*& 07
8$0, 07
8$0, #*
+T# $D*CTJ#*
,d$  '.
/'# 07
8$0, *1
2D*& %,
-t%! 07
8$0, /6
7/+ #4)A4H)0
2D*& $D*CTJ$T+EtL:@\\!t$"(--331, , *, ,, *, 4, &B, (F,  $>!," +L#,$ (F%,& .R',( 0V),* <n+,, ,N-,. 3\/,0 .R1,2 .R3,4 .R5,6 .R7,8 4^9,: 4^;,< 'D=,> !8?,@ (FA,B +LC,D 4^E,F .RG,H )HI,J 4^K,L 3\M,N .RO,P  6Q,R !8S,T ":U,V 2W,Fr 	..0w?	- 
	&	& 
.J ;
;;;JJ,- 
-
.s   3B,O APPc                   2    \ rS rSrSr\r\S 5       rS r	Sr
g)UpdateiV  (Updates an existing Cloud Pub/Sub topic.c                     [        U 5        g)r!   Nr4   r2   s    r   ArgsUpdate.Args]  s     
r   c                     [        U5      $ r;   r   selfr   s     r   Run
Update.Rund      :r    N)__name__
__module____qualname____firstlineno____doc__DETAILED_HELPdetailed_helpstaticmethodr   r   __static_attributes__r   r   r   r   r   V  s#     1- r   r   c                   .    \ rS rSrSr\S 5       rS rSrg)
UpdateBetaih  r   c                     [        U 5        g r;   r   r2   s    r   r   UpdateBeta.Argsl      	r   c                     [        U5      $ r;   r   r   s     r   r   UpdateBeta.Runr  r   r   r   N	r   r   r   r   r   r   r   r   r   r   r   r   r   r   h  s    0 
r   r   c                   .    \ rS rSrSr\S 5       rS rSrg)UpdateAlphaiv  r   c                     [        U 5        g r;   r   r2   s    r   r   UpdateAlpha.Argsz  r   r   c                     [        USS9$ )NTr5   r   r   s     r   r   UpdateAlpha.Run  s    400r   r   Nr   r   r   r   r   r   v  s    0 
1r   r   N)%r   
__future__r   r   r   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.callioper   googlecloudsdk.command_lib.kmsr   r)   !googlecloudsdk.command_lib.pubsubr	   r
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   r   r+   r,   r   r4   r   UniverseCompatibleReleaseTracksReleaseTrackGAUpdateCommandr   BETAr   ALPHAr   r   r   r   <module>r      s   + &  ' 0 ( M 3 ; 2 < = # $ $N (353	  ::8 +0 EP D%%(()T  *   D%%**+
 
 ,
 D%%++,
1* 
1 -
1r   