
                         j    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 r
SS	 jrSS
 jrg)z!services enable helper functions.    )absolute_import)division)unicode_literals)services_util)serviceusage)logc                 Z    [         R                  " X5      n[         R                  " U5      $ )a  Return true if the service is enabled.

Args:
  project_id: The ID of the project we want to query.
  service_name: The name of the service.

Raises:
  exceptions.GetServicePermissionDeniedException: if a 403 or 404
      error is returned by the Get request.
  apitools_exceptions.HttpError: Another miscellaneous error with the listing
      service.

Returns:
  True if the service is enabled, false otherwise.
)r   
GetServiceIsServiceEnabled)
project_idservice_nameservices      1lib/googlecloudsdk/api_lib/services/enable_api.pyr   r      s%      ##J='		&	&w	//    c                 J   [         R                  R                  SR                  X5      5        [        R
                  " X5      nU(       dX  UR                  (       dF  [        R                  " UR                  [        R                  5      n[        R                  " U5        ggg)a-  Enable a service without checking if it is already enabled.

Args:
  project_id: The ID of the project for which to enable the service.
  service_name: The name of the service to enable on the project.
  is_async: bool, if True, print the operation ID and return immediately,
         without waiting for the op to complete.

Raises:
  exceptions.EnableServicePermissionDeniedException: when enabling the API
      fails with a 403 or 404 error code.
  api_lib_exceptions.HttpException: Another miscellaneous error with the
      servicemanagement service.
z*Enabling service [{0}] on project [{1}]...N)r   statusPrintformatr   EnableApiCalldoner   WaitOperationnameGetOperationPrintOperation)r   r   is_asyncops       r   EnableServicer   /   ss     **?FF  ! !!*;"	"''		$	$RWWl.G.G	HB  $ "r   c                     [        X5      (       a&  [        R                  " SR                  X5      5        g[	        XU5        g)a  Check to see if the service is enabled, and if it is not, do so.

Args:
  project_id: The ID of the project for which to enable the service.
  service_name: The name of the service to enable on the project.
  is_async: bool, if True, print the operation ID and return immediately,
         without waiting for the op to complete.

Raises:
  exceptions.ListServicesPermissionDeniedException: if a 403 or 404 error
      is returned by the listing service.
  exceptions.EnableServicePermissionDeniedException: when enabling the API
      fails with a 403 or 404 error code.
  api_lib_exceptions.HttpException: Another miscellaneous error with the
      servicemanagement service.
z2Service [{0}] is already enabled for project [{1}]N)r   r   debugr   r   )r   r   r   s      r   EnableServiceIfDisabledr    H   s9    & j//IIBII" #

(3r   N)F)__doc__
__future__r   r   r   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.corer   r   r   r     r   r   <module>r&      s+     ( &  ' 9 8 #0(%24r   