
    =                        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KJr  SSKJr  SSKJr  SSKJr  SrSrSrS rS rS r\	R:                  " \	R<                  R>                  5      \	R@                   " S S\	RB                  5      5       5       r"\	R:                  " \	R<                  RF                  5       " S S\"5      5       r$g)z>Implementation of update command for updating bucket settings.    )absolute_import)division)unicode_literals)	cloud_api)arg_parsers)base)errors_util)flags)stdin_iterator)storage_url)user_request_args_factory)wildcard_iterator)task_executor)task_graph_executor)task_status)update_bucket_taska  
Sets the Cross-Origin Resource Sharing (CORS) configuration on a bucket.
An example CORS JSON document looks like the following:

  [
    {
      "origin": ["http://origin1.example.com"],
      "responseHeader": ["Content-Type"],
      "method": ["GET"],
      "maxAgeSeconds": 3600
    }
  ]

For more information about supported endpoints for CORS, see
[Cloud Storage CORS support](https://cloud.google.com/storage/docs/cross-origin#server-side-support).
z
Sets the label configuration for the bucket. An example label JSON document
looks like the following:

  {
    "your_label_key": "your_label_value",
    "your_other_label_key": "your_other_label_value"
  }
ad  
Sets the lifecycle management configuration on a bucket. For example,
The following lifecycle management configuration JSON document
specifies that all objects in this bucket that are more than 365 days
old are deleted automatically:

  {
    "rule":
    [
      {
        "action": {"type": "Delete"},
        "condition": {"age": 365}
      }
    ]
  }
c                    U R                  SS[        SS9  U R                  5       n[        R                  " U5        U R                  5       nUR                  SSS9  UR                  SS	S9  UR                  S
SS[
        R                  " 5       SS9  UR                  SSSS9  U R                  5       nUR                  S[        S9  UR                  SSSS9  U R                  SSS9  U R                  5       nUR                  SSS9  UR                  SSSS9  U R                  S[
        R                  SS9  U R                  5       nUR                  S[        S9  UR                  5       nUR                  SS [
        R                  " 5       S!S"9  UR                  S#S$[
        R                  " 5       S%S"9  UR                  S&SS'S9  U R                  5       nUR                  S([        S9  UR                  S)SS*S9  U R                  5       nUR                  S+S,S9  UR                  S-SS.S9  U R                  5       n	U	R                  S/S0S9  U	R                  S1SS2S9  U R                  5       n
U
R                  S3S4[
        R                  S5S9  U
R                  S6S7SS8S9  U R                  5       nUR                  S9S:S9  UR                  S;SS<S9  U R                  S=SS>S9  U R                  S?[
        R                  S@S9  U R                  SA[
        R                  " 5       SBSC9  U R                  SDSSES9  U R                  SF[
        R                  SGS9  U R                  SH[
        R                  SIS9  U R                  5       nUR                  SJSKS9  UR                  SLSSMS9  U R                  5       nUR                  SNSOS9  UR                  SPSSQS9  [        R                  " U 5        [        R                  " U 5        [        R                   " U 5        [        R"                  " U 5        [        R$                  " U 5        U R                  5       nUR                  SRSSSS9  [        R&                  " U5        gT)UzRegister flags for this command.

Args:
  parser (argparse.ArgumentParser): The parser to add the arguments to.

Returns:
  buckets update flag group
url*z,Specifies the URLs of the buckets to update.)nargstypehelpz--default-object-acl-filez5Sets the default object ACL from file for the bucket.)r   z--predefined-default-object-aclzBApply a predefined set of default object access controls tobucketsz--add-default-object-acl-grantappendDEFAULT_OBJECT_ACL_GRANTzNAdds default object ACL grant. See --add-acl-grant help text for more details.)actionmetavarr   r   z!--remove-default-object-acl-grantzTRemoves default object ACL grant. See --remove-acl-grant help text for more details.)r   r   z--cors-filez--clear-cors
store_truez"Clears the bucket's CORS settings.z--default-storage-classz.Sets the default storage class for the bucket.z--default-encryption-keyz'Set the default KMS key for the bucket.z--clear-default-encryption-keyz+Clears the bucket's default encryption key.z--default-event-based-holdzSets the default value for an event-based hold on the bucket. By setting the default event-based hold on a bucket, newly-created objects inherit that value as their event-based hold (it is not applied retroactively).z--labels-filez--update-labelsLABEL_KEYS_AND_VALUESzFAdd or update labels. Example: --update-labels=key1=value1,key2=value2)r   r   r   z--remove-labels
LABEL_KEYSz!Remove labels by their key names.z--clear-labelsz*Clear all labels associated with a bucket.z--lifecycle-filez--clear-lifecyclez3Removes all lifecycle configuration for the bucket.z--log-bucketaj  Enables usage and storage logging for the bucket specified in the overall update command, outputting log files to the bucket specified in this flag. Cloud Storage does not validate the existence of the bucket receiving logs. In addition to enabling logging on your bucket, you also need to grant cloud-storage-analytics@google.com write access to the log bucket.z--clear-log-bucketzZDisables usage and storage logging for the bucket specified in the overall update command.z--log-object-prefixzSpecifies a prefix for the names of logs generated in the log bucket. The default prefix is the bucket name. If logging is not enabled, this flag has no effect.z--clear-log-object-prefixzTClears the prefix used to determine the naming of log objects in the logging bucket.z--public-access-preventionz--papzIf True, sets [public access prevention](https://cloud.google.com/storage/docs/public-access-prevention) to "enforced". If False, sets public access prevention to "inherited".z --clear-public-access-preventionz--clear-papz8Unsets the public access prevention setting on a bucket.z--retention-periodao  Minimum [retention period](https://cloud.google.com/storage/docs/bucket-lock#retention-periods) for objects stored in the bucket, for example ``--retention-period=P1Y1M1DT5S''. Objects added to the bucket cannot be deleted until they've been stored for the specified length of time. Default is no retention period. Only available for Cloud Storage using the JSON API.z--clear-retention-periodz0Clears the object retention period for a bucket.z--lock-retention-periodzLocks an unlocked retention policy on the buckets. Caution: A locked retention policy cannot be removed from a bucket or reduced in duration. Once locked, deleting the bucket is the only way to "remove" a retention policy.z--requester-payszAllows you to configure a Cloud Storage bucket so that the requester pays all costs related to accessing the bucket and its objects.z--soft-delete-durationzVDuration to retain soft-deleted objects. For example, "2w1d" is two weeks and one day.)r   r   z--clear-soft-deletezZClears bucket soft delete settings. Does not affect objects already in soft-deleted state.z--uniform-bucket-level-accessz|Enables or disables [uniform bucket-level access](https://cloud.google.com/storage/docs/bucket-policy-only) for the buckets.z--versioningzOAllows you to configure a Cloud Storage bucket to keep old versions of objects.z--web-main-page-suffixzCloud Storage allows you to configure a bucket to behave like a static website. A subsequent GET bucket request through a custom domain serves the specified "main" page instead of performing the usual bucket listing.z--clear-web-main-page-suffixz<Clear website main page suffix if bucket is hosting website.z--web-error-pagezCloud Storage allows you to configure a bucket to behave like a static website. A subsequent GET bucket request through a custom domain for a non-existent object serves the specified error page instead of the standard Cloud Storage error.z--clear-web-error-pagez6Clear website error page if bucket is hosting website.z--clear-ip-filterz:Disables and clears IP filter configuration of the bucket.N)add_argumentstr	add_groupr
   add_acl_modifier_flagsr   ArgDictadd_mutually_exclusive_group_CORS_HELP_TEXTStoreTrueFalseAction_LABELS_HELP_TEXTArgList_LIFECYCLE_HELP_TEXTDurationadd_additional_headers_flagadd_autoclass_flagsadd_continue_on_error_flag!add_recovery_point_objective_flagadd_read_paths_from_stdin_flagadd_ip_filter_file_flag)parseracl_flags_groupdefault_acl_flags_groupcorsdefault_encryption_keylabelsupdate_labels	lifecycle
log_bucketlog_object_prefixpublic_access_preventionretention_periodweb_main_page_suffixweb_error_page	ip_filters                  %lib/surface/storage/buckets/update.py_add_common_argsrB   O   s    	9	   $$&//",,.&&!B '  &&'O '  &&&(  ' 	 &&)	 '  
	,	,	.$M8/  1 	;   ">>@%% 4 & 6 %%&8 & : 	"--!  " ..0&o,=>""$-% 1	  2  .	  0
 	7  9 113)+2FG@  B 224*   !  "
 99;  + ! ,
   ! ! 
 $@@B''"--A	 ( B ''(E	 (  88:/   0  =   ? 	&  ' 	--   	!$	   	$	   	%--	   	--"	    <<>### $  ##$I $ 
 668.:   C  
 ##F+F#""6*))&1&&v.113)G  
 	*    c                     A g)zRegister flags for the alpha version of this command.

Args:
  parser (argparse.ArgumentParser): The parser to add the arguments to.

N r2   s    rA   _add_alpha_argsrG   >  s     rC   c                     U R                   nU(       d  g[        R                  " U 5      =(       d,    [        UR                  UR
                  UR                  /5      $ )z?Determines if the bucket update has to patch existing metadata.F)resource_argsr   adds_or_removes_aclsanylabels_file_pathlabels_to_appendlabels_to_remove)user_request_argsrI   s     rA   "_is_initial_bucket_metadata_neededrP   I  sV    #11-		"	7	7
 
	

(
(

(
(

(
(! 		rC   c                   >    \ rS rSrSrSSS.r\S 5       rS rS r	S	r
g
)UpdateiV  Update bucket settings.z/
      Update the settings for a bucket.
      aK  

      The following command updates the default storage class of a Cloud Storage
      bucket named "my-bucket" to NEARLINE and sets requester pays to true:

        $ {command} gs://my-bucket --default-storage-class=NEARLINE --requester-pays

      The following command updates the retention period of a Cloud Storage
      bucket named "my-bucket" to one year and thirty-six minutes:

        $ {command} gs://my-bucket --retention-period=1y36m

      The following command clears the retention period of a bucket:

        $ {command} gs://my-bucket --clear-retention-period
      DESCRIPTIONEXAMPLESc                     [        U 5        g N)rB   rF   s    rA   ArgsUpdate.Argss  s
    VrC   c              #   T  #    [         R                  " U[         R                  R                  S9n[         R                  " U5      (       a  [
        R                  R                  nO[
        R                  R                  n[        R                  " UR                  UR                  5      nU Hv  n[        R                  " U5      n[        R                   " UR"                  U5        [$        R&                  " UU[)        U5      S9 H  n[*        R,                  " XrS9v   M     Mx     g 7f)N)metadata_type)fields_scopeget_bucket_metadata)rO   )r   'get_user_request_args_from_command_argsMetadataTypeBUCKETrJ   r   FieldsScopeFULLNO_ACLr   get_urls_iterabler   read_paths_from_stdinr   storage_url_from_stringr	   raise_error_if_not_bucketcommand_pathr   get_wildcard_iteratorrP   r   UpdateBucketTask)selfargsrO   r]   urls
url_stringr   resources           rA   update_task_iteratorUpdate.update_task_iteratorw  s     !II 9 F F M M	
 
 !556GHH**//l**11l++$,,D 
//
;c++D,=,=sC'==
#@!"(
 !11; 	;" s   D&D(c           
      &   [         R                  R                  5       n[        USS5      n[        R
                  " U R                  U5      U(       + U[        R                  " [        R                  R                  S S9UR                  S9U l        g )Nlock_retention_periodF)increment_typemanifest_path)parallelizabletask_status_queueprogress_manager_argscontinue_on_error)r   multiprocessing_contextQueuegetattrr   execute_tasksrq   r   ProgressManagerArgsIncrementTypeINTEGERrz   	exit_code)rl   rm   rx   locks_retention_periods       rA   Run
Update.Run  s{    +CCIIK$T+BEJ"00!!$'11+)==&44<<  00DNrC   )r   N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodrY   rq   r   __static_attributes__rE   rC   rA   rR   rR   V  s6      

-0  ;2rC   rR   c                   2    \ rS rSrSrSSS.r\S 5       rSrg)	UpdateAlphai  rS   z
      Update a bucket.
      aW  

      The following command updates the retention period of a Cloud Storage
      bucket named "my-bucket" to one year and thirty-six minutes:

        $ {command} gs://my-bucket --retention-period=1y36m

      The following command clears the retention period of a bucket:

        $ {command} gs://my-bucket --clear-retention-period
      rT   c                 0    [        U 5        [        U 5        g rX   )rB   rG   rF   s    rA   rY   UpdateAlpha.Args  s    VFrC   rE   N)	r   r   r   r   r   r   r   rY   r   rE   rC   rA   r   r     s*    


-&  rC   r   N)%r   
__future__r   r   r   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.storager	   r
   r   r   r   r   (googlecloudsdk.command_lib.storage.tasksr   r   r   0googlecloudsdk.command_lib.storage.tasks.bucketsr   r&   r(   r*   rB   rG   rP   ReleaseTracksReleaseTrackGAUniverseCompatibleCommandrR   ALPHAr   rE   rC   rA   <module>r      s    E &  ' 4 / ( : 4 = : H @ B H @ O   $l+^
	 D%%(()ET\\ E  *EP D%%++,&  -rC   