
    ,                        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  \R,                  \R.                  " \R0                  R2                  \R0                  R4                  5       " S S\R6                  5      5       5       r\R,                  \R.                  " \R0                  R:                  5       " S S\5      5       5       rg)z,The gcloud datastore indexes create command.    )absolute_import)division)unicode_literals)yaml_parsing)	constants)	index_api)base)
exceptions)parser_arguments)output_helpers)flags)
properties)
console_ioc                   x    \ rS rSrSrSSSS.r\S\R                  SS	4S
 j5       r	SS jr
S\S\S\SS	4S jrSrg	)Create!   zCreate Cloud Datastore indexes.zECreate new datastore indexes based on your local index configuration.z
Create new datastore indexes based on your local index configuration.
Any indexes in your index file that do not exist will be created.
      a)            To create new indexes based on your local configuration, run:

            $ {command} ~/myapp/index.yaml

          Detailed information about index configuration can be found at the
          [index.yaml reference](https://cloud.google.com/datastore/docs/tools/indexconfig).
          )briefDESCRIPTIONEXAMPLESparserreturnNc                 \    [         R                  " U 5        [         R                  " U 5        g)zGet arguments for this command.N)r   AddIndexFileFlagAddDatabaseIdFlag)r   s    'lib/surface/datastore/indexes/create.pyArgsCreate.Args9   s      
6"	F#    c                     UR                   (       a  UR                   O[        R                  nU R                  UR                  USS9  g)z9Create missing indexes as defined in the index.yaml file.F
index_filedatabaseenable_vectorNr"   r   DEFAULT_NAMESPACECreateIndexesr!   selfargsdatabase_ids      r   Run
Create.Run?   s>     I,G,G  	??[  r   r!   r"   r#   c                    [         R                  R                  R                  R	                  SS9n[
        R                  R                  U5      nU(       a(  UR                  [
        R                  R                  :w  a  [        R                  " SS5      e[        R                  " XE/S9  [        R                  " SSSS9  [         R"                  " UUUR$                  US9  g	)
a  Cleates missing 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 created.

Args:
  index_file: The users definition of their desired indexes.
  database: The database within the project we are operating on.
  enable_vector: Whether or not vector indexes are supported.
T)requiredr!   z5You must provide the path to a valid index.yaml file.)projectconfigsF)defaultthrow_if_unattendedcancel_on_no)
project_idr*   index_definitionsr#   N)r   VALUEScorer/   Getr   ConfigYamlInfoFromFilenameINDEXr
   InvalidArgumentExceptionr    DisplayProposedConfigDeploymentsr   PromptContinuer   #CreateMissingIndexesViaFirestoreApiparsed)r(   r!   r"   r#   r/   infos         r   r&   Create.CreateIndexesI   s     $$,,00$0?G&&//
;D499 ; ; A AA//
O  33 %d 11++#	r    r   N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   ArgumentInterceptorr   r+   strboolr&   __static_attributes__rD   r   r   r   r   !   sp     (
-& $#77 $D $ $
  '* ;?  r   r   c                   "    \ rS rSrSrSS jrSrg)CreateFirestoreAPIl   z2Create Cloud Datastore indexes with Firestore API.Nc                     UR                   (       d  [        R                  OUR                   nU R                  UR                  USS9$ )NTr    r$   r'   s      r   r+   CreateFirestoreAPI.Runq   sC     ,0==	##dmm  ??[   r   rD   rE   )rF   rG   rH   rI   rJ   r+   rP   rD   r   r   rR   rR   l   s     ;r   rR   N)rJ   
__future__r   r   r   googlecloudsdk.api_lib.appr    googlecloudsdk.api_lib.datastorer   r   googlecloudsdk.callioper	   r
   r   googlecloudsdk.command_lib.appr   $googlecloudsdk.command_lib.datastorer   googlecloudsdk.corer   googlecloudsdk.core.consoler   DefaultUniverseOnlyReleaseTracksReleaseTrackBETAGACommandr   ALPHArR   rD   r   r   <module>re      s    3 &  ' 3 6 6 ( . 4 9 6 * 2 D%%**D,=,=,@,@AFT\\ F B FR D%%++,
 
 - 
r   