
    =                     z    d 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
)z6Command for setting IAM policies for service accounts.    )absolute_import)division)unicode_literals)util)base)iam_utilc                       e Zd ZdZ ej
                  dd      Zedxx   d ej                  d      z   z  cc<   ed        Z	d Z
y	)
SetIamPolicya  Set the IAM policy for a service account.

  This command replaces the existing IAM policy for a service account, given
  an IAM_ACCOUNT and a file encoded in JSON or YAML that contains the IAM
  policy. If the given policy file specifies an "etag" value, then the
  replacement will succeed only if the policy already in place matches that
  etag. (An etag obtained via $ gcloud iam service-accounts get-iam-policy will
  prevent the replacement if the policy for the service account has been
  subsequently updated.) A policy file that does not contain an etag value will
  replace any existing policy for the service account.

  If the service account does not exist, this command returns a
  `PERMISSION_DENIED` error.
  service accountz1my-iam-account@my-project.iam.gserviceaccount.comDESCRIPTIONz

zset the iam policy ofc                 Z    t        j                  | d       | j                  ddd       y )Nzwhose policy to set)actionpolicy_filePOLICY_FILEzFPath to a local JSON or YAML formatted file containing a valid policy.)metavarhelp)r   AddServiceAccountNameArgadd_argument)parsers    2lib/surface/iam/service_accounts/set_iam_policy.pyArgszSetIamPolicy.Args1   s6    %%$& %  &    c                    t        j                         \  }}t        j                  |j                  |j
                        }t        j                  |_        |j                  j                  |j                  t        j                  |j                        |j                  |                  }t        j                  |j                  d       |S )N)policy)resourcesetIamPolicyRequestr   )r   GetClientAndMessagesr   ParsePolicyFiler   Policy!MAX_LIBRARY_IAM_SUPPORTED_VERSIONversionprojects_serviceAccountsr
   -IamProjectsServiceAccountsSetIamPolicyRequestEmailToAccountResourceNameservice_accountSetIamPolicyRequestLogSetIamPolicy)selfargsclientmessagesr   results         r   RunzSetIamPolicy.Run<   s    002FH%%d&6&6HF??FN,,99>>889M9MN ( < < != ! 	? 	 !F
 T113DEMr   N)__name__
__module____qualname____doc__r   GetDetailedHelpForSetIamPolicydetailed_help GetHintForServiceAccountResourcestaticmethodr   r-    r   r   r
   r
      se     :(99LN-&/h//
!##$ $ & &r   r
   N)r1   
__future__r   r   r   googlecloudsdk.api_lib.iamr   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   Commandr
   r6   r   r   <module>r<      s,     = &  ' + ( 3,4<< ,r   