
                             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
KJr  SSKJr  SSKJr  \" SS/5      rS rS rS rg)z3Utilities for checking and enabling necessary APIs.    )absolute_import)division)unicode_literalsN)
enable_api)services_util)serviceusage)#GetServicePermissionDeniedException)log)
properties)
console_iorun.googleapis.comz"staging-run.sandbox.googleapis.comc                      [         R                  R                  R                  R	                  5       n U (       a,  [
        R
                  " U 5      R                  nU[        ;   a  U$ g)Nr   )r   VALUESapi_endpoint_overridesrunGeturlparsehostname_RUN_API_NAMES)endpointapis     -lib/googlecloudsdk/api_lib/run/api_enabler.pyget_run_apir   $   sK    5599==?(


H
%
.
.C
nj	    c                 \   [         R                  R                  R                  R	                  5       (       d  g [        X5      nU(       a  SR                  U5      n[        R                  " SSSR                  X5      SS9  [        R                  R                  SR                  U 5      5        [        R                  " X5      nUR                   (       dE  ["        R$                  " UR&                  [        R(                  5      n["        R*                  " U5        g! [         a     gf = f)z<Ensure the given APIs are enabled for the specified project.Fz
	Tz9The following APIs are not enabled on project [{0}]:
	{1}zIDo you want enable these APIs to continue (this will take a few minutes)?)defaultcancel_on_nomessageprompt_stringz!Enabling APIs on project [{0}]...)r   r   coreshould_prompt_to_enable_apiGetBoolget_disabled_apisr	   joinr   PromptContinueformatr
   statusPrintr   BatchEnableApiCalldoner   WaitOperationnameGetOperationPrintOperation)
project_idrequired_apisapis_not_enabledapis_to_enableops        r   check_and_enable_apisr4   -   s    						;	;	C	C	E	E(C [[!12NIVJ/5	 JJ8??
KL		(	(	FB77&&rww0I0IJb""2&	) 
- s   D 
D+*D+c                     [        U5       Vs/ s H"  n[        R                  " X5      (       a  M   UPM$     nnU$ s  snf )N)sortedr   IsServiceEnabled)r/   r0   r   r1   s       r   r#   r#   K   sF    
 &	 '#((9 
&	   
s   ;;)__doc__
__future__r   r   r   urllib.parseparser   googlecloudsdk.api_lib.servicesr   r   r   *googlecloudsdk.api_lib.services.exceptionsr	   googlecloudsdk.corer
   r   googlecloudsdk.core.consoler   	frozensetr   r   r4   r#    r   r   <module>rB      sM    : &  '  6 9 8 Z # * 2?@
<r   