
                            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dl
mZ dd	lmZ dd
lmZ dZdZdZdZdZedz   ZdddZe	j,                  e	j.                   e	j0                  e	j2                  j4                  e	j2                  j6                         G d de	j8                                             Zee_        y)z*services policies add-enable-rule command.    )absolute_import)division)unicode_literals)services_util)serviceusage)base)common_flags)log)
propertieszprojects/{}z
folders/{}zorganizations/{}z/consumerPolicies/{}z gcloud beta services operations zwait {0}z[        Add service(s) to a consumer policy for a project, folder or organization.
        af          To add enable rule for a service called `my-consumed-service` on default consumer policy on the current
        project, run:

          $ {command} my-consumed-service
              OR
          $ {command} my-consumed-service --policy_name=default

        To add enable rule for a service called `my-consumed-service` on default consumer policy on the
        project `my-project` , run:

          $ {command} my-consumed-service --project=my-project
              OR
          $ {command} my-consumed-service --policy_name=default --project=my-project

        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 default policy , run:

          $ {command} service1 service2 service3
        )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)AddEnableRuleszJAdd service(s) to a consumer policy for a project, folder or organization.c                    t        j                  d      j                  |        | j                  ddd       t        j                  |        t        j
                  | d       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.
    zto add enable rule for)suffixz--policy-namezCName of the consumer policy. Currently only "default" is supported.default)helpr   zadd enable ruleN)r	   available_service_flagAddToParseradd_argumentadd_resource_argsvalidate_only_argsr   
ASYNC_FLAG)parsers    1lib/surface/services/policies/add_enable_rules.pyArgszAddEnableRules.ArgsL   sr     '''k&
    ""6*##F3DEOO'    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 policies add-enable-rule.

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

    Returns:
      The services in the consumer policy.
    projectT)requiredfolderNorganizationz`Asynchronous operation is in progress... Use the following command to wait for its completion:
 )IsSpecifiedr   r   VALUEScoreGetr!   r"   r   AddEnableRuleservicepolicy_namevalidate_onlyasync__OP_WAIT_CMDformatnamer
   statusPrintr   WaitOperationGetOperationV2AlphaPrintOperationPrintOperationWithResponse)selfargsr   r!   r"   opcmds          r   RunzAddEnableRules.Runc   s2    I& 	##++///> 
 !,,X6T[[DF!--n=4  
	#	#
B {{(c	jj%!
 		$	$RWWl.N.N	OB""2&..r2r   N)__name__
__module____qualname____doc__staticmethodr   r9    r   r   r   r   F   s     S( (,)3r   r   N)r=   
__future__r   r   r   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr	   googlecloudsdk.corer
   r   _PROJECT_RESOURCE_FOLDER_RESOURCE_ORGANIZATION_RESOURCE_CONSUMER_POLICY_DEFAULT_OP_BASE_CMDr,   _DETAILED_HELPUniverseCompatibleHiddenReleaseTracksReleaseTrackALPHABETASilentCommandr   detailed_helpr?   r   r   <module>rS      s     1 &  ' 9 8 ( < # * "  + 1 1j(	@ D%%++T->->-C-CDC3T'' C3 E  C3L  . r   