
                         j   d Z ddlmZ ddlmZ ddlmZ ddl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  e
j"                  e
j$                  j&                  e
j$                  j(                  e
j$                  j*                        e
j,                   G d de
j.                                      Zy)zhDeletes a user in a given instance.

Deletes a user in a given instance specified by username and host.
    )absolute_import)division)unicode_literalsN)api_util)
operations)base)flags)
properties)
console_ioc                   @    e Zd ZdZed        Zdej                  fdZy)DeletezDeletes a Cloud SQL user in a given instance.

  Deletes a Cloud SQL user in a given instance specified by username and host.
  c                    t        j                  |        t        j                  |        t        j                  |        t        j
                  j                  |        | j                  j                  t         j                         y )N)
r	   AddInstanceAddUsernameAddHostr   
ASYNC_FLAGAddToParserdisplay_infoAddCacheUpdaterUserCompleter)parsers    lib/surface/sql/users/delete.pyArgszDelete.Args+   sV    	f	f	MM&OO'
''(;(;<    argsc                    t        j                  t         j                        }|j                  }|j                  }|j
                  j                  |j                  dt        j                  j                  j                  j                  id      }d}|j                  }|j                  r&dj                  |j                  |j                        }t!        j"                  dj                  |      dd       |j$                  j'                  |j)                  |j                  |j+                         |j                  |j                  	            }|j
                  j-                  d
|j.                  |j                        }|j0                  r@|j2                  j5                  |j7                  |j                  |j8                              S t2        j:                  j=                  ||d       y)zLists Cloud SQL users in a given instance.

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

    Returns:
      SQL user resource iterator.
    projectzsql.instances)params
collectionNzf{0}@{1}zr{0} will be deleted. New connections can no longer be made using this user. Existing connections are not affected.T)messagedefaultcancel_on_no)r   instancenamehostzsql.operations)	operationr   )r   r&   zDeleting Cloud SQL user)r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesresource_parserParser#   r
   VALUEScorer   	GetOrFailusernamer%   formatr   PromptContinueusersr   SqlUsersDeleteRequestNameCreater$   async_r   GetSqlOperationsGetRequestr&   OperationsV1Beta4WaitForOperation)	selfr   clientr)   r*   instance_refoperation_ref	user_nameresult_operations	            r   Runz
Delete.Run3   s     < <=F""J&&L))//:,,1199CCD" 0 $L MIyy##DMM499=iGGMvH "''..** ((!&&(	 	+ 	 **11"''$$ 2 &M {{""&&

.
.#++}7N7N / PQ Q   11*m2KMr   N)	__name__
__module____qualname____doc__staticmethodr   argparse	NamespacerB    r   r   r   r   "   s/    
 = =-Mh(( -Mr   r   )rF   
__future__r   r   r   rH   googlecloudsdk.api_lib.sqlr   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.sqlr	   googlecloudsdk.corer
   googlecloudsdk.core.consoler   ReleaseTracksReleaseTrackGABETAALPHAUniverseCompatibleDeleteCommandr   rJ   r   r   <module>rX      s   
 '  '  / 1 ( 0 * 2 D%%(($*;*;*@*@%%++-;MT ;M -;Mr   