
                  
          d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dej                  j                  fd	Zd
ededede	j                  de	j                  f
dZd
edede	j"                  fdZd
ededede	j                  fdZy)zEUseful commands for interacting with the Cloud Firestore Indexes API.    )absolute_import)division)unicode_literals)	api_utils)firestore_v1_client)firestore_v1_messagesreturnc                  >    t        j                         j                  S )zUReturns the Firestore Index service for interacting with the Firestore Admin service.)r   	GetClient+projects_databases_collectionGroups_indexes     /lib/googlecloudsdk/api_lib/firestore/indexes.py_GetIndexServicer      s     
				J	JJr   projectdatabasecollection_idindexc           	          t        j                         }t               j                  |j	                  dj                  | ||      |            S )aR  Performs a Firestore Admin v1 Index Creation.

  Args:
    project: the project of the database of the index, a string.
    database: the database id of the index, a string.
    collection_id: the current group of the index, a string.
    index: the index to create, a GoogleFirestoreAdminV1Index message.

  Returns:
    an Operation.
  z,projects/{}/databases/{}/collectionGroups/{})parentgoogleFirestoreAdminV1Index)r   GetMessagesr   Create>FirestoreProjectsDatabasesCollectionGroupsIndexesCreateRequestformat)r   r   r   r   messagess        r   CreateIndexr   !   sV    " ""$(			"	"MM?FFx ',	 N 
 r   c                     t        j                         }t               j                  |j	                  dj                  | |                  S )zPerforms a Firestore Admin v1 Index list.

  Args:
    project: the project of the database of the index, a string.
    database: the database id of the index, a string.

  Returns:
    a list of Indexes.
  z+projects/{}/databases/{}/collectionGroups/-)r   )r   r   r   List<FirestoreProjectsDatabasesCollectionGroupsIndexesListRequestr   )r   r   r   s      r   ListIndexesr!   =   sO     ""$(			 	 KK>EEx L 
 r   index_idc           	          t        j                         }t               j                  |j	                  dj                  | ||                  S )a   Performs a Firestore Admin v1 Index Deletion.

  Args:
    project: the project of the database of the index, a string.
    database: the database id of the index, a string.
    index_id: the index id of the index, a string

  Returns:
    an Operation.
  z6projects/{}/databases/{}/collectionGroups/-/indexes/{})name)r   r   r   Delete>FirestoreProjectsDatabasesCollectionGroupsIndexesDeleteRequestr   )r   r   r"   r   s       r   DeleteIndexr'   S   sS     ""$(			"	"MMFMM N 

 
r   N)__doc__
__future__r   r   r    googlecloudsdk.api_lib.firestorer   2googlecloudsdk.generated_clients.apis.firestore.v1r   r   FirestoreV1/ProjectsDatabasesCollectionGroupsIndexesServicer   strGoogleFirestoreAdminV1IndexGoogleLongrunningOperationr   )GoogleFirestoreAdminV1ListIndexesResponser!   r'   r   r   r   <module>r2      s    L &  ' 6 R TK##SSK  !<<	
 558DD,+.55r   