
    p                         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  G d de	j"                        Zy)z+Command for deleting a service account key.    )absolute_import)division)unicode_literalsN)util)base)iam_util)log)	resources)
console_ioc                   N    e Zd ZdZd ej
                  d      iZed        Zd Z	y)Deletez~Delete a service account key.

  If the service account does not exist, this command returns a
  `PERMISSION_DENIED` error.
  EXAMPLESa  
          To delete a key with ID `b4f1037aeef9ab37deee9` for the service
          account `my-iam-account@my-project.iam.gserviceaccount.com`, run:

            $ {command} b4f1037aeef9ab37deee9 --iam-account=my-iam-account@my-project.iam.gserviceaccount.com
      c                 z    | j                  ddt        j                         d       | j                  ddd       y )	Nz--iam-accountTz                          The service account from which to delete a key.

                          To list all service accounts in the project, run:

                            $ gcloud iam service-accounts list
                        )requiredtypehelpkeyzKEY-IDzThe key to delete.)metavarr   )add_argumentr   GetIamAccountFormatValidator)parsers    /lib/surface/iam/service_accounts/keys/delete.pyArgszDelete.Args0   sH    
!%%BBD  	  (1  3    c                    t         j                  j                  |j                  d|j                  dd      }|j
                  }t        j                  dj                  |j                  |j                        d       t        j                         \  }}|j                  j                  |j                  |j                                      t        j                   j#                  d	j                  |j                  |             y )
Nz!iam.projects.serviceAccounts.keys-)serviceAccountsId
projectsId)
collectionparamsz<You are about to delete key [{0}] for service account [{1}].T)messagecancel_on_no)namez+deleted key [{1}] for service account [{0}])r
   REGISTRYParser   iam_accountkeysIdr   PromptContinueformatr   GetClientAndMessagesprojects_serviceAccounts_keysr   +IamProjectsServiceAccountsKeysDeleteRequestRelativeNamer	   statusPrint)selfargskey_refr   clientmessagess         r   Runz
Delete.RunA   s      &&6!%!1!1
 ' G ..C$*:*:;
 002FH
((//<<%%' 	= 	)* JJBII#  r   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r5    r   r   r   r       s>     /(// #
 - 3 3  r   r   )r9   
__future__r   r   r   r:   googlecloudsdk.api_lib.iamr   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   googlecloudsdk.corer	   r
   googlecloudsdk.core.consoler   Commandr   r>   r   r   <module>rF      s8     2 &  '  + ( 3 # ) 25 T\\ 5 r   