
                              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rS	rS
r " S S\R                  5      r " S S\R                  5      rS rS r   SS jr    SS jrg)zUtilities for app creation.    )absolute_import)division)unicode_literals)
exceptions)log)
console_iozCreating an App Engine application for a project is irreversible and the region
cannot be changed. More information about regions is at
<https://cloud.google.com/appengine/docs/locations>.
a  Starting from March, 2025, App Engine sets the automatic scaling maximum instances
default for standard environment deployments to 20. This change doesn't impact
existing apps. To override the default, specify the new max_instances value in your
app.yaml file, and deploy a new version or redeploy over an existing version.
For more details on max_instances, see
<https://cloud.google.com/appengine/docs/standard/reference/app-yaml.md#scaling_elements>.
aZ  Cloud Run offers the most modern fully managed application hosting experience
with lower minimum billable times and support for GPUs on demand for your AI/ML workloads.
Deploy code written in any programming language supported by App Engine on Cloud Run.
Learn more at https://cloud.google.com/run/docs/quickstarts#build-and-deploy-a-web-service
c                       \ rS rSrSrSrg)UnspecifiedRegionError2   zERegion is not provided on the command line and running interactively. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       1lib/googlecloudsdk/command_lib/app/create_util.pyr
   r
   2   s    Mr   r
   c                       \ rS rSrSrSrg)AppAlreadyExistsError6   z0The app which is getting created already exists.r   Nr   r   r   r   r   r   6   s    8r   r   c                 j    U R                  SSS9  U R                  SSS9  U R                  SSS/S	S
9  g)z-Add the common flags to a app create command.z--regionzThe region to create the app within.  Use `gcloud app regions list` to list available regions.  If not provided, select region interactively.)helpz--service-accountaw            The app-level default service account to create the app with.
          Note that you can specify a distinct service account for each
          App Engine version with `gcloud app deploy --service-account`.
          However if you do not specify a version-level service account,
          this default will be used. If this parameter is not provided for app
          creation, the app-level default will be set to be the out-of-box
          App Engine Default Service Account,
          https://cloud.google.com/appengine/docs/standard/python3/service-account
          outlines the limitation of that service account.z--ssl-policyTLS_VERSION_1_0TLS_VERSION_1_2z0The app-level SSL policy to create the app with.)choicesr   N)add_argument)parsers    r   AddAppCreateFlagsr    :   s^    :   		>   	 "34=  r   c                      U R                  5       nUR                  (       a  SR                  UR                  5      OSn[        SR                  XS95      e! [        R
                   a     gf = f)zRaises an error if the app already exists.

Args:
  api_client: The App Engine Admin API client
  project: The GCP project

Raises:
  AppAlreadyExistsError if app already exists
z in region [{}] zThe project [{project}] already contains an App Engine application{region}.  You can deploy your application using `gcloud app deploy`.)projectregionN)GetApplication
locationIdformatr   apitools_exceptionsHttpNotFoundError)
api_clientr#   appr$   s       r   CheckAppNotExistsr,   X   so    	G

#
#
%C :=%%cnn5RF
	%vgvEG G	 
	.	. 		s   A A/.A/Nc                 4   U R                   R                  R                  R                  U R                   R                  R                  R                  S.R                  U5      nU(       d  [        R                  R                  SR                  US95        U(       a,  [        R                  R                  SR                  US95        U(       a,  [        R                  R                  SR                  US95        [        R                  " [        5        [        R                  " [        5        [        R                  R                  S[        -   5         U R                  X$US	9  g! [        R                    a    [#        S
R                  US95      ef = f)a1  Create an App Engine app in the given region.

Prints info about the app being created and displays a progress tracker.

Args:
  api_client: The App Engine Admin API client
  project: The GCP project
  region: The region to create the app
  suppress_warning: True if user doesn't need to be warned this is
    irreversible.
  service_account: The app level service account for the App Engine app.
  ssl_policy: str, the app-level SSL policy to update for this App Engine app.
    Can be default or modern.

Raises:
  AppAlreadyExistsError if app already exists
)r   r   z0You are creating an app for project [{project}].)r#   zHDesignating app-level default service account to be [{service_account}].)service_accountz6Designating app-level SSL policy to be [{ssl_policy}].)
ssl_policyNOTE: )r.   r/   z~The project [{project}] already contains an App Engine application. You can deploy your application using `gcloud app deploy`.N)messagesApplicationSslPolicyValueValuesEnumDEFAULTMODERNgetr   statusPrintr'   warningAPP_CREATE_WARNING,DEFAULT_MAX_INSTANCES_FORWARD_CHANGE_WARNINGTRY_CLOUD_RUN_NUDGE_MSG	CreateAppr(   HttpConflictErrorr   )r*   r#   r$   suppress_warningr.   r/   ssl_policy_enums          r   r=   r=   n   se   8 


)
)
B
B
J
J 


)
)
B
B
I
I C
O  
JJ:AA 	B 	

 	jj!!'!H 	jj
B
I
I# J 
 KK"#KK<=JJX 778O   
	.	. 
	EEKV FL F s   E* *-Fc           	         [         R                  R                  SR                  U5      5        [         R                  " [
        5        [         R                  " [        5        [         R                  R                  S[        -   5        U=(       d%    [        [        U R                  5       5      [        S9nU(       a  [         R                  " U5        [        R                  " USSS9nX&   n[        U UUR                  SUUS9  g)	a  Interactively choose a region and create an App Engine app.

The caller is responsible for calling this method only when the user can be
prompted interactively.

Example interaction:

    Please choose the region where you want your App Engine application
    located:

      [1] us-east1      (supports standard and flexible)
      [2] europe-west   (supports standard)
      [3] us-central    (supports standard and flexible)
      [4] cancel
    Please enter your numeric choice:  1

Args:
  api_client: The App Engine Admin API client
  project: The GCP project
  regions: The list of regions to choose from; if None, all possible regions
    are listed
  extra_warning: An additional warning to print before listing regions.
  service_account: The app level service account for the App Engine app.
  ssl_policy: str, the app-level SSL policy to update for this App Engine app.
    Can be default or modern.

Raises:
  AppAlreadyExistsError if app already exists
z)You are creating an app for project [{}].r0   )keyzNPlease choose the region where you want your App Engine application located:

T)messagecancel_option)r?   r.   r/   N)r   r7   r8   r'   r9   r:   r;   r<   sortedsetListRegionsstrr   PromptChoicer=   r$   )r*   r#   regionsextra_warningr.   r/   idxr$   s           r   CreateAppInteractivelyrM      s    J **>EEgNO++ !++:;**8556Evc*"8"8":;E'KK% 	# <&mm%r   )FNN)Nr"   NN)r   
__future__r   r   r   apitools.base.pyr   r(   googlecloudsdk.corer   googlecloudsdk.core.consoler   r:   r;   r<   Errorr
   r   r    r,   r=   rM   r   r   r   <module>rS      s     " &  ' > * # 2 
0 , NZ-- N9J,, 9<G4 AN >r   