
    P                        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  \	R.                  " \	R0                  R2                  5      \	R4                   " S S\	R6                  5      5       5       r\	R.                  " \	R0                  R:                  5      \	R4                   " S S\5      5       5       rg)zUpdate an existing secret.    )absolute_import)division)unicode_literals)api)base)
exceptions)args)log)util)labels_util)map_util)
console_ioc                   H    \ rS rSrSrSrSrSrSrSr	\
S 5       rS	 rS
 rSrg)Update    a  Update a secret's metadata.

Update a secret's metadata (e.g. labels). This command will
return an error if given a secret that does not exist.

## EXAMPLES

Update the label of a secret named `my-secret`.

  $ {command} my-secret --update-labels=foo=bar

Update the label of a secret using an etag.

  $ {command} my-secret --update-labels=foo=bar --etag=123

Update a secret to have a next-rotation-time:

  $ {command} my-secret --next-rotation-time="2030-01-01T15:30:00-05:00"

Update a secret to have a next-rotation-time and rotation-period:

  $ {command} my-secret --next-rotation-time="2030-01-01T15:30:00-05:00"
  --rotation-period="7200s"

Update a secret to remove the next-rotation-time:

  $ {command} my-secret --remove-next-rotation-time

Update a secret to clear rotation policy:

  $ {command} my-secret --remove-rotation-schedule

Update version destroy ttl of a secret:

  $ {command} my-secret --version-destroy-ttl="86400s"

Disable delayed secret version destroy:

  $ {command} my-secret --remove-version-destroy-ttl
