
    Y                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  S
 rSrSrSrSS jrS rS r " S S\R(                  5      rg)z0Utility functions for gcloud firestore emulator.    )absolute_import)division)unicode_literalsN)util)execution_utils)log)	platformsc                    [         R                  R                  5       nU[         R                  R                  L aQ  Sn[        R
                  R                  [        R                  " [        5      U5      n[        R                  " U/U Q76 $ Sn[        R
                  R                  [        R                  " [        5      U5      n[        R                  " U/U Q76 $ )zConstructs an argument list for calling the Firestore emulator.

Args:
  emulator_args: args for the emulator.

Returns:
  An argument list to execute the Firestore emulator.
zcloud_firestore_emulator.cmdcloud_firestore_emulator)r	   OperatingSystemCurrentWINDOWSospathjoinr   GetEmulatorRootCLOUD_FIRESTOREr   ArgsForCMDToolArgsForExecutableTool)emulator_args
current_oscmdexes       :lib/googlecloudsdk/command_lib/emulators/firestore_util.pyArgsForFirestoreEmulatorr      s     ((002*9,,444
(C
'',,t++O<c
BC))#>>>
$C
'',,t++O<c
BC00E}EE    	firestorezcloud-firestorezGoogle Cloud Firestore emulatorc                    S/nUR                  SR                  U R                  R                  5      5        UR                  SR                  U R                  R                  5      5        U R
                  (       a*  UR                  SR                  U R
                  5      5        U R                  (       a  UR                  S5        O*UR                  SR                  U R                  5      5        U R                  (       a*  UR                  SR                  U R                  5      5        U R                  (       a*  UR                  SR                  U R                  5      5        U R                  (       a  UR                  S	5        [        U5      n[        R                  R                  S
R                  SR                  U5      5      5        [         R"                  " X1S9$ )a  Starts the firestore emulator with the given arguments.

Args:
  args: Arguments passed to the start command.
  log_file: optional file argument to reroute process's output.

Returns:
  process, The handle of the child process running the datastore emulator.
startz
--host={0}z
--port={0}z--rules={0}z--database-mode=datastore-modez--database-mode={0}z--import-data={0}z--export-on-exit={0}z
--licenseszExecuting: {0} )log_file)appendformat	host_porthostportrulesuse_firestore_in_datastore_modedatabase_modeimport_dataexport_on_exitlicensesr   r   statusPrintr   r   Exec)argsr!   
start_args	exec_argss       r   StartFirestoreEmulatorr3   5   sT    y*L''(;(;<=L''(;(;<=	ZZm**4::67	))67+2243E3EFG	)001A1ABC	,33D4G4GHI	]]l#&z2)**#**388I+>?@	9	00r   c                     g N )r0   s    r   ValidateStartArgsr7   T   s    r   c                  6    [         R                  " [        5      $ r5   )r   GetHostPort	FIRESTOREr6   r   r   r9   r9   X   s    			)	$$r   c                   ^    \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	\S 5       r
Srg	)
FirestoreEmulator\   z=Represents the ability to start and route firestore emulator.c                 j    [         R                  " SSUS.05      n[        X R                  5       5      $ )Nr$   	localhost)r%   r&   )r   AttrDictr3   	_GetLogNo)selfr&   r0   s      r   StartFirestoreEmulator.Start_   s7    ==
 D "$(899r   c                     S/$ )Nzgoogle.firestorer6   rB   s    r   prefixesFirestoreEmulator.prefixesh   s    r   c                     [         $ r5   )r:   rF   s    r   service_nameFirestoreEmulator.service_namel   s    r   c                     [         $ r5   )FIRESTORE_TITLErF   s    r   emulator_title FirestoreEmulator.emulator_titlep   s    r   c                     g)Nzcloud-firestore-emulatorr6   rF   s    r   emulator_component$FirestoreEmulator.emulator_componentt   s    %r   r6   N)__name__
__module____qualname____firstlineno____doc__rC   propertyrG   rJ   rN   rQ   __static_attributes__r6   r   r   r<   r<   \   sZ    E:         & &r   r<   r5   )rW   
__future__r   r   r   r   $googlecloudsdk.command_lib.emulatorsr   googlecloudsdk.corer   r   googlecloudsdk.core.utilr	   r   r:   r   rM   r3   r7   r9   Emulatorr<   r6   r   r   <module>r_      sX    7 &  ' 	 5 / # .F( 	#31>%& &r   