
                         "   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d
lmZ ddlmZ dZ e
j$                  e
j&                  j(                         G d dej*                  e
j,                               Zy)zdeployments stop command.    )absolute_import)division)unicode_literals)
exceptions)dm_api_util)dm_base)base)dm_util)dm_write)flagsi  c                   .    e Zd ZdZddiZed        Zd Zy)StopzStop a pending or running deployment update or creation.

  This command will stop a currently running or pending operation on
  a deployment.
  EXAMPLESaO  
To stop a running operation on a deployment, run:

  $ {command} my-deployment

To issue a stop command without waiting for the operation to complete, run:

  $ {command} my-deployment --async

To stop a running operation on a deployment providing a fingerprint, run:

  $ {command} my-deployment --fingerprint=deployment-fingerprint
c                     t        j                  |        t        j                  |        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.
    N)r   AddAsyncFlagAddDeploymentNameFlagAddFingerprintFlag)parsers    2lib/surface/deployment_manager/deployments/stop.pyArgsz	Stop.Args<   s.     
v	'	V$    c           	      6   |j                   r t        j                  |j                         }nLt        j                  | j
                  | j                  t        j                         |j                        xs d}	 | j
                  j                  j                  | j                  j                  t        j                         |j                  | j                  j                  |                  }|j&                  r|S |j(                  }	 t+        j,                  | j
                  | j                  |dt        j                         t.              }t        j0                  |d       	 | j
                  j2                  j5                  | j                  j7                  t        j                         |j                              }|j2                  r|j2                  S g S # t        j                  $ r)}t!        j"                  |t        j$                        d}~ww xY w# t        j                  $ r)}t!        j"                  |t        j$                        d}~ww xY w# t        j                  $ r)}t!        j"                  |t        j$                        d}~ww xY w)	ay  Run 'deployments stop'.

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

    Returns:
      If --async=true, returns Operation to poll.
      Else, returns boolean indicating whether stop operation succeeded.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    r   )fingerprint)project
deploymentdeploymentsStopRequestNstop)timeoutr   )r   r   )r   r
   DecodeFingerprintr   FetchDeploymentFingerprintclientmessagesr   
GetProjectdeployment_namedeploymentsr   'DeploymentmanagerDeploymentsStopRequestDeploymentsStopRequestapitools_exceptions	HttpErrorr   HttpExceptionHTTP_ERROR_FORMATasync_namer   WaitForOperationOPERATION_TIMEOUTLogOperationStatus	resourcesList%DeploymentmanagerResourcesListRequest)selfargsr   	operationerrorop_nameresponses          r   RunzStop.RunI   s.    --d.>.>?k
  ::
++
--






	  ' $'	 
K++))..
--
?
?((*----66"- 7 /	 @ 	i {{g
M--KKMM %'	 	""9f5M;;((--MM??**,// @ 
 &.%7%7x!!?R?5 (( K$$UK,I,IJJK !** M&&uk.K.KLLM !** M&&uk.K.KLLMsQ   :A7G AH (A3I I H1$HHI0$IIJ/$JJN)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r:    r   r   r   r   $   s3      -  
% 
%AMr   r   N)r>   
__future__r   r   r   apitools.base.pyr   r(   )googlecloudsdk.api_lib.deployment_managerr   r   googlecloudsdk.callioper	   -googlecloudsdk.command_lib.deployment_managerr
   r   r   r/   UseDmApiDmApiVersionV2Command	DmCommandr   rA   r   r   <module>rL      sy       &  ' > A = ( . A B ?   '&&))*eM4<<** eM +eMr   