
    
                         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	  \R                  " S5      rS	1rS
 rS rSS jrg)zUtilities for API enablement.    )absolute_import)division)unicode_literalsN)
enable_api)
console_ioz.*Enable it by visiting https://console.(?:cloud|developers).google.com/apis/api/([^/]+)/overview\?project=(\S+) then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.\w*zgoogle.com:cloudsdktoolc                     U [         ;  $ )N)_PROJECTS_NOT_TO_ENABLE)projects    1lib/googlecloudsdk/api_lib/util/api_enablement.pyShouldAttemptProjectEnabler   &   s    	/	//    c                     [         R                  U 5      nU(       a:  UR                  S5      UR                  S5      p2Ub  [        U5      (       a  Ub  X#4$ g)zParses error message for API enablement messages.

Args:
  status_message: str, error message to parse.

Returns:
  tuple[str]: The project, service token to be used for prompting to enable
      the API.
      N)API_ENABLEMENT_REGEXmatchgroupr   )status_messager   r
   service_tokens       r   GetApiEnablementInfor   *   sQ     
$
$^
4%
 %AAm :7 C C%%%	r   c                     [         R                  " USR                  X5      S9nU(       a  [        R                  " X5        U$ )a1  Prompts to enable the API.

Args:
  project (str): The project that the API is not enabled on.
  service_token (str): The service token of the API to prompt for.
  enable_by_default (bool): The default choice for the enablement prompt.

Returns:
  bool, whether or not the API was attempted to be enabled
zhAPI [{}] not enabled on project [{}]. Would you like to enable and retry (this will take a few minutes)?)defaultprompt_string)r   PromptContinueformatr   EnableService)r
   r   enable_by_defaultapi_enable_attempteds       r   PromptToEnableApir   =   sA     $22%&,f]&D	F
 W4	r   )F)__doc__
__future__r   r   r   regooglecloudsdk.api_lib.servicesr   googlecloudsdk.core.consoler   compiler   r	   r   r   r    r   r   <module>r'      sL     $ &  ' 	 6 2 zz%&  55 0&r   