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__/relocate.cpython-312.pyc
�

��W ��Z�dZddlZddlmZddlmZddlmZddlmZddl	mZ
ddl	mZddl	mZdd	l	m
Z
dd
l	mZddlmZddlmZej&d
�Zej&d�Zej&d�Zd�Zd�Zd�Zej4Gd�dej6��Zy)z+Implementation of buckets relocate command.�N)�api_factory)�errors)�arg_parsers)�base)�errors_util)�flags)�operations_util)�storage_url)�log)�
console_ioa5
1. This move will involve write downtime.
2. In-flight resumable uploads not finished before the write downtime will be lost.
3. Bucket tags added to the bucket will result in the relocation being canceled.
4. Please ensure that you have sufficient quota in the destination before performing the relocation.
z�
1. This is a policy change move (no write downtime).
2. Please ensure that you have sufficient quota in the destination before performing the relocation.
zl
1. Any ongoing, in-flight resumable uploads will be canceled and lost.
2. Write downtime will be incurred.
c��	|j|j�S#tj$r}t	j
|�|�d}~wwxYw)z=Fetches the bucket resource for the given bucket storage URL.N)�
get_bucket�bucket_name�
api_errors�
CloudApiError�command_errors�
FatalError)�
gcs_client�
bucket_url�es   �'lib/surface/storage/buckets/relocate.py�_get_bucket_resourcer6sG��.�� � ��!7�!7�8�8��	�	!�	!�.�
�
#�
#�A�
&�A�-��.�s��A�A�Ac��|jry|j�}|jr|d|j��z
}|jj�|jj�k(rt}nt
}t
jd|j�d|�d��t
j|�tjd|j�d�d�	�tjjd
|j�d��y)z*Prompt the user to confirm the relocation.N� zThe bucket z is in �.zWPlease acknowledge that you've read the above warnings and want to relocate the bucket �?T��
prompt_string�cancel_on_nozStarting bucket relocation for z...
)
�dry_run�location�data_locations�casefold�1_BUCKET_RELOCATION_WITHOUT_WRITE_DOWNTIME_WARNING�*_BUCKET_RELCOCATION_WRITE_DOWNTIME_WARNINGr�warning�urlr�PromptContinue�status�Print)�bucket_resource�args�source_location�warning_messages    r�&_prompt_user_to_confirm_the_relocationr/>s���	�\�\�
�&�/�/�0�/��#�#���?�9�9�:�;�;�O����&�&�(�D�M�M�,B�,B�,D�D�G�O�@�O��+�+��D�H�H�:�W�_�,=�Q�?�@��+�+�o�����"�"&�(�(��1�.����*�*���4�T�X�X�J�e�D�E�c�l�tjt�tjd|�d�d��y)z4Prompt the user to confirm advancing the relocation.z?This will start the write downtime for your relocation of gs://z$, are you sure you want to continue?TrN)rr&�$_ADVANCING_BUCKET_RELOCATION_WARNINGrr()rs r�0_prompt_user_to_confirm_advancing_the_relocationr3Zs2���+�+�2�3����
K�
�M�=�?��r0c�0�eZdZdZddd�Zed��Zd�Zy)�Relocatez-Relocates bucket between different locations.z=
      Relocates a bucket between different locations.
      a<
      To move a bucket (``gs://my-bucket'') to the ``us-central1'' location, use
      the following command:

          $ {command} gs://my-bucket --location=us-central1

      To move a bucket to a custom dual-region, use the following command:

          $ {command} gs://my-bucket --location=us
              --placement=us-central1,us-east1

      To validate the operation without actually moving the bucket, use the
      following command:

          $ {command} gs://my-bucket --location=us-central1 --dry-run

      To schedule a write lock for the move, with ttl for reverting the write
      lock after 7h, if the relocation has not succeeded, use the following
      command:

          $ {command}
              --operation=projects/_/buckets/my-bucket/operations/C894F35J
              --finalize --ttl=7h
      )�DESCRIPTION�EXAMPLESc�.�|jd�|jd��}|jd�}|jd�|jdtd��|jdtdd	�
�tj|�|jddd
��|jd�}|jd�|jdtdd�
�|jdddd��|jdtj�d��y)NFT)�requiredz7Arguments for initiating the bucket relocate operation.r'z"The URL of the bucket to relocate.)�type�helpz
--locationz�The final [location](https://cloud.google.com/storage/docs/locations) where the bucket will be relocated to. If no location is provided, Cloud Storage will use the default location, which is us.)r:r9r;z	--dry-run�
store_truez�Prints the operations that the relocate command would perform without actually performing relocation. This is helpful to identify any issues that need to be detected asynchronously.)�actionr;z1Arguments for advancing the relocation operation.z--operationz�Specify the relocation operation name to advance the relocation operation.The relocation operation name must include the Cloud Storage bucket and operation ID.z
--finalizeaSchedules the write lock to occur. Once activated, no further writes will be allowed to the associated bucket. This helps minimize disruption to bucket usage. For certain types of moves(between Multi Region and Custom Dual Regions), finalize is not required.)r=r9r;z--ttlzKTime to live for the relocation operation. Defaults to 12h if not provided.)	�SetSortArgs�add_mutually_exclusive_group�	add_group�add_argument�strr�add_placement_flagr�Duration)�cls�parser�relocate_arguments_group�bucket_relocate_group� advance_relocate_operation_groups     r�Argsz
Relocate.Args�sT��
���u��%�B�B�� C� ��5�>�>�A����%�%�e�,��&�&�
�
�
1�'��
�&�&��
��
C�'�
�
���2�3��&�&���
L�	'��(@�'I�'I�;�(�$�%�0�0��7�$�1�1��
��
0�2�	�%�1�1����
�2��%�1�1��
�
!�
!�
#�
�	2�r0c�|�tjtjj�}|j
r�tj|j
�}tj|j|�t||�}t||�|j|j|j|j|j �St#j$|j&�\}}t)|�|j+|||j,�t.j0j3d|�d|�d��y)Nz3Sent request to advance relocation for bucket gs://z with operation r)r�get_apir
�ProviderPrefix�GCSr'�storage_url_from_stringr�raise_error_if_not_gcs_bucket�command_pathrr/�relocate_bucketrr!�	placementr r	�%get_operation_bucket_and_id_from_name�	operationr3�advance_relocate_bucket�ttlrr)r*)�selfr,rr'r+�bucket�operation_ids       r�RunzRelocate.Run�s����$�$�[�%?�%?�%C�%C�D�J��x�x��/�/����9�c��/�/��0A�0A�3�G�,�Z��=�o�,�_�d�C�
�
'�
'�

�/�/�
�-�-�
�.�.�
�,�,�	��	�=�=�d�n�n�M��F�L�5�V�<��&�&�v�|�T�X�X�F��J�J���
=�f�X�F�"�^�1�	&�r0N)�__name__�
__module__�__qualname__�__doc__�
detailed_help�classmethodrJr[�r0rr5r5gs2��5�
�
�	�-�<�E��E�Nr0r5)r_�textwrap�googlecloudsdk.api_lib.storagerrr�googlecloudsdk.callioperr�"googlecloudsdk.command_lib.storagerrrr	r
�googlecloudsdk.corer�googlecloudsdk.core.consoler�dedentr%r$r2rr/r3�DefaultUniverseOnly�Commandr5rbr0r�<module>rls��� 2��6�?�/�(�G�:�4�>�:�#�2�.=�X�_�_�>�.�*�5D�H�O�O�E�5�1�(7�x���8�(�$�.�F�8	����B�t�|�|�B��Br0