
    m1                     z   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S.r\	R"                  \	R$                  " \	R&                  R(                  \	R&                  R*                  \	R&                  R,                  5       " S S\	R.                  5      5       5       r\\l        g)z!'logging buckets update' command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)
exceptions)log)
console_ioz0
        Update the properties of a bucket.
    aG  
     To update a bucket in your project, run:

        $ {command} my-bucket --location=global --description=my-new-description

     To update a bucket in your project and remove all indexes, run:

        $ {command} my-bucket --location=global --clear-indexes

     To update a bucket in your project and remove an index, run:

        $ {command} my-bucket --location=global --remove-indexes=jsonPayload.foo2

     To update a bucket in your project and add an index, run:

        $ {command} my-bucket --location=global --add-index=fieldPath=jsonPayload.foo2,type=INDEX_TYPE_STRING

     To update a bucket in your project and update an existing index, run:

        $ {command} my-bucket --location=global --update-index=fieldPath=jsonPayload.foo,type=INDEX_TYPE_INTEGER

     To update a bucket in your project and update existing cmek, run:

        $ {command} my-bucket --location=global --cmek-kms-key-name=CMEK_KEY_NAME

     To asynchronously enroll a bucket in your project into Log Analytics, run:

        $ {command} my-bucket --location=global --async --enable-analytics
    )DESCRIPTIONEXAMPLESc                   N   ^  \ rS rSrSrU 4S jr\S 5       rS rS r	S r
SrU =r$ )	Update@   zKUpdate a bucket.

Changes one or more properties associated with a bucket.
c                 <   > [         [        U ]
  " U0 UD6  S U l        g )N)superr   __init___current_bucket)selfargskwargs	__class__s      %lib/surface/logging/buckets/update.pyr   Update.__init__J   s    	&$ $1&1D    c           
      f   U R                  SSS9  U R                  S[        [        R                  " SSS9S9  U R                  S	S
S9  [        R
                  " U S5        [        R                  " U SS5        U R                  SSSS9  U R                  SS[        R                  " 5       SS9  U R                  SSSS9  U R                  S[        R                  " 5       SSS9  U R                  SS[        R                  " [        [        R                  S.SS /S!9S"S#S$9  U R                  S%S[        R                  " [        [        R                  S.SS /S!9S"S&S$9  U R                  S'SS([        R                  " S)SS9S*9  U R                  S+S,S9  [        R                  R                  U 5        g()-z Register flags for this command.	BUCKET_IDzThe id of the bucket to update.)help--retention-daysz&A new retention period for the bucket.zThis is not available.
)defaultuniverse_help)typer   --descriptionz!A new description for the bucket.zbucket to updateTzLocation of the bucket.--locked
store_truezSLock the bucket and prevent it from being modified or deleted (unless it is empty).)actionr   z--restricted-fieldsz.A new set of restricted fields for the bucket.RESTRICTED_FIELD)r   r"   metavarz--clear-indexesz+Remove all logging indexes from the bucket.--remove-indexesz
FIELD PATHz:Specify the field path of the logging index(es) to delete.)r"   r(   r   z--add-indexappend)	fieldPathr"   r+   r"   )specrequired_keyszKEY=VALUE, ...a'  Add an index to be added to the log bucket. This flag can be repeated. The ``fieldPath'' and ``type'' attributes are required. For example:  --index=fieldPath=jsonPayload.foo,type=INDEX_TYPE_STRING. The following keys are accepted:

*fieldPath*::: The LogEntry field path to index. For example: jsonPayload.request.status. Paths are limited to 800 characters and can include only letters, digits, underscores, hyphens, and periods.

*type*::: The type of data in this index. For example: INDEX_TYPE_STRING Supported types are strings and integers. 

 )r&   r"   r(   r   --update-indexa  Update an index to be added to the log bucket. This will update the type of the index, and also update its createTime to the new update time. This flag can be repeated. The ``fieldPath'' and ``type'' attributes are required. For example:  --index=fieldPath=jsonPayload.foo,type=INDEX_TYPE_STRING. The following keys are accepted:

*fieldPath*::: The LogEntry field path to index. For example: jsonPayload.request.status. Paths are limited to 800 characters and can include only letters, digits, underscores, hyphens, and periods.

*type*::: The type of data in this index. For example: INDEX_TYPE_STRING Supported types are strings and integers. z--enable-analyticsNzmWhether to opt the bucket into Log Analytics. Once opted in, the bucket cannot be opted out of Log Analytics.)r&   r    r   z--cmek-kms-key-namez7A valid `kms_key_name` will enable CMEK for the bucket.)add_argumentintr   UniverseHelpTextr   AddParentArgsAddBucketLocationArgArgListArgDictstrIndexTypeToEnumr   
ASYNC_FLAGAddToParser)parsers    r   ArgsUpdate.ArgsN   s    *KL
))<4
   A  Cv12fd,EF
&  (
 =  ""	  $
 ;  >   "J	  M
    ,, '/1 !@  B,    ,, '/1 !9  ;2 ))D 5
	   F  H 	OO'r   c                    U R                   (       d  [        R                  " 5       R                  R	                  [        R
                  " 5       R                  [        R                  " [        R                  " [        R                  " U5      SUR                  5      SUR                  5      S95      U l         U R                   $ )a  Returns a bucket specified by the arguments.

Loads the current bucket at most once. If called multiple times, the
previously-loaded bucket will be returned.

