HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/storage/buckets/__pycache__/update.cpython-312.pyc
�

���=����dZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddl
mZddl
mZdd
l
mZddlmZddlmZddlmZddlmZdZdZdZd�Zd�Zd�Ze	j:e	j<j>�e	j@Gd�de	jB���Z"e	j:e	j<jF�Gd�de"��Z$y)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�	�|jddtd��|j�}tj|�|j�}|jdd��|jdd	��|jd
ddtj�d
��|jddd��|j�}|jdt��|jddd��|jdd��|j�}|jdd��|jddd��|jdt
jd��|j�}|jdt��|j�}|jdd tj�d!�"�|jd#d$tj�d%�"�|jd&dd'��|j�}|jd(t��|jd)dd*��|j�}|jd+d,��|jd-dd.��|j�}	|	jd/d0��|	jd1dd2��|j�}
|
jd3d4t
jd5��|
jd6d7dd8��|j�}|jd9d:��|jd;dd<��|jd=dd>��|jd?t
jd@��|jdAtj�dB�C�|jdDddE��|jdFt
jdG��|jdHt
jdI��|j�}|jdJdK��|jdLddM��|j�}
|
jdNdO��|
jdPddQ��tj|�tj|�tj |�tj"|�tj$|�|j�}|jdRddS��tj&|�yT)Uz�Register 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.)rz--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�metavarrrz!--remove-default-object-acl-grantzTRemoves default object ACL grant. See --remove-acl-grant help text for more details.)rrz--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-holdz�Sets 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)rrrz--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-bucketajEnables 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-prefixz�Specifies 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--papz�If 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-periodaoMinimum [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-periodz�Locks 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-paysz�Allows 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.)rrz--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-suffixz�Cloud 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-pagez�Cloud 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_argsrBOs���	������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��~y)z�Register flags for the alpha version of this command.

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

  N��r2s rA�_add_alpha_argsrG>s��
rCc��|j}|sytj|�xs,t|j|j
|jg�S)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_argsrIs  rA�"_is_initial_bucket_metadata_neededrPIsV��#�1�1�-�	��	"�	7�	7��
�
	��
�
(�
(�
�
(�
(�
�
(�
(�!�	�	rCc�6�eZdZdZddd�Zed��Zd�Zd�Zy)	�Update�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��t|�y�N)rBrFs rA�ArgszUpdate.Argsss
���V�rCc#�HK�tj|tjj��}tj|�rt
jj}nt
jj}tj|j|j�}|D]v}tj|�}tj |j"|�t%j&||t)|���D]}t+j,||������xy�w)N)�
metadata_type)�fields_scope�get_bucket_metadata)rO)r
�'get_user_request_args_from_command_args�MetadataType�BUCKETrJr�FieldsScope�FULL�NO_ACLr�get_urls_iterabler�read_paths_from_stdinr�storage_url_from_stringr	�raise_error_if_not_bucket�command_pathr�get_wildcard_iteratorrPr�UpdateBucketTask)�self�argsrOr\�urls�
url_stringr�resources        rA�update_task_iteratorzUpdate.update_task_iteratorws�����!�I�I�� 9� F� F� M� M�	
��
!�5�5�6G�H��*�*�/�/�l��*�*�1�1�l��+�+����$�,�,��D��
��/�/�
�;�c��+�+�D�,=�,=�s�C�'�=�=�
�#�@��!�"�(�
!�1�1��(9�;�	;�"��s�D D"c	�&�tjj�}t|dd�}t	j
|j
|�||tjtjjd��|j��|_y)N�lock_retention_periodF)�increment_type�
manifest_path)�parallelizable�task_status_queue�progress_manager_args�continue_on_error)
r�multiprocessing_context�Queue�getattrr�
execute_tasksrpr�ProgressManagerArgs�
IncrementType�INTEGERrx�	exit_code)rkrlrv�locks_retention_periods    rA�Runz
Update.Run�s{��+�C�C�I�I�K��$�T�+B�E�J��"�0�0��!�!�$�'�1�1�+�)�=�=�&�4�4�<�<�� ��0�0��D�NrCN)	�__name__�
__module__�__qualname__�__doc__�
detailed_help�staticmethodrYrpr�rErCrArRrRVs6�� �
�
�
�-�0����;�2
rCrRc�*�eZdZdZddd�Zed��Zy)�UpdateAlpharSz
      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
      rTc�0�t|�t|�yrX)rBrGrFs rArYzUpdateAlpha.Args�s���V���F�rCN)r�r�r�r�r�r�rYrErCrAr�r��s*���
�

�
�-�&���rCr�N)%r��
__future__rrr�googlecloudsdk.api_lib.storager�googlecloudsdk.callioperr�"googlecloudsdk.command_lib.storager	r
rrr
r�(googlecloudsdk.command_lib.storage.tasksrrr�0googlecloudsdk.command_lib.storage.tasks.bucketsrr&r(r*rBrGrP�
ReleaseTracks�ReleaseTrack�GA�UniverseCompatible�CommandrR�ALPHAr�rErCrA�<module>r�s���E�&��'�4�/�(�:�4�=�:�H�@�B�H�@�O��� ����$l+�^
�
	�����D�%�%�(�(�)����E�T�\�\�E��*�E�P����D�%�%�+�+�,��&��-�rC