
                             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\R                  5      r " S S\R                  5      r " S S\R                  5      rS rg)z Utilities for database creation.    )absolute_import)division)unicode_literals)
exceptions)appengine_api_client)base)log)
propertiesc                       \ rS rSrSrSrg)AppEngineAppDoesNotExist   z(An App Engine app must be created first. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       7lib/googlecloudsdk/command_lib/firestore/create_util.pyr   r      s    0r   r   c                       \ rS rSrSrSrg)AppEngineAppRegionDoesNotMatch    z.An App Engine app must have a matching region.r   Nr   r   r   r   r   r       s    6r   r   c                       \ rS rSrSrSrg)RegionNotSpecified$   z*Must specify a region to use this command.r   Nr   r   r   r   r   r   $   s    2r   r   c                    [         R                  " [        R                  R                  5      nSn UR                  5       nUR                  nU (       d  [        SR                  US95      eXP:w  a  [        SR                  XPS95      e[        R                  R                  R                   R#                  S	S
9nUR$                  U:w  a  UR'                  U5        O-[(        R*                  R-                  SR                  XS95        g[(        R*                  R-                  SR                  XS95        g! [        R                   a'    U c  [        S5      e[        SR                  U S95      ef = f)aA  Helper for implementing Firestore database create comamnds.

Guides the user through the gcloud app creation process and then updates the
database type to the requested type.

Args:
  region: The region of Firestore database.
  product_name: The product name of the database trying to be created.
  enum_value: Enum value representing the product name in the API.

Raises:
  AppEngineAppDoesNotExist: If no app has been created.
  AppEngineAppRegionDoesNotMatch: If app created but region doesn't match the
   --region flag.
  RegionNotSpecified: User didn't specify --region.
NzYou must first create a Google App Engine app by running:
gcloud app create
The region you create the App Engine app in is the same region that the Firestore database will be created in. Once an App Engine region has been chosen it cannot be changed.zzYou must first create an Google App Engine app in the corresponding region by running:
gcloud app create --region={region})regionzYou must specify a region using the --region flag to use this command. The region needs to match the Google App Engine region: --region={current_region})current_regionzThe app engine region is {current_region} which is not the same as {region}. Right now the Firestore region must match the App Engine region.
Try running this command with --region={current_region})r    r   T)requiredzGSuccess! Confirmed selection of a {product_name} database for {project})product_nameprojectz7Success! Selected {product_name} database for {project})r   GetApiClientForTrackr   ReleaseTrackGAGetApplicationapitools_exceptionsHttpNotFoundErrorr   format
locationIdr   r   r
   VALUEScorer#   GetdatabaseTypeUpdateDatabaseTyper	   statusPrint)r   r"   
enum_value
api_clientappr    r#   s          r   creater6   (   s   " $889J9J9M9MN*#G

#
#
%C >>.	
	$$*F.F$IK K
 
(	B CI&) CI C:	; ; ""**...='#!!*-JJQ	\	;= **?FF# G 67O 
	.	. G~$LM M %006f0EG GGs   D7 7;E2N)r   
__future__r   r   r   apitools.base.pyr   r(   googlecloudsdk.api_lib.appr   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   Errorr   r   r   r6   r   r   r   <module>r=      s`    ' &  ' > ; ( # *1288 17%8%>%> 73,22 3?7r   