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/datastore/indexes/__pycache__/cleanup.cpython-312.pyc
�

������dZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddlmZddlmZdd
lmZddlmZej,ej.ej0j2ej0j4ej0j6�Gd�dej8���Zy)z-The gcloud datastore indexes cleanup command.�)�absolute_import)�division)�unicode_literals)�yaml_parsing)�	constants)�	index_api)�base)�
exceptions)�parser_arguments)�output_helpers)�flags)�
properties)�
console_ioc��eZdZdZdddd�Zedejddfd	��Zdd
�Z	de
de
ddfd
�Zdejde
de
ddfd�Zy)�Cleanupz Cleanup Cloud Datastore indexes.zHRemove unused datastore indexes based on your local index configuration.z�
This command removes unused datastore indexes based on your local index
configuration. Any indexes that exist that are not in the index file will be
removed.
      z�          To remove unused indexes based on your local configuration, run:

            $ {command} ~/myapp/index.yaml
          )�brief�DESCRIPTION�EXAMPLES�parser�returnNc�X�tj|�tj|�y)zsGet arguments for this command.

    Args:
      parser: argparse.ArgumentParser, the parser for this command.
    N)r
�AddIndexFileFlag�AddDatabaseIdFlag)rs �(lib/surface/datastore/indexes/cleanup.py�ArgszCleanup.Args9s ��
���6�"�	���F�#�c��|jr|jntj}|j|j|��y)z@Deletes indexes that have been removed from the index.yaml file.)�
index_file�databaseN)rr�DEFAULT_NAMESPACErr)�self�args�database_ids   r�RunzCleanup.RunCs4������
�
�I�,G�,G��	�L�L�D�O�O�k�L�Brrrc��tjjjj	d��}t
jj|�}|r'|jt
jjk7rtjdd��tj||g��tjddd��|j!|||�y)	z?Delete indexes that have been removed from the index.yaml file.T)�requiredrz5You must provide the path to a valid index.yaml file.)�project�configsF)�default�throw_if_unattended�cancel_on_noN)r�VALUES�corer'�Getr�ConfigYamlInfo�FromFile�name�INDEXr
�InvalidArgumentExceptionr� DisplayProposedConfigDeploymentsr�PromptContinue�"PerformApiCleanupViaFirestoreAdmin)r!rrr'�infos     rrzCleanup.CleanupKs������$�$�,�,�0�0�$�0�?�G��&�&�/�/�
�;�D��4�9�9�� ;� ;� A� A�A��/�/�
�O�
���3�3��$�������%�d��	�+�+�D�'�8�Drr7r'c��tj|jjxsg�}t	�}tj
||�}|D]j\}}tj|�}	|	|vr� dj|j��}
d}tj|
|d��s�Z|j|��ltj|||�y)a�Cleans up removed indexes via the Firestore Admin API.

    Lists the database's existing indexes, and then compares them against the
    indexes that are defined in the given index.yaml file. Any discrepancies
    against the index.yaml file are deleted.

    Args:
      info: The parsed index.yaml information.
      project: The project we are operating on.
      database: The database within the project we are operating on.
    z<This index is no longer defined in your index.yaml file.
{0}z Do you want to delete this indexT)r)N)
r�NormalizeIndexesForFirestoreApi�parsed�indexes�set�#ListDatastoreIndexesViaFirestoreApi�NormalizeIndexForFirestoreApi�format�ToYAMLrr5�add�DeleteIndexesViaFirestoreApi)r!r7r'r�received_indexes�indexes_to_delete_ids�current_indexes�index_id�index�normalized_index�msg�prompts            rr6z*Cleanup.PerformApiCleanupViaFirestoreAdmin[s���	�1�1�$�+�+�2E�2E�2K��L�� �E���C�C����O�+���%�#�@�@��G��	�-�	-��
I��6�%�,�,�.�!�
�2�f�	�	"�	"�3���	=��!�!�(�+�+��*�*���0�r)rN)�__name__�
__module__�__qualname__�__doc__�
detailed_help�staticmethodr�ArgumentInterceptorrr$�strrrr/r6�rrrr!s���
)��
�
��-�"�$�#�7�7�$�D�$��$�C�E��E�s�E�t�E� $��-�-�$�8;�$�GJ�$��$rrN)rN�
__future__rrr�googlecloudsdk.api_lib.appr� googlecloudsdk.api_lib.datastorerr�googlecloudsdk.callioper	r
r�googlecloudsdk.command_lib.appr�$googlecloudsdk.command_lib.datastorer
�googlecloudsdk.corer�googlecloudsdk.core.consoler�DefaultUniverseOnly�
ReleaseTracks�ReleaseTrack�ALPHA�BETA�GA�CommandrrSrr�<module>rcs���4�&��'�3�6�6�(�.�4�9�6�*�2�������������T�.�.�3�3�T�5F�5F�5I�5I��Z�d�l�l�Z���Zr