
    $                        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edz   Zej                   ej"                   ej$                  ej&                  j(                         G d dej*                                             Z ej$                  ej&                  j.                  ej&                  j0                         G d dej*                               Zy)zservices disable command.    )services_util)serviceusage)base)arg_parsers)common_flags)log)
properties)
console_ioz gcloud beta services operations zwait {0}c                   &    e Zd ZdZed        Zd Zy)DisableAlphaa  Disable a service for consumption for a project, folder or organization.

  This command disables one or more previously-enabled services for
  consumption.

  To see a list of the enabled services for a project, run:

    $ {parent_command} list

  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

  ## EXAMPLES
  To disable a service called `my-consumed-service` for the current
  project, run:

    $ {command} my-consumed-service

  To disable a service called `my-consumed-service` for the project
  `my-project`, run:

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

  To disable a service called `my-consumed-service` for the folder
  `my-folder`, run:

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

  To disable a service called `my-consumed-service` for 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
  c                 `   t        j                  d      j                  |        t        j                  |        t        j
                  j                  |        t        j                  | d       t        j                  |        t        j                  |        | j                  ddd       y)	Args 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 disablesuffixdisable--force
store_truea  If specified, the disable call will proceed even if there are enabled services which depend on the service to be disabled, or the service to be disabled was used in the last 30 days, or the service to be disabled was enabled in the last 3 days. Forcing the call means that the services which depend on the service to be disabled will also be disabled. (Note): If  --bypass-api-usage-check, --bypass-dependency-service-check, or --disable-dependency-services flags are used, they will take precedence over --force.actionhelpN)
r   consumer_service_flagAddToParseradd_resource_argsr   
ASYNC_FLAGvalidate_only_argsbypass_api_usage_check_flagadd_dependency_check_argsadd_argumentparsers    lib/surface/services/disable.pyArgszDisableAlpha.ArgsM   s     &&l;GGO""6*OO'##F9=,,V4**62
(	      c           
         |j                  d      r|j                  n3t        j                  j                  j                  j                  d      }|j                  d      r|j                  nd}|j                  d      r|j                  nd}|j                  }d}d}|j                  d      s|j                  d	      rd}|j                  d
      rd}|j                  d      rd}g }|j                  D ]  }	t        j                  |	      }	t        j                  |	      }
|
r@|j                  d      rt        j                         t        j                   |
dd      }|so|j#                  |	        |syt        j$                  ||||||j&                  ||      }|j(                  rAt*        j-                  |j.                        }t0        j2                  j5                  d|        t7        j8                  |j.                  t        j:                        }|j&                  rt7        j<                  |       yt7        j>                  |       y)Run 'services disable'.

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

    Returns:
      Nothing.
    projectTrequiredfolderNorganizationFforcedisable_dependency_servicesbypass_api_usage_checkbypass_dependency_service_checkquietdefaultthrow_if_unattended)r,   r*   r+   validate_onlyskip_dependency_checkr-   `Asynchronous operation is in progress... Use the following command to wait for its completion:
 ) IsSpecifiedr'   r	   VALUEScoreGetr*   r+   r,   servicer   GetServiceNameFromArgr   GetProtectedServiceWarningr
   RequiredPromptErrorPromptContinueappendRemoveEnableRuler4   async_OP_WAIT_CMDformatnamer   statusPrintr   WaitOperationGetOperationV2BetaPrintOperationPrintOperationWithResponse)selfargsr'   r*   r+   r.   r5   r-   service_namesservice_nameprotected_msg
do_disableopcmds                 r"   RunzDisableAlpha.Runk   s!    I& 	##++///> 
 !,,X6T[[DF!--n=4  "ZZ
 ""'  D$4$4%% %)! 01# 9:"M 66|Dl"==lKm	G$..0
0..5d

 
<( % 		&	&$!((3$?	
B {{rww'c	jj4475: 
	$	$RWWl.M.M	NB""2&..r2r$   N__name__
__module____qualname____doc__staticmethodr#   rT    r$   r"   r   r   !   s"    &P  :R3r$   r   c                   &    e Zd ZdZed        Zd Zy)Disablea  Disable a service for consumption for a project.

  This command disables one or more previously-enabled services for
  consumption.

  To see a list of the enabled services for a project, run:

    $ {parent_command} list

  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

  ## EXAMPLES
  To disable a service called `my-consumed-service` for the active
  project, run:

    $ {command} my-consumed-service

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

    $ {command} my-consumed-service --async
  c                     t        j                  d      j                  |        t        j                  j                  |        | j                  ddd       y)r   r   r   r   r   a1  If specified, the disable call will proceed even if there are enabled services which depend on the service to be disabled or disable the service used in last 30 days or was enabled in recent 3 days. Forcing the call means that the services which depend on the service to be disabled will also be disabled.r   N)r   r   r   r   r   r   r    s    r"   r#   zDisable.Args   sN     &&l;GGOOO'
K	  
r$   c                    t         j                  j                  j                  j	                  d      }|j
                  D ].  }t        j                  |      }t        j                  |      }|r@|j                  d      rt        j                         t        j                  |dd      }|spt        j                  |||j                        }|j                   r|j"                  rBt$        j'                  |j(                        }t*        j,                  j/                  d|        t1        j2                  |j(                  t        j4                        }t1        j6                  |       1 y)r&   Tr(   r0   Fr1   r6   N)r	   r8   r9   r'   r:   r;   r   r<   r   r=   r7   r
   r>   r?   DisableApiCallr,   donerB   rC   rD   rE   r   rF   rG   r   rH   GetOperationrJ   )rL   rM   r'   rO   rP   rQ   rR   rS   s           r"   rT   zDisable.Run   s#    $$,,00$0?G 66|Dl"==lKm	G$..0
0..5d

 
&&wdjjIb		  )

 E#	

 	&&rww0I0IJb""2&1 %r$   NrU   r[   r$   r"   r]   r]      s     2  *#'r$   r]   N)rY   googlecloudsdk.api_lib.servicesr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr   r   googlecloudsdk.corer   r	   googlecloudsdk.core.consoler
   OP_BASE_CMDrC   UniverseCompatibleHiddenReleaseTracksReleaseTrackALPHASilentCommandr   BETAGAr]   r[   r$   r"   <module>rq      s       9 8 ( ; < # * 2 1J& D%%++,Y34%% Y3 -  Y3x D%%**D,=,=,@,@AS'd   S' BS'r$   