z9There are no changes to the secret [{secret}] for update.zxThe secret [{secret}] cannot be updated because it does not exist. Please use the create command to create a new secret.zrThis secret and all of its versions will be automatically deleted at the requested expire-time of [{expire_time}].zqThis secret and all of its versions will be automatically deleted after the requested ttl of [{ttl}] has elapsed.zThe --regional-kms-key-name or --remove-regional-kms-key-name flag can only be used when update a regional secret with "--location".c                 ,   [         R                  " U SSSS9  [         R                  " U SSS9  U R                  SSS9nU R                  SS	S9n[        R
                  " U 5        [         R                  " U S
S9  [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [        R                  " USS[        [        5        [        R                   " USS[        5        [        R"                  " USS5        [        R                  " USS	[        [        5        [        R                   " USS	[        5        [        R"                  " USS	5        g)zArgs is called by calliope to gather arguments for this command.

Args:
  parser: An argparse parser that you can use to add arguments that will be
    available to this command.
	to updateTpurpose
positionalrequiredto update secretFr   hiddenVersion AliasesmutexhelpAnnotationsupdatedactionversion-aliasesannotationsN)secrets_args	AddSecretAddLocation	add_groupr   AddUpdateLabelsFlagsAddSecretEtagAddUpdateExpirationGroupAddUpdateTopicsGroupAddUpdateRotationGroupAddUpdateVersionDestroyTTLAddUpdateRegionalKmsKeyr   AddMapUpdateFlagstrintAddMapRemoveFlagAddMapClearFlagparseraliasr$   s      lib/surface/secrets/update.pyArgsUpdate.Args\   sC    t V-?N4.?@E""M"BK$$V,vi8))&1%%f-''/++F3((0e%68I3!#e%68I3OU$57HIk=-!#k=-M[-G    c                    [         R                  " U R                  5       5      n[         R                  " US9nUR                  R
                  R                  5       n/ n[        R                  R                  U5      nUR                  5       (       a  UR                  S5        UR                  S5      (       a  UR                  S5        UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S	5        UR                  S
5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d  UR                  S5      (       a  UR                  S5        U(       d>  [        R                  " / SQU R                  R!                  UR#                  5       S95      eUR%                  UR&                  R(                  UR*                  5      nUR*                  n	UR,                  (       a  UR*                  n	UR.                  (       a9  U R0                  R!                  UR.                  S 9n
[2        R4                  " U
S!S!S"9  UR6                  (       a9  U R8                  R!                  UR6                  S#9n
[2        R4                  " U
S!S!S"9  SU;   a!  [:        R<                  " X!R>                  5      nO/ n/ nSU;   a  / nUR@                  c  UR&                  RC                  / S$9Ul         [:        RD                  " X!R@                  RF                  5      nURI                  5        H7  u  pUR                  UR&                  RB                  RK                  XS%95        M9     / nSU;   a  URL                  c  UR&                  RO                  / S$9Ul&        [:        RP                  " X!RL                  RF                  5      nURI                  5        H9  u  nnUR                  UR&                  RN                  RK                  UUS%95        M;     URR                  (       a  URR                   S&3nOS nURT                  (       dC  URV                  (       d  URX                  (       a!  [        RZ                  " S'U R\                  5      e[         R^                  " US(9Ra                  UU	UUUURb                  UR.                  UR6                  UURd                  URf                  UURV                  URT                  S)9n[h        R^                  " 5       Rk                  U5        U$ )*Nversionlabelsttlexpire_timeremove_expirationnext_rotation_timeremove_next_rotation_timeremove_rotation_schedulerotation.next_rotation_timerotation_periodremove_rotation_periodrotation.rotation_period
add_topicsremove_topicsclear_topicstopicsupdate_version_aliasesremove_version_aliasesclear_version_aliasesversion_aliasesupdate_annotationsremove_annotationsclear_annotationsr$   version_destroy_ttlremove_version_destroy_ttlregional_kms_key_nameremove_regional_kms_key_namecustomer_managed_encryptionz--clear-labelsz--remove-labelsz--update-labelsz--ttlz--expire-timez--remove-expirationz--clear-topicsz--remove-topicsz--add-topicsz--update-version-aliasesz--remove-version-aliasesz--clear-version-aliasesz--update-annotationsz--remove-annotationsz--clear-annotationsz--next-rotation-timez--remove-next-rotation-timez--rotation-periodz--remove-rotation-periodz--remove-rotation-schedulez--version-destroy-ttlz--remove-version-destroy-ttlz--remove_regional_kms_key_namez--regional-kms-key-namesecretrA   Tthrow_if_unattendedcancel_on_nor@   additionalPropertieskeyvalueslocationapi_version)
secret_refr?   rQ   r$   update_masketagrA   r@   rM   rC   rG   rU   rW   secret_location)6secrets_apiGetApiFromTrackReleaseTrackGetMessagesCONCEPTSr\   Parser   DiffFromUpdateArgsMayHaveUpdatesappendIsSpecifiedr   MinimumArgumentExceptionNO_CHANGES_MESSAGEformatNameApplySecretLabelsValuer?   needs_updaterA   CONFIRM_EXPIRE_TIME_MESSAGEr   PromptContinuer@   CONFIRM_TTL_MESSAGEsecrets_utilApplyTopicsUpdaterM   versionAliasesVersionAliasesValueApplyAliasUpdaterc   itemsAdditionalPropertyr$   AnnotationsValueApplyAnnotationsUpdaterU   rh   rW   rX   RequiredArgumentExceptionREGIONAL_KMS_FLAG_MESSAGESecretsr   rm   rC   rG   secrets_logUpdated)selforiginalr	   rj   messagesrk   rl   labels_difflabels_updater?   msgrM   rQ   version_aliases_dictr7   r>   r$   annotations_dict
annotationmetadatarU   r\   s                         r8   
_RunUpdateUpdate._RunUpdatez   s   --d.?.?.ABK&&{;H%%++-J K""11$7K!!##"&&$*:*:;N*O*O'			.	/	/			5	6	634467			+	,	,			2	3	334434%%)9)9* * ,,^<<"011T5E5E 6" 6"%)%5%56M%N%N*+,--1A1A2 2!%!1!12E!F!F'-..$2B2B$3 3 .//00D4D4D&5 5 67 //4 
!
!
(
(
0A
(
B7 <  %%hoo&A&A&.oo7M__F!!##f,,33&& 4 (c
4d< xx$$+++9c
4d< ;--dOODffOK'o		 	 	("*//"E"E!# #F #%)::
''<<>0668.%OO//BB C *	+ 9 K#				%'??!#  @  %%<<
$$99;"2"8"8":
*hOO,,??h @ 0	1 #; #778: ==""d&G&G00
d44    [9@@'YY$$HH22,,/"88 A F  !!*-Mr;   c                    [         R                  " U R                  5       5      nUR                  R                  R                  5       n[         R                  " US9R                  X1R                  S9nUc<  [        R                  " SU R                  R                  UR                  5       S95      eU R                  XA5      $ )zRun is called by calliope to update the secret.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
    with.

Returns:
  The API call to service for secret update.
ri   rn   r\   r[   ro   rp   rq   rs   r\   rt   r   	GetOrNonerh   r   InvalidArgumentExceptionSECRET_MISSING_MESSAGEr|   r}   r   r   r	   rj   rk   r\   s        r8   Run
Update.Run  s     --d.?.?.ABK%%++-J  [9CCMM D F
 ~//
D//66joo>O6P 
 ??6((r;    N)__name__
__module____qualname____firstlineno____doc__r{   r   r   r   r   staticmethodr9   r   r   __static_attributes__r   r;   r8   r   r       s^    'T B > 6 8 G 
 H H:Yv)r;   r   c                   8    \ rS rSrSrSr\S 5       rS rS r	Sr
g)	
UpdateBetai/  ao  Update a secret's metadata.

Update a secret's metadata (e.g. labels). This command will
return an error if given a secret that does not exist.

## EXAMPLES

    Update the label of a secret named `my-secret`.

  $ {command} my-secret --update-labels=foo=bar

Update the label of a secret using etag.

      $ {command} my-secret --update-labels=foo=bar --etag=123

Update the expiration of a secret named 'my-secret' using a ttl.

  $ {command} my-secret --ttl="600s"

Update the expiration of a secret named 'my-secret' using an expire-time.

  $ {command} my-secret --expire-time="2030-01-01T08:15:30-05:00"

Remove the expiration of a secret named 'my-secret'.

  $ {command} my-secret --remove-expiration

Update a secret to have a next-rotation-time:

  $ {command} my-secret --next-rotation-time="2030-01-01T15:30:00-05:00"

Update a secret to have a next-rotation-time and rotation-period:

  $ {command} my-secret --next-rotation-time="2030-01-01T15:30:00-05:00"
  --rotation-period="7200s"

Update a secret to remove the next-rotation-time:

  $ {command} my-secret --remove-next-rotation-time

Update a secret to clear rotation policy:

  $ {command} my-secret --remove-rotation-schedule

Update version destroy ttl of a secret:

  $ {command} my-secret --version-destroy-ttl="86400s"

Disable delayed secret version destroy:

  $ {command} my-secret --remove-version-destroy-ttl
z8There are no changes to the secret [{secret}] for updatec                 ,   [         R                  " U SSSS9  [         R                  " U SSS9  U R                  SSS9nU R                  SS	S9n[        R
                  " U 5        [         R                  " U S
S9  [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [        R                  " USS[        [        5        [        R                   " USS[        5        [        R"                  " USS5        [        R                  " USS	[        [        5        [        R                   " USS	[        5        [        R"                  " USS	5        g )Nr   Tr   r   Fr   r   r   r   r    r!   r#   r$   )r%   r&   r'   r(   r   r)   r*   r+   r-   r,   r.   r/   r   r0   r1   r2   r3   r4   r5   s      r8   r9   UpdateBeta.Argsk  sA   t V-?N4.?@E""M"BK$$V,vi8))&1''/%%f-++F3((0e%68I3!#e%68I3OU$57HIk=-!#k=-M[-Gr;   c                    [         R                  " U R                  5       5      n[         R                  " US9nUR                  R
                  R                  5       n/ n[        R                  R                  U5      nUR                  5       (       a  UR                  S5        UR                  S5      (       a  UR                  S5        UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S	5        UR                  S
5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d  UR                  S5      (       a  UR                  S5        UR                  S5      (       d  UR                  S5      (       a  UR                  S5        U(       d>  [        R                  " / SQU R                  R!                  UR#                  5       S95      eUR%                  UR&                  R(                  UR*                  5      nUR*                  n	UR,                  (       a  UR*                  n	S	U;   a!  [.        R0                  " X!R2                  5      n
O/ n
/ nSU;   a  UR4                  c  UR&                  R7                  / S 9Ul        [.        R8                  " X!R4                  R:                  5      nUR=                  5        H7  u  pUR                  UR&                  R6                  R?                  XS!95        M9     / nSU;   a  / nUR@                  c  UR&                  RC                  / S 9Ul         [.        RD                  " X!R@                  R:                  5      nUR=                  5        H9  u  nnUR                  UR&                  RB                  R?                  UUS!95        M;     URF                  (       a9  U RH                  R!                  URF                  S"9n[J        RL                  " US#S#S$9  URN                  (       a9  U RP                  R!                  URN                  S%9n[J        RL                  " US#S#S$9  URR                  (       a  URR                   S&3nOS nURT                  (       dC  URV                  (       d  URX                  (       a!  [        RZ                  " S'U R\                  5      e[         R^                  " US(9Ra                  UU	UUUURb                  URF                  URN                  U
URd                  URf                  UURV                  URT                  S)9n[h        R^                  " 5       Rk                  U5        U$ )*Nr=   r?   r@   rA   rB   rJ   rK   rL   rM   rC   rD   rE   rF   rG   rH   rI   rN   rO   rP   rQ   rR   rS   rT   r$   rU   rV   rW   rX   rY   rZ   r[   rb   rd   r]   Tr^   ra   rg   rh   ri   )rk   r?   rl   rQ   r$   rm   rA   r@   rM   rC   rG   rU   rW   rn   )6ro   rp   rq   rr   rs   r\   rt   r   ru   rv   rw   rx   ry   r   rz   r{   r|   r}   r~   r   r   r?   r   r   r   rM   r   r   r   rc   r   r   r$   r   r   rA   r   r   r   r@   r   rU   rh   rW   rX   r   r   r   r   rm   rC   rG   r   r   )r   r   r	   rj   r   rk   rl   r   r   r?   rM   rQ   r   r7   r>   r$   r   r   r   r   rU   r\   s                         r8   r   UpdateBeta._RunUpdate  s   --d.?.?.ABK&&{;H%%++-J K""11$7K!!##"&&$*:*:;N*O*O'%%)9)9* * ,,^<<"			.	/	/			5	6	634467			+	,	,			2	3	334434011T5E5E 6" 6"%)%5%56M%N%N*+,--1A1A2 2!%!1!12E!F!F'-..$2B2B$3 3 .//00D4D4D&5 5 67 //4 
!
!
(
(
0A
(
B7 <  %%hoo&A&A&.oo7M__F!!##f;--dOODffOK'		 	 	("*//"E"E!# #F #
 *::
''<< 1668.%OO//BB C 	
 9 K#k				%'??!#  @  
 &<<
$$99 #3"8"8":
*hOO,,??h @ 	
 #; ,,33&& 4 c 
4d xx$$+++9c
4d #778: ==""d&G&G00
d44    [9@@'YY$$HH22,,/"88 A F  !!*-Mr;   c                    [         R                  " U R                  5       5      nUR                  R                  R                  5       n[         R                  " US9R                  X1R                  S9nUc<  [        R                  " SU R                  R                  UR                  5       S95      eU R                  XA5      $ )Nri   r   r\   r[   r   r   s        r8   r   UpdateBeta.Run*  s    --d.?.?.ABK%%++-J  [9CCMM D F
 ~//
D//66joo>O6P 
 ??6((r;   r   N)r   r   r   r   r   r{   r   r9   r   r   r   r   r;   r8   r   r   /  s5    3l A  H H.eN)r;   r   N)r   
__future__r   r   r   googlecloudsdk.api_lib.secretsr   ro   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.secretsr	   r%   r
   r   r   r   $googlecloudsdk.command_lib.util.argsr   r   googlecloudsdk.core.consoler   ReleaseTracksrq   GADefaultUniverseOnlyUpdateCommandr   BETAr   r   r;   r8   <module>r      s    ! &  ' = ( . C A C < 9 2 D%%(()J)T J)  *J)Z D%%**+G) G)  ,G)r;   