
    v                     h   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
ZdZdZdZdZedz   Zej(                  ej*                   ej,                  ej.                  j0                  ej.                  j2                         G d dej4                                             Zy)z-services policies remove-enable-rule command.    )services_util)serviceusage)base)arg_parsers)common_flags)log)
properties)
console_iozprojects/{}z
folders/{}zorganizations/{}z/consumerPolicies/{}z gcloud beta services operations zwait {0}c                   &    e Zd ZdZed        Zd Zy)RemovedEnableRulesa  Remove service(s) from a consumer policy for a project, folder or organization.

  Remove service(s) from a consumer policy for a project, folder or
  organization.

  ## EXAMPLES
  To remove service called `my-consumed-service` from the default consumer
  policy on the current project, run:

    $ {command} my-consumed-service
        OR
    $ {command} my-consumed-service --policy-name=default

   To remove service called `my-consumed-service` from from the default consumer
   policy on project `my-project`, run:

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

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

    $ {command} my-consumed-service --async
  c                 4   t        j                  d      j                  |        | j                  ddd       t        j                  |        t
        j                  j                  |        | j                  ddd	
       t        j                  | d       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 remove enable rule for)suffixz--policy-namezCName of the consumer policy. Currently only "default" is supported.default)helpr   z--force
store_truea  If specified, the remove-enable-rules call will proceed even if there are enabled services which depend on the service to be removed from enable rule or the service to be removed was used in the last 30 days, or the service to be removed was enabled in the last 3 days. Forcing the call means that the services which depend on the service to be removed from the enable rule will also be removed.)actionr   zremove enable ruleN)r   consumer_service_flagAddToParseradd_argumentadd_resource_argsr   
ASYNC_FLAGvalidate_only_args)parsers    4lib/surface/services/policies/remove_enable_rules.pyArgszRemovedEnableRules.ArgsB   s     &&*k&
    ""6*OO'
 	   ##F3GH    c                 4   |j                  d      r|j                  n3t        j                  j                  j                  j                  d      }|j                  d      r|j                  nd}|j                  d      r|j                  nd}g }|j                  D ]  }t        j                  |      }t        j                  |      }|r@|j                  d      rt        j                         t        j                  |dd	      }|so|j!                  |        t        j"                  |||j$                  |j&                  |||j(                  d|j&                  
	      }	|j*                  rBt,        j/                  |	j0                        }
t2        j4                  j7                  d|
        yt9        j:                  |	j0                  t        j<                        }	|j(                  rt9        j>                  |	       yt9        j@                  |	       y)zRun services policies remove-enable-rules.

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

    Returns:
      The services in the consumer policy.
    projectT)requiredfolderNorganizationquietF)r   throw_if_unattended)skip_dependency_checkdisable_dependency_servicesz`Asynchronous operation is in progress... Use the following command to wait for its completion:
 )!IsSpecifiedr   r	   VALUEScoreGetr    r!   servicer   GetServiceNameFromArgr   GetProtectedServiceWarningr
   RequiredPromptErrorPromptContinueappendRemoveEnableRulepolicy_nameforcevalidate_onlyasync__OP_WAIT_CMDformatnamer   statusPrintr   WaitOperationGetOperationV2BetaPrintOperationPrintOperationWithResponse)selfargsr   r    r!   service_namesservice_nameprotected_msg
do_disableopcmds              r   RunzRemovedEnableRules.Runf   s    I& 	##++///> 
 !,,X6T[[DF!--n=4  M 66|Dl"==lKm	G$..0
0..5d

 
<( % 
	&	&

#$(JJ

B {{(c	jj%!
 		$	$RWWl.M.M	NB""2&..r2r   N)__name__
__module____qualname____doc__staticmethodr   rF    r   r   r   r   %   s#    2 !I !IF=3r   r   N)rJ   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr   r   googlecloudsdk.corer   r	   googlecloudsdk.core.consoler
   _PROJECT_RESOURCE_FOLDER_RESOURCE_ORGANIZATION_RESOURCE_CONSUMER_POLICY_DEFAULT_OP_BASE_CMDr5   UniverseCompatibleHiddenReleaseTracksReleaseTrackALPHABETASilentCommandr   rL   r   r   <module>r^      s     4 9 8 ( ; < # * 2!  + 1 1j( D%%++T->->-C-CD{3++ {3 E  {3r   