Args:
  args: The argument set. This is not checked across GetCurrentBucket calls,
    and must be consistent.
	locationsbuckets)name)r   r   	GetClientprojects_locations_bucketsGetGetMessages)LoggingProjectsLocationsBucketsGetRequestCreateResourceNameGetParentFromArgslocationr   r   r   s     r   GetCurrentBucketUpdate.GetCurrentBucket   s     !^^-HHLL




F
F**)),,T2K .. G 
d r   c                 R   0 n/ n/ SQnUR                  S5      (       a   UR                  US'   UR                  S5        UR                  S5      (       a   UR                  US'   UR                  S5        UR                  S5      (       aG  UR                  US'   UR                  S5        UR                  (       a  [
        R                  " SSSS	9  UR                  S
5      (       a   UR                  US'   UR                  S
5        UR                  S5      (       a   UR                  US'   UR                  S5        UR                  S5      (       dC  UR                  S5      (       d-  UR                  S5      (       d  UR                  S5      (       Ga  U R                  U5      n/ US'   UR                  S5        UR                  S5      (       a  UR                  O/ nUR                  S5      (       a  UR                  O/ nUR                   H  nUR                  U;   a  UR                  UR                  5        M0  [        [!        U5      5       HT  n	UR                  Xy   S   :X  d  M  Xy   R#                  5        H  u  pU
S:X  d  M  Xl        M     UR'                  U	5          O   US   R                  U5        M     U(       a5  [(        R*                  " SSR-                  SR/                  U5      5      5      eU(       aH  [(        R*                  " SSR-                  SR/                  U Vs/ s H  oS   PM	     sn5      5      5      eUR                  S5      (       a  / US'   UR                  S5      (       a  US==   UR0                  -  ss'   UR                  S5      (       ax  U R                  U5      nUR2                  (       d  [
        R                  " SSS9  [4        R6                  " 5       R9                  UR:                  S9nXS'   UR                  S 5        U(       d  [(        R<                  " US!5      eUR>                  (       a  [4        R@                  " 5       RB                  RE                  [4        R6                  " 5       RG                  [4        RH                  " [4        RH                  " [4        RJ                  " U5      S"URL                  5      S#URN                  5      [4        R6                  " 5       RP                  " S'0 UD6SR/                  U5      S$95      n[R        RT                  " URV                  S%SS&9  U$ [4        R@                  " 5       RB                  RY                  [4        R6                  " 5       R[                  [4        RH                  " [4        RH                  " [4        RJ                  " U5      S"URL                  5      S#URN                  5      [4        R6                  " 5       RP                  " S'0 UD6SR/                  U5      S$95      $ s  snf )(N)r   r#   r$   retention_daysretentionDaysdescriptionlockedz+WARNING: Locking a bucket cannot be undone.FT)r    cancel_on_norestricted_fieldsrestrictedFieldsenable_analyticsanalyticsEnabledanalytics_enabledclear_indexesremove_indexes	add_indexupdate_indexindexConfigsindex_configsr+   r"   r)   zIndexes {0} do not exist,r.   cmek_kms_key_namez1CMEK cannot be disabled on a bucket once enabled.)rQ   )
kmsKeyNamecmekSettingscmek_settingsz.Please specify at least one property to updater>   r?   )r@   	logBucket
updateMaskbucket)is_async ).IsSpecifiedrM   r*   rO   rP   r   PromptContinuerR   rT   rJ   rX   rZ   r[   r+   removerangelenitemsr"   popcalliope_exceptionsInvalidArgumentExceptionformatjoinrY   r`   r   rD   CmekSettingsr^   MinimumArgumentExceptionasync_rA   rB   UpdateAsync1LoggingProjectsLocationsBucketsUpdateAsyncRequestrF   rG   rH   r   	LogBucketr
   UpdatedResourcer@   Patch+LoggingProjectsLocationsBucketsPatchRequest)r   r   bucket_dataupdate_maskparameter_namesrd   indexes_to_removeindexes_to_updateindexikeyvaluera   results                 r   _RunUpdate._Run   sO   KKGO())%)%8%8k/")*&&#'#3#3k- '!!"kkk("	!!9	 +,,(,(>(>k$%,-*++(,(=(=k$%,-)))**d.>.>{.K.K(($$T*f$&k.!)!%!1!12B!C!C$

   $//??$

R &&%??//

"
"5??
3./0a"3"6{"CC 1 4 : : <*#&=$* !=  ##A& 1 n
%
,
,U
3 ' 
!::&--chh7H.IJL 	L 
!::8??1BC1B{#1BCAE FG 	G 
		/	*	*&(N#			+	&	&N#t~~5#+,,$$T*f   	!!?	 &&(55++ 6 -m$1.!)88
KM M {{~~::FF




N
N**)),,T2!mm
 .. ((*44C{C+. O f 
&++x$?m^^88>>




H
H**)),,T2!mm
 .. ((*44C{C+. I  [ Ds   4X$c                 $    U R                  U5      $ )zThis 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.

Returns:
  The updated bucket.
)r   rI   s     r   Run
Update.Run?  s     99T?r   )r   )__name__
__module____qualname____firstlineno____doc__r   staticmethodr;   rJ   r   r   __static_attributes____classcell__)r   s   @r   r   r   @   s:    

  `( `(D 0tl
 
r   r   N)r   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   r	   rn   googlecloudsdk.corer
   googlecloudsdk.core.consoler   DETAILED_HELPUniverseCompatibleReleaseTracksReleaseTrackALPHABETAGAUpdateCommandr   detailed_helprf   r   r   <module>r      s    ( &  ' / / ( E # 2	!H T..33T5F5F5I5IET E EP % r   