
    h                     4   d Z ddlmZ ddlmZ ddlmZ ddl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  ej                  ej                  j                   ej                  j"                        ej$                   G d dej&                                      Zy)z(gcloud datastore emulator start command.    )absolute_import)division)unicode_literalsN)arg_parsers)base)datastore_util)util)javac                   .    e Zd ZdZddiZed        Zd Zy)StartzWStart a local datastore emulator.

  This command starts a local datastore emulator.
  EXAMPLESzN
To start a local datastore emulator, run:

  $ {command} --data-dir=DATA-DIR
c                     | j                  ddd d       | j                  dddd	
       | j                         }|j                  ddt        dd       |j                  dddd
       y )Nz--host-portFc                 D    t         j                  j                  | d      S )NTipv6_enabled)r   HostPortParse)args    (lib/surface/emulators/datastore/start.py<lambda>zStart.Args.<locals>.<lambda>2   s    --33Cd3K    a*  The host:port to which the emulator should be bound. Can take the form of a single address (hostname, IPv4, or IPv6) and/or port:

  [ADDRESS][:PORT]

In this format you must enclose IPv6 addresses in square brackets: e.g.

  [2001:db8:0:0:0:ff00:42:8329]:8080

The default value is localhost:8081.)requiredtypehelpz--store-on-diskT
store_truez)Whether data should be persisted to disk.)defaultactionr   z--consistencyg?zFraction of eventually consistent operations that should succeed immediately. Setting to 1.0 can be useful for unit tests, but may mask incorrect assumptions about non-ancestor queries which are eventually consistent.)r   r   r   r   z!--use-firestore-in-datastore-modezRuns the emulator in Cloud Firestore in Datastore Mode. Reads are always strongly consistent and --consistency flag may not be specified.)add_argumentadd_mutually_exclusive_groupfloat)parsergroups     r   Argsz
Start.Args-   s    
K/	  
0 8	  :
 //1E	E  F 
+	  r   c                 j   |j                   sFt        j                  j                  t	        j
                         t        j                        |_         |j                   j                  xs d|j                   _        |j                   j                  xs d|j                   _	        t        j                  t        j                  d       t	        j                  |       t	        j                  |      5 }t	        j                  |       t!        j"                  |d       d d d        y # 1 sw Y   y xY w)Nr   	localhost8081   )min_version	datastore)	host_portr   r   r   r   GetHostPortsockethas_ipv6hostportr
   RequireJavaInstalledDATASTORE_TITLEPrepareGCDDataDirStartGCDEmulatorWriteGCDEnvYamlr	   PrefixOutput)selfargsprocs      r   Runz	Start.RunQ   s    >>"++11

$
$
&V__ 2 Fdn..--<DNN..--7DNNn<<"M$$T*		(	(	.$$$T*
k* 
/	.	.s   4,D))D2N)__name__
__module____qualname____doc__detailed_helpstaticmethodr#   r9    r   r   r   r      s2      - ! !F+r   r   )r=   
__future__r   r   r   r,   googlecloudsdk.callioper   r   $googlecloudsdk.command_lib.emulatorsr   r	   googlecloudsdk.command_lib.utilr
   ReleaseTracksReleaseTrackALPHABETADefaultUniverseOnlyCommandr   r@   r   r   <module>rK      sz    / &  '  / ( ? 5 0 D%%++T->->-C-CD=+DLL =+  E=+r   