
                         @   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  e	j                  e	j                   j"                  e	j                   j$                  e	j                   j&                         G d de	j(                               Zy)z2Command to create a service account for a project.    )absolute_import)division)unicode_literalsN)util)base)iam_util)log)
propertiesc                   N    e Zd ZdZd ej
                  d      iZed        Zd Z	y)CreatezCreate a service account for a project.

  This command creates a service account with the provided name. For
  subsequent commands regarding service accounts, this service account should
  be referred to by the email account in the response.
  EXAMPLESa.  
          To create a service account for your project, run:

            $ {command} some-account-name --display-name="My Service Account"

          To work with this service account in subsequent IAM commands, use the
          email resulting from this call as the IAM_ACCOUNT argument.
          c                 x    | j                  dd       | j                  dd       | j                  ddd	       y )
Nz--display-namez*A textual name to display for the account.)helpz--descriptionz&A textual description for the account.nameNAMEzThe internal name of the new service account. Used to generate an IAM_ACCOUNT (an IAM internal email address used as an identifier of service account), which must be passed to subsequent commands.)metavarr   )add_argument)parsers    *lib/surface/iam/service_accounts/create.pyArgszCreate.Args5   sX    
K  M F  H       c                    t         j                  j                  j                  j	                  d      }t        j                         \  }}|j                  j                  |j                  t        j                  |      |j                  |j                  |j                  |j                  |j                                           }t#        j$                  |j                  d       |S )NT)required)displayNamedescription)	accountIdserviceAccount)r   createServiceAccountRequestzservice account)kind)r
   VALUEScoreprojectGetr   GetClientAndMessagesprojects_serviceAccountsr   'IamProjectsServiceAccountsCreateRequestr   ProjectToProjectResourceNameCreateServiceAccountRequestr   ServiceAccountdisplay_namer   r	   CreatedResource)selfargsr"   clientmessagesresults         r   Runz
Create.RunF   s    $$,,00$0?G002FH,,338866w?(0(L(L))'66 $ 1 1 $ 0 0  7  2 )M )3 	9 	45F 		(9:Mr   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r1    r   r   r   r      s?     
(//  
-   r   r   )r5   
__future__r   r   r   r6   googlecloudsdk.api_lib.iamr   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   googlecloudsdk.corer	   r
   ReleaseTracksReleaseTrackALPHABETAGACreateCommandr   r:   r   r   <module>rF      s~     9 &  '  + ( 3 # * D%%++T->->-C-C%%((*2T 2*2r   