
    e                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  \R                  \R                  " \R                  R                  5       " S	 S
\R                   5      5       5       rg)zACommand for setting the default service account on a GCE project.    )absolute_import)division)unicode_literals)base_classes)base)
exceptions)
propertiesc                   4    \ rS rSrSr\S 5       rS rS rSr	g)SetDefaultServiceAccount   aX  Set the default service account on the project.

  *{command}* is used to configure the default service account on project.

The project's default service account is used when a new instance is
created unless a custom service account is set via --scopes or
--no-scopes. Existing instances are not affected.

For example,

  $ {command} --service-account=example@developers.gserviceaccount.com
  $ gcloud compute instances create instance-name

will set the project's default service account as
example@developers.gserviceaccount.com. The instance created will have
example@developers.gserviceaccount.com as the service account associated
with because no service account email was specified in the
"instances create" command.

To remove the default service account from the project, issue the command:

  $ {command} --no-service-account

The required permission to execute this command is
`compute.projects.setDefaultServiceAccount`. If needed, you can include this
permission, or choose any of the following preexisting IAM roles that contain
this particular permission:

  * Owner
  * Editor
  * Compute Admin
c                 f    U R                  5       nUR                  SSS9  UR                  SSSS9  g )N--service-accountaR          The email address of the service account that will be set as the default
        service account for all newly created instances in the project.

        To set the default service account to
        example@project.iam.gserviceaccount.com:

          $ {command} --service-account example@project.iam.gserviceaccount.com
        )helpz--no-service-account
store_trueaA          Sets the default service account on the project as no service account.
        This causes newly created instances to not run as a service account
        by default.

        To set the default service account as no service account, specify this
        flag:

          $ {command} --no-service-account
        )actionr   )add_mutually_exclusive_groupadd_argument)parseraccounts_groups     ?lib/surface/compute/project_info/set_default_service_account.pyArgsSetDefaultServiceAccount.Args?   sK    88:N   
 	       c                    [         R                  " U R                  5       5      nUR                  nU R	                  U5        UR
                  (       ac  UR                  R                  [        R                  R                  R                  R                  5       UR                  R                  5       S9nOkUR                  R                  [        R                  R                  R                  R                  5       UR                  R                  UR                  S9S9nUR                  UR                   R"                  SU4/5      $ )N)project'projectsSetDefaultServiceAccountRequest)emailr   )r   ComputeApiHolderReleaseTrackclientvalidateFlagsno_service_accountmessages.ComputeProjectsSetDefaultServiceAccountRequestr	   VALUEScorer   	GetOrFail'ProjectsSetDefaultServiceAccountRequestservice_accountMakeRequestsapitools_clientprojects)selfargsholderr    requests        r   RunSetDefaultServiceAccount.Run[   s   **4+<+<+>?F]]FtNN##((00::<
//
A
A
C O Eg
 NN##((00::<
//
A
A(( B  O g !7!7!@!@!;W!F  G H Hr   c                 x    UR                   (       d)  UR                  (       d  [        R                  " SS5      eg g )Nr   zjmust be specified with a service account. To clear the default service account use [--no-service-account].)r"   r)   r   RequiredArgumentException)r-   r.   s     r   r!   &SetDefaultServiceAccount.validateFlagsr   s:    ""4+?+?00
  JK K ,@"r    N)
__name__
__module____qualname____firstlineno____doc__staticmethodr   r1   r!   __static_attributes__r6   r   r   r   r      s(    B  6H.Kr   r   N)r;   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   googlecloudsdk.corer	   UniverseCompatibleReleaseTracksr   ALPHASilentCommandr   r6   r   r   <module>rF      sl    H &  ' 7 ( . * D%%++,YKt11 YK - YKr   