
    Q                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SS	KJr   " S
 S\	R                  5      rg)z'Command to create service account keys.    )absolute_import)division)unicode_literalsN)util)base)iam_util)logc                   x    \ rS rSrSr\R                  " S5      \R                  " S5      S.r\S 5       r	S r
Srg	)
Create   zxCreate a service account key.

If the service account does not exist, this command returns a
`PERMISSION_DENIED` error.
z
          The option --key-file-type=p12 is available here only for legacy
          reasons; all new use cases are encouraged to use the default 'json'
          format.
          z
          To create a new service account key and save the private
          portion of the key locally, run:

            $ {command} key.json --iam-account=my-iam-account@my-project.iam.gserviceaccount.com
          )NOTESEXAMPLESc                     U R                  SSS/SSS9  U R                  SS[        R                  " 5       SS	9  U R                  S
S[        R                  " 5       SS9  g )Nz--key-file-typejsonp12zThe type of key to create.)choicesdefaulthelpz--iam-accountTz                        The service account for which to create a key.

                        To list all service accounts in the project, run:

                          $ gcloud iam service-accounts list
                        )requiredtyper   outputzOUTPUT-FILEzThe path where the resulting private key should be written. File system write permission will be checked on the specified path prior to the key creation.)metavarr   r   )add_argumentr   GetIamAccountFormatValidatorGetIamOutputFileValidator)parsers    /lib/surface/iam/service_accounts/keys/create.pyArgsCreate.Args3   s{    
)!' &9  ;
 !%%BBD  	  -%??A$  %    c                    [         R                  " 5       u  p#UR                  R                  UR	                  [
        R                  " UR                  5      UR                  [
        R                  " [
        R                  " UR                  5      5      S9S95      n[        R                  " UR                  UR                  SSS9  [        R                   R#                  SR%                  [
        R&                  " UR(                  5      [
        R*                  " UR,                  5      UR                  UR                  5      5        g )N)privateKeyType)namecreateServiceAccountKeyRequestT)contentbinaryprivatez2created key [{0}] of type [{1}] as [{2}] for [{3}])r   GetClientAndMessagesprojects_serviceAccounts_keysr   +IamProjectsServiceAccountsKeysCreateRequestr   EmailToAccountResourceNameiam_accountCreateServiceAccountKeyRequestKeyTypeToCreateKeyTypeKeyTypeFromStringkey_file_typer	   WriteToFileOrStdoutr   privateKeyDatastatusPrintformatGetKeyIdFromResourceNamer#   KeyTypeToStringr"   )selfargsclientmessagesresults        r   Run
Create.RunM   s   002F1188<<44T5E5EF33'>>..t/A/AB D 4 E 	= 	FGF V224OJJ<CC--fkk:$$V%:%:;KK		r     N)__name__
__module____qualname____firstlineno____doc__textwrapdedentdetailed_helpstaticmethodr   r=   __static_attributes__r?   r    r   r   r      sM        
 // # - % %2r    r   )rD   
__future__r   r   r   rE   googlecloudsdk.api_lib.iamr   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   googlecloudsdk.corer	   Commandr   r?   r    r   <module>rP      s4     . &  '  + ( 3 #AT\\ Ar    