
    e                         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 r
\R                  4S jr\R                  4S	 jrS
 rS r\4S jrg)z#Utilities for handling region flag.    )
exceptions)	constants)log)
properties)
console_ioc                      [         R                  R                  R                  R	                  5       [         R                  R                  R                  R
                  :H  $ N)r   VALUEScoreuniverse_domainGetdefault     0lib/googlecloudsdk/command_lib/ai/region_util.py_IsDefaultUniverser      sE    ,,002						/	/	7	78r   c                    ^  U 4S j$ )z]Returns a no argument function that prompts available regions and catches the user selection.c                     > [        T 5      $ r	   )PromptForRegionavailable_regionss   r   <lambda>(GetPromptForRegionFunc.<locals>.<lambda>"   s    !23r   r   r   s   `r   GetPromptForRegionFuncr       s	    	33r   c                    [         R                  " 5       (       ae  [        5       (       aU  [        U 5      n[         R                  " USSS9nX   n[
        R                  R                  SR                  U5      5        U$ gg)aP  Prompt for region from list of available regions.

This method is referenced by the declaritive iam commands as a fallthrough
for getting the region. Prompts only in GDU

Args:
  available_regions: list of the available regions to choose from

Returns:
  The region specified by the user, str, or None if not in GDU or cannot
  prompt.
Please specify a region:
Tmessagecancel_optionGTo make this the default region, run `gcloud config set ai/region {}`.
N)	r   	CanPromptr   listPromptChoicer   statusPrintformat)r   all_regionsidxregions       r   r   r   %   sv      2 4 4()K

!
!9OCFJJ ;;A6&>KM !5r   c                     [         R                  " 5       (       as  [        5       (       ac  [        [        R
                  5      n [         R                  " U SSS9nX   n[        R                  R                  SR                  U5      5        U$ gg)a  Prompt for region from list of online prediction available regions.

This method is referenced by the declaritive iam commands as a fallthrough
for getting the region. Prompts only in GDU.

Returns:
  The region specified by the user, str, or None if not in GDU or cannot
  prompt.
r   Tr   r    N)r   r!   r   r"   r   SUPPORTED_OP_REGIONSr#   r   r$   r%   r&   r'   r(   r)   s      r   PromptForOpRegionr-   =   s{      2 4 4y556K

!
!9OCFJJ ;;A6&>KM !5r   c                     [         R                  " 5       (       as  [        5       (       ac  [        [        R
                  5      n [         R                  " U SSS9nX   n[        R                  R                  SR                  U5      5        U$ gg)a!  Prompt for region from list of deployment resource pool available regions.

This method is referenced by the declaritive iam commands as a fallthrough
for getting the region. Prompts only in GDU.

Returns:
  The region specified by the user, str, or None if not in GDU or cannot
  prompt.
r   Tr   r    N)r   r!   r   r"   r   *SUPPORTED_DEPLOYMENT_RESOURCE_POOL_REGIONSr#   r   r$   r%   r&   r,   s      r   .PromptForDeploymentResourcePoolSupportedRegionr0   R   s{      2 4 4yKKLK

!
!9OCFJJ ;;A6&>KM !5r   c                 ^   [        U SS5      (       a  U R                  $ [        R                  R                  R                  R                  5       (       a2  [        R                  R                  R                  R                  5       $ U" 5       nU(       a  U$ [        R                  " SS5      e)aX  Gets the region and prompt for region if not provided.

  Region is decided in the following order:
- region argument;
- ai/region gcloud config;
- prompt user input (only in GDU).

Args:
  args: Namespace, The args namespace.
  prompt_func: Function, To prompt for region from list of available regions.

Returns:
  A str representing region.
r)   Nz--regionzRegion is required)	getattrr)   r   r
   aiIsExplicitlySetr   r   RequiredArgumentException)argsprompt_funcr)   s      r   	GetRegionr8   g   s     T8T"";;  0022&&**,,=&M 	,,Z9MNNr   N)__doc__googlecloudsdk.callioper   googlecloudsdk.command_lib.air   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   r   SUPPORTED_REGIONr   r   r-   r0   r8   r   r   r   <module>r?      sU    * / 3 # * 2 .7-G-G 4
 '0&@&@ 0** !0 Or   