
                            d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dZed	z   Zd
ddZdddZej                  ej                    ej"                  ej$                  j&                         G d dej(                                             Zee_         ej"                  ej$                  j.                  ej$                  j0                         G d dej(                               Zee_        y)zservices enable command.    )services_util)serviceusage)base)common_flags)log)
propertiesz gcloud beta services operations zwait {0}a          This command enables a service for consumption for a project, folder or organization.

        To see a list of available services for a project, run:

          $ {parent_command} list --available

     More information on listing services can be found at:
     https://cloud.google.com/service-usage/docs/list-services and on
     disabling a service at:
     https://cloud.google.com/service-usage/docs/enable-disable
        a          To enable a service called `my-consumed-service` on the current
        project, run:

          $ {command} my-consumed-service

        To enable a service called `my-consumed-service` on the project
        `my-project`, run:

          $ {command} my-consumed-service --project=my-project

        To enable a service called `my-consumed-service` on the folder
        `my-folder, run:

          $ {command} my-consumed-service --folder=my-folder

        To enable a service called `my-consumed-service` on the organization
        `my-organization`, run:

          $ {command} my-consumed-service --organization=my-organization

        To run the same command asynchronously (non-blocking), run:

          $ {command} my-consumed-service --async

        To enable services called `service1`, `service2`, and `service3` on the
        current project, run:

          $ {command} service1 service2 service3
        )DESCRIPTIONEXAMPLESa          This command enables a service for consumption for a project.

        To see a list of available services for a project, run:

          $ {parent_command} list --available

     More information on listing services can be found at:
     https://cloud.google.com/service-usage/docs/list-services and on
     disabling a service at:
     https://cloud.google.com/service-usage/docs/enable-disable
        a          To enable a service called `my-consumed-service` on the current
        project, run:

          $ {command} my-consumed-service

        To run the same command asynchronously (non-blocking), run:

          $ {command} my-consumed-service --async

        To enable services called `service1`, `service2`, and `service3` on the
        current project, run:

          $ {command} service1 service2 service3
        c                   &    e Zd ZdZed        Zd Zy)EnableAlphazHEnables a service for consumption for a project, folder or organization.c                    t        j                  d      j                  |        t        j                  |        t        j
                  j                  |        t        j                  | d       t        j                  |        y)zArgs is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go on
        the command line after this command. Positional arguments are allowed.
    	to enablesuffixenableN)r   available_service_flagAddToParseradd_resource_argsr   
ASYNC_FLAGvalidate_only_argsskip_dependency_flagparsers    lib/surface/services/enable.pyArgszEnableAlpha.Argso   s[     ''{;GGO""6*OO'##F8<%%f-    c                    |j                  d      r|j                  n3t        j                  j                  j                  j                  d      }|j                  d      r|j                  nd}|j                  d      r|j                  nd}t        j                  |j                  ||||j                  |j                        }|j                  rBt        j                  |j                         }t"        j$                  j'                  d|        yt)        j*                  |j                   t        j,                        }|j                  rt)        j.                  |       yt)        j0                  |       y)	zRun 'services enable'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      Nothing.
    projectTrequiredfolderNorganization)r!   r"   validate_onlyskip_dependency`Asynchronous operation is in progress... Use the following command to wait for its completion:
 )IsSpecifiedr   r   VALUEScoreGetr!   r"   r   AddEnableRuleservicer#   r$   async__OP_WAIT_CMDformatnamer   statusPrintr   WaitOperationGetOperationV2BetaPrintOperationPrintOperationWithResponse)selfargsr   r!   r"   opcmds          r   RunzEnableAlpha.Run}   s2    I& 	##++///> 
 !,,X6T[[DF!--n=4  
	#	#!((,,
B {{(c	jj%!
 		$	$RWWl.M.M	NB""2&..r2r   N__name__
__module____qualname____doc__staticmethodr   r:    r   r   r   r   i   s     Q. .)3r   r   c                   &    e Zd ZdZed        Zd Zy)Enablez0Enables a service for consumption for a project.c                     t        j                  d      j                  |        t        j                  j                  |        y)zArgs is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
    r   r   N)r   r   r   r   r   r   s    r   r   zEnable.Args   s/     ''{;GGOOO'r   c                 `   t         j                  j                  j                  j	                  d      }t        |j                        dk(  r$t        j                  ||j                  d         }n t        j                  ||j                        }|j                  ry|j                  rBt        j                  |j                        }t        j                   j#                  d|        yt%        j&                  |j                  t        j(                        }t%        j*                  |       y)zRun 'services enable'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      Nothing.
    Tr      r   Nr%   )r   r'   r(   r   r)   lenr+   r   EnableApiCallBatchEnableApiCalldoner,   r-   r.   r/   r   r0   r1   r   r2   GetOperationr4   )r6   r7   r   r8   r9   s        r   r:   z
Enable.Run   s     $$,,00$0?G
4<<A%%gt||A?b**7DLLAb	ww{{(c	jj%!
 		$	$RWWl.G.G	HB  $r   Nr;   rA   r   r   rC   rC      s    8	( 	(%r   rC   N)r?   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr   googlecloudsdk.corer   r   _OP_BASE_CMDr-   _DETAILED_HELP_ALPHA_DETAILED_HELPUniverseCompatibleHiddenReleaseTracksReleaseTrackALPHASilentCommandr   detailed_helpBETAGArC   rA   r   r   <module>r\      s     9 8 ( < # *1j(+ \@ D%%++,:3$$$ :3 -  :3x 1  D%%**D,=,=,@,@A)%T )% B)%X & r   